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_ALL_TABS
58 class WXDLLIMPEXP_AUI wxTabArt
63 virtual ~wxTabArt() { }
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 bool with_close_button
,
81 virtual void DrawButton(
83 const wxRect
& in_rect
,
87 const wxBitmap
& bitmap_override
,
88 wxRect
* out_rect
) = 0;
90 virtual wxSize
GetTabSize(
92 const wxString
& caption
,
94 bool with_close_button
,
97 virtual int GetBestTabCtrlSize(wxWindow
* wnd
) = 0;
101 class WXDLLIMPEXP_AUI wxDefaultTabArt
: public wxTabArt
107 virtual ~wxDefaultTabArt();
109 void SetNormalFont(const wxFont
& font
);
110 void SetSelectedFont(const wxFont
& font
);
111 void SetMeasuringFont(const wxFont
& font
);
117 void DrawTab(wxDC
* dc
,
118 const wxRect
& in_rect
,
119 const wxString
& caption
,
121 bool with_close_button
,
127 const wxRect
& in_rect
,
131 const wxBitmap
& bitmap_override
,
136 const wxString
& caption
,
138 bool with_close_button
,
141 int GetBestTabCtrlSize(wxWindow
* wnd
);
145 wxFont m_normal_font
;
146 wxFont m_selected_font
;
147 wxFont m_measuring_font
;
148 wxPen m_normal_bkpen
;
149 wxPen m_selected_bkpen
;
150 wxBrush m_normal_bkbrush
;
151 wxBrush m_selected_bkbrush
;
153 wxBitmap m_active_close_bmp
;
154 wxBitmap m_disabled_close_bmp
;
155 wxBitmap m_active_left_bmp
;
156 wxBitmap m_disabled_left_bmp
;
157 wxBitmap m_active_right_bmp
;
158 wxBitmap m_disabled_right_bmp
;
163 // event declarations/classes
165 class WXDLLIMPEXP_AUI wxAuiNotebookEvent
: public wxNotifyEvent
168 wxAuiNotebookEvent(wxEventType command_type
= wxEVT_NULL
,
170 : wxNotifyEvent(command_type
, win_id
)
174 wxAuiNotebookEvent(const wxAuiNotebookEvent
& c
) : wxNotifyEvent(c
)
176 old_selection
= c
.old_selection
;
177 selection
= c
.selection
;
180 wxEvent
*Clone() const { return new wxAuiNotebookEvent(*this); }
182 void SetSelection(int s
) { selection
= s
; m_commandInt
= s
; }
183 void SetOldSelection(int s
) { old_selection
= s
; }
184 int GetSelection() const { return selection
; }
185 int GetOldSelection() const { return old_selection
; }
193 DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxAuiNotebookEvent
)
201 class WXDLLIMPEXP_AUI wxAuiNotebookPage
204 wxWindow
* window
; // page's associated window
205 wxString caption
; // caption displayed on the tab
206 wxBitmap bitmap
; // tab's bitmap
207 wxRect rect
; // tab's hit rectangle
208 bool active
; // true if the page is currently active
211 class WXDLLIMPEXP_AUI wxAuiTabContainerButton
214 int id
; // button's id
215 int cur_state
; // current state (normal, hover, pressed, etc.)
216 int location
; // buttons location (wxLEFT or wxRIGHT)
217 wxBitmap bitmap
; // button's hover bitmap
218 wxBitmap dis_bitmap
; // button's disabled bitmap
219 wxRect rect
; // button's hit rectangle
224 WX_DECLARE_USER_EXPORTED_OBJARRAY(wxAuiNotebookPage
, wxAuiNotebookPageArray
, WXDLLIMPEXP_AUI
);
225 WX_DECLARE_USER_EXPORTED_OBJARRAY(wxAuiTabContainerButton
, wxAuiTabContainerButtonArray
, WXDLLIMPEXP_AUI
);
229 class WXDLLIMPEXP_AUI wxAuiTabContainer
234 virtual ~wxAuiTabContainer();
236 void SetArtProvider(wxTabArt
* art
);
237 wxTabArt
* GetArtProvider();
239 void SetFlags(unsigned int flags
);
240 unsigned int GetFlags() const;
242 bool AddPage(wxWindow
* page
, const wxAuiNotebookPage
& info
);
243 bool InsertPage(wxWindow
* page
, const wxAuiNotebookPage
& info
, size_t idx
);
244 bool MovePage(wxWindow
* page
, size_t new_idx
);
245 bool RemovePage(wxWindow
* page
);
246 bool SetActivePage(wxWindow
* page
);
247 bool SetActivePage(size_t page
);
248 void SetNoneActive();
249 int GetActivePage() const;
250 bool TabHitTest(int x
, int y
, wxWindow
** hit
) const;
251 bool ButtonHitTest(int x
, int y
, wxAuiTabContainerButton
** hit
) const;
252 wxWindow
* GetWindowFromIdx(size_t idx
) const;
253 int GetIdxFromWindow(wxWindow
* page
) const;
254 size_t GetPageCount() const;
255 wxAuiNotebookPage
& GetPage(size_t idx
);
256 wxAuiNotebookPageArray
& GetPages();
257 void SetNormalFont(const wxFont
& normal_font
);
258 void SetSelectedFont(const wxFont
& selected_font
);
259 void SetMeasuringFont(const wxFont
& measuring_font
);
261 void SetRect(const wxRect
& rect
);
262 void AddButton(int id
,
264 const wxBitmap
& normal_bitmap
= wxNullBitmap
,
265 const wxBitmap
& disabled_bitmap
= wxNullBitmap
);
267 size_t GetTabOffset() const;
268 void SetTabOffset(size_t offset
);
272 virtual void Render(wxDC
* dc
);
277 wxAuiNotebookPageArray m_pages
;
278 wxAuiTabContainerButtonArray m_buttons
;
281 unsigned int m_flags
;
286 class WXDLLIMPEXP_AUI wxAuiTabCtrl
: public wxControl
,
287 public wxAuiTabContainer
291 wxAuiTabCtrl(wxWindow
* parent
,
292 wxWindowID id
= wxID_ANY
,
293 const wxPoint
& pos
= wxDefaultPosition
,
294 const wxSize
& size
= wxDefaultSize
,
301 void OnPaint(wxPaintEvent
& evt
);
302 void OnEraseBackground(wxEraseEvent
& evt
);
303 void OnSize(wxSizeEvent
& evt
);
304 void OnLeftDown(wxMouseEvent
& evt
);
305 void OnLeftUp(wxMouseEvent
& evt
);
306 void OnMotion(wxMouseEvent
& evt
);
307 void OnLeaveWindow(wxMouseEvent
& evt
);
308 void OnButton(wxAuiNotebookEvent
& evt
);
314 wxWindow
* m_click_tab
;
316 wxAuiTabContainerButton
* m_hover_button
;
319 DECLARE_EVENT_TABLE()
326 class WXDLLIMPEXP_AUI wxAuiMultiNotebook
: public wxControl
331 wxAuiMultiNotebook();
333 wxAuiMultiNotebook(wxWindow
* parent
,
334 wxWindowID id
= wxID_ANY
,
335 const wxPoint
& pos
= wxDefaultPosition
,
336 const wxSize
& size
= wxDefaultSize
,
337 long style
= wxAUI_NB_DEFAULT_STYLE
);
339 virtual ~wxAuiMultiNotebook();
341 bool Create(wxWindow
* parent
,
342 wxWindowID id
= wxID_ANY
,
343 const wxPoint
& pos
= wxDefaultPosition
,
344 const wxSize
& size
= wxDefaultSize
,
347 bool AddPage(wxWindow
* page
,
348 const wxString
& caption
,
350 const wxBitmap
& bitmap
= wxNullBitmap
);
352 bool InsertPage(size_t page_idx
,
354 const wxString
& caption
,
356 const wxBitmap
& bitmap
= wxNullBitmap
);
358 bool DeletePage(size_t page
);
359 bool RemovePage(size_t page
);
361 bool SetPageText(size_t page
, const wxString
& text
);
362 size_t SetSelection(size_t new_page
);
363 int GetSelection() const;
364 size_t GetPageCount() const;
365 wxWindow
* GetPage(size_t page_idx
) const;
367 void SetArtProvider(wxTabArt
* art
);
368 wxTabArt
* GetArtProvider();
372 wxAuiTabCtrl
* GetTabCtrlFromPoint(const wxPoint
& pt
);
373 wxWindow
* GetTabFrameFromTabCtrl(wxWindow
* tab_ctrl
);
374 wxAuiTabCtrl
* GetActiveTabCtrl();
375 bool FindTab(wxWindow
* page
, wxAuiTabCtrl
** ctrl
, int* idx
);
376 void RemoveEmptyTabFrames();
381 void InitNotebook(long style
);
383 void OnChildFocus(wxChildFocusEvent
& evt
);
384 void OnRender(wxFrameManagerEvent
& evt
);
385 void OnEraseBackground(wxEraseEvent
& evt
);
386 void OnSize(wxSizeEvent
& evt
);
387 void OnTabClicked(wxCommandEvent
& evt
);
388 void OnTabBeginDrag(wxCommandEvent
& evt
);
389 void OnTabDragMotion(wxCommandEvent
& evt
);
390 void OnTabEndDrag(wxCommandEvent
& evt
);
391 void OnTabButton(wxCommandEvent
& evt
);
395 wxFrameManager m_mgr
;
396 wxAuiTabContainer m_tabs
;
398 int m_tab_id_counter
;
399 wxWindow
* m_dummy_wnd
;
401 wxFont m_selected_font
;
402 wxFont m_normal_font
;
403 int m_tab_ctrl_height
;
406 unsigned int m_flags
;
409 DECLARE_EVENT_TABLE()
416 // wx event machinery
420 BEGIN_DECLARE_EVENT_TYPES()
421 DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_AUI
, wxEVT_COMMAND_AUINOTEBOOK_PAGE_CHANGED
, 0)
422 DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_AUI
, wxEVT_COMMAND_AUINOTEBOOK_PAGE_CHANGING
, 0)
423 DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_AUI
, wxEVT_COMMAND_AUINOTEBOOK_BUTTON
, 0)
424 DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_AUI
, wxEVT_COMMAND_AUINOTEBOOK_BEGIN_DRAG
, 0)
425 DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_AUI
, wxEVT_COMMAND_AUINOTEBOOK_END_DRAG
, 0)
426 DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_AUI
, wxEVT_COMMAND_AUINOTEBOOK_DRAG_MOTION
, 0)
427 END_DECLARE_EVENT_TYPES()
429 typedef void (wxEvtHandler::*wxAuiNotebookEventFunction
)(wxAuiNotebookEvent
&);
431 #define wxAuiNotebookEventHandler(func) \
432 (wxObjectEventFunction)(wxEventFunction)wxStaticCastEvent(wxAuiNotebookEventFunction, &func)
434 #define EVT_AUINOTEBOOK_PAGE_CHANGED(winid, fn) \
435 wx__DECLARE_EVT1(wxEVT_COMMAND_AUINOTEBOOK_PAGE_CHANGED, winid, wxAuiNotebookEventHandler(fn))
436 #define EVT_AUINOTEBOOK_PAGE_CHANGING(winid, fn) \
437 wx__DECLARE_EVT1(wxEVT_COMMAND_AUINOTEBOOK_PAGE_CHANGING, winid, wxAuiNotebookEventHandler(fn))
438 #define EVT_AUINOTEBOOK_BUTTON(winid, fn) \
439 wx__DECLARE_EVT1(wxEVT_COMMAND_AUINOTEBOOK_BUTTON, winid, wxAuiNotebookEventHandler(fn))
440 #define EVT_AUINOTEBOOK_BEGIN_DRAG(winid, fn) \
441 wx__DECLARE_EVT1(wxEVT_COMMAND_AUINOTEBOOK_BEGIN_DRAG, winid, wxAuiNotebookEventHandler(fn))
442 #define EVT_AUINOTEBOOK_END_DRAG(winid, fn) \
443 wx__DECLARE_EVT1(wxEVT_COMMAND_AUINOTEBOOK_END_DRAG, winid, wxAuiNotebookEventHandler(fn))
444 #define EVT_AUINOTEBOOK_DRAG_MOTION(winid, fn) \
445 wx__DECLARE_EVT1(wxEVT_COMMAND_AUINOTEBOOK_DRAG_MOTION, winid, wxAuiNotebookEventHandler(fn))
449 // wxpython/swig event work
450 %constant wxEventType wxEVT_COMMAND_AUINOTEBOOK_PAGE_CHANGED
;
451 %constant wxEventType wxEVT_COMMAND_AUINOTEBOOK_PAGE_CHANGING
;
452 %constant wxEventType wxEVT_COMMAND_AUINOTEBOOK_BUTTON
;
453 %constant wxEventType wxEVT_COMMAND_AUINOTEBOOK_BEGIN_DRAG
;
454 %constant wxEventType wxEVT_COMMAND_AUINOTEBOOK_END_DRAG
;
455 %constant wxEventType wxEVT_COMMAND_AUINOTEBOOK_DRAG_MOTION
;
458 EVT_AUINOTEBOOK_PAGE_CHANGED
= wx
.PyEventBinder( wxEVT_COMMAND_AUINOTEBOOK_PAGE_CHANGED
, 1 )
459 EVT_AUINOTEBOOK_PAGE_CHANGING
= wx
.PyEventBinder( wxEVT_COMMAND_AUINOTEBOOK_PAGE_CHANGING
, 1 )
460 EVT_AUINOTEBOOK_BUTTON
= wx
.PyEventBinder( wxEVT_COMMAND_AUINOTEBOOK_BUTTON
, 1 )
461 EVT_AUINOTEBOOK_BEGIN_DRAG
= wx
.PyEventBinder( wxEVT_COMMAND_AUINOTEBOOK_BEGIN_DRAG
, 1 )
462 EVT_AUINOTEBOOK_END_DRAG
= wx
.PyEventBinder( wxEVT_COMMAND_AUINOTEBOOK_END_DRAG
, 1 )
463 EVT_AUINOTEBOOK_DRAG_MOTION
= wx
.PyEventBinder( wxEVT_COMMAND_AUINOTEBOOK_DRAG_MOTION
, 1 )
469 #endif // _WX_AUINOTEBOOK_H_