]> git.saurik.com Git - wxWidgets.git/blame - include/wx/aui/auibook.h
implemented wxAUI_NB_WINDOWLIST_BUTTON and wxAUI_NB_SCROLL_BUTTONS in wxAuiNotebook
[wxWidgets.git] / include / wx / aui / auibook.h
CommitLineData
a3219eea 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
702b1c7e
BW
30
31enum wxAuiNotebookOption
32{
33 wxAUI_NB_TOP = 1 << 0,
34 wxAUI_NB_LEFT = 1 << 1, // not implemented yet
35 wxAUI_NB_RIGHT = 1 << 2, // not implemented yet
36 wxAUI_NB_BOTTOM = 1 << 3, // not implemented yet
37 wxAUI_NB_TAB_SPLIT = 1 << 4,
38 wxAUI_NB_TAB_MOVE = 1 << 5,
39 wxAUI_NB_SCROLL_BUTTONS = 1 << 6,
01372b8f 40 wxAUI_NB_WINDOWLIST_BUTTON = 1 << 7,
0ce53f32 41 wxAUI_NB_CLOSE_BUTTON = 1 << 8,
702b1c7e
BW
42 wxAUI_NB_CLOSE_ON_ACTIVE_TAB = 1 << 9,
43 wxAUI_NB_CLOSE_ON_ALL_TABS = 1 << 10,
44
45 wxAUI_NB_DEFAULT_STYLE = wxAUI_NB_TOP |
46 wxAUI_NB_TAB_SPLIT |
47 wxAUI_NB_TAB_MOVE |
41b76acd
BW
48 wxAUI_NB_SCROLL_BUTTONS |
49 wxAUI_NB_CLOSE_ON_ACTIVE_TAB
702b1c7e
BW
50};
51
3f69756e
BW
52
53
702b1c7e
BW
54
55
56// tab art class
57
a3a5df9d 58class WXDLLIMPEXP_AUI wxAuiTabArt
3f69756e
BW
59{
60public:
61
a3a5df9d
BW
62 wxAuiTabArt() { }
63 virtual ~wxAuiTabArt() { }
a4c8fc23
BW
64
65 virtual void SetNormalFont(const wxFont& font) = 0;
66 virtual void SetSelectedFont(const wxFont& font) = 0;
67 virtual void SetMeasuringFont(const wxFont& font) = 0;
488e50ee 68
3f69756e
BW
69 virtual void DrawBackground(
70 wxDC* dc,
01372b8f 71 wxWindow* wnd,
3f69756e
BW
72 const wxRect& rect) = 0;
73
74 virtual void DrawTab(wxDC* dc,
01372b8f 75 wxWindow* wnd,
3f69756e
BW
76 const wxRect& in_rect,
77 const wxString& caption,
78 bool active,
41b76acd
BW
79 int close_button_state,
80 wxRect* out_tab_rect,
81 wxRect* out_button_rect,
3f69756e 82 int* x_extent) = 0;
4953f8cf
BW
83
84 virtual void DrawButton(
85 wxDC* dc,
01372b8f 86 wxWindow* wnd,
4953f8cf
BW
87 const wxRect& in_rect,
88 int bitmap_id,
89 int button_state,
90 int orientation,
91 const wxBitmap& bitmap_override,
92 wxRect* out_rect) = 0;
01372b8f
BW
93
94 virtual int ShowWindowList(
95 wxWindow* wnd,
96 const wxArrayString& items,
97 int active_idx) = 0;
4953f8cf
BW
98
99 virtual wxSize GetTabSize(
100 wxDC* dc,
01372b8f 101 wxWindow* wnd,
4953f8cf
BW
102 const wxString& caption,
103 bool active,
41b76acd 104 int close_button_state,
4953f8cf 105 int* x_extent) = 0;
01372b8f
BW
106
107 virtual int GetBestTabCtrlSize(wxWindow* wnd) = 0;
3f69756e
BW
108};
109
110
a3a5df9d 111class WXDLLIMPEXP_AUI wxAuiDefaultTabArt : public wxAuiTabArt
3f69756e
BW
112{
113
114public:
115
a3a5df9d
BW
116 wxAuiDefaultTabArt();
117 virtual ~wxAuiDefaultTabArt();
3f69756e 118
01372b8f 119 void SetWindow(wxWindow* wnd);
a4c8fc23
BW
120 void SetNormalFont(const wxFont& font);
121 void SetSelectedFont(const wxFont& font);
122 void SetMeasuringFont(const wxFont& font);
123
3f69756e
BW
124 void DrawBackground(
125 wxDC* dc,
01372b8f 126 wxWindow* wnd,
3f69756e
BW
127 const wxRect& rect);
128
129 void DrawTab(wxDC* dc,
01372b8f 130 wxWindow* wnd,
3f69756e
BW
131 const wxRect& in_rect,
132 const wxString& caption,
133 bool active,
41b76acd
BW
134 int close_button_state,
135 wxRect* out_tab_rect,
136 wxRect* out_button_rect,
3f69756e 137 int* x_extent);
4953f8cf
BW
138
139 void DrawButton(
140 wxDC* dc,
01372b8f 141 wxWindow* wnd,
4953f8cf
BW
142 const wxRect& in_rect,
143 int bitmap_id,
144 int button_state,
145 int orientation,
146 const wxBitmap& bitmap_override,
147 wxRect* out_rect);
148
01372b8f
BW
149 int ShowWindowList(
150 wxWindow* wnd,
151 const wxArrayString& items,
152 int active_idx);
153
4953f8cf
BW
154 wxSize GetTabSize(
155 wxDC* dc,
01372b8f 156 wxWindow* wnd,
4953f8cf
BW
157 const wxString& caption,
158 bool active,
41b76acd 159 int close_button_state,
4953f8cf 160 int* x_extent);
a4c8fc23 161
01372b8f 162 int GetBestTabCtrlSize(wxWindow* wnd);
a4c8fc23 163
3f69756e
BW
164private:
165
166 wxFont m_normal_font;
167 wxFont m_selected_font;
168 wxFont m_measuring_font;
169 wxPen m_normal_bkpen;
170 wxPen m_selected_bkpen;
171 wxBrush m_normal_bkbrush;
172 wxBrush m_selected_bkbrush;
173 wxBrush m_bkbrush;
4953f8cf
BW
174 wxBitmap m_active_close_bmp;
175 wxBitmap m_disabled_close_bmp;
176 wxBitmap m_active_left_bmp;
177 wxBitmap m_disabled_left_bmp;
178 wxBitmap m_active_right_bmp;
179 wxBitmap m_disabled_right_bmp;
01372b8f
BW
180 wxBitmap m_active_windowlist_bmp;
181 wxBitmap m_disabled_windowlist_bmp;
3f69756e
BW
182};
183
184
185
a3219eea
BW
186// event declarations/classes
187
188class WXDLLIMPEXP_AUI wxAuiNotebookEvent : public wxNotifyEvent
189{
190public:
191 wxAuiNotebookEvent(wxEventType command_type = wxEVT_NULL,
192 int win_id = 0)
193 : wxNotifyEvent(command_type, win_id)
194 {
195 }
196#ifndef SWIG
197 wxAuiNotebookEvent(const wxAuiNotebookEvent& c) : wxNotifyEvent(c)
198 {
199 old_selection = c.old_selection;
200 selection = c.selection;
201 }
202#endif
203 wxEvent *Clone() const { return new wxAuiNotebookEvent(*this); }
204
08c068a4 205 void SetSelection(int s) { selection = s; m_commandInt = s; }
a3219eea
BW
206 void SetOldSelection(int s) { old_selection = s; }
207 int GetSelection() const { return selection; }
208 int GetOldSelection() const { return old_selection; }
4444d148 209
a3219eea
BW
210public:
211 int old_selection;
212 int selection;
4444d148 213
a3219eea
BW
214#ifndef SWIG
215private:
216 DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxAuiNotebookEvent)
217#endif
218};
219
220
221
222
223
224class WXDLLIMPEXP_AUI wxAuiNotebookPage
225{
226public:
227 wxWindow* window; // page's associated window
228 wxString caption; // caption displayed on the tab
229 wxBitmap bitmap; // tab's bitmap
230 wxRect rect; // tab's hit rectangle
231 bool active; // true if the page is currently active
232};
233
234class WXDLLIMPEXP_AUI wxAuiTabContainerButton
235{
236public:
41b76acd 237
a3219eea 238 int id; // button's id
4953f8cf 239 int cur_state; // current state (normal, hover, pressed, etc.)
41b76acd 240 int location; // buttons location (wxLEFT, wxRIGHT, or wxCENTER)
4953f8cf
BW
241 wxBitmap bitmap; // button's hover bitmap
242 wxBitmap dis_bitmap; // button's disabled bitmap
a3219eea
BW
243 wxRect rect; // button's hit rectangle
244};
245
246
d91fa282 247#ifndef SWIG
a3219eea
BW
248WX_DECLARE_USER_EXPORTED_OBJARRAY(wxAuiNotebookPage, wxAuiNotebookPageArray, WXDLLIMPEXP_AUI);
249WX_DECLARE_USER_EXPORTED_OBJARRAY(wxAuiTabContainerButton, wxAuiTabContainerButtonArray, WXDLLIMPEXP_AUI);
d91fa282 250#endif
a3219eea
BW
251
252
253class WXDLLIMPEXP_AUI wxAuiTabContainer
254{
255public:
256
257 wxAuiTabContainer();
9fabaac4 258 virtual ~wxAuiTabContainer();
a3219eea 259
a3a5df9d
BW
260 void SetArtProvider(wxAuiTabArt* art);
261 wxAuiTabArt* GetArtProvider();
3f69756e 262
702b1c7e
BW
263 void SetFlags(unsigned int flags);
264 unsigned int GetFlags() const;
265
a3219eea
BW
266 bool AddPage(wxWindow* page, const wxAuiNotebookPage& info);
267 bool InsertPage(wxWindow* page, const wxAuiNotebookPage& info, size_t idx);
2fadbbfd 268 bool MovePage(wxWindow* page, size_t new_idx);
a3219eea
BW
269 bool RemovePage(wxWindow* page);
270 bool SetActivePage(wxWindow* page);
271 bool SetActivePage(size_t page);
272 void SetNoneActive();
273 int GetActivePage() const;
274 bool TabHitTest(int x, int y, wxWindow** hit) const;
275 bool ButtonHitTest(int x, int y, wxAuiTabContainerButton** hit) const;
276 wxWindow* GetWindowFromIdx(size_t idx) const;
277 int GetIdxFromWindow(wxWindow* page) const;
278 size_t GetPageCount() const;
279 wxAuiNotebookPage& GetPage(size_t idx);
280 wxAuiNotebookPageArray& GetPages();
281 void SetNormalFont(const wxFont& normal_font);
282 void SetSelectedFont(const wxFont& selected_font);
283 void SetMeasuringFont(const wxFont& measuring_font);
284 void DoShowHide();
285 void SetRect(const wxRect& rect);
41b76acd
BW
286
287 void RemoveButton(int id);
4953f8cf
BW
288 void AddButton(int id,
289 int location,
290 const wxBitmap& normal_bitmap = wxNullBitmap,
291 const wxBitmap& disabled_bitmap = wxNullBitmap);
4444d148 292
4953f8cf
BW
293 size_t GetTabOffset() const;
294 void SetTabOffset(size_t offset);
295
a3219eea
BW
296protected:
297
01372b8f 298 virtual void Render(wxDC* dc, wxWindow* wnd);
a3219eea 299
01372b8f 300protected:
a3219eea 301
a3a5df9d 302 wxAuiTabArt* m_art;
a3219eea
BW
303 wxAuiNotebookPageArray m_pages;
304 wxAuiTabContainerButtonArray m_buttons;
41b76acd 305 wxAuiTabContainerButtonArray m_tab_close_buttons;
a3219eea 306 wxRect m_rect;
4953f8cf 307 size_t m_tab_offset;
702b1c7e 308 unsigned int m_flags;
a3219eea
BW
309};
310
311
312
313class WXDLLIMPEXP_AUI wxAuiTabCtrl : public wxControl,
314 public wxAuiTabContainer
315{
316public:
317
318 wxAuiTabCtrl(wxWindow* parent,
d91fa282 319 wxWindowID id = wxID_ANY,
a3219eea
BW
320 const wxPoint& pos = wxDefaultPosition,
321 const wxSize& size = wxDefaultSize,
322 long style = 0);
4444d148 323
26da5e4f
BW
324 ~wxAuiTabCtrl();
325
a3219eea
BW
326protected:
327
328 void OnPaint(wxPaintEvent& evt);
329 void OnEraseBackground(wxEraseEvent& evt);
330 void OnSize(wxSizeEvent& evt);
331 void OnLeftDown(wxMouseEvent& evt);
332 void OnLeftUp(wxMouseEvent& evt);
333 void OnMotion(wxMouseEvent& evt);
334 void OnLeaveWindow(wxMouseEvent& evt);
4953f8cf 335 void OnButton(wxAuiNotebookEvent& evt);
4444d148 336
4953f8cf 337
a3219eea 338protected:
4444d148 339
a3219eea 340 wxPoint m_click_pt;
08c068a4 341 wxWindow* m_click_tab;
a3219eea
BW
342 bool m_is_dragging;
343 wxAuiTabContainerButton* m_hover_button;
344
d91fa282 345#ifndef SWIG
a3219eea 346 DECLARE_EVENT_TABLE()
d91fa282 347#endif
a3219eea
BW
348};
349
350
351
352
a3a5df9d 353class WXDLLIMPEXP_AUI wxAuiNotebook : public wxControl
a3219eea
BW
354{
355
356public:
357
a3a5df9d 358 wxAuiNotebook();
4444d148 359
a3a5df9d 360 wxAuiNotebook(wxWindow* parent,
0ce53f32
BW
361 wxWindowID id = wxID_ANY,
362 const wxPoint& pos = wxDefaultPosition,
363 const wxSize& size = wxDefaultSize,
364 long style = wxAUI_NB_DEFAULT_STYLE);
4444d148 365
a3a5df9d 366 virtual ~wxAuiNotebook();
a3219eea
BW
367
368 bool Create(wxWindow* parent,
d91fa282 369 wxWindowID id = wxID_ANY,
a3219eea
BW
370 const wxPoint& pos = wxDefaultPosition,
371 const wxSize& size = wxDefaultSize,
4444d148 372 long style = 0);
a3219eea
BW
373
374 bool AddPage(wxWindow* page,
375 const wxString& caption,
376 bool select = false,
377 const wxBitmap& bitmap = wxNullBitmap);
4444d148 378
a3219eea
BW
379 bool InsertPage(size_t page_idx,
380 wxWindow* page,
381 const wxString& caption,
382 bool select = false,
383 const wxBitmap& bitmap = wxNullBitmap);
4444d148 384
a3219eea
BW
385 bool DeletePage(size_t page);
386 bool RemovePage(size_t page);
0ce53f32
BW
387
388 void SetWindowStyleFlag(long style);
4444d148 389
a3219eea
BW
390 bool SetPageText(size_t page, const wxString& text);
391 size_t SetSelection(size_t new_page);
392 int GetSelection() const;
393 size_t GetPageCount() const;
394 wxWindow* GetPage(size_t page_idx) const;
4444d148 395
0ce53f32 396
a3a5df9d
BW
397 void SetArtProvider(wxAuiTabArt* art);
398 wxAuiTabArt* GetArtProvider();
3f69756e 399
a3219eea 400protected:
4444d148 401
a3219eea
BW
402 wxAuiTabCtrl* GetTabCtrlFromPoint(const wxPoint& pt);
403 wxWindow* GetTabFrameFromTabCtrl(wxWindow* tab_ctrl);
404 wxAuiTabCtrl* GetActiveTabCtrl();
405 bool FindTab(wxWindow* page, wxAuiTabCtrl** ctrl, int* idx);
406 void RemoveEmptyTabFrames();
4444d148 407
a3219eea
BW
408protected:
409
410 void DoSizing();
702b1c7e 411 void InitNotebook(long style);
4444d148 412
a3219eea 413 void OnChildFocus(wxChildFocusEvent& evt);
a3a5df9d 414 void OnRender(wxAuiManagerEvent& evt);
a3219eea
BW
415 void OnEraseBackground(wxEraseEvent& evt);
416 void OnSize(wxSizeEvent& evt);
417 void OnTabClicked(wxCommandEvent& evt);
418 void OnTabBeginDrag(wxCommandEvent& evt);
419 void OnTabDragMotion(wxCommandEvent& evt);
420 void OnTabEndDrag(wxCommandEvent& evt);
421 void OnTabButton(wxCommandEvent& evt);
4953f8cf 422
a3219eea
BW
423protected:
424
a3a5df9d 425 wxAuiManager m_mgr;
a3219eea
BW
426 wxAuiTabContainer m_tabs;
427 int m_curpage;
428 int m_tab_id_counter;
429 wxWindow* m_dummy_wnd;
4444d148 430
a3219eea
BW
431 wxFont m_selected_font;
432 wxFont m_normal_font;
da5e85d9 433 int m_tab_ctrl_height;
08c068a4
BW
434
435 int m_last_drag_x;
702b1c7e 436 unsigned int m_flags;
4444d148 437
d91fa282 438#ifndef SWIG
0ce53f32 439 DECLARE_CLASS(wxAuiNotebook)
a3219eea 440 DECLARE_EVENT_TABLE()
d91fa282 441#endif
a3219eea
BW
442};
443
444
445
446
447// wx event machinery
448
449#ifndef SWIG
450
451BEGIN_DECLARE_EVENT_TYPES()
452 DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_AUI, wxEVT_COMMAND_AUINOTEBOOK_PAGE_CHANGED, 0)
453 DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_AUI, wxEVT_COMMAND_AUINOTEBOOK_PAGE_CHANGING, 0)
454 DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_AUI, wxEVT_COMMAND_AUINOTEBOOK_BUTTON, 0)
455 DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_AUI, wxEVT_COMMAND_AUINOTEBOOK_BEGIN_DRAG, 0)
456 DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_AUI, wxEVT_COMMAND_AUINOTEBOOK_END_DRAG, 0)
457 DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_AUI, wxEVT_COMMAND_AUINOTEBOOK_DRAG_MOTION, 0)
458END_DECLARE_EVENT_TYPES()
459
460typedef void (wxEvtHandler::*wxAuiNotebookEventFunction)(wxAuiNotebookEvent&);
461
462#define wxAuiNotebookEventHandler(func) \
463 (wxObjectEventFunction)(wxEventFunction)wxStaticCastEvent(wxAuiNotebookEventFunction, &func)
464
465#define EVT_AUINOTEBOOK_PAGE_CHANGED(winid, fn) \
466 wx__DECLARE_EVT1(wxEVT_COMMAND_AUINOTEBOOK_PAGE_CHANGED, winid, wxAuiNotebookEventHandler(fn))
467#define EVT_AUINOTEBOOK_PAGE_CHANGING(winid, fn) \
468 wx__DECLARE_EVT1(wxEVT_COMMAND_AUINOTEBOOK_PAGE_CHANGING, winid, wxAuiNotebookEventHandler(fn))
4953f8cf 469#define EVT_AUINOTEBOOK_BUTTON(winid, fn) \
a3219eea
BW
470 wx__DECLARE_EVT1(wxEVT_COMMAND_AUINOTEBOOK_BUTTON, winid, wxAuiNotebookEventHandler(fn))
471#define EVT_AUINOTEBOOK_BEGIN_DRAG(winid, fn) \
472 wx__DECLARE_EVT1(wxEVT_COMMAND_AUINOTEBOOK_BEGIN_DRAG, winid, wxAuiNotebookEventHandler(fn))
473#define EVT_AUINOTEBOOK_END_DRAG(winid, fn) \
474 wx__DECLARE_EVT1(wxEVT_COMMAND_AUINOTEBOOK_END_DRAG, winid, wxAuiNotebookEventHandler(fn))
475#define EVT_AUINOTEBOOK_DRAG_MOTION(winid, fn) \
476 wx__DECLARE_EVT1(wxEVT_COMMAND_AUINOTEBOOK_DRAG_MOTION, winid, wxAuiNotebookEventHandler(fn))
4444d148 477
a3219eea
BW
478#else
479
480// wxpython/swig event work
d91fa282
RD
481%constant wxEventType wxEVT_COMMAND_AUINOTEBOOK_PAGE_CHANGED;
482%constant wxEventType wxEVT_COMMAND_AUINOTEBOOK_PAGE_CHANGING;
483%constant wxEventType wxEVT_COMMAND_AUINOTEBOOK_BUTTON;
484%constant wxEventType wxEVT_COMMAND_AUINOTEBOOK_BEGIN_DRAG;
485%constant wxEventType wxEVT_COMMAND_AUINOTEBOOK_END_DRAG;
486%constant wxEventType wxEVT_COMMAND_AUINOTEBOOK_DRAG_MOTION;
487
488%pythoncode {
489 EVT_AUINOTEBOOK_PAGE_CHANGED = wx.PyEventBinder( wxEVT_COMMAND_AUINOTEBOOK_PAGE_CHANGED, 1 )
490 EVT_AUINOTEBOOK_PAGE_CHANGING = wx.PyEventBinder( wxEVT_COMMAND_AUINOTEBOOK_PAGE_CHANGING, 1 )
491 EVT_AUINOTEBOOK_BUTTON = wx.PyEventBinder( wxEVT_COMMAND_AUINOTEBOOK_BUTTON, 1 )
492 EVT_AUINOTEBOOK_BEGIN_DRAG = wx.PyEventBinder( wxEVT_COMMAND_AUINOTEBOOK_BEGIN_DRAG, 1 )
493 EVT_AUINOTEBOOK_END_DRAG = wx.PyEventBinder( wxEVT_COMMAND_AUINOTEBOOK_END_DRAG, 1 )
4444d148 494 EVT_AUINOTEBOOK_DRAG_MOTION = wx.PyEventBinder( wxEVT_COMMAND_AUINOTEBOOK_DRAG_MOTION, 1 )
d91fa282 495}
a3219eea
BW
496#endif
497
498
499#endif // wxUSE_AUI
500#endif // _WX_AUINOTEBOOK_H_