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