]>
Commit | Line | Data |
---|---|---|
23324ae1 FM |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: aui/auibook.h | |
e54c96f1 | 3 | // Purpose: interface of wxAuiNotebook |
23324ae1 | 4 | // Author: wxWidgets team |
526954c5 | 5 | // Licence: wxWindows licence |
23324ae1 FM |
6 | ///////////////////////////////////////////////////////////////////////////// |
7 | ||
8 | /** | |
9 | @class wxAuiNotebook | |
7c913512 | 10 | |
c55488df VZ |
11 | wxAuiNotebook is part of the wxAUI class framework, which represents a |
12 | notebook control, managing multiple windows with associated tabs. | |
13 | ||
47d602c1 | 14 | See also @ref overview_aui. |
7c913512 | 15 | |
23324ae1 FM |
16 | wxAuiNotebook is a notebook control which implements many features common in |
17 | applications with dockable panes. | |
18 | Specifically, wxAuiNotebook implements functionality which allows the user to | |
47d602c1 FM |
19 | rearrange tab order via drag-and-drop, split the tab window into many different |
20 | splitter configurations, and toggle through different themes to customize | |
23324ae1 | 21 | the control's look and feel. |
7c913512 | 22 | |
23324ae1 FM |
23 | The default theme that is used is wxAuiDefaultTabArt, which provides a modern, |
24 | glossy look and feel. | |
25 | The theme can be changed by calling wxAuiNotebook::SetArtProvider. | |
7c913512 | 26 | |
23324ae1 | 27 | @beginStyleTable |
8c6791e4 | 28 | @style{wxAUI_NB_DEFAULT_STYLE} |
23324ae1 | 29 | Defined as wxAUI_NB_TOP | wxAUI_NB_TAB_SPLIT | wxAUI_NB_TAB_MOVE | |
73b1a25d VZ |
30 | wxAUI_NB_SCROLL_BUTTONS | wxAUI_NB_CLOSE_ON_ACTIVE_TAB | |
31 | wxAUI_NB_MIDDLE_CLICK_CLOSE. | |
8c6791e4 | 32 | @style{wxAUI_NB_TAB_SPLIT} |
23324ae1 | 33 | Allows the tab control to be split by dragging a tab. |
8c6791e4 | 34 | @style{wxAUI_NB_TAB_MOVE} |
23324ae1 | 35 | Allows a tab to be moved horizontally by dragging. |
8c6791e4 | 36 | @style{wxAUI_NB_TAB_EXTERNAL_MOVE} |
23324ae1 | 37 | Allows a tab to be moved to another tab control. |
8c6791e4 | 38 | @style{wxAUI_NB_TAB_FIXED_WIDTH} |
23324ae1 | 39 | With this style, all tabs have the same width. |
8c6791e4 | 40 | @style{wxAUI_NB_SCROLL_BUTTONS} |
23324ae1 | 41 | With this style, left and right scroll buttons are displayed. |
8c6791e4 | 42 | @style{wxAUI_NB_WINDOWLIST_BUTTON} |
23324ae1 | 43 | With this style, a drop-down list of windows is available. |
8c6791e4 | 44 | @style{wxAUI_NB_CLOSE_BUTTON} |
23324ae1 | 45 | With this style, a close button is available on the tab bar. |
8c6791e4 | 46 | @style{wxAUI_NB_CLOSE_ON_ACTIVE_TAB} |
23324ae1 | 47 | With this style, the close button is visible on the active tab. |
8c6791e4 | 48 | @style{wxAUI_NB_CLOSE_ON_ALL_TABS} |
23324ae1 | 49 | With this style, the close button is visible on all tabs. |
73b1a25d VZ |
50 | @style{wxAUI_NB_MIDDLE_CLICK_CLOSE} |
51 | With this style, middle click on a tab closes the tab. | |
8c6791e4 | 52 | @style{wxAUI_NB_TOP} |
23324ae1 | 53 | With this style, tabs are drawn along the top of the notebook. |
8c6791e4 | 54 | @style{wxAUI_NB_BOTTOM} |
23324ae1 FM |
55 | With this style, tabs are drawn along the bottom of the notebook. |
56 | @endStyleTable | |
7c913512 | 57 | |
3051a44a | 58 | @beginEventEmissionTable{wxAuiNotebookEvent} |
1bc693a9 | 59 | @event{EVT_AUINOTEBOOK_PAGE_CLOSE(id, func)} |
ce7fe42e | 60 | A page is about to be closed. Processes a @c wxEVT_AUINOTEBOOK_PAGE_CLOSE event. |
8b896112 | 61 | @event{EVT_AUINOTEBOOK_PAGE_CLOSED(winid, fn)} |
ce7fe42e | 62 | A page has been closed. Processes a @c wxEVT_AUINOTEBOOK_PAGE_CLOSED event. |
1bc693a9 | 63 | @event{EVT_AUINOTEBOOK_PAGE_CHANGED(id, func)} |
ce7fe42e | 64 | The page selection was changed. Processes a @c wxEVT_AUINOTEBOOK_PAGE_CHANGED event. |
1bc693a9 | 65 | @event{EVT_AUINOTEBOOK_PAGE_CHANGING(id, func)} |
ce7fe42e | 66 | The page selection is about to be changed. Processes a @c wxEVT_AUINOTEBOOK_PAGE_CHANGING event. This event can be vetoed. |
1bc693a9 | 67 | @event{EVT_AUINOTEBOOK_BUTTON(id, func)} |
ce7fe42e | 68 | The window list button has been pressed. Processes a @c wxEVT_AUINOTEBOOK_BUTTON event. |
1bc693a9 | 69 | @event{EVT_AUINOTEBOOK_BEGIN_DRAG(id, func)} |
ce7fe42e | 70 | Dragging is about to begin. Processes a @c wxEVT_AUINOTEBOOK_BEGIN_DRAG event. |
1bc693a9 | 71 | @event{EVT_AUINOTEBOOK_END_DRAG(id, func)} |
ce7fe42e | 72 | Dragging has ended. Processes a @c wxEVT_AUINOTEBOOK_END_DRAG event. |
1bc693a9 | 73 | @event{EVT_AUINOTEBOOK_DRAG_MOTION(id, func)} |
ce7fe42e | 74 | Emitted during a drag and drop operation. Processes a @c wxEVT_AUINOTEBOOK_DRAG_MOTION event. |
1bc693a9 | 75 | @event{EVT_AUINOTEBOOK_ALLOW_DND(id, func)} |
ce7fe42e | 76 | Whether to allow a tab to be dropped. Processes a @c wxEVT_AUINOTEBOOK_ALLOW_DND event. This event must be specially allowed. |
8b896112 | 77 | @event{EVT_AUINOTEBOOK_DRAG_DONE(winid, fn)} |
ce7fe42e | 78 | Notify that the tab has been dragged. Processes a @c wxEVT_AUINOTEBOOK_DRAG_DONE event. |
8b896112 | 79 | @event{EVT_AUINOTEBOOK_TAB_MIDDLE_DOWN(winid, fn)} |
ce7fe42e | 80 | The middle mouse button is pressed on a tab. Processes a @c wxEVT_AUINOTEBOOK_TAB_MIDDLE_DOWN event. |
8b896112 | 81 | @event{EVT_AUINOTEBOOK_TAB_MIDDLE_UP(winid, fn)} |
ce7fe42e | 82 | The middle mouse button is released on a tab. Processes a @c wxEVT_AUINOTEBOOK_TAB_MIDDLE_UP event. |
8b896112 | 83 | @event{EVT_AUINOTEBOOK_TAB_RIGHT_DOWN(winid, fn)} |
ce7fe42e | 84 | The right mouse button is pressed on a tab. Processes a @c wxEVT_AUINOTEBOOK_TAB_RIGHT_DOWN event. |
8b896112 | 85 | @event{EVT_AUINOTEBOOK_TAB_RIGHT_UP(winid, fn)} |
ce7fe42e | 86 | The right mouse button is released on a tab. Processes a @c wxEVT_AUINOTEBOOK_TAB_RIGHT_UP event. |
8b896112 | 87 | @event{EVT_AUINOTEBOOK_BG_DCLICK(winid, fn)} |
ce7fe42e | 88 | Double clicked on the tabs background area. Processes a @c wxEVT_AUINOTEBOOK_BG_DCLICK event. |
4a15036c FM |
89 | @endEventTable |
90 | ||
23324ae1 FM |
91 | @library{wxaui} |
92 | @category{aui} | |
93 | */ | |
873ff54b | 94 | class wxAuiNotebook : public wxBookCtrlBase |
23324ae1 FM |
95 | { |
96 | public: | |
4a15036c FM |
97 | /** |
98 | Default ctor. | |
99 | */ | |
47d602c1 FM |
100 | wxAuiNotebook(); |
101 | ||
23324ae1 FM |
102 | /** |
103 | Constructor. Creates a wxAuiNotebok control. | |
104 | */ | |
7c913512 FM |
105 | wxAuiNotebook(wxWindow* parent, wxWindowID id = wxID_ANY, |
106 | const wxPoint& pos = wxDefaultPosition, | |
107 | const wxSize& size = wxDefaultSize, | |
108 | long style = wxAUI_NB_DEFAULT_STYLE); | |
23324ae1 FM |
109 | |
110 | /** | |
47d602c1 FM |
111 | Adds a page. |
112 | If the @a select parameter is @true, calling this will generate a page change event. | |
23324ae1 FM |
113 | */ |
114 | bool AddPage(wxWindow* page, const wxString& caption, | |
4cc4bfaf | 115 | bool select = false, |
23324ae1 FM |
116 | const wxBitmap& bitmap = wxNullBitmap); |
117 | ||
873ff54b SL |
118 | /** |
119 | Adds a new page. | |
120 | ||
121 | The page must have the book control itself as the parent and must not | |
122 | have been added to this control previously. | |
123 | ||
124 | The call to this function may generate the page changing events. | |
125 | ||
126 | @param page | |
127 | Specifies the new page. | |
128 | @param text | |
129 | Specifies the text for the new page. | |
130 | @param select | |
131 | Specifies whether the page should be selected. | |
132 | @param imageId | |
133 | Specifies the optional image index for the new page. | |
134 | ||
135 | @return @true if successful, @false otherwise. | |
136 | ||
137 | @remarks Do not delete the page, it will be deleted by the book control. | |
138 | ||
139 | @see InsertPage() | |
140 | @since 2.9.3 | |
141 | */ | |
142 | virtual bool AddPage(wxWindow *page, const wxString &text, bool select, int imageId); | |
143 | ||
23324ae1 FM |
144 | /** |
145 | Sets the selection to the next or previous page. | |
146 | */ | |
4cc4bfaf | 147 | void AdvanceSelection(bool forward = true); |
23324ae1 | 148 | |
873ff54b SL |
149 | /** |
150 | Changes the selection for the given page, returning the previous selection. | |
151 | ||
152 | This function behaves as SetSelection() but does @em not generate the | |
153 | page changing events. | |
154 | ||
155 | See @ref overview_events_prog for more information. | |
156 | @since 2.9.3 | |
157 | */ | |
158 | virtual int ChangeSelection(size_t n); | |
159 | ||
23324ae1 FM |
160 | /** |
161 | Creates the notebook window. | |
162 | */ | |
163 | bool Create(wxWindow* parent, wxWindowID id = wxID_ANY, | |
164 | const wxPoint& pos = wxDefaultPosition, | |
165 | const wxSize& size = wxDefaultSize, | |
166 | long style = 0); | |
167 | ||
873ff54b SL |
168 | /** |
169 | Deletes all pages. | |
170 | @since 2.9.3 | |
171 | */ | |
172 | virtual bool DeleteAllPages(); | |
173 | ||
23324ae1 | 174 | /** |
47d602c1 FM |
175 | Deletes a page at the given index. |
176 | Calling this method will generate a page change event. | |
23324ae1 FM |
177 | */ |
178 | bool DeletePage(size_t page); | |
179 | ||
180 | /** | |
181 | Returns the associated art provider. | |
182 | */ | |
328f5751 | 183 | wxAuiTabArt* GetArtProvider() const; |
23324ae1 | 184 | |
873ff54b SL |
185 | /** |
186 | Returns the currently selected page or @NULL. | |
187 | @since 2.9.3 | |
188 | */ | |
189 | wxWindow* GetCurrentPage () const; | |
190 | ||
23324ae1 | 191 | /** |
47d602c1 FM |
192 | Returns the desired height of the notebook for the given page height. |
193 | Use this to fit the notebook to a given page size. | |
23324ae1 FM |
194 | */ |
195 | int GetHeightForPageHeight(int pageHeight); | |
196 | ||
197 | /** | |
198 | Returns the page specified by the given index. | |
199 | */ | |
328f5751 | 200 | wxWindow* GetPage(size_t page_idx) const; |
23324ae1 FM |
201 | |
202 | /** | |
203 | Returns the tab bitmap for the page. | |
204 | */ | |
328f5751 | 205 | wxBitmap GetPageBitmap(size_t page) const; |
23324ae1 FM |
206 | |
207 | /** | |
208 | Returns the number of pages in the notebook. | |
209 | */ | |
328f5751 | 210 | size_t GetPageCount() const; |
23324ae1 FM |
211 | |
212 | /** | |
1d497b99 | 213 | Returns the page index for the specified window. |
47d602c1 | 214 | If the window is not found in the notebook, wxNOT_FOUND is returned. |
23324ae1 | 215 | */ |
328f5751 | 216 | int GetPageIndex(wxWindow* page_wnd) const; |
23324ae1 FM |
217 | |
218 | /** | |
219 | Returns the tab label for the page. | |
220 | */ | |
328f5751 | 221 | wxString GetPageText(size_t page) const; |
23324ae1 | 222 | |
11527fc9 VZ |
223 | /** |
224 | Returns the tooltip for the tab label of the page. | |
225 | ||
226 | @since 2.9.4 | |
227 | */ | |
228 | wxString GetPageToolTip(size_t pageIdx) const; | |
229 | ||
23324ae1 FM |
230 | /** |
231 | Returns the currently selected page. | |
232 | */ | |
328f5751 | 233 | int GetSelection() const; |
23324ae1 FM |
234 | |
235 | /** | |
236 | Returns the height of the tab control. | |
237 | */ | |
328f5751 | 238 | int GetTabCtrlHeight() const; |
23324ae1 FM |
239 | |
240 | /** | |
241 | InsertPage() is similar to AddPage, but allows the ability to specify the | |
242 | insert location. | |
4cc4bfaf | 243 | If the @a select parameter is @true, calling this will generate a page change |
23324ae1 FM |
244 | event. |
245 | */ | |
246 | bool InsertPage(size_t page_idx, wxWindow* page, | |
247 | const wxString& caption, | |
4cc4bfaf | 248 | bool select = false, |
23324ae1 FM |
249 | const wxBitmap& bitmap = wxNullBitmap); |
250 | ||
873ff54b SL |
251 | /** |
252 | Inserts a new page at the specified position. | |
253 | ||
254 | @param index | |
255 | Specifies the position for the new page. | |
256 | @param page | |
257 | Specifies the new page. | |
258 | @param text | |
259 | Specifies the text for the new page. | |
260 | @param select | |
261 | Specifies whether the page should be selected. | |
262 | @param imageId | |
263 | Specifies the optional image index for the new page. | |
264 | ||
265 | @return @true if successful, @false otherwise. | |
266 | ||
267 | @remarks Do not delete the page, it will be deleted by the book control. | |
268 | ||
269 | @see AddPage() | |
270 | @since 2.9.3 | |
271 | */ | |
272 | virtual bool InsertPage(size_t index, wxWindow *page, const wxString &text, | |
273 | bool select=false, int imageId=NO_IMAGE); | |
274 | ||
23324ae1 FM |
275 | /** |
276 | Removes a page, without deleting the window pointer. | |
277 | */ | |
278 | bool RemovePage(size_t page); | |
279 | ||
280 | /** | |
281 | Sets the art provider to be used by the notebook. | |
282 | */ | |
283 | void SetArtProvider(wxAuiTabArt* art); | |
284 | ||
285 | /** | |
286 | Sets the font for drawing the tab labels, using a bold version of the font for | |
287 | selected tab labels. | |
288 | */ | |
d2aa927a | 289 | virtual bool SetFont(const wxFont& font); |
23324ae1 FM |
290 | |
291 | /** | |
292 | Sets the font for measuring tab labels. | |
293 | */ | |
294 | void SetMeasuringFont(const wxFont& font); | |
295 | ||
296 | /** | |
297 | Sets the font for drawing unselected tab labels. | |
298 | */ | |
299 | void SetNormalFont(const wxFont& font); | |
300 | ||
301 | /** | |
302 | Sets the bitmap for the page. To remove a bitmap from the tab caption, pass | |
303 | wxNullBitmap. | |
304 | */ | |
305 | bool SetPageBitmap(size_t page, const wxBitmap& bitmap); | |
306 | ||
873ff54b SL |
307 | /** |
308 | Sets the image index for the given page. @a image is an index into | |
309 | the image list which was set with SetImageList(). | |
310 | @since 2.9.3 | |
311 | */ | |
312 | virtual bool SetPageImage(size_t n, int imageId); | |
313 | ||
23324ae1 FM |
314 | /** |
315 | Sets the tab label for the page. | |
316 | */ | |
317 | bool SetPageText(size_t page, const wxString& text); | |
318 | ||
11527fc9 VZ |
319 | /** |
320 | Sets the tooltip displayed when hovering over the tab label of the page. | |
321 | ||
322 | @return | |
323 | @true if tooltip was updated, @false if it failed, e.g. because the | |
324 | page index is invalid. | |
325 | ||
326 | @since 2.9.4 | |
327 | */ | |
328 | bool SetPageToolTip(size_t page, const wxString& text); | |
329 | ||
23324ae1 FM |
330 | /** |
331 | Sets the font for drawing selected tab labels. | |
332 | */ | |
333 | void SetSelectedFont(const wxFont& font); | |
334 | ||
335 | /** | |
336 | Sets the page selection. Calling this method will generate a page change event. | |
337 | */ | |
338 | size_t SetSelection(size_t new_page); | |
339 | ||
340 | /** | |
47d602c1 FM |
341 | Sets the tab height. By default, the tab control height is calculated |
342 | by measuring the text height and bitmap sizes on the tab captions. Calling this | |
23324ae1 | 343 | method will override that calculation and set the tab control to the specified |
47d602c1 | 344 | height parameter. A call to this method will override any call to |
23324ae1 | 345 | SetUniformBitmapSize(). |
47d602c1 | 346 | |
23324ae1 FM |
347 | Specifying -1 as the height will return the control to its default auto-sizing |
348 | behaviour. | |
349 | */ | |
d2aa927a | 350 | virtual void SetTabCtrlHeight(int height); |
23324ae1 FM |
351 | |
352 | //@{ | |
353 | /** | |
4cc4bfaf | 354 | Split performs a split operation programmatically. The argument @a page |
47d602c1 FM |
355 | indicates the page that will be split off. This page will also become the |
356 | active page after the split. | |
357 | ||
358 | The @a direction argument specifies where the pane should go, it should be one | |
23324ae1 FM |
359 | of the following: wxTOP, wxBOTTOM, wxLEFT, or wxRIGHT. |
360 | */ | |
382f12e4 FM |
361 | virtual void SetUniformBitmapSize(const wxSize& size); |
362 | virtual void Split(size_t page, int direction); | |
23324ae1 FM |
363 | //@} |
364 | ||
365 | /** | |
366 | Shows the window menu for the active tab control associated with this notebook, | |
367 | and returns @true if a selection was made. | |
368 | */ | |
369 | bool ShowWindowMenu(); | |
370 | }; | |
371 | ||
c55488df VZ |
372 | /** |
373 | @class wxAuiTabContainerButton | |
374 | ||
375 | A simple class which holds information about wxAuiNotebook tab buttons and their state. | |
376 | ||
377 | @library{wxaui} | |
378 | @category{aui} | |
379 | */ | |
380 | class wxAuiTabContainerButton | |
381 | { | |
382 | public: | |
383 | /// button's id | |
384 | int id; | |
385 | /// current state (normal, hover, pressed, etc.) | |
386 | int curState; | |
387 | /// buttons location (wxLEFT, wxRIGHT, or wxCENTER) | |
388 | int location; | |
389 | /// button's hover bitmap | |
390 | wxBitmap bitmap; | |
391 | /// button's disabled bitmap | |
392 | wxBitmap disBitmap; | |
393 | /// button's hit rectangle | |
394 | wxRect rect; | |
395 | }; | |
396 | ||
397 | ||
398 | /** | |
399 | @class wxAuiTabContainer | |
400 | ||
401 | wxAuiTabContainer is a class which contains information about each tab. | |
402 | It also can render an entire tab control to a specified DC. | |
403 | It's not a window class itself, because this code will be used by | |
404 | the wxAuiNotebook, where it is disadvantageous to have separate | |
405 | windows for each tab control in the case of "docked tabs". | |
406 | ||
407 | A derived class, wxAuiTabCtrl, is an actual wxWindow - derived window | |
408 | which can be used as a tab control in the normal sense. | |
409 | ||
410 | @library{wxaui} | |
411 | @category{aui} | |
412 | */ | |
413 | class wxAuiTabContainer | |
414 | { | |
415 | public: | |
416 | ||
417 | /** | |
418 | Default ctor. | |
419 | */ | |
420 | wxAuiTabContainer(); | |
421 | ||
422 | /** | |
423 | Default dtor. | |
424 | */ | |
425 | virtual ~wxAuiTabContainer(); | |
426 | ||
427 | void SetArtProvider(wxAuiTabArt* art); | |
428 | wxAuiTabArt* GetArtProvider() const; | |
429 | ||
430 | void SetFlags(unsigned int flags); | |
431 | unsigned int GetFlags() const; | |
432 | ||
433 | bool AddPage(wxWindow* page, const wxAuiNotebookPage& info); | |
434 | bool InsertPage(wxWindow* page, const wxAuiNotebookPage& info, size_t idx); | |
435 | bool MovePage(wxWindow* page, size_t newIdx); | |
436 | bool RemovePage(wxWindow* page); | |
437 | bool SetActivePage(wxWindow* page); | |
438 | bool SetActivePage(size_t page); | |
439 | void SetNoneActive(); | |
440 | int GetActivePage() const; | |
441 | bool TabHitTest(int x, int y, wxWindow** hit) const; | |
442 | bool ButtonHitTest(int x, int y, wxAuiTabContainerButton** hit) const; | |
443 | wxWindow* GetWindowFromIdx(size_t idx) const; | |
444 | int GetIdxFromWindow(wxWindow* page) const; | |
445 | size_t GetPageCount() const; | |
446 | wxAuiNotebookPage& GetPage(size_t idx); | |
447 | const wxAuiNotebookPage& GetPage(size_t idx) const; | |
448 | wxAuiNotebookPageArray& GetPages(); | |
449 | void SetNormalFont(const wxFont& normalFont); | |
450 | void SetSelectedFont(const wxFont& selectedFont); | |
451 | void SetMeasuringFont(const wxFont& measuringFont); | |
452 | void SetColour(const wxColour& colour); | |
453 | void SetActiveColour(const wxColour& colour); | |
454 | void DoShowHide(); | |
455 | void SetRect(const wxRect& rect); | |
456 | ||
457 | void RemoveButton(int id); | |
458 | void AddButton(int id, | |
459 | int location, | |
460 | const wxBitmap& normalBitmap = wxNullBitmap, | |
461 | const wxBitmap& disabledBitmap = wxNullBitmap); | |
462 | ||
463 | size_t GetTabOffset() const; | |
464 | void SetTabOffset(size_t offset); | |
465 | ||
466 | // Is the tab visible? | |
467 | bool IsTabVisible(int tabPage, int tabOffset, wxDC* dc, wxWindow* wnd); | |
468 | ||
469 | // Make the tab visible if it wasn't already | |
470 | void MakeTabVisible(int tabPage, wxWindow* win); | |
471 | ||
472 | protected: | |
473 | ||
474 | virtual void Render(wxDC* dc, wxWindow* wnd); | |
475 | ||
476 | protected: | |
477 | ||
478 | wxAuiTabArt* m_art; | |
479 | wxAuiNotebookPageArray m_pages; | |
480 | wxAuiTabContainerButtonArray m_buttons; | |
481 | wxAuiTabContainerButtonArray m_tabCloseButtons; | |
482 | wxRect m_rect; | |
483 | size_t m_tabOffset; | |
484 | unsigned int m_flags; | |
485 | }; | |
486 | ||
23324ae1 | 487 | |
e54c96f1 | 488 | |
23324ae1 FM |
489 | /** |
490 | @class wxAuiTabArt | |
7c913512 | 491 | |
c55488df | 492 | Tab art provider defines all the drawing functions used by wxAuiNotebook. |
7c913512 | 493 | |
c55488df VZ |
494 | This allows the wxAuiNotebook to have a pluggable look-and-feel. |
495 | ||
496 | By default, a wxAuiNotebook uses an instance of this class called | |
497 | wxAuiDefaultTabArt which provides bitmap art and a colour scheme that is | |
498 | adapted to the major platforms' look. You can either derive from that class | |
499 | to alter its behaviour or write a completely new tab art class. | |
500 | ||
501 | Another example of creating a new wxAuiNotebook tab bar is wxAuiSimpleTabArt. | |
502 | ||
503 | Call wxAuiNotebook::SetArtProvider() to make use of this new tab art. | |
47d602c1 | 504 | |
23324ae1 FM |
505 | @library{wxaui} |
506 | @category{aui} | |
507 | */ | |
7c913512 | 508 | class wxAuiTabArt |
23324ae1 FM |
509 | { |
510 | public: | |
511 | /** | |
512 | Constructor. | |
513 | */ | |
514 | wxAuiTabArt(); | |
515 | ||
516 | /** | |
517 | Clones the art object. | |
518 | */ | |
d2aa927a | 519 | virtual wxAuiTabArt* Clone() = 0; |
23324ae1 FM |
520 | |
521 | /** | |
522 | Draws a background on the given area. | |
523 | */ | |
d2aa927a | 524 | virtual void DrawBackground(wxDC& dc, wxWindow* wnd, const wxRect& rect) = 0; |
23324ae1 FM |
525 | |
526 | /** | |
527 | Draws a button. | |
528 | */ | |
1d497b99 FM |
529 | virtual void DrawButton(wxDC& dc, wxWindow* wnd, const wxRect& in_rect, |
530 | int bitmap_id, int button_state, int orientation, | |
531 | wxRect* out_rect) = 0; | |
23324ae1 FM |
532 | |
533 | /** | |
534 | Draws a tab. | |
535 | */ | |
1d497b99 FM |
536 | virtual void DrawTab(wxDC& dc, wxWindow* wnd, const wxAuiNotebookPage& page, |
537 | const wxRect& rect, int close_button_state, | |
538 | wxRect* out_tab_rect, wxRect* out_button_rect, int* x_extent) = 0; | |
23324ae1 FM |
539 | |
540 | /** | |
541 | Returns the tab control size. | |
542 | */ | |
1d497b99 | 543 | virtual int GetBestTabCtrlSize(wxWindow*, const wxAuiNotebookPageArray&, const wxSize&) = 0; |
23324ae1 FM |
544 | |
545 | /** | |
546 | Returns the indent size. | |
547 | */ | |
d2aa927a | 548 | virtual int GetIndentSize() = 0; |
23324ae1 FM |
549 | |
550 | /** | |
551 | Returns the tab size for the given caption, bitmap and state. | |
552 | */ | |
1d497b99 FM |
553 | virtual wxSize GetTabSize(wxDC& dc, wxWindow* wnd, const wxString& caption, |
554 | const wxBitmap& bitmap, bool active, | |
555 | int close_button_state, int* x_extent) = 0; | |
23324ae1 FM |
556 | |
557 | /** | |
558 | Sets flags. | |
559 | */ | |
d2aa927a | 560 | virtual void SetFlags(unsigned int flags) = 0; |
23324ae1 FM |
561 | |
562 | /** | |
563 | Sets the font used for calculating measurements. | |
564 | */ | |
d2aa927a | 565 | virtual void SetMeasuringFont(const wxFont& font) = 0; |
23324ae1 FM |
566 | |
567 | /** | |
568 | Sets the normal font for drawing labels. | |
569 | */ | |
d2aa927a | 570 | virtual void SetNormalFont(const wxFont& font) = 0; |
23324ae1 FM |
571 | |
572 | /** | |
573 | Sets the font for drawing text for selected UI elements. | |
574 | */ | |
d2aa927a | 575 | virtual void SetSelectedFont(const wxFont& font) = 0; |
23324ae1 | 576 | |
ceb9b8db VZ |
577 | /** |
578 | Sets the colour of the inactive tabs. | |
579 | ||
580 | @since 2.9.2 | |
581 | */ | |
582 | virtual void SetColour(const wxColour& colour) = 0; | |
583 | ||
584 | /** | |
585 | Sets the colour of the selected tab. | |
586 | ||
587 | @since 2.9.2 | |
588 | */ | |
589 | virtual void SetActiveColour(const wxColour& colour) = 0; | |
590 | ||
23324ae1 FM |
591 | /** |
592 | Sets sizing information. | |
593 | */ | |
d2aa927a | 594 | virtual void SetSizingInfo(const wxSize& tab_ctrl_size, size_t tab_count) = 0; |
23324ae1 | 595 | }; |
e54c96f1 | 596 | |
873ff54b SL |
597 | /** |
598 | @class wxAuiNotebookEvent | |
599 | ||
600 | This class is used by the events generated by wxAuiNotebook. | |
601 | ||
602 | @beginEventEmissionTable{wxAuiNotebookEvent} | |
603 | @event{EVT_AUINOTEBOOK_PAGE_CLOSE(id, func)} | |
ce7fe42e | 604 | A page is about to be closed. Processes a @c wxEVT_AUINOTEBOOK_PAGE_CLOSE event. |
27674b66 | 605 | @event{EVT_AUINOTEBOOK_PAGE_CLOSED(winid, fn)} |
ce7fe42e | 606 | A page has been closed. Processes a @c wxEVT_AUINOTEBOOK_PAGE_CLOSED event. |
873ff54b | 607 | @event{EVT_AUINOTEBOOK_PAGE_CHANGED(id, func)} |
ce7fe42e | 608 | The page selection was changed. Processes a @c wxEVT_AUINOTEBOOK_PAGE_CHANGED event. |
873ff54b | 609 | @event{EVT_AUINOTEBOOK_PAGE_CHANGING(id, func)} |
ce7fe42e | 610 | The page selection is about to be changed. Processes a @c wxEVT_AUINOTEBOOK_PAGE_CHANGING event. This event can be vetoed. |
873ff54b | 611 | @event{EVT_AUINOTEBOOK_BUTTON(id, func)} |
ce7fe42e | 612 | The window list button has been pressed. Processes a @c wxEVT_AUINOTEBOOK_BUTTON event. |
873ff54b | 613 | @event{EVT_AUINOTEBOOK_BEGIN_DRAG(id, func)} |
ce7fe42e | 614 | Dragging is about to begin. Processes a @c wxEVT_AUINOTEBOOK_BEGIN_DRAG event. |
873ff54b | 615 | @event{EVT_AUINOTEBOOK_END_DRAG(id, func)} |
ce7fe42e | 616 | Dragging has ended. Processes a @c wxEVT_AUINOTEBOOK_END_DRAG event. |
873ff54b | 617 | @event{EVT_AUINOTEBOOK_DRAG_MOTION(id, func)} |
ce7fe42e | 618 | Emitted during a drag and drop operation. Processes a @c wxEVT_AUINOTEBOOK_DRAG_MOTION event. |
873ff54b | 619 | @event{EVT_AUINOTEBOOK_ALLOW_DND(id, func)} |
ce7fe42e | 620 | Whether to allow a tab to be dropped. Processes a @c wxEVT_AUINOTEBOOK_ALLOW_DND event. This event must be specially allowed. |
27674b66 | 621 | @event{EVT_AUINOTEBOOK_DRAG_DONE(winid, fn)} |
ce7fe42e | 622 | Notify that the tab has been dragged. Processes a @c wxEVT_AUINOTEBOOK_DRAG_DONE event. |
27674b66 | 623 | @event{EVT_AUINOTEBOOK_TAB_MIDDLE_DOWN(winid, fn)} |
ce7fe42e | 624 | The middle mouse button is pressed on a tab. Processes a @c wxEVT_AUINOTEBOOK_TAB_MIDDLE_DOWN event. |
27674b66 | 625 | @event{EVT_AUINOTEBOOK_TAB_MIDDLE_UP(winid, fn)} |
ce7fe42e | 626 | The middle mouse button is released on a tab. Processes a @c wxEVT_AUINOTEBOOK_TAB_MIDDLE_UP event. |
27674b66 | 627 | @event{EVT_AUINOTEBOOK_TAB_RIGHT_DOWN(winid, fn)} |
ce7fe42e | 628 | The right mouse button is pressed on a tab. Processes a @c wxEVT_AUINOTEBOOK_TAB_RIGHT_DOWN event. |
27674b66 | 629 | @event{EVT_AUINOTEBOOK_TAB_RIGHT_UP(winid, fn)} |
ce7fe42e | 630 | The right mouse button is released on a tab. Processes a @c wxEVT_AUINOTEBOOK_TAB_RIGHT_UP event. |
27674b66 | 631 | @event{EVT_AUINOTEBOOK_BG_DCLICK(winid, fn)} |
ce7fe42e | 632 | Double clicked on the tabs background area. Processes a @c wxEVT_AUINOTEBOOK_BG_DCLICK event. |
873ff54b SL |
633 | @endEventTable |
634 | ||
635 | @library{wxaui} | |
636 | @category{events,bookctrl} | |
637 | ||
638 | @see wxAuiNotebook, wxBookCtrlEvent | |
639 | */ | |
640 | class wxAuiNotebookEvent : public wxBookCtrlEvent | |
641 | { | |
642 | public: | |
643 | /** | |
644 | Constructor. | |
645 | */ | |
646 | wxAuiNotebookEvent(wxEventType command_type = wxEVT_NULL, int win_id = 0); | |
647 | ||
648 | wxEvent *Clone(); | |
649 | }; | |
650 | ||
c55488df VZ |
651 | /** |
652 | Default art provider for wxAuiNotebook. | |
653 | ||
654 | @see wxAuiTabArt | |
655 | ||
656 | @genericAppearance{auidefaulttabart.png} | |
657 | ||
658 | @library{wxaui} | |
659 | @category{aui} | |
660 | */ | |
661 | ||
662 | class wxAuiDefaultTabArt : public wxAuiTabArt | |
663 | { | |
664 | public: | |
665 | ||
666 | wxAuiDefaultTabArt(); | |
667 | virtual ~wxAuiDefaultTabArt(); | |
668 | ||
669 | wxAuiTabArt* Clone(); | |
670 | void SetFlags(unsigned int flags); | |
671 | void SetSizingInfo(const wxSize& tabCtrlSize, | |
672 | size_t tabCount); | |
673 | ||
674 | void SetNormalFont(const wxFont& font); | |
675 | void SetSelectedFont(const wxFont& font); | |
676 | void SetMeasuringFont(const wxFont& font); | |
677 | void SetColour(const wxColour& colour); | |
678 | void SetActiveColour(const wxColour& colour); | |
679 | ||
680 | void DrawBackground( | |
681 | wxDC& dc, | |
682 | wxWindow* wnd, | |
683 | const wxRect& rect); | |
684 | ||
685 | void DrawTab(wxDC& dc, | |
686 | wxWindow* wnd, | |
687 | const wxAuiNotebookPage& pane, | |
688 | const wxRect& inRect, | |
689 | int closeButtonState, | |
690 | wxRect* outTabRect, | |
691 | wxRect* outButtonRect, | |
692 | int* xExtent); | |
693 | ||
694 | void DrawButton( | |
695 | wxDC& dc, | |
696 | wxWindow* wnd, | |
697 | const wxRect& inRect, | |
698 | int bitmapId, | |
699 | int buttonState, | |
700 | int orientation, | |
701 | wxRect* outRect); | |
702 | ||
703 | int GetIndentSize(); | |
704 | ||
705 | wxSize GetTabSize( | |
706 | wxDC& dc, | |
707 | wxWindow* wnd, | |
708 | const wxString& caption, | |
709 | const wxBitmap& bitmap, | |
710 | bool active, | |
711 | int closeButtonState, | |
712 | int* xExtent); | |
713 | ||
714 | int ShowDropDown( | |
715 | wxWindow* wnd, | |
716 | const wxAuiNotebookPageArray& items, | |
717 | int activeIdx); | |
718 | ||
719 | int GetBestTabCtrlSize(wxWindow* wnd, | |
720 | const wxAuiNotebookPageArray& pages, | |
721 | const wxSize& requiredBmpSize); | |
722 | ||
723 | protected: | |
724 | /** | |
725 | The font used for all tabs | |
726 | */ | |
727 | wxFont m_normalFont; | |
728 | wxFont m_selectedFont; /// The font used on the selected tab | |
729 | wxFont m_measuringFont; | |
730 | wxColour m_baseColour; | |
731 | wxPen m_baseColourPen; | |
732 | wxPen m_borderPen; | |
733 | wxBrush m_baseColourBrush; | |
734 | wxColour m_activeColour; | |
735 | wxBitmap m_activeCloseBmp; | |
736 | wxBitmap m_disabledCloseBmp; | |
737 | wxBitmap m_activeLeftBmp; | |
738 | wxBitmap m_disabledLeftBmp; | |
739 | wxBitmap m_activeRightBmp; | |
740 | wxBitmap m_disabledRightBmp; | |
741 | wxBitmap m_activeWindowListBmp; | |
742 | wxBitmap m_disabledWindowListBmp; | |
743 | ||
744 | int m_fixedTabWidth; | |
745 | int m_tabCtrlHeight; | |
746 | unsigned int m_flags; | |
747 | }; | |
748 | ||
749 | ||
750 | /** | |
751 | @class wxAuiSimpleTabArt | |
752 | ||
753 | Another standard tab art provider for wxAuiNotebook. | |
754 | ||
755 | wxAuiSimpleTabArt is derived from wxAuiTabArt demonstrating how to write a | |
756 | completely new tab art class. It can also be used as alternative to | |
757 | wxAuiDefaultTabArt. | |
758 | ||
759 | @genericAppearance{auisimpletabart.png} | |
760 | ||
761 | @library{wxaui} | |
762 | @category{aui} | |
763 | */ | |
764 | ||
765 | class wxAuiSimpleTabArt : public wxAuiTabArt | |
766 | { | |
767 | ||
768 | public: | |
769 | ||
770 | wxAuiSimpleTabArt(); | |
771 | virtual ~wxAuiSimpleTabArt(); | |
772 | ||
773 | wxAuiTabArt* Clone(); | |
774 | void SetFlags(unsigned int flags); | |
775 | ||
776 | void SetSizingInfo(const wxSize& tabCtrlSize, | |
777 | size_t tabCount); | |
778 | ||
779 | void SetNormalFont(const wxFont& font); | |
780 | void SetSelectedFont(const wxFont& font); | |
781 | void SetMeasuringFont(const wxFont& font); | |
782 | void SetColour(const wxColour& colour); | |
783 | void SetActiveColour(const wxColour& colour); | |
784 | ||
785 | void DrawBackground( | |
786 | wxDC& dc, | |
787 | wxWindow* wnd, | |
788 | const wxRect& rect); | |
789 | ||
790 | void DrawTab(wxDC& dc, | |
791 | wxWindow* wnd, | |
792 | const wxAuiNotebookPage& pane, | |
793 | const wxRect& inRect, | |
794 | int closeButtonState, | |
795 | wxRect* outTabRect, | |
796 | wxRect* outButtonRect, | |
797 | int* xExtent); | |
798 | ||
799 | void DrawButton( | |
800 | wxDC& dc, | |
801 | wxWindow* wnd, | |
802 | const wxRect& inRect, | |
803 | int bitmapId, | |
804 | int buttonState, | |
805 | int orientation, | |
806 | wxRect* outRect); | |
807 | ||
808 | int GetIndentSize(); | |
809 | ||
810 | wxSize GetTabSize( | |
811 | wxDC& dc, | |
812 | wxWindow* wnd, | |
813 | const wxString& caption, | |
814 | const wxBitmap& bitmap, | |
815 | bool active, | |
816 | int closeButtonState, | |
817 | int* xExtent); | |
818 | ||
819 | int ShowDropDown( | |
820 | wxWindow* wnd, | |
821 | const wxAuiNotebookPageArray& items, | |
822 | int activeIdx); | |
823 | ||
824 | int GetBestTabCtrlSize(wxWindow* wnd, | |
825 | const wxAuiNotebookPageArray& pages, | |
826 | const wxSize& requiredBmpSize); | |
827 | ||
828 | protected: | |
829 | ||
830 | wxFont m_normalFont; | |
831 | wxFont m_selectedFont; | |
832 | wxFont m_measuringFont; | |
833 | wxPen m_normalBkPen; | |
834 | wxPen m_selectedBkPen; | |
835 | wxBrush m_normalBkBrush; | |
836 | wxBrush m_selectedBkBrush; | |
837 | wxBrush m_bkBrush; | |
838 | wxBitmap m_activeCloseBmp; | |
839 | wxBitmap m_disabledCloseBmp; | |
840 | wxBitmap m_activeLeftBmp; | |
841 | wxBitmap m_disabledLeftBmp; | |
842 | wxBitmap m_activeRightBmp; | |
843 | wxBitmap m_disabledRightBmp; | |
844 | wxBitmap m_activeWindowListBmp; | |
845 | wxBitmap m_disabledWindowListBmp; | |
846 | ||
847 | int m_fixedTabWidth; | |
848 | unsigned int m_flags; | |
849 | }; |