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