]>
Commit | Line | Data |
---|---|---|
1 | ////////////////////////////////////////////////////////////////////////////// | |
2 | // Name: wx/aui/auibook.h | |
3 | // Purpose: wxaui: wx advanced user interface - notebook | |
4 | // Author: Benjamin I. Williams | |
5 | // Modified by: | |
6 | // Created: 2006-06-28 | |
7 | // Copyright: (C) Copyright 2006, Kirix Corporation, All Rights Reserved. | |
8 | // Licence: wxWindows Library Licence, Version 3.1 | |
9 | /////////////////////////////////////////////////////////////////////////////// | |
10 | ||
11 | ||
12 | ||
13 | #ifndef _WX_AUINOTEBOOK_H_ | |
14 | #define _WX_AUINOTEBOOK_H_ | |
15 | ||
16 | // ---------------------------------------------------------------------------- | |
17 | // headers | |
18 | // ---------------------------------------------------------------------------- | |
19 | ||
20 | #include "wx/defs.h" | |
21 | ||
22 | #if wxUSE_AUI | |
23 | ||
24 | #include "wx/aui/framemanager.h" | |
25 | #include "wx/aui/dockart.h" | |
26 | #include "wx/aui/floatpane.h" | |
27 | #include "wx/control.h" | |
28 | ||
29 | ||
30 | class wxAuiNotebook; | |
31 | ||
32 | ||
33 | enum wxAuiNotebookOption | |
34 | { | |
35 | wxAUI_NB_TOP = 1 << 0, | |
36 | wxAUI_NB_LEFT = 1 << 1, // not implemented yet | |
37 | wxAUI_NB_RIGHT = 1 << 2, // not implemented yet | |
38 | wxAUI_NB_BOTTOM = 1 << 3, | |
39 | wxAUI_NB_TAB_SPLIT = 1 << 4, | |
40 | wxAUI_NB_TAB_MOVE = 1 << 5, | |
41 | wxAUI_NB_TAB_EXTERNAL_MOVE = 1 << 6, | |
42 | wxAUI_NB_TAB_FIXED_WIDTH = 1 << 7, | |
43 | wxAUI_NB_SCROLL_BUTTONS = 1 << 8, | |
44 | wxAUI_NB_WINDOWLIST_BUTTON = 1 << 9, | |
45 | wxAUI_NB_CLOSE_BUTTON = 1 << 10, | |
46 | wxAUI_NB_CLOSE_ON_ACTIVE_TAB = 1 << 11, | |
47 | wxAUI_NB_CLOSE_ON_ALL_TABS = 1 << 12, | |
48 | wxAUI_NB_MIDDLE_CLICK_CLOSE = 1 << 13, | |
49 | ||
50 | wxAUI_NB_DEFAULT_STYLE = wxAUI_NB_TOP | | |
51 | wxAUI_NB_TAB_SPLIT | | |
52 | wxAUI_NB_TAB_MOVE | | |
53 | wxAUI_NB_SCROLL_BUTTONS | | |
54 | wxAUI_NB_CLOSE_ON_ACTIVE_TAB | | |
55 | wxAUI_NB_MIDDLE_CLICK_CLOSE | |
56 | }; | |
57 | ||
58 | ||
59 | ||
60 | ||
61 | // aui notebook event class | |
62 | ||
63 | class WXDLLIMPEXP_AUI wxAuiNotebookEvent : public wxNotifyEvent | |
64 | { | |
65 | public: | |
66 | wxAuiNotebookEvent(wxEventType command_type = wxEVT_NULL, | |
67 | int win_id = 0) | |
68 | : wxNotifyEvent(command_type, win_id) | |
69 | { | |
70 | old_selection = -1; | |
71 | selection = -1; | |
72 | drag_source = NULL; | |
73 | } | |
74 | #ifndef SWIG | |
75 | wxAuiNotebookEvent(const wxAuiNotebookEvent& c) : wxNotifyEvent(c) | |
76 | { | |
77 | old_selection = c.old_selection; | |
78 | selection = c.selection; | |
79 | drag_source = c.drag_source; | |
80 | } | |
81 | #endif | |
82 | wxEvent *Clone() const { return new wxAuiNotebookEvent(*this); } | |
83 | ||
84 | void SetSelection(int s) { selection = s; m_commandInt = s; } | |
85 | int GetSelection() const { return selection; } | |
86 | ||
87 | void SetOldSelection(int s) { old_selection = s; } | |
88 | int GetOldSelection() const { return old_selection; } | |
89 | ||
90 | void SetDragSource(wxAuiNotebook* s) { drag_source = s; } | |
91 | wxAuiNotebook* GetDragSource() const { return drag_source; } | |
92 | ||
93 | public: | |
94 | int old_selection; | |
95 | int selection; | |
96 | wxAuiNotebook* drag_source; | |
97 | ||
98 | #ifndef SWIG | |
99 | private: | |
100 | DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxAuiNotebookEvent) | |
101 | #endif | |
102 | }; | |
103 | ||
104 | ||
105 | class WXDLLIMPEXP_AUI wxAuiNotebookPage | |
106 | { | |
107 | public: | |
108 | wxWindow* window; // page's associated window | |
109 | wxString caption; // caption displayed on the tab | |
110 | wxBitmap bitmap; // tab's bitmap | |
111 | wxRect rect; // tab's hit rectangle | |
112 | bool active; // true if the page is currently active | |
113 | }; | |
114 | ||
115 | class WXDLLIMPEXP_AUI wxAuiTabContainerButton | |
116 | { | |
117 | public: | |
118 | ||
119 | int id; // button's id | |
120 | int cur_state; // current state (normal, hover, pressed, etc.) | |
121 | int location; // buttons location (wxLEFT, wxRIGHT, or wxCENTER) | |
122 | wxBitmap bitmap; // button's hover bitmap | |
123 | wxBitmap dis_bitmap; // button's disabled bitmap | |
124 | wxRect rect; // button's hit rectangle | |
125 | }; | |
126 | ||
127 | ||
128 | #ifndef SWIG | |
129 | WX_DECLARE_USER_EXPORTED_OBJARRAY(wxAuiNotebookPage, wxAuiNotebookPageArray, WXDLLIMPEXP_AUI); | |
130 | WX_DECLARE_USER_EXPORTED_OBJARRAY(wxAuiTabContainerButton, wxAuiTabContainerButtonArray, WXDLLIMPEXP_AUI); | |
131 | #endif | |
132 | ||
133 | ||
134 | // tab art class | |
135 | ||
136 | class WXDLLIMPEXP_AUI wxAuiTabArt | |
137 | { | |
138 | public: | |
139 | ||
140 | wxAuiTabArt() { } | |
141 | virtual ~wxAuiTabArt() { } | |
142 | ||
143 | virtual wxAuiTabArt* Clone() = 0; | |
144 | virtual void SetFlags(unsigned int flags) = 0; | |
145 | ||
146 | virtual void SetSizingInfo(const wxSize& tab_ctrl_size, | |
147 | size_t tab_count) = 0; | |
148 | ||
149 | virtual void SetNormalFont(const wxFont& font) = 0; | |
150 | virtual void SetSelectedFont(const wxFont& font) = 0; | |
151 | virtual void SetMeasuringFont(const wxFont& font) = 0; | |
152 | virtual void SetColour(const wxColour& colour) = 0; | |
153 | virtual void SetActiveColour(const wxColour& colour) = 0; | |
154 | ||
155 | virtual void DrawBackground( | |
156 | wxDC& dc, | |
157 | wxWindow* wnd, | |
158 | const wxRect& rect) = 0; | |
159 | ||
160 | virtual void DrawTab(wxDC& dc, | |
161 | wxWindow* wnd, | |
162 | const wxAuiNotebookPage& pane, | |
163 | const wxRect& in_rect, | |
164 | int close_button_state, | |
165 | wxRect* out_tab_rect, | |
166 | wxRect* out_button_rect, | |
167 | int* x_extent) = 0; | |
168 | ||
169 | virtual void DrawButton( | |
170 | wxDC& dc, | |
171 | wxWindow* wnd, | |
172 | const wxRect& in_rect, | |
173 | int bitmap_id, | |
174 | int button_state, | |
175 | int orientation, | |
176 | wxRect* out_rect) = 0; | |
177 | ||
178 | virtual wxSize GetTabSize( | |
179 | wxDC& dc, | |
180 | wxWindow* wnd, | |
181 | const wxString& caption, | |
182 | const wxBitmap& bitmap, | |
183 | bool active, | |
184 | int close_button_state, | |
185 | int* x_extent) = 0; | |
186 | ||
187 | virtual int ShowDropDown( | |
188 | wxWindow* wnd, | |
189 | const wxAuiNotebookPageArray& items, | |
190 | int active_idx) = 0; | |
191 | ||
192 | virtual int GetIndentSize() = 0; | |
193 | ||
194 | virtual int GetBestTabCtrlSize( | |
195 | wxWindow* wnd, | |
196 | const wxAuiNotebookPageArray& pages, | |
197 | const wxSize& required_bmp_size) = 0; | |
198 | }; | |
199 | ||
200 | ||
201 | class WXDLLIMPEXP_AUI wxAuiDefaultTabArt : public wxAuiTabArt | |
202 | { | |
203 | ||
204 | public: | |
205 | ||
206 | wxAuiDefaultTabArt(); | |
207 | virtual ~wxAuiDefaultTabArt(); | |
208 | ||
209 | wxAuiTabArt* Clone(); | |
210 | void SetFlags(unsigned int flags); | |
211 | void SetSizingInfo(const wxSize& tab_ctrl_size, | |
212 | size_t tab_count); | |
213 | ||
214 | void SetNormalFont(const wxFont& font); | |
215 | void SetSelectedFont(const wxFont& font); | |
216 | void SetMeasuringFont(const wxFont& font); | |
217 | void SetColour(const wxColour& colour); | |
218 | void SetActiveColour(const wxColour& colour); | |
219 | ||
220 | void DrawBackground( | |
221 | wxDC& dc, | |
222 | wxWindow* wnd, | |
223 | const wxRect& rect); | |
224 | ||
225 | void DrawTab(wxDC& dc, | |
226 | wxWindow* wnd, | |
227 | const wxAuiNotebookPage& pane, | |
228 | const wxRect& in_rect, | |
229 | int close_button_state, | |
230 | wxRect* out_tab_rect, | |
231 | wxRect* out_button_rect, | |
232 | int* x_extent); | |
233 | ||
234 | void DrawButton( | |
235 | wxDC& dc, | |
236 | wxWindow* wnd, | |
237 | const wxRect& in_rect, | |
238 | int bitmap_id, | |
239 | int button_state, | |
240 | int orientation, | |
241 | wxRect* out_rect); | |
242 | ||
243 | int GetIndentSize(); | |
244 | ||
245 | wxSize GetTabSize( | |
246 | wxDC& dc, | |
247 | wxWindow* wnd, | |
248 | const wxString& caption, | |
249 | const wxBitmap& bitmap, | |
250 | bool active, | |
251 | int close_button_state, | |
252 | int* x_extent); | |
253 | ||
254 | int ShowDropDown( | |
255 | wxWindow* wnd, | |
256 | const wxAuiNotebookPageArray& items, | |
257 | int active_idx); | |
258 | ||
259 | int GetBestTabCtrlSize(wxWindow* wnd, | |
260 | const wxAuiNotebookPageArray& pages, | |
261 | const wxSize& required_bmp_size); | |
262 | ||
263 | protected: | |
264 | ||
265 | wxFont m_normal_font; | |
266 | wxFont m_selected_font; | |
267 | wxFont m_measuring_font; | |
268 | wxColour m_base_colour; | |
269 | wxPen m_base_colour_pen; | |
270 | wxPen m_border_pen; | |
271 | wxBrush m_base_colour_brush; | |
272 | wxColour m_active_colour; | |
273 | wxBitmap m_active_close_bmp; | |
274 | wxBitmap m_disabled_close_bmp; | |
275 | wxBitmap m_active_left_bmp; | |
276 | wxBitmap m_disabled_left_bmp; | |
277 | wxBitmap m_active_right_bmp; | |
278 | wxBitmap m_disabled_right_bmp; | |
279 | wxBitmap m_active_windowlist_bmp; | |
280 | wxBitmap m_disabled_windowlist_bmp; | |
281 | ||
282 | int m_fixed_tab_width; | |
283 | int m_tab_ctrl_height; | |
284 | unsigned int m_flags; | |
285 | }; | |
286 | ||
287 | ||
288 | class WXDLLIMPEXP_AUI wxAuiSimpleTabArt : public wxAuiTabArt | |
289 | { | |
290 | ||
291 | public: | |
292 | ||
293 | wxAuiSimpleTabArt(); | |
294 | virtual ~wxAuiSimpleTabArt(); | |
295 | ||
296 | wxAuiTabArt* Clone(); | |
297 | void SetFlags(unsigned int flags); | |
298 | ||
299 | void SetSizingInfo(const wxSize& tab_ctrl_size, | |
300 | size_t tab_count); | |
301 | ||
302 | void SetNormalFont(const wxFont& font); | |
303 | void SetSelectedFont(const wxFont& font); | |
304 | void SetMeasuringFont(const wxFont& font); | |
305 | void SetColour(const wxColour& colour); | |
306 | void SetActiveColour(const wxColour& colour); | |
307 | ||
308 | void DrawBackground( | |
309 | wxDC& dc, | |
310 | wxWindow* wnd, | |
311 | const wxRect& rect); | |
312 | ||
313 | void DrawTab(wxDC& dc, | |
314 | wxWindow* wnd, | |
315 | const wxAuiNotebookPage& pane, | |
316 | const wxRect& in_rect, | |
317 | int close_button_state, | |
318 | wxRect* out_tab_rect, | |
319 | wxRect* out_button_rect, | |
320 | int* x_extent); | |
321 | ||
322 | void DrawButton( | |
323 | wxDC& dc, | |
324 | wxWindow* wnd, | |
325 | const wxRect& in_rect, | |
326 | int bitmap_id, | |
327 | int button_state, | |
328 | int orientation, | |
329 | wxRect* out_rect); | |
330 | ||
331 | int GetIndentSize(); | |
332 | ||
333 | wxSize GetTabSize( | |
334 | wxDC& dc, | |
335 | wxWindow* wnd, | |
336 | const wxString& caption, | |
337 | const wxBitmap& bitmap, | |
338 | bool active, | |
339 | int close_button_state, | |
340 | int* x_extent); | |
341 | ||
342 | int ShowDropDown( | |
343 | wxWindow* wnd, | |
344 | const wxAuiNotebookPageArray& items, | |
345 | int active_idx); | |
346 | ||
347 | int GetBestTabCtrlSize(wxWindow* wnd, | |
348 | const wxAuiNotebookPageArray& pages, | |
349 | const wxSize& required_bmp_size); | |
350 | ||
351 | protected: | |
352 | ||
353 | wxFont m_normal_font; | |
354 | wxFont m_selected_font; | |
355 | wxFont m_measuring_font; | |
356 | wxPen m_normal_bkpen; | |
357 | wxPen m_selected_bkpen; | |
358 | wxBrush m_normal_bkbrush; | |
359 | wxBrush m_selected_bkbrush; | |
360 | wxBrush m_bkbrush; | |
361 | wxBitmap m_active_close_bmp; | |
362 | wxBitmap m_disabled_close_bmp; | |
363 | wxBitmap m_active_left_bmp; | |
364 | wxBitmap m_disabled_left_bmp; | |
365 | wxBitmap m_active_right_bmp; | |
366 | wxBitmap m_disabled_right_bmp; | |
367 | wxBitmap m_active_windowlist_bmp; | |
368 | wxBitmap m_disabled_windowlist_bmp; | |
369 | ||
370 | int m_fixed_tab_width; | |
371 | unsigned int m_flags; | |
372 | }; | |
373 | ||
374 | ||
375 | ||
376 | ||
377 | ||
378 | ||
379 | ||
380 | ||
381 | ||
382 | class WXDLLIMPEXP_AUI wxAuiTabContainer | |
383 | { | |
384 | public: | |
385 | ||
386 | wxAuiTabContainer(); | |
387 | virtual ~wxAuiTabContainer(); | |
388 | ||
389 | void SetArtProvider(wxAuiTabArt* art); | |
390 | wxAuiTabArt* GetArtProvider() const; | |
391 | ||
392 | void SetFlags(unsigned int flags); | |
393 | unsigned int GetFlags() const; | |
394 | ||
395 | bool AddPage(wxWindow* page, const wxAuiNotebookPage& info); | |
396 | bool InsertPage(wxWindow* page, const wxAuiNotebookPage& info, size_t idx); | |
397 | bool MovePage(wxWindow* page, size_t new_idx); | |
398 | bool RemovePage(wxWindow* page); | |
399 | bool SetActivePage(wxWindow* page); | |
400 | bool SetActivePage(size_t page); | |
401 | void SetNoneActive(); | |
402 | int GetActivePage() const; | |
403 | bool TabHitTest(int x, int y, wxWindow** hit) const; | |
404 | bool ButtonHitTest(int x, int y, wxAuiTabContainerButton** hit) const; | |
405 | wxWindow* GetWindowFromIdx(size_t idx) const; | |
406 | int GetIdxFromWindow(wxWindow* page) const; | |
407 | size_t GetPageCount() const; | |
408 | wxAuiNotebookPage& GetPage(size_t idx); | |
409 | const wxAuiNotebookPage& GetPage(size_t idx) const; | |
410 | wxAuiNotebookPageArray& GetPages(); | |
411 | void SetNormalFont(const wxFont& normal_font); | |
412 | void SetSelectedFont(const wxFont& selected_font); | |
413 | void SetMeasuringFont(const wxFont& measuring_font); | |
414 | void SetColour(const wxColour& colour); | |
415 | void SetActiveColour(const wxColour& colour); | |
416 | void DoShowHide(); | |
417 | void SetRect(const wxRect& rect); | |
418 | ||
419 | void RemoveButton(int id); | |
420 | void AddButton(int id, | |
421 | int location, | |
422 | const wxBitmap& normal_bitmap = wxNullBitmap, | |
423 | const wxBitmap& disabled_bitmap = wxNullBitmap); | |
424 | ||
425 | size_t GetTabOffset() const; | |
426 | void SetTabOffset(size_t offset); | |
427 | ||
428 | // Is the tab visible? | |
429 | bool IsTabVisible(int tabPage, int tabOffset, wxDC* dc, wxWindow* wnd); | |
430 | ||
431 | // Make the tab visible if it wasn't already | |
432 | void MakeTabVisible(int tabPage, wxWindow* win); | |
433 | ||
434 | protected: | |
435 | ||
436 | virtual void Render(wxDC* dc, wxWindow* wnd); | |
437 | ||
438 | protected: | |
439 | ||
440 | wxAuiTabArt* m_art; | |
441 | wxAuiNotebookPageArray m_pages; | |
442 | wxAuiTabContainerButtonArray m_buttons; | |
443 | wxAuiTabContainerButtonArray m_tab_close_buttons; | |
444 | wxRect m_rect; | |
445 | size_t m_tab_offset; | |
446 | unsigned int m_flags; | |
447 | }; | |
448 | ||
449 | ||
450 | ||
451 | class WXDLLIMPEXP_AUI wxAuiTabCtrl : public wxControl, | |
452 | public wxAuiTabContainer | |
453 | { | |
454 | public: | |
455 | ||
456 | wxAuiTabCtrl(wxWindow* parent, | |
457 | wxWindowID id = wxID_ANY, | |
458 | const wxPoint& pos = wxDefaultPosition, | |
459 | const wxSize& size = wxDefaultSize, | |
460 | long style = 0); | |
461 | ||
462 | ~wxAuiTabCtrl(); | |
463 | ||
464 | bool IsDragging() const { return m_is_dragging; } | |
465 | ||
466 | protected: | |
467 | // choose the default border for this window | |
468 | virtual wxBorder GetDefaultBorder() const { return wxBORDER_NONE; } | |
469 | ||
470 | void OnPaint(wxPaintEvent& evt); | |
471 | void OnEraseBackground(wxEraseEvent& evt); | |
472 | void OnSize(wxSizeEvent& evt); | |
473 | void OnLeftDown(wxMouseEvent& evt); | |
474 | void OnLeftDClick(wxMouseEvent& evt); | |
475 | void OnLeftUp(wxMouseEvent& evt); | |
476 | void OnMiddleDown(wxMouseEvent& evt); | |
477 | void OnMiddleUp(wxMouseEvent& evt); | |
478 | void OnRightDown(wxMouseEvent& evt); | |
479 | void OnRightUp(wxMouseEvent& evt); | |
480 | void OnMotion(wxMouseEvent& evt); | |
481 | void OnLeaveWindow(wxMouseEvent& evt); | |
482 | void OnButton(wxAuiNotebookEvent& evt); | |
483 | void OnSetFocus(wxFocusEvent& event); | |
484 | void OnKillFocus(wxFocusEvent& event); | |
485 | void OnChar(wxKeyEvent& event); | |
486 | void OnCaptureLost(wxMouseCaptureLostEvent& evt); | |
487 | ||
488 | protected: | |
489 | ||
490 | wxPoint m_click_pt; | |
491 | wxWindow* m_click_tab; | |
492 | bool m_is_dragging; | |
493 | wxAuiTabContainerButton* m_hover_button; | |
494 | wxAuiTabContainerButton* m_pressed_button; | |
495 | ||
496 | #ifndef SWIG | |
497 | DECLARE_CLASS(wxAuiTabCtrl) | |
498 | DECLARE_EVENT_TABLE() | |
499 | #endif | |
500 | }; | |
501 | ||
502 | ||
503 | ||
504 | ||
505 | class WXDLLIMPEXP_AUI wxAuiNotebook : public wxControl | |
506 | { | |
507 | ||
508 | public: | |
509 | ||
510 | wxAuiNotebook(); | |
511 | ||
512 | wxAuiNotebook(wxWindow* parent, | |
513 | wxWindowID id = wxID_ANY, | |
514 | const wxPoint& pos = wxDefaultPosition, | |
515 | const wxSize& size = wxDefaultSize, | |
516 | long style = wxAUI_NB_DEFAULT_STYLE); | |
517 | ||
518 | virtual ~wxAuiNotebook(); | |
519 | ||
520 | bool Create(wxWindow* parent, | |
521 | wxWindowID id = wxID_ANY, | |
522 | const wxPoint& pos = wxDefaultPosition, | |
523 | const wxSize& size = wxDefaultSize, | |
524 | long style = 0); | |
525 | ||
526 | void SetWindowStyleFlag(long style); | |
527 | void SetArtProvider(wxAuiTabArt* art); | |
528 | wxAuiTabArt* GetArtProvider() const; | |
529 | ||
530 | virtual void SetUniformBitmapSize(const wxSize& size); | |
531 | virtual void SetTabCtrlHeight(int height); | |
532 | ||
533 | bool AddPage(wxWindow* page, | |
534 | const wxString& caption, | |
535 | bool select = false, | |
536 | const wxBitmap& bitmap = wxNullBitmap); | |
537 | ||
538 | bool InsertPage(size_t page_idx, | |
539 | wxWindow* page, | |
540 | const wxString& caption, | |
541 | bool select = false, | |
542 | const wxBitmap& bitmap = wxNullBitmap); | |
543 | ||
544 | bool DeletePage(size_t page); | |
545 | bool RemovePage(size_t page); | |
546 | ||
547 | size_t GetPageCount() const; | |
548 | wxWindow* GetPage(size_t page_idx) const; | |
549 | int GetPageIndex(wxWindow* page_wnd) const; | |
550 | ||
551 | bool SetPageText(size_t page, const wxString& text); | |
552 | wxString GetPageText(size_t page_idx) const; | |
553 | ||
554 | bool SetPageBitmap(size_t page, const wxBitmap& bitmap); | |
555 | wxBitmap GetPageBitmap(size_t page_idx) const; | |
556 | ||
557 | size_t SetSelection(size_t new_page); | |
558 | int GetSelection() const; | |
559 | ||
560 | virtual void Split(size_t page, int direction); | |
561 | ||
562 | const wxAuiManager& GetAuiManager() const { return m_mgr; } | |
563 | ||
564 | // Sets the normal font | |
565 | void SetNormalFont(const wxFont& font); | |
566 | ||
567 | // Sets the selected tab font | |
568 | void SetSelectedFont(const wxFont& font); | |
569 | ||
570 | // Sets the measuring font | |
571 | void SetMeasuringFont(const wxFont& font); | |
572 | ||
573 | // Sets the tab font | |
574 | virtual bool SetFont(const wxFont& font); | |
575 | ||
576 | // Gets the tab control height | |
577 | int GetTabCtrlHeight() const; | |
578 | ||
579 | // Gets the height of the notebook for a given page height | |
580 | int GetHeightForPageHeight(int pageHeight); | |
581 | ||
582 | // Advances the selection, generation page selection events | |
583 | void AdvanceSelection(bool forward = true); | |
584 | ||
585 | // Shows the window menu | |
586 | bool ShowWindowMenu(); | |
587 | ||
588 | // we do have multiple pages | |
589 | virtual bool HasMultiplePages() const { return true; } | |
590 | ||
591 | // we don't want focus for ourselves | |
592 | // virtual bool AcceptsFocus() const { return false; } | |
593 | ||
594 | // Redo sizing after thawing | |
595 | virtual void Thaw(); | |
596 | ||
597 | protected: | |
598 | // choose the default border for this window | |
599 | virtual wxBorder GetDefaultBorder() const { return wxBORDER_NONE; } | |
600 | ||
601 | // these can be overridden | |
602 | ||
603 | // update the height, return true if it was done or false if the new height | |
604 | // calculated by CalculateTabCtrlHeight() is the same as the old one | |
605 | virtual bool UpdateTabCtrlHeight(); | |
606 | ||
607 | virtual int CalculateTabCtrlHeight(); | |
608 | virtual wxSize CalculateNewSplitSize(); | |
609 | ||
610 | protected: | |
611 | ||
612 | void DoSizing(); | |
613 | void InitNotebook(long style); | |
614 | wxAuiTabCtrl* GetTabCtrlFromPoint(const wxPoint& pt); | |
615 | wxWindow* GetTabFrameFromTabCtrl(wxWindow* tab_ctrl); | |
616 | wxAuiTabCtrl* GetActiveTabCtrl(); | |
617 | bool FindTab(wxWindow* page, wxAuiTabCtrl** ctrl, int* idx); | |
618 | void RemoveEmptyTabFrames(); | |
619 | void UpdateHintWindowSize(); | |
620 | ||
621 | protected: | |
622 | ||
623 | void OnChildFocusNotebook(wxChildFocusEvent& evt); | |
624 | void OnRender(wxAuiManagerEvent& evt); | |
625 | void OnSize(wxSizeEvent& evt); | |
626 | void OnTabClicked(wxAuiNotebookEvent& evt); | |
627 | void OnTabBeginDrag(wxAuiNotebookEvent& evt); | |
628 | void OnTabDragMotion(wxAuiNotebookEvent& evt); | |
629 | void OnTabEndDrag(wxAuiNotebookEvent& evt); | |
630 | void OnTabButton(wxAuiNotebookEvent& evt); | |
631 | void OnTabMiddleDown(wxAuiNotebookEvent& evt); | |
632 | void OnTabMiddleUp(wxAuiNotebookEvent& evt); | |
633 | void OnTabRightDown(wxAuiNotebookEvent& evt); | |
634 | void OnTabRightUp(wxAuiNotebookEvent& evt); | |
635 | void OnTabBgDClick(wxAuiNotebookEvent& evt); | |
636 | void OnNavigationKeyNotebook(wxNavigationKeyEvent& event); | |
637 | ||
638 | // set selection to the given window (which must be non-NULL and be one of | |
639 | // our pages, otherwise an assert is raised) | |
640 | void SetSelectionToWindow(wxWindow *win); | |
641 | void SetSelectionToPage(const wxAuiNotebookPage& page) | |
642 | { | |
643 | SetSelectionToWindow(page.window); | |
644 | } | |
645 | ||
646 | protected: | |
647 | ||
648 | wxAuiManager m_mgr; | |
649 | wxAuiTabContainer m_tabs; | |
650 | int m_curpage; | |
651 | int m_tab_id_counter; | |
652 | wxWindow* m_dummy_wnd; | |
653 | ||
654 | wxSize m_requested_bmp_size; | |
655 | int m_requested_tabctrl_height; | |
656 | wxFont m_selected_font; | |
657 | wxFont m_normal_font; | |
658 | int m_tab_ctrl_height; | |
659 | ||
660 | int m_last_drag_x; | |
661 | unsigned int m_flags; | |
662 | ||
663 | #ifndef SWIG | |
664 | DECLARE_CLASS(wxAuiNotebook) | |
665 | DECLARE_EVENT_TABLE() | |
666 | #endif | |
667 | ||
668 | WX_DECLARE_CONTROL_CONTAINER(); | |
669 | ||
670 | }; | |
671 | ||
672 | ||
673 | ||
674 | ||
675 | // wx event machinery | |
676 | ||
677 | #ifndef SWIG | |
678 | ||
679 | wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_AUI, wxEVT_COMMAND_AUINOTEBOOK_PAGE_CLOSE, wxAuiNotebookEvent); | |
680 | wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_AUI, wxEVT_COMMAND_AUINOTEBOOK_PAGE_CHANGED, wxAuiNotebookEvent); | |
681 | wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_AUI, wxEVT_COMMAND_AUINOTEBOOK_PAGE_CHANGING, wxAuiNotebookEvent); | |
682 | wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_AUI, wxEVT_COMMAND_AUINOTEBOOK_PAGE_CLOSED, wxAuiNotebookEvent); | |
683 | wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_AUI, wxEVT_COMMAND_AUINOTEBOOK_BUTTON, wxAuiNotebookEvent); | |
684 | wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_AUI, wxEVT_COMMAND_AUINOTEBOOK_BEGIN_DRAG, wxAuiNotebookEvent); | |
685 | wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_AUI, wxEVT_COMMAND_AUINOTEBOOK_END_DRAG, wxAuiNotebookEvent); | |
686 | wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_AUI, wxEVT_COMMAND_AUINOTEBOOK_DRAG_MOTION, wxAuiNotebookEvent); | |
687 | wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_AUI, wxEVT_COMMAND_AUINOTEBOOK_ALLOW_DND, wxAuiNotebookEvent); | |
688 | wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_AUI, wxEVT_COMMAND_AUINOTEBOOK_TAB_MIDDLE_DOWN, wxAuiNotebookEvent); | |
689 | wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_AUI, wxEVT_COMMAND_AUINOTEBOOK_TAB_MIDDLE_UP, wxAuiNotebookEvent); | |
690 | wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_AUI, wxEVT_COMMAND_AUINOTEBOOK_TAB_RIGHT_DOWN, wxAuiNotebookEvent); | |
691 | wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_AUI, wxEVT_COMMAND_AUINOTEBOOK_TAB_RIGHT_UP, wxAuiNotebookEvent); | |
692 | wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_AUI, wxEVT_COMMAND_AUINOTEBOOK_DRAG_DONE, wxAuiNotebookEvent); | |
693 | wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_AUI, wxEVT_COMMAND_AUINOTEBOOK_BG_DCLICK, wxAuiNotebookEvent); | |
694 | ||
695 | typedef void (wxEvtHandler::*wxAuiNotebookEventFunction)(wxAuiNotebookEvent&); | |
696 | ||
697 | #define wxAuiNotebookEventHandler(func) \ | |
698 | wxEVENT_HANDLER_CAST(wxAuiNotebookEventFunction, func) | |
699 | ||
700 | #define EVT_AUINOTEBOOK_PAGE_CLOSE(winid, fn) \ | |
701 | wx__DECLARE_EVT1(wxEVT_COMMAND_AUINOTEBOOK_PAGE_CLOSE, winid, wxAuiNotebookEventHandler(fn)) | |
702 | #define EVT_AUINOTEBOOK_PAGE_CLOSED(winid, fn) \ | |
703 | wx__DECLARE_EVT1(wxEVT_COMMAND_AUINOTEBOOK_PAGE_CLOSED, winid, wxAuiNotebookEventHandler(fn)) | |
704 | #define EVT_AUINOTEBOOK_PAGE_CHANGED(winid, fn) \ | |
705 | wx__DECLARE_EVT1(wxEVT_COMMAND_AUINOTEBOOK_PAGE_CHANGED, winid, wxAuiNotebookEventHandler(fn)) | |
706 | #define EVT_AUINOTEBOOK_PAGE_CHANGING(winid, fn) \ | |
707 | wx__DECLARE_EVT1(wxEVT_COMMAND_AUINOTEBOOK_PAGE_CHANGING, winid, wxAuiNotebookEventHandler(fn)) | |
708 | #define EVT_AUINOTEBOOK_BUTTON(winid, fn) \ | |
709 | wx__DECLARE_EVT1(wxEVT_COMMAND_AUINOTEBOOK_BUTTON, winid, wxAuiNotebookEventHandler(fn)) | |
710 | #define EVT_AUINOTEBOOK_BEGIN_DRAG(winid, fn) \ | |
711 | wx__DECLARE_EVT1(wxEVT_COMMAND_AUINOTEBOOK_BEGIN_DRAG, winid, wxAuiNotebookEventHandler(fn)) | |
712 | #define EVT_AUINOTEBOOK_END_DRAG(winid, fn) \ | |
713 | wx__DECLARE_EVT1(wxEVT_COMMAND_AUINOTEBOOK_END_DRAG, winid, wxAuiNotebookEventHandler(fn)) | |
714 | #define EVT_AUINOTEBOOK_DRAG_MOTION(winid, fn) \ | |
715 | wx__DECLARE_EVT1(wxEVT_COMMAND_AUINOTEBOOK_DRAG_MOTION, winid, wxAuiNotebookEventHandler(fn)) | |
716 | #define EVT_AUINOTEBOOK_ALLOW_DND(winid, fn) \ | |
717 | wx__DECLARE_EVT1(wxEVT_COMMAND_AUINOTEBOOK_ALLOW_DND, winid, wxAuiNotebookEventHandler(fn)) | |
718 | #define EVT_AUINOTEBOOK_DRAG_DONE(winid, fn) \ | |
719 | wx__DECLARE_EVT1(wxEVT_COMMAND_AUINOTEBOOK_DRAG_DONE, winid, wxAuiNotebookEventHandler(fn)) | |
720 | #define EVT_AUINOTEBOOK_TAB_MIDDLE_DOWN(winid, fn) \ | |
721 | wx__DECLARE_EVT1(wxEVT_COMMAND_AUINOTEBOOK_TAB_MIDDLE_DOWN, winid, wxAuiNotebookEventHandler(fn)) | |
722 | #define EVT_AUINOTEBOOK_TAB_MIDDLE_UP(winid, fn) \ | |
723 | wx__DECLARE_EVT1(wxEVT_COMMAND_AUINOTEBOOK_TAB_MIDDLE_UP, winid, wxAuiNotebookEventHandler(fn)) | |
724 | #define EVT_AUINOTEBOOK_TAB_RIGHT_DOWN(winid, fn) \ | |
725 | wx__DECLARE_EVT1(wxEVT_COMMAND_AUINOTEBOOK_TAB_RIGHT_DOWN, winid, wxAuiNotebookEventHandler(fn)) | |
726 | #define EVT_AUINOTEBOOK_TAB_RIGHT_UP(winid, fn) \ | |
727 | wx__DECLARE_EVT1(wxEVT_COMMAND_AUINOTEBOOK_TAB_RIGHT_UP, winid, wxAuiNotebookEventHandler(fn)) | |
728 | #define EVT_AUINOTEBOOK_BG_DCLICK(winid, fn) \ | |
729 | wx__DECLARE_EVT1(wxEVT_COMMAND_AUINOTEBOOK_BG_DCLICK, winid, wxAuiNotebookEventHandler(fn)) | |
730 | #else | |
731 | ||
732 | // wxpython/swig event work | |
733 | %constant wxEventType wxEVT_COMMAND_AUINOTEBOOK_PAGE_CLOSE; | |
734 | %constant wxEventType wxEVT_COMMAND_AUINOTEBOOK_PAGE_CLOSED; | |
735 | %constant wxEventType wxEVT_COMMAND_AUINOTEBOOK_PAGE_CHANGED; | |
736 | %constant wxEventType wxEVT_COMMAND_AUINOTEBOOK_PAGE_CHANGING; | |
737 | %constant wxEventType wxEVT_COMMAND_AUINOTEBOOK_BUTTON; | |
738 | %constant wxEventType wxEVT_COMMAND_AUINOTEBOOK_BEGIN_DRAG; | |
739 | %constant wxEventType wxEVT_COMMAND_AUINOTEBOOK_END_DRAG; | |
740 | %constant wxEventType wxEVT_COMMAND_AUINOTEBOOK_DRAG_MOTION; | |
741 | %constant wxEventType wxEVT_COMMAND_AUINOTEBOOK_ALLOW_DND; | |
742 | %constant wxEventType wxEVT_COMMAND_AUINOTEBOOK_DRAG_DONE; | |
743 | %constant wxEventType wxEVT_COMMAND_AUINOTEBOOK_TAB_MIDDLE_DOWN; | |
744 | %constant wxEventType wxEVT_COMMAND_AUINOTEBOOK_TAB_MIDDLE_UP; | |
745 | %constant wxEventType wxEVT_COMMAND_AUINOTEBOOK_TAB_RIGHT_DOWN; | |
746 | %constant wxEventType wxEVT_COMMAND_AUINOTEBOOK_TAB_RIGHT_UP; | |
747 | %constant wxEventType wxEVT_COMMAND_AUINOTEBOOK_BG_DCLICK; | |
748 | ||
749 | %pythoncode { | |
750 | EVT_AUINOTEBOOK_PAGE_CLOSE = wx.PyEventBinder( wxEVT_COMMAND_AUINOTEBOOK_PAGE_CLOSE, 1 ) | |
751 | EVT_AUINOTEBOOK_PAGE_CLOSED = wx.PyEventBinder( wxEVT_COMMAND_AUINOTEBOOK_PAGE_CLOSED, 1 ) | |
752 | EVT_AUINOTEBOOK_PAGE_CHANGED = wx.PyEventBinder( wxEVT_COMMAND_AUINOTEBOOK_PAGE_CHANGED, 1 ) | |
753 | EVT_AUINOTEBOOK_PAGE_CHANGING = wx.PyEventBinder( wxEVT_COMMAND_AUINOTEBOOK_PAGE_CHANGING, 1 ) | |
754 | EVT_AUINOTEBOOK_BUTTON = wx.PyEventBinder( wxEVT_COMMAND_AUINOTEBOOK_BUTTON, 1 ) | |
755 | EVT_AUINOTEBOOK_BEGIN_DRAG = wx.PyEventBinder( wxEVT_COMMAND_AUINOTEBOOK_BEGIN_DRAG, 1 ) | |
756 | EVT_AUINOTEBOOK_END_DRAG = wx.PyEventBinder( wxEVT_COMMAND_AUINOTEBOOK_END_DRAG, 1 ) | |
757 | EVT_AUINOTEBOOK_DRAG_MOTION = wx.PyEventBinder( wxEVT_COMMAND_AUINOTEBOOK_DRAG_MOTION, 1 ) | |
758 | EVT_AUINOTEBOOK_ALLOW_DND = wx.PyEventBinder( wxEVT_COMMAND_AUINOTEBOOK_ALLOW_DND, 1 ) | |
759 | EVT_AUINOTEBOOK_DRAG_DONE = wx.PyEventBinder( wxEVT_COMMAND_AUINOTEBOOK_DRAG_DONE, 1 ) | |
760 | EVT__AUINOTEBOOK_TAB_MIDDLE_DOWN = wx.PyEventBinder( wxEVT_COMMAND_AUINOTEBOOK_TAB_MIDDLE_DOWN, 1 ) | |
761 | EVT__AUINOTEBOOK_TAB_MIDDLE_UP = wx.PyEventBinder( wxEVT_COMMAND_AUINOTEBOOK_TAB_MIDDLE_UP, 1 ) | |
762 | EVT__AUINOTEBOOK_TAB_RIGHT_DOWN = wx.PyEventBinder( wxEVT_COMMAND_AUINOTEBOOK_TAB_RIGHT_DOWN, 1 ) | |
763 | EVT__AUINOTEBOOK_TAB_RIGHT_UP = wx.PyEventBinder( wxEVT_COMMAND_AUINOTEBOOK_TAB_RIGHT_UP, 1 ) | |
764 | EVT_AUINOTEBOOK_BG_DCLICK = wx.PyEventBinder( wxEVT_COMMAND_AUINOTEBOOK_BG_DCLICK, 1 ) | |
765 | } | |
766 | #endif | |
767 | ||
768 | ||
769 | #endif // wxUSE_AUI | |
770 | #endif // _WX_AUINOTEBOOK_H_ |