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_CLOSE_BUTTON
= 1 << 7,
41 wxAUI_NB_PAGELIST_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(
71 const wxRect
& rect
) = 0;
73 virtual void DrawTab(wxDC
* dc
,
74 const wxRect
& in_rect
,
75 const wxString
& caption
,
77 int close_button_state
,
79 wxRect
* out_button_rect
,
82 virtual void DrawButton(
84 const wxRect
& in_rect
,
88 const wxBitmap
& bitmap_override
,
89 wxRect
* out_rect
) = 0;
91 virtual wxSize
GetTabSize(
93 const wxString
& caption
,
95 int close_button_state
,
98 virtual int GetBestTabCtrlSize(wxWindow
* wnd
) = 0;
102 class WXDLLIMPEXP_AUI wxAuiDefaultTabArt
: public wxAuiTabArt
107 wxAuiDefaultTabArt();
108 virtual ~wxAuiDefaultTabArt();
110 void SetNormalFont(const wxFont
& font
);
111 void SetSelectedFont(const wxFont
& font
);
112 void SetMeasuringFont(const wxFont
& font
);
118 void DrawTab(wxDC
* dc
,
119 const wxRect
& in_rect
,
120 const wxString
& caption
,
122 int close_button_state
,
123 wxRect
* out_tab_rect
,
124 wxRect
* out_button_rect
,
129 const wxRect
& in_rect
,
133 const wxBitmap
& bitmap_override
,
138 const wxString
& caption
,
140 int close_button_state
,
143 int GetBestTabCtrlSize(wxWindow
* wnd
);
147 wxFont m_normal_font
;
148 wxFont m_selected_font
;
149 wxFont m_measuring_font
;
150 wxPen m_normal_bkpen
;
151 wxPen m_selected_bkpen
;
152 wxBrush m_normal_bkbrush
;
153 wxBrush m_selected_bkbrush
;
155 wxBitmap m_active_close_bmp
;
156 wxBitmap m_disabled_close_bmp
;
157 wxBitmap m_active_left_bmp
;
158 wxBitmap m_disabled_left_bmp
;
159 wxBitmap m_active_right_bmp
;
160 wxBitmap m_disabled_right_bmp
;
165 // event declarations/classes
167 class WXDLLIMPEXP_AUI wxAuiNotebookEvent
: public wxNotifyEvent
170 wxAuiNotebookEvent(wxEventType command_type
= wxEVT_NULL
,
172 : wxNotifyEvent(command_type
, win_id
)
176 wxAuiNotebookEvent(const wxAuiNotebookEvent
& c
) : wxNotifyEvent(c
)
178 old_selection
= c
.old_selection
;
179 selection
= c
.selection
;
182 wxEvent
*Clone() const { return new wxAuiNotebookEvent(*this); }
184 void SetSelection(int s
) { selection
= s
; m_commandInt
= s
; }
185 void SetOldSelection(int s
) { old_selection
= s
; }
186 int GetSelection() const { return selection
; }
187 int GetOldSelection() const { return old_selection
; }
195 DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxAuiNotebookEvent
)
203 class WXDLLIMPEXP_AUI wxAuiNotebookPage
206 wxWindow
* window
; // page's associated window
207 wxString caption
; // caption displayed on the tab
208 wxBitmap bitmap
; // tab's bitmap
209 wxRect rect
; // tab's hit rectangle
210 bool active
; // true if the page is currently active
213 class WXDLLIMPEXP_AUI wxAuiTabContainerButton
217 int id
; // button's id
218 int cur_state
; // current state (normal, hover, pressed, etc.)
219 int location
; // buttons location (wxLEFT, wxRIGHT, or wxCENTER)
220 wxBitmap bitmap
; // button's hover bitmap
221 wxBitmap dis_bitmap
; // button's disabled bitmap
222 wxRect rect
; // button's hit rectangle
227 WX_DECLARE_USER_EXPORTED_OBJARRAY(wxAuiNotebookPage
, wxAuiNotebookPageArray
, WXDLLIMPEXP_AUI
);
228 WX_DECLARE_USER_EXPORTED_OBJARRAY(wxAuiTabContainerButton
, wxAuiTabContainerButtonArray
, WXDLLIMPEXP_AUI
);
232 class WXDLLIMPEXP_AUI wxAuiTabContainer
237 virtual ~wxAuiTabContainer();
239 void SetArtProvider(wxAuiTabArt
* art
);
240 wxAuiTabArt
* GetArtProvider();
242 void SetFlags(unsigned int flags
);
243 unsigned int GetFlags() const;
245 bool AddPage(wxWindow
* page
, const wxAuiNotebookPage
& info
);
246 bool InsertPage(wxWindow
* page
, const wxAuiNotebookPage
& info
, size_t idx
);
247 bool MovePage(wxWindow
* page
, size_t new_idx
);
248 bool RemovePage(wxWindow
* page
);
249 bool SetActivePage(wxWindow
* page
);
250 bool SetActivePage(size_t page
);
251 void SetNoneActive();
252 int GetActivePage() const;
253 bool TabHitTest(int x
, int y
, wxWindow
** hit
) const;
254 bool ButtonHitTest(int x
, int y
, wxAuiTabContainerButton
** hit
) const;
255 wxWindow
* GetWindowFromIdx(size_t idx
) const;
256 int GetIdxFromWindow(wxWindow
* page
) const;
257 size_t GetPageCount() const;
258 wxAuiNotebookPage
& GetPage(size_t idx
);
259 wxAuiNotebookPageArray
& GetPages();
260 void SetNormalFont(const wxFont
& normal_font
);
261 void SetSelectedFont(const wxFont
& selected_font
);
262 void SetMeasuringFont(const wxFont
& measuring_font
);
264 void SetRect(const wxRect
& rect
);
266 void RemoveButton(int id
);
267 void AddButton(int id
,
269 const wxBitmap
& normal_bitmap
= wxNullBitmap
,
270 const wxBitmap
& disabled_bitmap
= wxNullBitmap
);
272 size_t GetTabOffset() const;
273 void SetTabOffset(size_t offset
);
277 virtual void Render(wxDC
* dc
);
282 wxAuiNotebookPageArray m_pages
;
283 wxAuiTabContainerButtonArray m_buttons
;
284 wxAuiTabContainerButtonArray m_tab_close_buttons
;
287 unsigned int m_flags
;
292 class WXDLLIMPEXP_AUI wxAuiTabCtrl
: public wxControl
,
293 public wxAuiTabContainer
297 wxAuiTabCtrl(wxWindow
* parent
,
298 wxWindowID id
= wxID_ANY
,
299 const wxPoint
& pos
= wxDefaultPosition
,
300 const wxSize
& size
= wxDefaultSize
,
307 void OnPaint(wxPaintEvent
& evt
);
308 void OnEraseBackground(wxEraseEvent
& evt
);
309 void OnSize(wxSizeEvent
& evt
);
310 void OnLeftDown(wxMouseEvent
& evt
);
311 void OnLeftUp(wxMouseEvent
& evt
);
312 void OnMotion(wxMouseEvent
& evt
);
313 void OnLeaveWindow(wxMouseEvent
& evt
);
314 void OnButton(wxAuiNotebookEvent
& evt
);
320 wxWindow
* m_click_tab
;
322 wxAuiTabContainerButton
* m_hover_button
;
325 DECLARE_EVENT_TABLE()
332 class WXDLLIMPEXP_AUI wxAuiNotebook
: public wxControl
339 wxAuiNotebook(wxWindow
* parent
,
340 wxWindowID id
= wxID_ANY
,
341 const wxPoint
& pos
= wxDefaultPosition
,
342 const wxSize
& size
= wxDefaultSize
,
343 long style
= wxAUI_NB_DEFAULT_STYLE
);
345 virtual ~wxAuiNotebook();
347 bool Create(wxWindow
* parent
,
348 wxWindowID id
= wxID_ANY
,
349 const wxPoint
& pos
= wxDefaultPosition
,
350 const wxSize
& size
= wxDefaultSize
,
353 bool AddPage(wxWindow
* page
,
354 const wxString
& caption
,
356 const wxBitmap
& bitmap
= wxNullBitmap
);
358 bool InsertPage(size_t page_idx
,
360 const wxString
& caption
,
362 const wxBitmap
& bitmap
= wxNullBitmap
);
364 bool DeletePage(size_t page
);
365 bool RemovePage(size_t page
);
367 bool SetPageText(size_t page
, const wxString
& text
);
368 size_t SetSelection(size_t new_page
);
369 int GetSelection() const;
370 size_t GetPageCount() const;
371 wxWindow
* GetPage(size_t page_idx
) const;
373 void SetArtProvider(wxAuiTabArt
* art
);
374 wxAuiTabArt
* GetArtProvider();
378 wxAuiTabCtrl
* GetTabCtrlFromPoint(const wxPoint
& pt
);
379 wxWindow
* GetTabFrameFromTabCtrl(wxWindow
* tab_ctrl
);
380 wxAuiTabCtrl
* GetActiveTabCtrl();
381 bool FindTab(wxWindow
* page
, wxAuiTabCtrl
** ctrl
, int* idx
);
382 void RemoveEmptyTabFrames();
387 void InitNotebook(long style
);
389 void OnChildFocus(wxChildFocusEvent
& evt
);
390 void OnRender(wxAuiManagerEvent
& evt
);
391 void OnEraseBackground(wxEraseEvent
& evt
);
392 void OnSize(wxSizeEvent
& evt
);
393 void OnTabClicked(wxCommandEvent
& evt
);
394 void OnTabBeginDrag(wxCommandEvent
& evt
);
395 void OnTabDragMotion(wxCommandEvent
& evt
);
396 void OnTabEndDrag(wxCommandEvent
& evt
);
397 void OnTabButton(wxCommandEvent
& evt
);
402 wxAuiTabContainer m_tabs
;
404 int m_tab_id_counter
;
405 wxWindow
* m_dummy_wnd
;
407 wxFont m_selected_font
;
408 wxFont m_normal_font
;
409 int m_tab_ctrl_height
;
412 unsigned int m_flags
;
415 DECLARE_EVENT_TABLE()
422 // wx event machinery
426 BEGIN_DECLARE_EVENT_TYPES()
427 DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_AUI
, wxEVT_COMMAND_AUINOTEBOOK_PAGE_CHANGED
, 0)
428 DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_AUI
, wxEVT_COMMAND_AUINOTEBOOK_PAGE_CHANGING
, 0)
429 DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_AUI
, wxEVT_COMMAND_AUINOTEBOOK_BUTTON
, 0)
430 DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_AUI
, wxEVT_COMMAND_AUINOTEBOOK_BEGIN_DRAG
, 0)
431 DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_AUI
, wxEVT_COMMAND_AUINOTEBOOK_END_DRAG
, 0)
432 DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_AUI
, wxEVT_COMMAND_AUINOTEBOOK_DRAG_MOTION
, 0)
433 END_DECLARE_EVENT_TYPES()
435 typedef void (wxEvtHandler
::*wxAuiNotebookEventFunction
)(wxAuiNotebookEvent
&);
437 #define wxAuiNotebookEventHandler(func) \
438 (wxObjectEventFunction)(wxEventFunction)wxStaticCastEvent(wxAuiNotebookEventFunction, &func)
440 #define EVT_AUINOTEBOOK_PAGE_CHANGED(winid, fn) \
441 wx__DECLARE_EVT1(wxEVT_COMMAND_AUINOTEBOOK_PAGE_CHANGED, winid, wxAuiNotebookEventHandler(fn))
442 #define EVT_AUINOTEBOOK_PAGE_CHANGING(winid, fn) \
443 wx__DECLARE_EVT1(wxEVT_COMMAND_AUINOTEBOOK_PAGE_CHANGING, winid, wxAuiNotebookEventHandler(fn))
444 #define EVT_AUINOTEBOOK_BUTTON(winid, fn) \
445 wx__DECLARE_EVT1(wxEVT_COMMAND_AUINOTEBOOK_BUTTON, winid, wxAuiNotebookEventHandler(fn))
446 #define EVT_AUINOTEBOOK_BEGIN_DRAG(winid, fn) \
447 wx__DECLARE_EVT1(wxEVT_COMMAND_AUINOTEBOOK_BEGIN_DRAG, winid, wxAuiNotebookEventHandler(fn))
448 #define EVT_AUINOTEBOOK_END_DRAG(winid, fn) \
449 wx__DECLARE_EVT1(wxEVT_COMMAND_AUINOTEBOOK_END_DRAG, winid, wxAuiNotebookEventHandler(fn))
450 #define EVT_AUINOTEBOOK_DRAG_MOTION(winid, fn) \
451 wx__DECLARE_EVT1(wxEVT_COMMAND_AUINOTEBOOK_DRAG_MOTION, winid, wxAuiNotebookEventHandler(fn))
455 // wxpython/swig event work
456 %constant wxEventType wxEVT_COMMAND_AUINOTEBOOK_PAGE_CHANGED
;
457 %constant wxEventType wxEVT_COMMAND_AUINOTEBOOK_PAGE_CHANGING
;
458 %constant wxEventType wxEVT_COMMAND_AUINOTEBOOK_BUTTON
;
459 %constant wxEventType wxEVT_COMMAND_AUINOTEBOOK_BEGIN_DRAG
;
460 %constant wxEventType wxEVT_COMMAND_AUINOTEBOOK_END_DRAG
;
461 %constant wxEventType wxEVT_COMMAND_AUINOTEBOOK_DRAG_MOTION
;
464 EVT_AUINOTEBOOK_PAGE_CHANGED
= wx
.PyEventBinder( wxEVT_COMMAND_AUINOTEBOOK_PAGE_CHANGED
, 1 )
465 EVT_AUINOTEBOOK_PAGE_CHANGING
= wx
.PyEventBinder( wxEVT_COMMAND_AUINOTEBOOK_PAGE_CHANGING
, 1 )
466 EVT_AUINOTEBOOK_BUTTON
= wx
.PyEventBinder( wxEVT_COMMAND_AUINOTEBOOK_BUTTON
, 1 )
467 EVT_AUINOTEBOOK_BEGIN_DRAG
= wx
.PyEventBinder( wxEVT_COMMAND_AUINOTEBOOK_BEGIN_DRAG
, 1 )
468 EVT_AUINOTEBOOK_END_DRAG
= wx
.PyEventBinder( wxEVT_COMMAND_AUINOTEBOOK_END_DRAG
, 1 )
469 EVT_AUINOTEBOOK_DRAG_MOTION
= wx
.PyEventBinder( wxEVT_COMMAND_AUINOTEBOOK_DRAG_MOTION
, 1 )
475 #endif // _WX_AUINOTEBOOK_H_