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