Menu

[r6946]: / branches / wxsmith_addons / src / include / cbauibook.h  Maximize  Restore  History

Download this file

403 lines (391 with data), 13.6 kB

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
/*
* This file is part of the Code::Blocks IDE and licensed under the GNU Lesser General Public License, version 3
* http://www.gnu.org/licenses/lgpl-3.0.html
*/
#ifndef CBAUIBOOK_H_INCLUDED
#define CBAUIBOOK_H_INCLUDED
#include <wx/aui/auibook.h>
#include <wx/dynarray.h>
class wxTipWindow;
class cbAuiNotebook;
WX_DEFINE_ARRAY_PTR(wxAuiTabCtrl*,cbAuiTabCtrlArray);
WX_DEFINE_ARRAY_PTR(cbAuiNotebook*,cbAuiNotebookArray);
/** \brief A notebook class
* This class is derived from wxAuiNotebook, to enhance its abilities.
* It adds the ability to store (and restore) the visible tab-order, because
* auinotebook-tabs can be reordered with drag and drop.
* Another added feature is the possibility to add tooltips to the tabs belonging
* to added panes.
*/
class cbAuiNotebook : public wxAuiNotebook
{
public:
/** \brief cbAuiNotebook constructor
*
* \param pParent the parent window, usually the app-window
* \param id the notebook id
* \param pos the position
* \param size the size
* \param style the notebook style
*
*/
cbAuiNotebook(wxWindow* pParent, wxWindowID id, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxAUI_NB_DEFAULT_STYLE);
/** cbAuiNotebook destructor */
virtual ~cbAuiNotebook();
/** \brief Advances the selection
*
* In contrast to the base-classes function, it uses the visible tab-order, not the order
* of creation and jumps to the first tab, if the last is reached (and vice versa)
* \param forward if false direction is backwards
*/
void AdvanceSelection(bool forward = true);
/** \brief Save layout of the notebook
* \return wxString the serialized layout
* @remarks Not used at the moment, because it's not (yet) possible to restore the layout,
* due to limitations of the base class.
*
*/
wxString SavePerspective();
/** \brief Loads serialized notebook layout
* \param layout the serialized layout
* \return bool true if successfull
* @remarks Not implemented. Don't use it.
*
*/
bool LoadPerspective(const wxString& layout){return false;}
/** \brief Get the tab position
*
* Returns the position of the tab as it is visible.
* Starts with 0
* \param index the index of the tab in order of creation
* \return int the visible position
*
*/
int GetTabPositionFromIndex(int index);
/** \brief Set a tab tooltip
*
* Sets the tooltip for the tab belonging to win.
* Starts the dwell timer and the stopwatch if it is not already done.
* \param win the pane that belongs to the tab
* \param msg the tooltip
* \return void
* @remarks Uses the name of the wxWindow to store the message
*
*/
void SetTabToolTip(wxWindow* win, wxString msg);
/** \brief Allow tooltips
*
* Allows or forbids tooltips.
* Cancels already shown tooltips, if allow is false
* \param allow if false toltips are not allowed
* \return void
*
*/
void AllowToolTips(bool allow = true);
/** \brief Minmize free horizontal page
*
* Moves the active tab to the rightmost place,
* to show as many tabs as possible.
* \return void
*
*/
void MinimizeFreeSpace();
/** \brief Delete Page
*
* Calls the base-class function and after that
* MinmizeFreeSpace(), needed to hook into the close-events.
* The system generated close event has to be veto'd, and Close()
* has to be called manually, so we can handle it ourselves.
* \param The index of the tab to be closed
* \return true if successfull
*
*/
bool DeletePage(size_t page);
/** \brief Remove Page
*
* Calls the base-class function and after that
* MinmizeFreeSpace(), needed to hook into the close-events.
* The system generated close event has to be veto'd, and Close()
* has to be called manually, so we can handle it ourselves.
* \param The index of the tab to be closed
* \return true if successfull
*
*/
bool RemovePage(size_t page);
/** \brief Move page
*
* Moves the tab containing page to new_idx
* \param page The page to move (e.g. cbEditor*)
* \param new_idx The index the page should be moved to
* \return true if successfull
*
*/
bool MovePage(wxWindow* page, size_t new_idx);
/** \brief Set zoomfactor for builtin editors
*
* Sets the zoomfactor for all visible builtin
* editors.
* \param zoom zoomfactor to use
* \return void
*
*/
void SetZoom(int zoom);
protected:
/** \brief Handle the navigation key event
*
* Tries to handle the navigation key-event and use "our" AdvanceSelection().
* \param event
* \return void
* @remarks Works not reliable, due to OS/wxWidgets-limitations
*
*/
#if wxCHECK_VERSION(2, 9, 0)
void OnNavigationKeyNotebook(wxNavigationKeyEvent& event);
#else
void OnNavigationKey(wxNavigationKeyEvent& event);
#endif
/** \brief OnIdle
*
* \param event unused
* \return void
*
*/
void OnIdle(wxIdleEvent& /*event*/);
/** \brief Check whether the mouse is over a tab
*
* \param event unused
* \return void
*
*/
void OnDwellTimerTrigger(wxTimerEvent& /*event*/);
/** \brief Catch doubleclick-events from wxTabCtrl
*
* Sends cbEVT_CBAUIBOOK_LEFT_DCLICK, if doubleclick was on a tab,
* event-Id is the notebook-Id, event-object is the pointer to the window the
* tab belongs to.
* \param event holds the wxTabCtrl, that sends the event
* \return void
*
*/
void OnTabCtrlDblClick(wxMouseEvent& event);
/** \brief Catch mousewheel-events from wxTabCtrl
*
* Sends cbEVT_CBAUIBOOK_MOUSEWHEEL, if doubleclick was on a tab,
* event-Id is the notebook-Id, event-object is the pointer to the window the
* tab belongs to.
* \param event holds the wxTabCtrl, that sends the event
* \return void
*
*/
void OnTabCtrlMouseWheel(wxMouseEvent& event);
/** \brief Catch mousewheel-events from tooltipwindow
*
* Closes Tooltip.
* \param event the tipwindow, that sends the event
* \return void
*
*/
void OnToolTipMouseWheel(wxMouseEvent& event);
/** \brief Catch resize-events and call MinimizeFreeSpace()
*
* \param event unused
* \return void
*
*/
void OnResize(wxSizeEvent& event);
#ifdef __WXMSW__
// hack needed on wxMSW, because only focused windows get mousewheel-events
/** \brief Catch mouseenter-events from wxTabCtrl
*
* Set focus on wxTabCtrl
* \param event holds the wxTabCtrl, that sends the event
* \return void
*
*/
void OnEnterTabCtrl(wxMouseEvent& event);
/** \brief Catch mouseleave-events from wxTabCtrl
*
* \param event holds the wxTabCtrl, that sends the event
* \return void
*
*/
void OnLeaveTabCtrl(wxMouseEvent& event);
/** \brief Checks the old focus
*
* Checks whether the old focused window or one of it's
* parents is the same as page.
* If they are equal, we have to reset the stored pointer,
* because we get a crash otherwise.
* \param page The page to check against
* \return bool
*
*/
bool IsFocusStored(wxWindow* page);
/** \brief Save old focus
*
* Save old focus and tab-selection,
* \param event holds the wxTabCtrl, that sends the event
* \return void
*
*/
void StoreFocus();
/** \brief Restore old focus
*
* Restore old focus or set the focus on the activated tab
* \param event holds the wxTabCtrl, that sends the event
* \return void
*
*/
void RestoreFocus();
#endif // #ifdef __WXMSW__
/** \brief Reset tabctrl events
*
* \return void
*
*/
void ResetTabCtrlEvents();
/** \brief Updates the array, that holds the wxTabCtrls
*
* \return void
*
*/
void UpdateTabControlsArray();
/** \brief Shows tooltip for win
*
* \param win
* \return void
*
*/
void ShowToolTip(wxWindow* win);
/** \brief Cancels tooltip
*
* \return void
*
*/
void CancelToolTip();
/** \brief Check for pressed modifier-keys
*
* Check whether all modifier keys in keyModifier are pressed
* or not
* \param keyModifier wxSTring containing the modifier(s) to check for
* \return true If all modifier-keys are pressed
*
*/
bool CheckKeyModifier();
/** \brief Holds the wxTabCtrls used by the notebook
* @remarks Should be updated with UpdateTabControlsArray(),
* before it's used
*/
cbAuiTabCtrlArray m_TabCtrls;
/** \brief Stopwatch used to determine how long the mouse has not
* been moved over a tab.
*/
wxStopWatch m_StopWatch;
/** \brief Timer used to check the mouse-position
*/
wxTimer* m_pDwellTimer;
/** \brief The actual shown tooltip or nullptr
*/
wxTipWindow* m_pToolTip;
/** \brief Position of the mouse, at last dwell timmer event.
*
* Used to determine whether the mouse was moved or not.
*/
wxPoint m_LastMousePosition;
/** \brief Position of tooltip
*
* Used to determine, whether a tooltiop is already shown at
* the actual mouse-position
*/
wxPoint m_LastShownAt;
/** \brief Last time the dwell timer triggered an event
*
* Used to determine how long the mouse has not been moved over a tab .
*/
long m_LastTime;
#ifdef __WXMSW__
// needed for wxMSW-hack, see above
/** \brief Last selected tab
*
* Used to determine whether the tab-selection has changed btween mouseenter
* and mouseleave-event.
*/
int m_LastSelected;
/** \brief Last focused window
*
* Used to restore the focus after a mouseleave-event on wxTabCtrl.
*/
wxWindow* m_pLastFocused;
#endif // #ifdef __WXMSW__
/** \brief If false, tooltips are temporary forbidden
*
* Needed to not interfere with context-menus etc.
*/
bool m_AllowToolTips;
/** \brief If true, zoom for all editors
* is set in next OnIdle-call
*
*/
bool m_SetZoomOnIdle;
/** \brief Holds the id of the dwell timer
*/
long m_IdNoteBookTimer;
//static stuff (common to all cbAuiNotebooks)
public:
/** \brief Enable or disable tabtooltips globally
*
* \param use If true tooltips are allowed
* \return void
*
*/
static void UseToolTips(bool use = true);
/** \brief Set the time before a tab-tooltip kicks in
*
* \param time The dwell time
* \return void
*
*/
static void SetDwellTime(long time = 1000);
/** \brief Enable or disable tab-scrolling with mousewheel
*
* \param allow If true scrolling is allowed
* \return void
*
*/
static void AllowScrolling(bool allow = true);
/** \brief Setss the modifier keys for scrolling
*
*/
static void SetModKeys(wxString keys = _T("Strg"));
/** \brief Use modkey to advance through tabs with mousewheel
*
*/
static void UseModToAdvance(bool use = false);
protected:
/** \brief Enable or disable tab tooltips
*
*/
static bool s_UseTabTooltips;
/** \brief Tab tooltip dwell time
*
*/
static long s_DwellTime;
/** \brief Enable or disable scrolling tabs with mousewheel
*
*/
static bool s_AllowMousewheel;
/** \brief Holds an array of all existing cbAuiNotebooks
*
*/
static cbAuiNotebookArray s_cbAuiNotebookArray;
/** \brief Holds the modifier keys for scrolling
*
*/
static wxString s_modKeys;
/** \brief Use modkey to advance through tabs with mousewheel
*
*/
static bool s_modToAdvance;
DECLARE_EVENT_TABLE()
};
#endif // CBAUIBOOK_H_INCLUDED
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.