]>
Commit | Line | Data |
---|---|---|
c7bfb76a | 1 | ////////////////////////////////////////////////////////////////////////////// |
4444d148 | 2 | // Name: wx/aui/auibook.h |
a3219eea BW |
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" | |
a3219eea BW |
21 | |
22 | #if wxUSE_AUI | |
23 | ||
4444d148 WS |
24 | #include "wx/aui/framemanager.h" |
25 | #include "wx/aui/dockart.h" | |
26 | #include "wx/aui/floatpane.h" | |
4107600f | 27 | #include "wx/control.h" |
a3219eea BW |
28 | |
29 | ||
5d3aeb0f BW |
30 | class wxAuiNotebook; |
31 | ||
702b1c7e BW |
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 | |
134198f1 | 38 | wxAUI_NB_BOTTOM = 1 << 3, |
702b1c7e BW |
39 | wxAUI_NB_TAB_SPLIT = 1 << 4, |
40 | wxAUI_NB_TAB_MOVE = 1 << 5, | |
5d3aeb0f | 41 | wxAUI_NB_TAB_EXTERNAL_MOVE = 1 << 6, |
b0d17f7c BW |
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, | |
69f5e420 | 48 | wxAUI_NB_MIDDLE_CLICK_CLOSE = 1 << 13, |
a56a1234 | 49 | |
702b1c7e BW |
50 | wxAUI_NB_DEFAULT_STYLE = wxAUI_NB_TOP | |
51 | wxAUI_NB_TAB_SPLIT | | |
52 | wxAUI_NB_TAB_MOVE | | |
41b76acd | 53 | wxAUI_NB_SCROLL_BUTTONS | |
69f5e420 BW |
54 | wxAUI_NB_CLOSE_ON_ACTIVE_TAB | |
55 | wxAUI_NB_MIDDLE_CLICK_CLOSE | |
702b1c7e BW |
56 | }; |
57 | ||
3f69756e BW |
58 | |
59 | ||
702b1c7e | 60 | |
2b9aac33 BW |
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; } | |
a56a1234 | 86 | |
2b9aac33 BW |
87 | void SetOldSelection(int s) { old_selection = s; } |
88 | int GetOldSelection() const { return old_selection; } | |
a56a1234 | 89 | |
2b9aac33 BW |
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 | ||
702b1c7e BW |
134 | // tab art class |
135 | ||
a3a5df9d | 136 | class WXDLLIMPEXP_AUI wxAuiTabArt |
3f69756e BW |
137 | { |
138 | public: | |
139 | ||
a3a5df9d BW |
140 | wxAuiTabArt() { } |
141 | virtual ~wxAuiTabArt() { } | |
a56a1234 | 142 | |
b0d17f7c BW |
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; | |
a56a1234 | 148 | |
a4c8fc23 BW |
149 | virtual void SetNormalFont(const wxFont& font) = 0; |
150 | virtual void SetSelectedFont(const wxFont& font) = 0; | |
151 | virtual void SetMeasuringFont(const wxFont& font) = 0; | |
488e50ee | 152 | |
3f69756e | 153 | virtual void DrawBackground( |
a6b0e5bd | 154 | wxDC& dc, |
01372b8f | 155 | wxWindow* wnd, |
3f69756e BW |
156 | const wxRect& rect) = 0; |
157 | ||
a6b0e5bd | 158 | virtual void DrawTab(wxDC& dc, |
01372b8f | 159 | wxWindow* wnd, |
793d4365 | 160 | const wxAuiNotebookPage& pane, |
3f69756e | 161 | const wxRect& in_rect, |
41b76acd BW |
162 | int close_button_state, |
163 | wxRect* out_tab_rect, | |
164 | wxRect* out_button_rect, | |
a56a1234 VZ |
165 | int* x_extent) = 0; |
166 | ||
4953f8cf | 167 | virtual void DrawButton( |
a6b0e5bd | 168 | wxDC& dc, |
01372b8f | 169 | wxWindow* wnd, |
4953f8cf BW |
170 | const wxRect& in_rect, |
171 | int bitmap_id, | |
172 | int button_state, | |
173 | int orientation, | |
4953f8cf | 174 | wxRect* out_rect) = 0; |
a56a1234 | 175 | |
4953f8cf | 176 | virtual wxSize GetTabSize( |
a6b0e5bd | 177 | wxDC& dc, |
01372b8f | 178 | wxWindow* wnd, |
4953f8cf | 179 | const wxString& caption, |
2b9aac33 | 180 | const wxBitmap& bitmap, |
4953f8cf | 181 | bool active, |
41b76acd | 182 | int close_button_state, |
4953f8cf | 183 | int* x_extent) = 0; |
a56a1234 | 184 | |
793d4365 | 185 | virtual int ShowDropDown( |
a6b0e5bd | 186 | wxWindow* wnd, |
793d4365 | 187 | const wxAuiNotebookPageArray& items, |
a6b0e5bd | 188 | int active_idx) = 0; |
a56a1234 | 189 | |
793d4365 | 190 | virtual int GetIndentSize() = 0; |
a56a1234 | 191 | |
793d4365 BW |
192 | virtual int GetBestTabCtrlSize( |
193 | wxWindow* wnd, | |
194 | const wxAuiNotebookPageArray& pages, | |
a56a1234 | 195 | const wxSize& required_bmp_size) = 0; |
3f69756e BW |
196 | }; |
197 | ||
198 | ||
2b9aac33 | 199 | class WXDLLIMPEXP_AUI wxAuiDefaultTabArt : public wxAuiTabArt |
b0d17f7c BW |
200 | { |
201 | ||
202 | public: | |
203 | ||
2b9aac33 BW |
204 | wxAuiDefaultTabArt(); |
205 | virtual ~wxAuiDefaultTabArt(); | |
a56a1234 | 206 | |
b0d17f7c BW |
207 | wxAuiTabArt* Clone(); |
208 | void SetFlags(unsigned int flags); | |
b0d17f7c BW |
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); | |
a56a1234 | 220 | |
b0d17f7c BW |
221 | void DrawTab(wxDC& dc, |
222 | wxWindow* wnd, | |
793d4365 | 223 | const wxAuiNotebookPage& pane, |
b0d17f7c | 224 | const wxRect& in_rect, |
b0d17f7c BW |
225 | int close_button_state, |
226 | wxRect* out_tab_rect, | |
227 | wxRect* out_button_rect, | |
228 | int* x_extent); | |
a56a1234 | 229 | |
b0d17f7c BW |
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, | |
b0d17f7c | 237 | wxRect* out_rect); |
a56a1234 | 238 | |
2b9aac33 | 239 | int GetIndentSize(); |
a56a1234 | 240 | |
b0d17f7c BW |
241 | wxSize GetTabSize( |
242 | wxDC& dc, | |
243 | wxWindow* wnd, | |
244 | const wxString& caption, | |
2b9aac33 | 245 | const wxBitmap& bitmap, |
b0d17f7c BW |
246 | bool active, |
247 | int close_button_state, | |
248 | int* x_extent); | |
a56a1234 | 249 | |
793d4365 | 250 | int ShowDropDown( |
b0d17f7c | 251 | wxWindow* wnd, |
793d4365 | 252 | const wxAuiNotebookPageArray& items, |
b0d17f7c BW |
253 | int active_idx); |
254 | ||
2b9aac33 | 255 | int GetBestTabCtrlSize(wxWindow* wnd, |
793d4365 | 256 | const wxAuiNotebookPageArray& pages, |
a56a1234 | 257 | const wxSize& required_bmp_size); |
b0d17f7c | 258 | |
760d3542 | 259 | protected: |
b0d17f7c BW |
260 | |
261 | wxFont m_normal_font; | |
262 | wxFont m_selected_font; | |
263 | wxFont m_measuring_font; | |
1750e8e2 BW |
264 | wxColour m_base_colour; |
265 | wxPen m_base_colour_pen; | |
003cf4ef | 266 | wxPen m_border_pen; |
1750e8e2 | 267 | wxBrush m_base_colour_brush; |
b0d17f7c BW |
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; | |
a56a1234 | 276 | |
b0d17f7c | 277 | int m_fixed_tab_width; |
2b9aac33 | 278 | int m_tab_ctrl_height; |
b0d17f7c BW |
279 | unsigned int m_flags; |
280 | }; | |
281 | ||
282 | ||
2b9aac33 | 283 | class WXDLLIMPEXP_AUI wxAuiSimpleTabArt : public wxAuiTabArt |
3f69756e BW |
284 | { |
285 | ||
286 | public: | |
287 | ||
2b9aac33 BW |
288 | wxAuiSimpleTabArt(); |
289 | virtual ~wxAuiSimpleTabArt(); | |
a56a1234 | 290 | |
b0d17f7c BW |
291 | wxAuiTabArt* Clone(); |
292 | void SetFlags(unsigned int flags); | |
2b9aac33 | 293 | |
b0d17f7c BW |
294 | void SetSizingInfo(const wxSize& tab_ctrl_size, |
295 | size_t tab_count); | |
296 | ||
a4c8fc23 BW |
297 | void SetNormalFont(const wxFont& font); |
298 | void SetSelectedFont(const wxFont& font); | |
299 | void SetMeasuringFont(const wxFont& font); | |
b0d17f7c | 300 | |
3f69756e | 301 | void DrawBackground( |
a6b0e5bd | 302 | wxDC& dc, |
01372b8f | 303 | wxWindow* wnd, |
3f69756e | 304 | const wxRect& rect); |
a56a1234 | 305 | |
a6b0e5bd | 306 | void DrawTab(wxDC& dc, |
01372b8f | 307 | wxWindow* wnd, |
793d4365 | 308 | const wxAuiNotebookPage& pane, |
3f69756e | 309 | const wxRect& in_rect, |
41b76acd BW |
310 | int close_button_state, |
311 | wxRect* out_tab_rect, | |
312 | wxRect* out_button_rect, | |
3f69756e | 313 | int* x_extent); |
a56a1234 | 314 | |
4953f8cf | 315 | void DrawButton( |
a6b0e5bd | 316 | wxDC& dc, |
01372b8f | 317 | wxWindow* wnd, |
4953f8cf BW |
318 | const wxRect& in_rect, |
319 | int bitmap_id, | |
320 | int button_state, | |
321 | int orientation, | |
4953f8cf | 322 | wxRect* out_rect); |
a56a1234 | 323 | |
b0d17f7c | 324 | int GetIndentSize(); |
a56a1234 | 325 | |
4953f8cf | 326 | wxSize GetTabSize( |
a6b0e5bd | 327 | wxDC& dc, |
01372b8f | 328 | wxWindow* wnd, |
4953f8cf | 329 | const wxString& caption, |
2b9aac33 | 330 | const wxBitmap& bitmap, |
4953f8cf | 331 | bool active, |
41b76acd | 332 | int close_button_state, |
4953f8cf | 333 | int* x_extent); |
a56a1234 | 334 | |
793d4365 | 335 | int ShowDropDown( |
a6b0e5bd | 336 | wxWindow* wnd, |
793d4365 | 337 | const wxAuiNotebookPageArray& items, |
a6b0e5bd BW |
338 | int active_idx); |
339 | ||
2b9aac33 | 340 | int GetBestTabCtrlSize(wxWindow* wnd, |
793d4365 | 341 | const wxAuiNotebookPageArray& pages, |
a56a1234 | 342 | const wxSize& required_bmp_size); |
a4c8fc23 | 343 | |
760d3542 | 344 | protected: |
3f69756e BW |
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; | |
4953f8cf BW |
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; | |
01372b8f BW |
360 | wxBitmap m_active_windowlist_bmp; |
361 | wxBitmap m_disabled_windowlist_bmp; | |
a56a1234 | 362 | |
b0d17f7c BW |
363 | int m_fixed_tab_width; |
364 | unsigned int m_flags; | |
3f69756e BW |
365 | }; |
366 | ||
367 | ||
368 | ||
b0d17f7c | 369 | |
41b76acd | 370 | |
a3219eea BW |
371 | |
372 | ||
a3219eea BW |
373 | |
374 | ||
375 | class WXDLLIMPEXP_AUI wxAuiTabContainer | |
376 | { | |
377 | public: | |
378 | ||
379 | wxAuiTabContainer(); | |
9fabaac4 | 380 | virtual ~wxAuiTabContainer(); |
a3219eea | 381 | |
a3a5df9d | 382 | void SetArtProvider(wxAuiTabArt* art); |
e0dc13d4 | 383 | wxAuiTabArt* GetArtProvider() const; |
3f69756e | 384 | |
702b1c7e BW |
385 | void SetFlags(unsigned int flags); |
386 | unsigned int GetFlags() const; | |
387 | ||
a3219eea BW |
388 | bool AddPage(wxWindow* page, const wxAuiNotebookPage& info); |
389 | bool InsertPage(wxWindow* page, const wxAuiNotebookPage& info, size_t idx); | |
2fadbbfd | 390 | bool MovePage(wxWindow* page, size_t new_idx); |
a3219eea BW |
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); | |
c3e016e4 | 402 | const wxAuiNotebookPage& GetPage(size_t idx) const; |
a3219eea BW |
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); | |
a56a1234 | 409 | |
41b76acd | 410 | void RemoveButton(int id); |
4953f8cf BW |
411 | void AddButton(int id, |
412 | int location, | |
413 | const wxBitmap& normal_bitmap = wxNullBitmap, | |
414 | const wxBitmap& disabled_bitmap = wxNullBitmap); | |
4444d148 | 415 | |
4953f8cf BW |
416 | size_t GetTabOffset() const; |
417 | void SetTabOffset(size_t offset); | |
a56a1234 | 418 | |
a0c2e4a0 JS |
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 | ||
a3219eea BW |
425 | protected: |
426 | ||
01372b8f | 427 | virtual void Render(wxDC* dc, wxWindow* wnd); |
a3219eea | 428 | |
01372b8f | 429 | protected: |
a3219eea | 430 | |
a3a5df9d | 431 | wxAuiTabArt* m_art; |
a3219eea BW |
432 | wxAuiNotebookPageArray m_pages; |
433 | wxAuiTabContainerButtonArray m_buttons; | |
41b76acd | 434 | wxAuiTabContainerButtonArray m_tab_close_buttons; |
a3219eea | 435 | wxRect m_rect; |
4953f8cf | 436 | size_t m_tab_offset; |
702b1c7e | 437 | unsigned int m_flags; |
a3219eea BW |
438 | }; |
439 | ||
440 | ||
441 | ||
442 | class WXDLLIMPEXP_AUI wxAuiTabCtrl : public wxControl, | |
443 | public wxAuiTabContainer | |
444 | { | |
445 | public: | |
446 | ||
447 | wxAuiTabCtrl(wxWindow* parent, | |
d91fa282 | 448 | wxWindowID id = wxID_ANY, |
a3219eea BW |
449 | const wxPoint& pos = wxDefaultPosition, |
450 | const wxSize& size = wxDefaultSize, | |
451 | long style = 0); | |
4444d148 | 452 | |
26da5e4f | 453 | ~wxAuiTabCtrl(); |
a56a1234 | 454 | |
d16619f8 | 455 | bool IsDragging() const { return m_is_dragging; } |
d16619f8 | 456 | |
a3219eea BW |
457 | protected: |
458 | ||
459 | void OnPaint(wxPaintEvent& evt); | |
460 | void OnEraseBackground(wxEraseEvent& evt); | |
461 | void OnSize(wxSizeEvent& evt); | |
462 | void OnLeftDown(wxMouseEvent& evt); | |
134198f1 | 463 | void OnLeftDClick(wxMouseEvent& evt); |
a3219eea | 464 | void OnLeftUp(wxMouseEvent& evt); |
69f5e420 BW |
465 | void OnMiddleDown(wxMouseEvent& evt); |
466 | void OnMiddleUp(wxMouseEvent& evt); | |
467 | void OnRightDown(wxMouseEvent& evt); | |
468 | void OnRightUp(wxMouseEvent& evt); | |
a3219eea BW |
469 | void OnMotion(wxMouseEvent& evt); |
470 | void OnLeaveWindow(wxMouseEvent& evt); | |
4953f8cf | 471 | void OnButton(wxAuiNotebookEvent& evt); |
a0c2e4a0 JS |
472 | void OnSetFocus(wxFocusEvent& event); |
473 | void OnKillFocus(wxFocusEvent& event); | |
474 | void OnChar(wxKeyEvent& event); | |
a56a1234 | 475 | |
a3219eea | 476 | protected: |
4444d148 | 477 | |
a3219eea | 478 | wxPoint m_click_pt; |
08c068a4 | 479 | wxWindow* m_click_tab; |
a3219eea BW |
480 | bool m_is_dragging; |
481 | wxAuiTabContainerButton* m_hover_button; | |
9b3f654a | 482 | wxAuiTabContainerButton* m_pressed_button; |
a3219eea | 483 | |
d91fa282 | 484 | #ifndef SWIG |
5d3aeb0f | 485 | DECLARE_CLASS(wxAuiTabCtrl) |
a3219eea | 486 | DECLARE_EVENT_TABLE() |
d91fa282 | 487 | #endif |
a3219eea BW |
488 | }; |
489 | ||
490 | ||
491 | ||
492 | ||
a3a5df9d | 493 | class WXDLLIMPEXP_AUI wxAuiNotebook : public wxControl |
a3219eea BW |
494 | { |
495 | ||
496 | public: | |
497 | ||
a3a5df9d | 498 | wxAuiNotebook(); |
4444d148 | 499 | |
a3a5df9d | 500 | wxAuiNotebook(wxWindow* parent, |
0ce53f32 BW |
501 | wxWindowID id = wxID_ANY, |
502 | const wxPoint& pos = wxDefaultPosition, | |
503 | const wxSize& size = wxDefaultSize, | |
504 | long style = wxAUI_NB_DEFAULT_STYLE); | |
4444d148 | 505 | |
a3a5df9d | 506 | virtual ~wxAuiNotebook(); |
a3219eea BW |
507 | |
508 | bool Create(wxWindow* parent, | |
d91fa282 | 509 | wxWindowID id = wxID_ANY, |
a3219eea BW |
510 | const wxPoint& pos = wxDefaultPosition, |
511 | const wxSize& size = wxDefaultSize, | |
4444d148 | 512 | long style = 0); |
a56a1234 | 513 | |
d606b6e9 BW |
514 | void SetWindowStyleFlag(long style); |
515 | void SetArtProvider(wxAuiTabArt* art); | |
516 | wxAuiTabArt* GetArtProvider() const; | |
a56a1234 | 517 | |
d606b6e9 BW |
518 | virtual void SetUniformBitmapSize(const wxSize& size); |
519 | virtual void SetTabCtrlHeight(int height); | |
a56a1234 | 520 | |
a3219eea BW |
521 | bool AddPage(wxWindow* page, |
522 | const wxString& caption, | |
523 | bool select = false, | |
524 | const wxBitmap& bitmap = wxNullBitmap); | |
4444d148 | 525 | |
a3219eea BW |
526 | bool InsertPage(size_t page_idx, |
527 | wxWindow* page, | |
528 | const wxString& caption, | |
529 | bool select = false, | |
530 | const wxBitmap& bitmap = wxNullBitmap); | |
4444d148 | 531 | |
a3219eea BW |
532 | bool DeletePage(size_t page); |
533 | bool RemovePage(size_t page); | |
a56a1234 | 534 | |
d606b6e9 BW |
535 | size_t GetPageCount() const; |
536 | wxWindow* GetPage(size_t page_idx) const; | |
537 | int GetPageIndex(wxWindow* page_wnd) const; | |
4444d148 | 538 | |
a3219eea | 539 | bool SetPageText(size_t page, const wxString& text); |
c3e016e4 JS |
540 | wxString GetPageText(size_t page_idx) const; |
541 | ||
e0dc13d4 | 542 | bool SetPageBitmap(size_t page, const wxBitmap& bitmap); |
c3e016e4 JS |
543 | wxBitmap GetPageBitmap(size_t page_idx) const; |
544 | ||
a3219eea BW |
545 | size_t SetSelection(size_t new_page); |
546 | int GetSelection() const; | |
c3e016e4 | 547 | |
d606b6e9 | 548 | virtual void Split(size_t page, int direction); |
0eaf8cd1 | 549 | |
0eaf8cd1 | 550 | const wxAuiManager& GetAuiManager() const { return m_mgr; } |
0eaf8cd1 | 551 | |
98d9f577 JS |
552 | // Sets the normal font |
553 | void SetNormalFont(const wxFont& font); | |
fc17828a | 554 | |
98d9f577 JS |
555 | // Sets the selected tab font |
556 | void SetSelectedFont(const wxFont& font); | |
fc17828a | 557 | |
98d9f577 JS |
558 | // Sets the measuring font |
559 | void SetMeasuringFont(const wxFont& font); | |
fc17828a | 560 | |
98d9f577 | 561 | // Sets the tab font |
fc17828a JS |
562 | virtual bool SetFont(const wxFont& font); |
563 | ||
98d9f577 | 564 | // Gets the tab control height |
fc17828a JS |
565 | int GetTabCtrlHeight() const; |
566 | ||
567 | // Gets the height of the notebook for a given page height | |
568 | int GetHeightForPageHeight(int pageHeight); | |
569 | ||
a0c2e4a0 JS |
570 | // Advances the selection, generation page selection events |
571 | void AdvanceSelection(bool forward = true); | |
572 | ||
573 | // Shows the window menu | |
574 | bool ShowWindowMenu(); | |
575 | ||
576 | // we do have multiple pages | |
577 | virtual bool HasMultiplePages() const { return true; } | |
578 | ||
579 | // we don't want focus for ourselves | |
c7bfb76a | 580 | // virtual bool AcceptsFocus() const { return false; } |
a0c2e4a0 | 581 | |
a3219eea | 582 | protected: |
4444d148 | 583 | |
2b9aac33 | 584 | // these can be overridden |
ca0d4407 | 585 | virtual void UpdateTabCtrlHeight(); |
2b9aac33 | 586 | virtual int CalculateTabCtrlHeight(); |
9fbb7d80 | 587 | virtual wxSize CalculateNewSplitSize(); |
a56a1234 | 588 | |
2b9aac33 BW |
589 | protected: |
590 | ||
591 | void DoSizing(); | |
592 | void InitNotebook(long style); | |
a3219eea BW |
593 | wxAuiTabCtrl* GetTabCtrlFromPoint(const wxPoint& pt); |
594 | wxWindow* GetTabFrameFromTabCtrl(wxWindow* tab_ctrl); | |
595 | wxAuiTabCtrl* GetActiveTabCtrl(); | |
596 | bool FindTab(wxWindow* page, wxAuiTabCtrl** ctrl, int* idx); | |
597 | void RemoveEmptyTabFrames(); | |
9fbb7d80 | 598 | void UpdateHintWindowSize(); |
a56a1234 | 599 | |
a3219eea BW |
600 | protected: |
601 | ||
5bf3f27f | 602 | void OnChildFocusNotebook(wxChildFocusEvent& evt); |
a3a5df9d | 603 | void OnRender(wxAuiManagerEvent& evt); |
a3219eea BW |
604 | void OnSize(wxSizeEvent& evt); |
605 | void OnTabClicked(wxCommandEvent& evt); | |
606 | void OnTabBeginDrag(wxCommandEvent& evt); | |
607 | void OnTabDragMotion(wxCommandEvent& evt); | |
608 | void OnTabEndDrag(wxCommandEvent& evt); | |
609 | void OnTabButton(wxCommandEvent& evt); | |
69f5e420 BW |
610 | void OnTabMiddleDown(wxCommandEvent& evt); |
611 | void OnTabMiddleUp(wxCommandEvent& evt); | |
612 | void OnTabRightDown(wxCommandEvent& evt); | |
613 | void OnTabRightUp(wxCommandEvent& evt); | |
134198f1 | 614 | void OnTabBgDClick(wxCommandEvent& evt); |
5bf3f27f | 615 | void OnNavigationKeyNotebook(wxNavigationKeyEvent& event); |
a56a1234 | 616 | |
849c353a VZ |
617 | // set selection to the given window (which must be non-NULL and be one of |
618 | // our pages, otherwise an assert is raised) | |
619 | void SetSelectionToWindow(wxWindow *win); | |
620 | void SetSelectionToPage(const wxAuiNotebookPage& page) | |
621 | { | |
622 | SetSelectionToWindow(page.window); | |
623 | } | |
624 | ||
a3219eea BW |
625 | protected: |
626 | ||
a3a5df9d | 627 | wxAuiManager m_mgr; |
a3219eea BW |
628 | wxAuiTabContainer m_tabs; |
629 | int m_curpage; | |
630 | int m_tab_id_counter; | |
631 | wxWindow* m_dummy_wnd; | |
4444d148 | 632 | |
9fbb7d80 | 633 | wxSize m_requested_bmp_size; |
ca0d4407 | 634 | int m_requested_tabctrl_height; |
a3219eea BW |
635 | wxFont m_selected_font; |
636 | wxFont m_normal_font; | |
da5e85d9 | 637 | int m_tab_ctrl_height; |
a56a1234 | 638 | |
08c068a4 | 639 | int m_last_drag_x; |
702b1c7e | 640 | unsigned int m_flags; |
4444d148 | 641 | |
d91fa282 | 642 | #ifndef SWIG |
0ce53f32 | 643 | DECLARE_CLASS(wxAuiNotebook) |
a3219eea | 644 | DECLARE_EVENT_TABLE() |
d91fa282 | 645 | #endif |
c7bfb76a JS |
646 | |
647 | WX_DECLARE_CONTROL_CONTAINER(); | |
648 | ||
a3219eea BW |
649 | }; |
650 | ||
651 | ||
652 | ||
653 | ||
654 | // wx event machinery | |
655 | ||
656 | #ifndef SWIG | |
657 | ||
658 | BEGIN_DECLARE_EVENT_TYPES() | |
3fd8c988 | 659 | DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_AUI, wxEVT_COMMAND_AUINOTEBOOK_PAGE_CLOSE, 0) |
a3219eea BW |
660 | DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_AUI, wxEVT_COMMAND_AUINOTEBOOK_PAGE_CHANGED, 0) |
661 | DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_AUI, wxEVT_COMMAND_AUINOTEBOOK_PAGE_CHANGING, 0) | |
134198f1 | 662 | DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_AUI, wxEVT_COMMAND_AUINOTEBOOK_PAGE_CLOSED, 0) |
a3219eea BW |
663 | DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_AUI, wxEVT_COMMAND_AUINOTEBOOK_BUTTON, 0) |
664 | DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_AUI, wxEVT_COMMAND_AUINOTEBOOK_BEGIN_DRAG, 0) | |
665 | DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_AUI, wxEVT_COMMAND_AUINOTEBOOK_END_DRAG, 0) | |
666 | DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_AUI, wxEVT_COMMAND_AUINOTEBOOK_DRAG_MOTION, 0) | |
5d3aeb0f | 667 | DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_AUI, wxEVT_COMMAND_AUINOTEBOOK_ALLOW_DND, 0) |
69f5e420 BW |
668 | DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_AUI, wxEVT_COMMAND_AUINOTEBOOK_TAB_MIDDLE_DOWN, 0) |
669 | DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_AUI, wxEVT_COMMAND_AUINOTEBOOK_TAB_MIDDLE_UP, 0) | |
670 | DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_AUI, wxEVT_COMMAND_AUINOTEBOOK_TAB_RIGHT_DOWN, 0) | |
671 | DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_AUI, wxEVT_COMMAND_AUINOTEBOOK_TAB_RIGHT_UP, 0) | |
134198f1 JS |
672 | DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_AUI, wxEVT_COMMAND_AUINOTEBOOK_DRAG_DONE, 0) |
673 | DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_AUI, wxEVT_COMMAND_AUINOTEBOOK_BG_DCLICK, 0) | |
a3219eea BW |
674 | END_DECLARE_EVENT_TYPES() |
675 | ||
676 | typedef void (wxEvtHandler::*wxAuiNotebookEventFunction)(wxAuiNotebookEvent&); | |
677 | ||
678 | #define wxAuiNotebookEventHandler(func) \ | |
679 | (wxObjectEventFunction)(wxEventFunction)wxStaticCastEvent(wxAuiNotebookEventFunction, &func) | |
a56a1234 | 680 | |
3fd8c988 BW |
681 | #define EVT_AUINOTEBOOK_PAGE_CLOSE(winid, fn) \ |
682 | wx__DECLARE_EVT1(wxEVT_COMMAND_AUINOTEBOOK_PAGE_CLOSE, winid, wxAuiNotebookEventHandler(fn)) | |
134198f1 JS |
683 | #define EVT_AUINOTEBOOK_PAGE_CLOSED(winid, fn) \ |
684 | wx__DECLARE_EVT1(wxEVT_COMMAND_AUINOTEBOOK_PAGE_CLOSED, winid, wxAuiNotebookEventHandler(fn)) | |
a3219eea BW |
685 | #define EVT_AUINOTEBOOK_PAGE_CHANGED(winid, fn) \ |
686 | wx__DECLARE_EVT1(wxEVT_COMMAND_AUINOTEBOOK_PAGE_CHANGED, winid, wxAuiNotebookEventHandler(fn)) | |
687 | #define EVT_AUINOTEBOOK_PAGE_CHANGING(winid, fn) \ | |
688 | wx__DECLARE_EVT1(wxEVT_COMMAND_AUINOTEBOOK_PAGE_CHANGING, winid, wxAuiNotebookEventHandler(fn)) | |
4953f8cf | 689 | #define EVT_AUINOTEBOOK_BUTTON(winid, fn) \ |
a3219eea BW |
690 | wx__DECLARE_EVT1(wxEVT_COMMAND_AUINOTEBOOK_BUTTON, winid, wxAuiNotebookEventHandler(fn)) |
691 | #define EVT_AUINOTEBOOK_BEGIN_DRAG(winid, fn) \ | |
692 | wx__DECLARE_EVT1(wxEVT_COMMAND_AUINOTEBOOK_BEGIN_DRAG, winid, wxAuiNotebookEventHandler(fn)) | |
693 | #define EVT_AUINOTEBOOK_END_DRAG(winid, fn) \ | |
694 | wx__DECLARE_EVT1(wxEVT_COMMAND_AUINOTEBOOK_END_DRAG, winid, wxAuiNotebookEventHandler(fn)) | |
695 | #define EVT_AUINOTEBOOK_DRAG_MOTION(winid, fn) \ | |
696 | wx__DECLARE_EVT1(wxEVT_COMMAND_AUINOTEBOOK_DRAG_MOTION, winid, wxAuiNotebookEventHandler(fn)) | |
5d3aeb0f BW |
697 | #define EVT_AUINOTEBOOK_ALLOW_DND(winid, fn) \ |
698 | wx__DECLARE_EVT1(wxEVT_COMMAND_AUINOTEBOOK_ALLOW_DND, winid, wxAuiNotebookEventHandler(fn)) | |
134198f1 JS |
699 | #define EVT_AUINOTEBOOK_DRAG_DONE(winid, fn) \ |
700 | wx__DECLARE_EVT1(wxEVT_COMMAND_AUINOTEBOOK_DRAG_DONE, winid, wxAuiNotebookEventHandler(fn)) | |
69f5e420 BW |
701 | #define EVT_AUINOTEBOOK_TAB_MIDDLE_DOWN(winid, fn) \ |
702 | wx__DECLARE_EVT1(wxEVT_COMMAND_AUINOTEBOOK_TAB_MIDDLE_DOWN, winid, wxAuiNotebookEventHandler(fn)) | |
703 | #define EVT_AUINOTEBOOK_TAB_MIDDLE_UP(winid, fn) \ | |
704 | wx__DECLARE_EVT1(wxEVT_COMMAND_AUINOTEBOOK_TAB_MIDDLE_UP, winid, wxAuiNotebookEventHandler(fn)) | |
705 | #define EVT_AUINOTEBOOK_TAB_RIGHT_DOWN(winid, fn) \ | |
706 | wx__DECLARE_EVT1(wxEVT_COMMAND_AUINOTEBOOK_TAB_RIGHT_DOWN, winid, wxAuiNotebookEventHandler(fn)) | |
707 | #define EVT_AUINOTEBOOK_TAB_RIGHT_UP(winid, fn) \ | |
708 | wx__DECLARE_EVT1(wxEVT_COMMAND_AUINOTEBOOK_TAB_RIGHT_UP, winid, wxAuiNotebookEventHandler(fn)) | |
134198f1 JS |
709 | #define EVT_AUINOTEBOOK_BG_DCLICK(winid, fn) \ |
710 | wx__DECLARE_EVT1(wxEVT_COMMAND_AUINOTEBOOK_BG_DCLICK, winid, wxAuiNotebookEventHandler(fn)) | |
a3219eea BW |
711 | #else |
712 | ||
713 | // wxpython/swig event work | |
3fd8c988 | 714 | %constant wxEventType wxEVT_COMMAND_AUINOTEBOOK_PAGE_CLOSE; |
134198f1 | 715 | %constant wxEventType wxEVT_COMMAND_AUINOTEBOOK_PAGE_CLOSED; |
d91fa282 RD |
716 | %constant wxEventType wxEVT_COMMAND_AUINOTEBOOK_PAGE_CHANGED; |
717 | %constant wxEventType wxEVT_COMMAND_AUINOTEBOOK_PAGE_CHANGING; | |
718 | %constant wxEventType wxEVT_COMMAND_AUINOTEBOOK_BUTTON; | |
719 | %constant wxEventType wxEVT_COMMAND_AUINOTEBOOK_BEGIN_DRAG; | |
720 | %constant wxEventType wxEVT_COMMAND_AUINOTEBOOK_END_DRAG; | |
721 | %constant wxEventType wxEVT_COMMAND_AUINOTEBOOK_DRAG_MOTION; | |
5d3aeb0f | 722 | %constant wxEventType wxEVT_COMMAND_AUINOTEBOOK_ALLOW_DND; |
134198f1 | 723 | %constant wxEventType wxEVT_COMMAND_AUINOTEBOOK_DRAG_DONE; |
4309ed17 RD |
724 | %constant wxEventType wxEVT_COMMAND_AUINOTEBOOK_TAB_MIDDLE_DOWN; |
725 | %constant wxEventType wxEVT_COMMAND_AUINOTEBOOK_TAB_MIDDLE_UP; | |
726 | %constant wxEventType wxEVT_COMMAND_AUINOTEBOOK_TAB_RIGHT_DOWN; | |
727 | %constant wxEventType wxEVT_COMMAND_AUINOTEBOOK_TAB_RIGHT_UP; | |
134198f1 | 728 | %constant wxEventType wxEVT_COMMAND_AUINOTEBOOK_BG_DCLICK; |
4309ed17 | 729 | |
d91fa282 | 730 | %pythoncode { |
3fd8c988 | 731 | EVT_AUINOTEBOOK_PAGE_CLOSE = wx.PyEventBinder( wxEVT_COMMAND_AUINOTEBOOK_PAGE_CLOSE, 1 ) |
134198f1 | 732 | EVT_AUINOTEBOOK_PAGE_CLOSED = wx.PyEventBinder( wxEVT_COMMAND_AUINOTEBOOK_PAGE_CLOSED, 1 ) |
d91fa282 RD |
733 | EVT_AUINOTEBOOK_PAGE_CHANGED = wx.PyEventBinder( wxEVT_COMMAND_AUINOTEBOOK_PAGE_CHANGED, 1 ) |
734 | EVT_AUINOTEBOOK_PAGE_CHANGING = wx.PyEventBinder( wxEVT_COMMAND_AUINOTEBOOK_PAGE_CHANGING, 1 ) | |
735 | EVT_AUINOTEBOOK_BUTTON = wx.PyEventBinder( wxEVT_COMMAND_AUINOTEBOOK_BUTTON, 1 ) | |
736 | EVT_AUINOTEBOOK_BEGIN_DRAG = wx.PyEventBinder( wxEVT_COMMAND_AUINOTEBOOK_BEGIN_DRAG, 1 ) | |
737 | EVT_AUINOTEBOOK_END_DRAG = wx.PyEventBinder( wxEVT_COMMAND_AUINOTEBOOK_END_DRAG, 1 ) | |
4444d148 | 738 | EVT_AUINOTEBOOK_DRAG_MOTION = wx.PyEventBinder( wxEVT_COMMAND_AUINOTEBOOK_DRAG_MOTION, 1 ) |
5d3aeb0f | 739 | EVT_AUINOTEBOOK_ALLOW_DND = wx.PyEventBinder( wxEVT_COMMAND_AUINOTEBOOK_ALLOW_DND, 1 ) |
134198f1 | 740 | EVT_AUINOTEBOOK_DRAG_DONE = wx.PyEventBinder( wxEVT_COMMAND_AUINOTEBOOK_DRAG_DONE, 1 ) |
4309ed17 RD |
741 | EVT__AUINOTEBOOK_TAB_MIDDLE_DOWN = wx.PyEventBinder( wxEVT_COMMAND_AUINOTEBOOK_TAB_MIDDLE_DOWN, 1 ) |
742 | EVT__AUINOTEBOOK_TAB_MIDDLE_UP = wx.PyEventBinder( wxEVT_COMMAND_AUINOTEBOOK_TAB_MIDDLE_UP, 1 ) | |
743 | EVT__AUINOTEBOOK_TAB_RIGHT_DOWN = wx.PyEventBinder( wxEVT_COMMAND_AUINOTEBOOK_TAB_RIGHT_DOWN, 1 ) | |
744 | EVT__AUINOTEBOOK_TAB_RIGHT_UP = wx.PyEventBinder( wxEVT_COMMAND_AUINOTEBOOK_TAB_RIGHT_UP, 1 ) | |
134198f1 | 745 | EVT_AUINOTEBOOK_BG_DCLICK = wx.PyEventBinder( wxEVT_COMMAND_AUINOTEBOOK_BG_DCLICK, 1 ) |
d91fa282 | 746 | } |
a3219eea BW |
747 | #endif |
748 | ||
749 | ||
750 | #endif // wxUSE_AUI | |
751 | #endif // _WX_AUINOTEBOOK_H_ |