1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: wx/aui/auibook.h
3 // Purpose: wxaui: wx advanced user interface - notebook
4 // Author: Benjamin I. Williams
7 // Copyright: (C) Copyright 2006, Kirix Corporation, All Rights Reserved.
8 // Licence: wxWindows Library Licence, Version 3.1
9 ///////////////////////////////////////////////////////////////////////////////
13 #ifndef _WX_AUINOTEBOOK_H_
14 #define _WX_AUINOTEBOOK_H_
16 // ----------------------------------------------------------------------------
18 // ----------------------------------------------------------------------------
24 #include "wx/aui/framemanager.h"
25 #include "wx/aui/dockart.h"
26 #include "wx/aui/floatpane.h"
27 #include "wx/control.h"
31 enum wxAuiNotebookOption
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,
40 wxAUI_NB_WINDOWLIST_BUTTON
= 1 << 7,
41 wxAUI_NB_CLOSE_BUTTON
= 1 << 8,
42 wxAUI_NB_CLOSE_ON_ACTIVE_TAB
= 1 << 9,
43 wxAUI_NB_CLOSE_ON_ALL_TABS
= 1 << 10,
45 wxAUI_NB_DEFAULT_STYLE
= wxAUI_NB_TOP
|
48 wxAUI_NB_SCROLL_BUTTONS
|
49 wxAUI_NB_CLOSE_ON_ACTIVE_TAB
58 class WXDLLIMPEXP_AUI wxAuiTabArt
63 virtual ~wxAuiTabArt() { }
65 virtual void SetNormalFont(const wxFont
& font
) = 0;
66 virtual void SetSelectedFont(const wxFont
& font
) = 0;
67 virtual void SetMeasuringFont(const wxFont
& font
) = 0;
69 virtual void DrawBackground(
72 const wxRect
& rect
) = 0;
74 virtual void DrawTab(wxDC
& dc
,
76 const wxRect
& in_rect
,
77 const wxString
& caption
,
79 int close_button_state
,
81 wxRect
* out_button_rect
,
84 virtual void DrawButton(
87 const wxRect
& in_rect
,
91 const wxBitmap
& bitmap_override
,
92 wxRect
* out_rect
) = 0;
94 virtual wxSize
GetTabSize(
97 const wxString
& caption
,
99 int close_button_state
,
102 virtual int ShowWindowList(
104 const wxArrayString
& items
,
107 virtual int GetBestTabCtrlSize(wxWindow
* wnd
) = 0;
111 class WXDLLIMPEXP_AUI wxAuiDefaultTabArt
: public wxAuiTabArt
116 wxAuiDefaultTabArt();
117 virtual ~wxAuiDefaultTabArt();
119 void SetWindow(wxWindow
* wnd
);
120 void SetNormalFont(const wxFont
& font
);
121 void SetSelectedFont(const wxFont
& font
);
122 void SetMeasuringFont(const wxFont
& font
);
129 void DrawTab(wxDC
& dc
,
131 const wxRect
& in_rect
,
132 const wxString
& caption
,
134 int close_button_state
,
135 wxRect
* out_tab_rect
,
136 wxRect
* out_button_rect
,
142 const wxRect
& in_rect
,
146 const wxBitmap
& bitmap_override
,
152 const wxString
& caption
,
154 int close_button_state
,
159 const wxArrayString
& items
,
162 int GetBestTabCtrlSize(wxWindow
* wnd
);
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
;
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
;
180 wxBitmap m_active_windowlist_bmp
;
181 wxBitmap m_disabled_windowlist_bmp
;
186 // event declarations/classes
188 class WXDLLIMPEXP_AUI wxAuiNotebookEvent
: public wxNotifyEvent
191 wxAuiNotebookEvent(wxEventType command_type
= wxEVT_NULL
,
193 : wxNotifyEvent(command_type
, win_id
)
197 wxAuiNotebookEvent(const wxAuiNotebookEvent
& c
) : wxNotifyEvent(c
)
199 old_selection
= c
.old_selection
;
200 selection
= c
.selection
;
203 wxEvent
*Clone() const { return new wxAuiNotebookEvent(*this); }
205 void SetSelection(int s
) { selection
= s
; m_commandInt
= s
; }
206 void SetOldSelection(int s
) { old_selection
= s
; }
207 int GetSelection() const { return selection
; }
208 int GetOldSelection() const { return old_selection
; }
216 DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxAuiNotebookEvent
)
224 class WXDLLIMPEXP_AUI wxAuiNotebookPage
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
234 class WXDLLIMPEXP_AUI wxAuiTabContainerButton
238 int id
; // button's id
239 int cur_state
; // current state (normal, hover, pressed, etc.)
240 int location
; // buttons location (wxLEFT, wxRIGHT, or wxCENTER)
241 wxBitmap bitmap
; // button's hover bitmap
242 wxBitmap dis_bitmap
; // button's disabled bitmap
243 wxRect rect
; // button's hit rectangle
248 WX_DECLARE_USER_EXPORTED_OBJARRAY(wxAuiNotebookPage
, wxAuiNotebookPageArray
, WXDLLIMPEXP_AUI
);
249 WX_DECLARE_USER_EXPORTED_OBJARRAY(wxAuiTabContainerButton
, wxAuiTabContainerButtonArray
, WXDLLIMPEXP_AUI
);
253 class WXDLLIMPEXP_AUI wxAuiTabContainer
258 virtual ~wxAuiTabContainer();
260 void SetArtProvider(wxAuiTabArt
* art
);
261 wxAuiTabArt
* GetArtProvider();
263 void SetFlags(unsigned int flags
);
264 unsigned int GetFlags() const;
266 bool AddPage(wxWindow
* page
, const wxAuiNotebookPage
& info
);
267 bool InsertPage(wxWindow
* page
, const wxAuiNotebookPage
& info
, size_t idx
);
268 bool MovePage(wxWindow
* page
, size_t new_idx
);
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
);
285 void SetRect(const wxRect
& rect
);
287 void RemoveButton(int id
);
288 void AddButton(int id
,
290 const wxBitmap
& normal_bitmap
= wxNullBitmap
,
291 const wxBitmap
& disabled_bitmap
= wxNullBitmap
);
293 size_t GetTabOffset() const;
294 void SetTabOffset(size_t offset
);
298 virtual void Render(wxDC
* dc
, wxWindow
* wnd
);
303 wxAuiNotebookPageArray m_pages
;
304 wxAuiTabContainerButtonArray m_buttons
;
305 wxAuiTabContainerButtonArray m_tab_close_buttons
;
308 unsigned int m_flags
;
313 class WXDLLIMPEXP_AUI wxAuiTabCtrl
: public wxControl
,
314 public wxAuiTabContainer
318 wxAuiTabCtrl(wxWindow
* parent
,
319 wxWindowID id
= wxID_ANY
,
320 const wxPoint
& pos
= wxDefaultPosition
,
321 const wxSize
& size
= wxDefaultSize
,
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
);
335 void OnButton(wxAuiNotebookEvent
& evt
);
341 wxWindow
* m_click_tab
;
343 wxAuiTabContainerButton
* m_hover_button
;
346 DECLARE_EVENT_TABLE()
353 class WXDLLIMPEXP_AUI wxAuiNotebook
: public wxControl
360 wxAuiNotebook(wxWindow
* parent
,
361 wxWindowID id
= wxID_ANY
,
362 const wxPoint
& pos
= wxDefaultPosition
,
363 const wxSize
& size
= wxDefaultSize
,
364 long style
= wxAUI_NB_DEFAULT_STYLE
);
366 virtual ~wxAuiNotebook();
368 bool Create(wxWindow
* parent
,
369 wxWindowID id
= wxID_ANY
,
370 const wxPoint
& pos
= wxDefaultPosition
,
371 const wxSize
& size
= wxDefaultSize
,
374 bool AddPage(wxWindow
* page
,
375 const wxString
& caption
,
377 const wxBitmap
& bitmap
= wxNullBitmap
);
379 bool InsertPage(size_t page_idx
,
381 const wxString
& caption
,
383 const wxBitmap
& bitmap
= wxNullBitmap
);
385 bool DeletePage(size_t page
);
386 bool RemovePage(size_t page
);
388 void SetWindowStyleFlag(long style
);
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;
397 void SetArtProvider(wxAuiTabArt
* art
);
398 wxAuiTabArt
* GetArtProvider();
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();
411 void InitNotebook(long style
);
413 void OnChildFocus(wxChildFocusEvent
& evt
);
414 void OnRender(wxAuiManagerEvent
& evt
);
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
);
426 wxAuiTabContainer m_tabs
;
428 int m_tab_id_counter
;
429 wxWindow
* m_dummy_wnd
;
431 wxFont m_selected_font
;
432 wxFont m_normal_font
;
433 int m_tab_ctrl_height
;
436 unsigned int m_flags
;
439 DECLARE_CLASS(wxAuiNotebook
)
440 DECLARE_EVENT_TABLE()
447 // wx event machinery
451 BEGIN_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)
458 END_DECLARE_EVENT_TYPES()
460 typedef void (wxEvtHandler::*wxAuiNotebookEventFunction
)(wxAuiNotebookEvent
&);
462 #define wxAuiNotebookEventHandler(func) \
463 (wxObjectEventFunction)(wxEventFunction)wxStaticCastEvent(wxAuiNotebookEventFunction, &func)
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))
469 #define EVT_AUINOTEBOOK_BUTTON(winid, fn) \
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))
480 // wxpython/swig event work
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
;
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 )
494 EVT_AUINOTEBOOK_DRAG_MOTION
= wx
.PyEventBinder( wxEVT_COMMAND_AUINOTEBOOK_DRAG_MOTION
, 1 )
500 #endif // _WX_AUINOTEBOOK_H_