Code::Blocks  SVN r11506
cbauibook.h
Go to the documentation of this file.
1 /*
2  * This file is part of the Code::Blocks IDE and licensed under the GNU Lesser General Public License, version 3
3  * http://www.gnu.org/licenses/lgpl-3.0.html
4  */
5 
6 #ifndef CBAUIBOOK_H_INCLUDED
7 #define CBAUIBOOK_H_INCLUDED
8 
9 #include "prep.h"
10 #include "settings.h" // DLLIMPORT
11 
12 #include <vector>
13 
14 #include <wx/aui/auibook.h>
15 #include <wx/dynarray.h>
16 
17 class wxTipWindow;
18 class cbAuiNotebook;
19 
20 WX_DEFINE_ARRAY_PTR(wxAuiTabCtrl*,cbAuiTabCtrlArray);
21 WX_DEFINE_ARRAY_PTR(cbAuiNotebook*,cbAuiNotebookArray);
22 
31 {
32  public:
41  cbAuiNotebook(wxWindow* pParent, wxWindowID id, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxAUI_NB_DEFAULT_STYLE);
43  ~cbAuiNotebook() override;
44 
51  void AdvanceSelection(bool forward = true);
56  wxString SavePerspective(const wxString projectTitle = wxEmptyString);
63  bool LoadPerspective(const wxString& layout, bool mergeLayouts = false);
72  int GetTabIndexFromTooltip(const wxString& text);
80  int GetTabPositionFromIndex(int index);
81 #if !wxCHECK_VERSION(3, 0, 0)
82 
91  bool SetPageToolTip(size_t idx, const wxString & text );
98  wxString GetPageToolTip(size_t idx );
99 #endif // !wxCHECK_VERSION(3, 0, 0)
100 
105  void MinimizeFreeSpace();
115  bool DeletePage(size_t page);
125  bool RemovePage(size_t page);
133  bool MovePage(wxWindow* page, size_t new_idx);
144  bool AddPage(wxWindow* page,
145  const wxString& caption,
146  bool select = false,
147  const wxBitmap& bitmap = wxNullBitmap);
159  bool InsertPage(size_t page_idx,
160  wxWindow* page,
161  const wxString& caption,
162  bool select = false,
163  const wxBitmap& bitmap = wxNullBitmap);
170  void SetZoom(int zoom);
173  void FocusActiveTabCtrl();
174 
177  wxAuiTabCtrl* GetTabCtrl(wxWindow *page);
178 
182  void GetPagesInTabCtrl(std::vector<wxWindow*> &result, wxWindow *page);
183  protected:
194  wxString UniqueIdFromTooltip(const wxString& text);
201  void MinimizeFreeSpace(wxAuiTabCtrl* tabCtrl);
208 #if wxCHECK_VERSION(3, 0, 0)
209  void OnNavigationKeyNotebook(wxNavigationKeyEvent& event);
210 #else
211  void OnNavigationKey(wxNavigationKeyEvent& event);
212 #endif // wxCHECK_VERSION(3, 0, 0)
213 
217  void OnIdle(cb_unused wxIdleEvent& event);
218 #if !wxCHECK_VERSION(3, 0, 0)
219 
225  void OnMotion(wxMouseEvent& event);
226 #endif // !wxCHECK_VERSION(3, 0, 0)
227 
234  void OnTabCtrlDblClick(wxMouseEvent& event);
242  void OnTabCtrlMouseWheel(wxMouseEvent& event);
247  void OnResize(wxSizeEvent& event);
251  void OnDragDone(wxAuiNotebookEvent& event);
252 #ifdef __WXMSW__
253 
258  void OnEnterTabCtrl(wxMouseEvent& event);
263  void OnLeaveTabCtrl(wxMouseEvent& event);
264  // hack needed on wxMSW, because only focused windows get mousewheel-events
274  bool IsFocusStored(wxWindow* page);
280  void StoreFocus();
286  void RestoreFocus();
287 #endif // __WXMSW__
288 
290  void ResetTabCtrlEvents();
293  void UpdateTabControlsArray();
301  bool CheckKeyModifier();
306  cbAuiTabCtrlArray m_TabCtrls;
307 #ifdef __WXMSW__
308  // needed for wxMSW-hack, see above
319  long m_LastId;
320 #endif // __WXMSW__
321 #if !wxCHECK_VERSION(3, 0, 0)
322 
328  bool m_HasToolTip;
329 #endif // !wxCHECK_VERSION(3, 0, 0)
330 
344 
345 //static stuff (common to all cbAuiNotebooks)
346  public:
351  static void UseToolTips(bool use = true);
356  static void AllowScrolling(bool allow = true);
359  static void SetModKeys(wxString keys = _T("Strg"));
362  static void UseModToAdvance(bool use = false);
367  static void InvertAdvanceDirection(bool invert = false);
372  static void InvertMoveDirection(bool invert = false);
373  protected:
376  static bool s_UseTabTooltips;
379  static bool s_AllowMousewheel;
382  static cbAuiNotebookArray s_cbAuiNotebookArray;
388  static bool s_modToAdvance;
391  static int s_moveDirection;
394  static int s_advanceDirection;
395 
396  private:
397  // the following two using directives remove the "-Woverloaded-virtual" warnings
400 
401  DECLARE_EVENT_TABLE()
402 };
403 
404 #endif // CBAUIBOOK_H_INCLUDED
void AdvanceSelection(bool forward=true)
static bool s_modToAdvance
Use modkey to advance through tabs with mousewheel.
Definition: cbauibook.h:388
wxSize m_TabCtrlSize
Holds the size of a tabCtrl after a resize event.
Definition: cbauibook.h:343
#define _T(string)
static int s_advanceDirection
Mouseweheel advance direction: negative => invert.
Definition: cbauibook.h:394
static cbAuiNotebookArray s_cbAuiNotebookArray
Holds an array of all existing cbAuiNotebooks.
Definition: cbauibook.h:382
static bool s_AllowMousewheel
Enable or disable scrolling tabs with mousewheel.
Definition: cbauibook.h:379
#define DLLIMPORT
Definition: settings.h:16
static int s_moveDirection
Mousewheel move direction: negative => invert.
Definition: cbauibook.h:391
bool InsertPage(size_t page_idx, wxWindow *page, const wxString &caption, bool select=false, const wxBitmap &bitmap=wxNullBitmap)
bool DeletePage(size_t page)
const wxSize wxDefaultSize
const wxPoint wxDefaultPosition
wxString GetPageToolTip(size_t pageIdx) const
bool AddPage(wxWindow *page, const wxString &caption, bool select=false, const wxBitmap &bitmap=wxNullBitmap)
WX_DEFINE_ARRAY_PTR(wxAuiTabCtrl *, cbAuiTabCtrlArray)
wxString wxEmptyString
bool RemovePage(size_t page)
bool SetPageToolTip(size_t page, const wxString &text)
A notebook class This class is derived from wxAuiNotebook, to enhance its abilities.
Definition: cbauibook.h:30
long m_LastId
Id of last focused window.
Definition: cbauibook.h:319
cbAuiTabCtrlArray m_TabCtrls
Holds the wxTabCtrls used by the notebook.
Definition: cbauibook.h:306
wxBitmap wxNullBitmap
bool m_SetZoomOnIdle
If true, zoom for all editors is set in next OnIdle-call.
Definition: cbauibook.h:333
int m_LastSelected
Last selected tab.
Definition: cbauibook.h:314
bool m_MinimizeFreeSpaceOnIdle
If true, MinimizeFreeSpace is called in next OnIdle-call.
Definition: cbauibook.h:337
int wxWindowID
static wxString s_modKeys
Holds the modifier keys for scrolling.
Definition: cbauibook.h:385
static bool s_UseTabTooltips
Enable or disable tab tooltips.
Definition: cbauibook.h:376