]>
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 | ||
153 | virtual void DrawBackground( | |
154 | wxDC& dc, | |
155 | wxWindow* wnd, | |
156 | const wxRect& rect) = 0; | |
157 | ||
158 | virtual void DrawTab(wxDC& dc, | |
159 | wxWindow* wnd, | |
160 | const wxAuiNotebookPage& pane, | |
161 | const wxRect& in_rect, | |
162 | int close_button_state, | |
163 | wxRect* out_tab_rect, | |
164 | wxRect* out_button_rect, | |
165 | int* x_extent) = 0; | |
166 | ||
167 | virtual void DrawButton( | |
168 | wxDC& dc, | |
169 | wxWindow* wnd, | |
170 | const wxRect& in_rect, | |
171 | int bitmap_id, | |
172 | int button_state, | |
173 | int orientation, | |
174 | wxRect* out_rect) = 0; | |
175 | ||
176 | virtual wxSize GetTabSize( | |
177 | wxDC& dc, | |
178 | wxWindow* wnd, | |
179 | const wxString& caption, | |
180 | const wxBitmap& bitmap, | |
181 | bool active, | |
182 | int close_button_state, | |
183 | int* x_extent) = 0; | |
184 | ||
185 | virtual int ShowDropDown( | |
186 | wxWindow* wnd, | |
187 | const wxAuiNotebookPageArray& items, | |
188 | int active_idx) = 0; | |
189 | ||
190 | virtual int GetIndentSize() = 0; | |
191 | ||
192 | virtual int GetBestTabCtrlSize( | |
193 | wxWindow* wnd, | |
194 | const wxAuiNotebookPageArray& pages, | |
195 | const wxSize& required_bmp_size) = 0; | |
196 | }; | |
197 | ||
198 | ||
199 | class WXDLLIMPEXP_AUI wxAuiDefaultTabArt : public wxAuiTabArt | |
200 | { | |
201 | ||
202 | public: | |
203 | ||
204 | wxAuiDefaultTabArt(); | |
205 | virtual ~wxAuiDefaultTabArt(); | |
206 | ||
207 | wxAuiTabArt* Clone(); | |
208 | void SetFlags(unsigned int flags); | |
209 | void SetSizingInfo(const wxSize& tab_ctrl_size, | |
210 | size_t tab_count); | |
211 | ||
212 | void SetNormalFont(const wxFont& font); | |
213 | void SetSelectedFont(const wxFont& font); | |
214 | void SetMeasuringFont(const wxFont& font); | |
215 | ||
216 | void DrawBackground( | |
217 | wxDC& dc, | |
218 | wxWindow* wnd, | |
219 | const wxRect& rect); | |
220 | ||
221 | void DrawTab(wxDC& dc, | |
222 | wxWindow* wnd, | |
223 | const wxAuiNotebookPage& pane, | |
224 | const wxRect& in_rect, | |
225 | int close_button_state, | |
226 | wxRect* out_tab_rect, | |
227 | wxRect* out_button_rect, | |
228 | int* x_extent); | |
229 | ||
230 | void DrawButton( | |
231 | wxDC& dc, | |
232 | wxWindow* wnd, | |
233 | const wxRect& in_rect, | |
234 | int bitmap_id, | |
235 | int button_state, | |
236 | int orientation, | |
237 | wxRect* out_rect); | |
238 | ||
239 | int GetIndentSize(); | |
240 | ||
241 | wxSize GetTabSize( | |
242 | wxDC& dc, | |
243 | wxWindow* wnd, | |
244 | const wxString& caption, | |
245 | const wxBitmap& bitmap, | |
246 | bool active, | |
247 | int close_button_state, | |
248 | int* x_extent); | |
249 | ||
250 | int ShowDropDown( | |
251 | wxWindow* wnd, | |
252 | const wxAuiNotebookPageArray& items, | |
253 | int active_idx); | |
254 | ||
255 | int GetBestTabCtrlSize(wxWindow* wnd, | |
256 | const wxAuiNotebookPageArray& pages, | |
257 | const wxSize& required_bmp_size); | |
258 | ||
259 | protected: | |
260 | ||
261 | wxFont m_normal_font; | |
262 | wxFont m_selected_font; | |
263 | wxFont m_measuring_font; | |
264 | wxColour m_base_colour; | |
265 | wxPen m_base_colour_pen; | |
266 | wxPen m_border_pen; | |
267 | wxBrush m_base_colour_brush; | |
268 | wxBitmap m_active_close_bmp; | |
269 | wxBitmap m_disabled_close_bmp; | |
270 | wxBitmap m_active_left_bmp; | |
271 | wxBitmap m_disabled_left_bmp; | |
272 | wxBitmap m_active_right_bmp; | |
273 | wxBitmap m_disabled_right_bmp; | |
274 | wxBitmap m_active_windowlist_bmp; | |
275 | wxBitmap m_disabled_windowlist_bmp; | |
276 | ||
277 | int m_fixed_tab_width; | |
278 | int m_tab_ctrl_height; | |
279 | unsigned int m_flags; | |
280 | }; | |
281 | ||
282 | ||
283 | class WXDLLIMPEXP_AUI wxAuiSimpleTabArt : public wxAuiTabArt | |
284 | { | |
285 | ||
286 | public: | |
287 | ||
288 | wxAuiSimpleTabArt(); | |
289 | virtual ~wxAuiSimpleTabArt(); | |
290 | ||
291 | wxAuiTabArt* Clone(); | |
292 | void SetFlags(unsigned int flags); | |
293 | ||
294 | void SetSizingInfo(const wxSize& tab_ctrl_size, | |
295 | size_t tab_count); | |
296 | ||
297 | void SetNormalFont(const wxFont& font); | |
298 | void SetSelectedFont(const wxFont& font); | |
299 | void SetMeasuringFont(const wxFont& font); | |
300 | ||
301 | void DrawBackground( | |
302 | wxDC& dc, | |
303 | wxWindow* wnd, | |
304 | const wxRect& rect); | |
305 | ||
306 | void DrawTab(wxDC& dc, | |
307 | wxWindow* wnd, | |
308 | const wxAuiNotebookPage& pane, | |
309 | const wxRect& in_rect, | |
310 | int close_button_state, | |
311 | wxRect* out_tab_rect, | |
312 | wxRect* out_button_rect, | |
313 | int* x_extent); | |
314 | ||
315 | void DrawButton( | |
316 | wxDC& dc, | |
317 | wxWindow* wnd, | |
318 | const wxRect& in_rect, | |
319 | int bitmap_id, | |
320 | int button_state, | |
321 | int orientation, | |
322 | wxRect* out_rect); | |
323 | ||
324 | int GetIndentSize(); | |
325 | ||
326 | wxSize GetTabSize( | |
327 | wxDC& dc, | |
328 | wxWindow* wnd, | |
329 | const wxString& caption, | |
330 | const wxBitmap& bitmap, | |
331 | bool active, | |
332 | int close_button_state, | |
333 | int* x_extent); | |
334 | ||
335 | int ShowDropDown( | |
336 | wxWindow* wnd, | |
337 | const wxAuiNotebookPageArray& items, | |
338 | int active_idx); | |
339 | ||
340 | int GetBestTabCtrlSize(wxWindow* wnd, | |
341 | const wxAuiNotebookPageArray& pages, | |
342 | const wxSize& required_bmp_size); | |
343 | ||
344 | protected: | |
345 | ||
346 | wxFont m_normal_font; | |
347 | wxFont m_selected_font; | |
348 | wxFont m_measuring_font; | |
349 | wxPen m_normal_bkpen; | |
350 | wxPen m_selected_bkpen; | |
351 | wxBrush m_normal_bkbrush; | |
352 | wxBrush m_selected_bkbrush; | |
353 | wxBrush m_bkbrush; | |
354 | wxBitmap m_active_close_bmp; | |
355 | wxBitmap m_disabled_close_bmp; | |
356 | wxBitmap m_active_left_bmp; | |
357 | wxBitmap m_disabled_left_bmp; | |
358 | wxBitmap m_active_right_bmp; | |
359 | wxBitmap m_disabled_right_bmp; | |
360 | wxBitmap m_active_windowlist_bmp; | |
361 | wxBitmap m_disabled_windowlist_bmp; | |
362 | ||
363 | int m_fixed_tab_width; | |
364 | unsigned int m_flags; | |
365 | }; | |
366 | ||
367 | ||
368 | ||
369 | ||
370 | ||
371 | ||
372 | ||
373 | ||
374 | ||
375 | class WXDLLIMPEXP_AUI wxAuiTabContainer | |
376 | { | |
377 | public: | |
378 | ||
379 | wxAuiTabContainer(); | |
380 | virtual ~wxAuiTabContainer(); | |
381 | ||
382 | void SetArtProvider(wxAuiTabArt* art); | |
383 | wxAuiTabArt* GetArtProvider() const; | |
384 | ||
385 | void SetFlags(unsigned int flags); | |
386 | unsigned int GetFlags() const; | |
387 | ||
388 | bool AddPage(wxWindow* page, const wxAuiNotebookPage& info); | |
389 | bool InsertPage(wxWindow* page, const wxAuiNotebookPage& info, size_t idx); | |
390 | bool MovePage(wxWindow* page, size_t new_idx); | |
391 | bool RemovePage(wxWindow* page); | |
392 | bool SetActivePage(wxWindow* page); | |
393 | bool SetActivePage(size_t page); | |
394 | void SetNoneActive(); | |
395 | int GetActivePage() const; | |
396 | bool TabHitTest(int x, int y, wxWindow** hit) const; | |
397 | bool ButtonHitTest(int x, int y, wxAuiTabContainerButton** hit) const; | |
398 | wxWindow* GetWindowFromIdx(size_t idx) const; | |
399 | int GetIdxFromWindow(wxWindow* page) const; | |
400 | size_t GetPageCount() const; | |
401 | wxAuiNotebookPage& GetPage(size_t idx); | |
402 | const wxAuiNotebookPage& GetPage(size_t idx) const; | |
403 | wxAuiNotebookPageArray& GetPages(); | |
404 | void SetNormalFont(const wxFont& normal_font); | |
405 | void SetSelectedFont(const wxFont& selected_font); | |
406 | void SetMeasuringFont(const wxFont& measuring_font); | |
407 | void DoShowHide(); | |
408 | void SetRect(const wxRect& rect); | |
409 | ||
410 | void RemoveButton(int id); | |
411 | void AddButton(int id, | |
412 | int location, | |
413 | const wxBitmap& normal_bitmap = wxNullBitmap, | |
414 | const wxBitmap& disabled_bitmap = wxNullBitmap); | |
415 | ||
416 | size_t GetTabOffset() const; | |
417 | void SetTabOffset(size_t offset); | |
418 | ||
419 | // Is the tab visible? | |
420 | bool IsTabVisible(int tabPage, int tabOffset, wxDC* dc, wxWindow* wnd); | |
421 | ||
422 | // Make the tab visible if it wasn't already | |
423 | void MakeTabVisible(int tabPage, wxWindow* win); | |
424 | ||
425 | protected: | |
426 | ||
427 | virtual void Render(wxDC* dc, wxWindow* wnd); | |
428 | ||
429 | protected: | |
430 | ||
431 | wxAuiTabArt* m_art; | |
432 | wxAuiNotebookPageArray m_pages; | |
433 | wxAuiTabContainerButtonArray m_buttons; | |
434 | wxAuiTabContainerButtonArray m_tab_close_buttons; | |
435 | wxRect m_rect; | |
436 | size_t m_tab_offset; | |
437 | unsigned int m_flags; | |
438 | }; | |
439 | ||
440 | ||
441 | ||
442 | class WXDLLIMPEXP_AUI wxAuiTabCtrl : public wxControl, | |
443 | public wxAuiTabContainer | |
444 | { | |
445 | public: | |
446 | ||
447 | wxAuiTabCtrl(wxWindow* parent, | |
448 | wxWindowID id = wxID_ANY, | |
449 | const wxPoint& pos = wxDefaultPosition, | |
450 | const wxSize& size = wxDefaultSize, | |
451 | long style = 0); | |
452 | ||
453 | ~wxAuiTabCtrl(); | |
454 | ||
455 | bool IsDragging() const { return m_is_dragging; } | |
456 | ||
457 | protected: | |
458 | // choose the default border for this window | |
459 | virtual wxBorder GetDefaultBorder() const { return wxBORDER_NONE; } | |
460 | ||
461 | void OnPaint(wxPaintEvent& evt); | |
462 | void OnEraseBackground(wxEraseEvent& evt); | |
463 | void OnSize(wxSizeEvent& evt); | |
464 | void OnLeftDown(wxMouseEvent& evt); | |
465 | void OnLeftDClick(wxMouseEvent& evt); | |
466 | void OnLeftUp(wxMouseEvent& evt); | |
467 | void OnMiddleDown(wxMouseEvent& evt); | |
468 | void OnMiddleUp(wxMouseEvent& evt); | |
469 | void OnRightDown(wxMouseEvent& evt); | |
470 | void OnRightUp(wxMouseEvent& evt); | |
471 | void OnMotion(wxMouseEvent& evt); | |
472 | void OnLeaveWindow(wxMouseEvent& evt); | |
473 | void OnButton(wxAuiNotebookEvent& evt); | |
474 | void OnSetFocus(wxFocusEvent& event); | |
475 | void OnKillFocus(wxFocusEvent& event); | |
476 | void OnChar(wxKeyEvent& event); | |
477 | void OnCaptureLost(wxMouseCaptureLostEvent& evt); | |
478 | ||
479 | protected: | |
480 | ||
481 | wxPoint m_click_pt; | |
482 | wxWindow* m_click_tab; | |
483 | bool m_is_dragging; | |
484 | wxAuiTabContainerButton* m_hover_button; | |
485 | wxAuiTabContainerButton* m_pressed_button; | |
486 | ||
487 | #ifndef SWIG | |
488 | DECLARE_CLASS(wxAuiTabCtrl) | |
489 | DECLARE_EVENT_TABLE() | |
490 | #endif | |
491 | }; | |
492 | ||
493 | ||
494 | ||
495 | ||
496 | class WXDLLIMPEXP_AUI wxAuiNotebook : public wxControl | |
497 | { | |
498 | ||
499 | public: | |
500 | ||
501 | wxAuiNotebook(); | |
502 | ||
503 | wxAuiNotebook(wxWindow* parent, | |
504 | wxWindowID id = wxID_ANY, | |
505 | const wxPoint& pos = wxDefaultPosition, | |
506 | const wxSize& size = wxDefaultSize, | |
507 | long style = wxAUI_NB_DEFAULT_STYLE); | |
508 | ||
509 | virtual ~wxAuiNotebook(); | |
510 | ||
511 | bool Create(wxWindow* parent, | |
512 | wxWindowID id = wxID_ANY, | |
513 | const wxPoint& pos = wxDefaultPosition, | |
514 | const wxSize& size = wxDefaultSize, | |
515 | long style = 0); | |
516 | ||
517 | void SetWindowStyleFlag(long style); | |
518 | void SetArtProvider(wxAuiTabArt* art); | |
519 | wxAuiTabArt* GetArtProvider() const; | |
520 | ||
521 | virtual void SetUniformBitmapSize(const wxSize& size); | |
522 | virtual void SetTabCtrlHeight(int height); | |
523 | ||
524 | bool AddPage(wxWindow* page, | |
525 | const wxString& caption, | |
526 | bool select = false, | |
527 | const wxBitmap& bitmap = wxNullBitmap); | |
528 | ||
529 | bool InsertPage(size_t page_idx, | |
530 | wxWindow* page, | |
531 | const wxString& caption, | |
532 | bool select = false, | |
533 | const wxBitmap& bitmap = wxNullBitmap); | |
534 | ||
535 | bool DeletePage(size_t page); | |
536 | bool RemovePage(size_t page); | |
537 | ||
538 | size_t GetPageCount() const; | |
539 | wxWindow* GetPage(size_t page_idx) const; | |
540 | int GetPageIndex(wxWindow* page_wnd) const; | |
541 | ||
542 | bool SetPageText(size_t page, const wxString& text); | |
543 | wxString GetPageText(size_t page_idx) const; | |
544 | ||
545 | bool SetPageBitmap(size_t page, const wxBitmap& bitmap); | |
546 | wxBitmap GetPageBitmap(size_t page_idx) const; | |
547 | ||
548 | size_t SetSelection(size_t new_page); | |
549 | int GetSelection() const; | |
550 | ||
551 | virtual void Split(size_t page, int direction); | |
552 | ||
553 | const wxAuiManager& GetAuiManager() const { return m_mgr; } | |
554 | ||
555 | // Sets the normal font | |
556 | void SetNormalFont(const wxFont& font); | |
557 | ||
558 | // Sets the selected tab font | |
559 | void SetSelectedFont(const wxFont& font); | |
560 | ||
561 | // Sets the measuring font | |
562 | void SetMeasuringFont(const wxFont& font); | |
563 | ||
564 | // Sets the tab font | |
565 | virtual bool SetFont(const wxFont& font); | |
566 | ||
567 | // Gets the tab control height | |
568 | int GetTabCtrlHeight() const; | |
569 | ||
570 | // Gets the height of the notebook for a given page height | |
571 | int GetHeightForPageHeight(int pageHeight); | |
572 | ||
573 | // Advances the selection, generation page selection events | |
574 | void AdvanceSelection(bool forward = true); | |
575 | ||
576 | // Shows the window menu | |
577 | bool ShowWindowMenu(); | |
578 | ||
579 | // we do have multiple pages | |
580 | virtual bool HasMultiplePages() const { return true; } | |
581 | ||
582 | // we don't want focus for ourselves | |
583 | // virtual bool AcceptsFocus() const { return false; } | |
584 | ||
585 | // Redo sizing after thawing | |
586 | virtual void Thaw(); | |
587 | ||
588 | protected: | |
589 | // choose the default border for this window | |
590 | virtual wxBorder GetDefaultBorder() const { return wxBORDER_NONE; } | |
591 | ||
592 | // these can be overridden | |
593 | virtual void UpdateTabCtrlHeight(); | |
594 | virtual int CalculateTabCtrlHeight(); | |
595 | virtual wxSize CalculateNewSplitSize(); | |
596 | ||
597 | protected: | |
598 | ||
599 | void DoSizing(); | |
600 | void InitNotebook(long style); | |
601 | wxAuiTabCtrl* GetTabCtrlFromPoint(const wxPoint& pt); | |
602 | wxWindow* GetTabFrameFromTabCtrl(wxWindow* tab_ctrl); | |
603 | wxAuiTabCtrl* GetActiveTabCtrl(); | |
604 | bool FindTab(wxWindow* page, wxAuiTabCtrl** ctrl, int* idx); | |
605 | void RemoveEmptyTabFrames(); | |
606 | void UpdateHintWindowSize(); | |
607 | ||
608 | protected: | |
609 | ||
610 | void OnChildFocusNotebook(wxChildFocusEvent& evt); | |
611 | void OnRender(wxAuiManagerEvent& evt); | |
612 | void OnSize(wxSizeEvent& evt); | |
613 | void OnTabClicked(wxAuiNotebookEvent& evt); | |
614 | void OnTabBeginDrag(wxAuiNotebookEvent& evt); | |
615 | void OnTabDragMotion(wxAuiNotebookEvent& evt); | |
616 | void OnTabEndDrag(wxAuiNotebookEvent& evt); | |
617 | void OnTabButton(wxAuiNotebookEvent& evt); | |
618 | void OnTabMiddleDown(wxAuiNotebookEvent& evt); | |
619 | void OnTabMiddleUp(wxAuiNotebookEvent& evt); | |
620 | void OnTabRightDown(wxAuiNotebookEvent& evt); | |
621 | void OnTabRightUp(wxAuiNotebookEvent& evt); | |
622 | void OnTabBgDClick(wxAuiNotebookEvent& evt); | |
623 | void OnNavigationKeyNotebook(wxNavigationKeyEvent& event); | |
624 | ||
625 | // set selection to the given window (which must be non-NULL and be one of | |
626 | // our pages, otherwise an assert is raised) | |
627 | void SetSelectionToWindow(wxWindow *win); | |
628 | void SetSelectionToPage(const wxAuiNotebookPage& page) | |
629 | { | |
630 | SetSelectionToWindow(page.window); | |
631 | } | |
632 | ||
633 | protected: | |
634 | ||
635 | wxAuiManager m_mgr; | |
636 | wxAuiTabContainer m_tabs; | |
637 | int m_curpage; | |
638 | int m_tab_id_counter; | |
639 | wxWindow* m_dummy_wnd; | |
640 | ||
641 | wxSize m_requested_bmp_size; | |
642 | int m_requested_tabctrl_height; | |
643 | wxFont m_selected_font; | |
644 | wxFont m_normal_font; | |
645 | int m_tab_ctrl_height; | |
646 | ||
647 | int m_last_drag_x; | |
648 | unsigned int m_flags; | |
649 | ||
650 | #ifndef SWIG | |
651 | DECLARE_CLASS(wxAuiNotebook) | |
652 | DECLARE_EVENT_TABLE() | |
653 | #endif | |
654 | ||
655 | WX_DECLARE_CONTROL_CONTAINER(); | |
656 | ||
657 | }; | |
658 | ||
659 | ||
660 | ||
661 | ||
662 | // wx event machinery | |
663 | ||
664 | #ifndef SWIG | |
665 | ||
666 | wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_AUI, wxEVT_COMMAND_AUINOTEBOOK_PAGE_CLOSE, wxAuiNotebookEvent); | |
667 | wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_AUI, wxEVT_COMMAND_AUINOTEBOOK_PAGE_CHANGED, wxAuiNotebookEvent); | |
668 | wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_AUI, wxEVT_COMMAND_AUINOTEBOOK_PAGE_CHANGING, wxAuiNotebookEvent); | |
669 | wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_AUI, wxEVT_COMMAND_AUINOTEBOOK_PAGE_CLOSED, wxAuiNotebookEvent); | |
670 | wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_AUI, wxEVT_COMMAND_AUINOTEBOOK_BUTTON, wxAuiNotebookEvent); | |
671 | wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_AUI, wxEVT_COMMAND_AUINOTEBOOK_BEGIN_DRAG, wxAuiNotebookEvent); | |
672 | wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_AUI, wxEVT_COMMAND_AUINOTEBOOK_END_DRAG, wxAuiNotebookEvent); | |
673 | wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_AUI, wxEVT_COMMAND_AUINOTEBOOK_DRAG_MOTION, wxAuiNotebookEvent); | |
674 | wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_AUI, wxEVT_COMMAND_AUINOTEBOOK_ALLOW_DND, wxAuiNotebookEvent); | |
675 | wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_AUI, wxEVT_COMMAND_AUINOTEBOOK_TAB_MIDDLE_DOWN, wxAuiNotebookEvent); | |
676 | wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_AUI, wxEVT_COMMAND_AUINOTEBOOK_TAB_MIDDLE_UP, wxAuiNotebookEvent); | |
677 | wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_AUI, wxEVT_COMMAND_AUINOTEBOOK_TAB_RIGHT_DOWN, wxAuiNotebookEvent); | |
678 | wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_AUI, wxEVT_COMMAND_AUINOTEBOOK_TAB_RIGHT_UP, wxAuiNotebookEvent); | |
679 | wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_AUI, wxEVT_COMMAND_AUINOTEBOOK_DRAG_DONE, wxAuiNotebookEvent); | |
680 | wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_AUI, wxEVT_COMMAND_AUINOTEBOOK_BG_DCLICK, wxAuiNotebookEvent); | |
681 | ||
682 | typedef void (wxEvtHandler::*wxAuiNotebookEventFunction)(wxAuiNotebookEvent&); | |
683 | ||
684 | #define wxAuiNotebookEventHandler(func) \ | |
685 | wxEVENT_HANDLER_CAST(wxAuiNotebookEventFunction, func) | |
686 | ||
687 | #define EVT_AUINOTEBOOK_PAGE_CLOSE(winid, fn) \ | |
688 | wx__DECLARE_EVT1(wxEVT_COMMAND_AUINOTEBOOK_PAGE_CLOSE, winid, wxAuiNotebookEventHandler(fn)) | |
689 | #define EVT_AUINOTEBOOK_PAGE_CLOSED(winid, fn) \ | |
690 | wx__DECLARE_EVT1(wxEVT_COMMAND_AUINOTEBOOK_PAGE_CLOSED, winid, wxAuiNotebookEventHandler(fn)) | |
691 | #define EVT_AUINOTEBOOK_PAGE_CHANGED(winid, fn) \ | |
692 | wx__DECLARE_EVT1(wxEVT_COMMAND_AUINOTEBOOK_PAGE_CHANGED, winid, wxAuiNotebookEventHandler(fn)) | |
693 | #define EVT_AUINOTEBOOK_PAGE_CHANGING(winid, fn) \ | |
694 | wx__DECLARE_EVT1(wxEVT_COMMAND_AUINOTEBOOK_PAGE_CHANGING, winid, wxAuiNotebookEventHandler(fn)) | |
695 | #define EVT_AUINOTEBOOK_BUTTON(winid, fn) \ | |
696 | wx__DECLARE_EVT1(wxEVT_COMMAND_AUINOTEBOOK_BUTTON, winid, wxAuiNotebookEventHandler(fn)) | |
697 | #define EVT_AUINOTEBOOK_BEGIN_DRAG(winid, fn) \ | |
698 | wx__DECLARE_EVT1(wxEVT_COMMAND_AUINOTEBOOK_BEGIN_DRAG, winid, wxAuiNotebookEventHandler(fn)) | |
699 | #define EVT_AUINOTEBOOK_END_DRAG(winid, fn) \ | |
700 | wx__DECLARE_EVT1(wxEVT_COMMAND_AUINOTEBOOK_END_DRAG, winid, wxAuiNotebookEventHandler(fn)) | |
701 | #define EVT_AUINOTEBOOK_DRAG_MOTION(winid, fn) \ | |
702 | wx__DECLARE_EVT1(wxEVT_COMMAND_AUINOTEBOOK_DRAG_MOTION, winid, wxAuiNotebookEventHandler(fn)) | |
703 | #define EVT_AUINOTEBOOK_ALLOW_DND(winid, fn) \ | |
704 | wx__DECLARE_EVT1(wxEVT_COMMAND_AUINOTEBOOK_ALLOW_DND, winid, wxAuiNotebookEventHandler(fn)) | |
705 | #define EVT_AUINOTEBOOK_DRAG_DONE(winid, fn) \ | |
706 | wx__DECLARE_EVT1(wxEVT_COMMAND_AUINOTEBOOK_DRAG_DONE, winid, wxAuiNotebookEventHandler(fn)) | |
707 | #define EVT_AUINOTEBOOK_TAB_MIDDLE_DOWN(winid, fn) \ | |
708 | wx__DECLARE_EVT1(wxEVT_COMMAND_AUINOTEBOOK_TAB_MIDDLE_DOWN, winid, wxAuiNotebookEventHandler(fn)) | |
709 | #define EVT_AUINOTEBOOK_TAB_MIDDLE_UP(winid, fn) \ | |
710 | wx__DECLARE_EVT1(wxEVT_COMMAND_AUINOTEBOOK_TAB_MIDDLE_UP, winid, wxAuiNotebookEventHandler(fn)) | |
711 | #define EVT_AUINOTEBOOK_TAB_RIGHT_DOWN(winid, fn) \ | |
712 | wx__DECLARE_EVT1(wxEVT_COMMAND_AUINOTEBOOK_TAB_RIGHT_DOWN, winid, wxAuiNotebookEventHandler(fn)) | |
713 | #define EVT_AUINOTEBOOK_TAB_RIGHT_UP(winid, fn) \ | |
714 | wx__DECLARE_EVT1(wxEVT_COMMAND_AUINOTEBOOK_TAB_RIGHT_UP, winid, wxAuiNotebookEventHandler(fn)) | |
715 | #define EVT_AUINOTEBOOK_BG_DCLICK(winid, fn) \ | |
716 | wx__DECLARE_EVT1(wxEVT_COMMAND_AUINOTEBOOK_BG_DCLICK, winid, wxAuiNotebookEventHandler(fn)) | |
717 | #else | |
718 | ||
719 | // wxpython/swig event work | |
720 | %constant wxEventType wxEVT_COMMAND_AUINOTEBOOK_PAGE_CLOSE; | |
721 | %constant wxEventType wxEVT_COMMAND_AUINOTEBOOK_PAGE_CLOSED; | |
722 | %constant wxEventType wxEVT_COMMAND_AUINOTEBOOK_PAGE_CHANGED; | |
723 | %constant wxEventType wxEVT_COMMAND_AUINOTEBOOK_PAGE_CHANGING; | |
724 | %constant wxEventType wxEVT_COMMAND_AUINOTEBOOK_BUTTON; | |
725 | %constant wxEventType wxEVT_COMMAND_AUINOTEBOOK_BEGIN_DRAG; | |
726 | %constant wxEventType wxEVT_COMMAND_AUINOTEBOOK_END_DRAG; | |
727 | %constant wxEventType wxEVT_COMMAND_AUINOTEBOOK_DRAG_MOTION; | |
728 | %constant wxEventType wxEVT_COMMAND_AUINOTEBOOK_ALLOW_DND; | |
729 | %constant wxEventType wxEVT_COMMAND_AUINOTEBOOK_DRAG_DONE; | |
730 | %constant wxEventType wxEVT_COMMAND_AUINOTEBOOK_TAB_MIDDLE_DOWN; | |
731 | %constant wxEventType wxEVT_COMMAND_AUINOTEBOOK_TAB_MIDDLE_UP; | |
732 | %constant wxEventType wxEVT_COMMAND_AUINOTEBOOK_TAB_RIGHT_DOWN; | |
733 | %constant wxEventType wxEVT_COMMAND_AUINOTEBOOK_TAB_RIGHT_UP; | |
734 | %constant wxEventType wxEVT_COMMAND_AUINOTEBOOK_BG_DCLICK; | |
735 | ||
736 | %pythoncode { | |
737 | EVT_AUINOTEBOOK_PAGE_CLOSE = wx.PyEventBinder( wxEVT_COMMAND_AUINOTEBOOK_PAGE_CLOSE, 1 ) | |
738 | EVT_AUINOTEBOOK_PAGE_CLOSED = wx.PyEventBinder( wxEVT_COMMAND_AUINOTEBOOK_PAGE_CLOSED, 1 ) | |
739 | EVT_AUINOTEBOOK_PAGE_CHANGED = wx.PyEventBinder( wxEVT_COMMAND_AUINOTEBOOK_PAGE_CHANGED, 1 ) | |
740 | EVT_AUINOTEBOOK_PAGE_CHANGING = wx.PyEventBinder( wxEVT_COMMAND_AUINOTEBOOK_PAGE_CHANGING, 1 ) | |
741 | EVT_AUINOTEBOOK_BUTTON = wx.PyEventBinder( wxEVT_COMMAND_AUINOTEBOOK_BUTTON, 1 ) | |
742 | EVT_AUINOTEBOOK_BEGIN_DRAG = wx.PyEventBinder( wxEVT_COMMAND_AUINOTEBOOK_BEGIN_DRAG, 1 ) | |
743 | EVT_AUINOTEBOOK_END_DRAG = wx.PyEventBinder( wxEVT_COMMAND_AUINOTEBOOK_END_DRAG, 1 ) | |
744 | EVT_AUINOTEBOOK_DRAG_MOTION = wx.PyEventBinder( wxEVT_COMMAND_AUINOTEBOOK_DRAG_MOTION, 1 ) | |
745 | EVT_AUINOTEBOOK_ALLOW_DND = wx.PyEventBinder( wxEVT_COMMAND_AUINOTEBOOK_ALLOW_DND, 1 ) | |
746 | EVT_AUINOTEBOOK_DRAG_DONE = wx.PyEventBinder( wxEVT_COMMAND_AUINOTEBOOK_DRAG_DONE, 1 ) | |
747 | EVT__AUINOTEBOOK_TAB_MIDDLE_DOWN = wx.PyEventBinder( wxEVT_COMMAND_AUINOTEBOOK_TAB_MIDDLE_DOWN, 1 ) | |
748 | EVT__AUINOTEBOOK_TAB_MIDDLE_UP = wx.PyEventBinder( wxEVT_COMMAND_AUINOTEBOOK_TAB_MIDDLE_UP, 1 ) | |
749 | EVT__AUINOTEBOOK_TAB_RIGHT_DOWN = wx.PyEventBinder( wxEVT_COMMAND_AUINOTEBOOK_TAB_RIGHT_DOWN, 1 ) | |
750 | EVT__AUINOTEBOOK_TAB_RIGHT_UP = wx.PyEventBinder( wxEVT_COMMAND_AUINOTEBOOK_TAB_RIGHT_UP, 1 ) | |
751 | EVT_AUINOTEBOOK_BG_DCLICK = wx.PyEventBinder( wxEVT_COMMAND_AUINOTEBOOK_BG_DCLICK, 1 ) | |
752 | } | |
753 | #endif | |
754 | ||
755 | ||
756 | #endif // wxUSE_AUI | |
757 | #endif // _WX_AUINOTEBOOK_H_ |