Code::Blocks  SVN r11506
infopane.h
Go to the documentation of this file.
1 /*
2  * This file is part of the Code::Blocks IDE and licensed under the GNU General Public License, version 3
3  * http://www.gnu.org/licenses/gpl-3.0.html
4  */
5 
6 #ifndef INFOPANE_H
7 #define INFOPANE_H
8 
9 
10 #include <limits>
11 #include <logmanager.h>
12 
13 #include "cbauibook.h"
14 
15 static const int infopane_flags = wxAUI_NB_MIDDLE_CLICK_CLOSE
16  | wxAUI_NB_WINDOWLIST_BUTTON
17  | wxAUI_NB_SCROLL_BUTTONS
18  | wxAUI_NB_TAB_MOVE
19  | wxAUI_NB_TAB_SPLIT;
20 
21 class wxWindow;
22 class wxCommandEvent;
23 class wxMouseEvent;
24 
25 class InfoPane : public cbAuiNotebook
26 {
27  DECLARE_EVENT_TABLE()
28 
29  struct Page
30  {
31  Page() : icon(nullptr), window(nullptr), logger(nullptr), indexInNB(std::numeric_limits<int>::min()), eventID(0), islogger(0) {};
36  int indexInNB; // used to be "visible" flag: invisible is <0, any other value means visible
37  int eventID;
38  bool islogger;
39  };
40 
41  typedef int (*CompareFunction)(Page**, Page**);
42  static int CompareIndexes(Page **p1, Page **p2);
43  void ReorderTabs(CompareFunction cmp_f);
44 
46 
47  WX_DEFINE_ARRAY(Page*, wxArrayOfPage);
48  wxArrayOfPage m_Pages;
49 
50  void Toggle(size_t index);
51  void Hide(size_t i);
52 
53  void OnMenu(wxCommandEvent& event);
54  void OnCopy(wxCommandEvent& event);
55  void OnWrapMode(wxCommandEvent& event);
56  void OnClear(wxCommandEvent& event);
57  void ContextMenu(wxContextMenuEvent& event);
60  void OnTabPosition(wxCommandEvent& event);
61  void DoShowContextMenu();
62  int AddPagePrivate(wxWindow* p, const wxString& title, wxBitmap* icon = nullptr);
63  bool InsertPagePrivate(wxWindow* p, const wxString& title, wxBitmap* icon = nullptr, int index = -1);
64  using wxWindow::Show;
65 public:
66 
67  InfoPane(wxWindow* parent);
68  virtual ~InfoPane();
69 
70  /*
71  * Show a tab, or bring it to the foreground if already shown.
72  * Only use this method if crucial information is shown which the user must not miss, or if
73  * information is shown that requires input from the user (for example search results).
74  * In all other cases, it is the user's decision which tab he wants to look at, not yours.
75  * Note that you cannot hide a tab programatically.
76  */
77  void Show(size_t index);
78  void Show(Logger* logger);
79  void Hide(Logger* logger);
80  void ShowNonLogger(wxWindow* p);
81  void HideNonLogger(wxWindow* p);
82 
84  int GetCurrentPage(bool &is_logger);
85 
86  Logger* GetLogger(int index);
87  wxWindow* GetWindow(int index);
88 
89  void UpdateEffectiveTabOrder(); // refreshes the tab effective order, needed, because tabs might have moved with drag and drop
90  void LoadTabOrder(wxString layout);
92 
93  /*
94  * You should not need to call these functions under normal conditions. The application initialises
95  * everything at startup, after the main window has been created and the plugins have been loaded.
96  * AddLogger:
97  * Add the GUI control obtained by a logger's CreateControl() function.
98  * DeleteLogger:
99  * Remove (delete) a tab and its logger. All log output directed to the corresponding log index
100  * will be redirected to the null log thereafter.
101  * To prove that you are serious, you must know the logger belonging to the tab to delete.
102  */
103  bool AddLogger(Logger* logger, wxWindow* p, const wxString& title, wxBitmap* icon = nullptr);
104  bool DeleteLogger(Logger* l);
105 
106  /*
107  * If something that is not a logger should be placed in the info pane (think twice about this before doing it),
108  * use AddNonLogger()/DeleteNonLogger() for that purpose.
109  * An example of something that is not a logger but might still show up in the info pane is the list of search results.
110  */
111  bool AddNonLogger(wxWindow* p, const wxString& title, wxBitmap* icon = nullptr);
112  bool RemoveNonLogger(wxWindow* p);
113  bool DeleteNonLogger(wxWindow* p);
114 };
115 
116 
117 #endif
static const int infopane_flags
Definition: infopane.h:15
virtual ~InfoPane()
Definition: infopane.cpp:61
static int CompareIndexes(Page **p1, Page **p2)
Definition: infopane.cpp:116
void DoShowContextMenu()
Definition: infopane.cpp:368
void HideNonLogger(wxWindow *p)
Definition: infopane.cpp:269
void OnTabPosition(wxCommandEvent &event)
Definition: infopane.cpp:435
void ShowNonLogger(wxWindow *p)
Definition: infopane.cpp:282
wxString title
Definition: infopane.h:31
bool RemoveNonLogger(wxWindow *p)
Definition: infopane.cpp:515
wxBitmap * icon
Definition: infopane.h:33
wxWindow * GetWindow(int index)
Definition: infopane.cpp:223
void OnClear(wxCommandEvent &event)
Definition: infopane.cpp:320
wxString SaveTabOrder()
Definition: infopane.cpp:70
The base class for all kinds of loggers, see loggers.h for its derived classes.
Definition: logger.h:23
wxWindow * GetCurrentPage() const
STL namespace.
int GetPageIndexByWindow(wxWindow *win)
Definition: infopane.cpp:199
WX_DEFINE_ARRAY(Page *, wxArrayOfPage)
bool AddLogger(Logger *logger, wxWindow *p, const wxString &title, wxBitmap *icon=nullptr)
Definition: infopane.cpp:448
void OnMenu(wxCommandEvent &event)
Definition: infopane.cpp:327
int AddPagePrivate(wxWindow *p, const wxString &title, wxBitmap *icon=nullptr)
Definition: infopane.cpp:152
void OnCloseClicked(wxAuiNotebookEvent &event)
Definition: infopane.cpp:357
void LoadTabOrder(wxString layout)
Definition: infopane.cpp:88
InfoPane(wxWindow *parent)
Definition: infopane.cpp:56
null_pointer_t nullptr
Definition: nullptr.cpp:16
void OnWrapMode(wxCommandEvent &event)
Definition: infopane.cpp:310
int(* CompareFunction)(Page **, Page **)
Definition: infopane.h:41
bool DeleteLogger(Logger *l)
Definition: infopane.cpp:490
void OnCopy(wxCommandEvent &event)
Definition: infopane.cpp:298
Logger * GetLogger(int index)
Definition: infopane.cpp:216
void UpdateEffectiveTabOrder()
Definition: infopane.cpp:167
wxArrayOfPage m_Pages
Definition: infopane.h:48
wxWindow * window
Definition: infopane.h:34
bool AddNonLogger(wxWindow *p, const wxString &title, wxBitmap *icon=nullptr)
Definition: infopane.cpp:468
A notebook class This class is derived from wxAuiNotebook, to enhance its abilities.
Definition: cbauibook.h:30
void Toggle(size_t index)
Definition: infopane.cpp:178
void Hide(size_t i)
void ReorderTabs(CompareFunction cmp_f)
Definition: infopane.cpp:123
bool islogger
Definition: infopane.h:38
wxBitmap m_DefaultBitmap
Definition: infopane.h:45
void ContextMenu(wxContextMenuEvent &event)
Definition: infopane.cpp:343
void Show(size_t index)
Definition: infopane.cpp:230
bool InsertPagePrivate(wxWindow *p, const wxString &title, wxBitmap *icon=nullptr, int index=-1)
Definition: infopane.cpp:160
Logger * logger
Definition: infopane.h:35
void OnTabContextMenu(wxAuiNotebookEvent &event)
Definition: infopane.cpp:348
bool DeleteNonLogger(wxWindow *p)
Definition: infopane.cpp:533