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"
30 // event declarations/classes
32 class WXDLLIMPEXP_AUI wxAuiNotebookEvent
: public wxNotifyEvent
35 wxAuiNotebookEvent(wxEventType command_type
= wxEVT_NULL
,
37 : wxNotifyEvent(command_type
, win_id
)
41 wxAuiNotebookEvent(const wxAuiNotebookEvent
& c
) : wxNotifyEvent(c
)
43 old_selection
= c
.old_selection
;
44 selection
= c
.selection
;
47 wxEvent
*Clone() const { return new wxAuiNotebookEvent(*this); }
49 void SetSelection(int s
) { selection
= s
; }
50 void SetOldSelection(int s
) { old_selection
= s
; }
51 int GetSelection() const { return selection
; }
52 int GetOldSelection() const { return old_selection
; }
60 DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxAuiNotebookEvent
)
68 class WXDLLIMPEXP_AUI wxAuiNotebookPage
71 wxWindow
* window
; // page's associated window
72 wxString caption
; // caption displayed on the tab
73 wxBitmap bitmap
; // tab's bitmap
74 wxRect rect
; // tab's hit rectangle
75 bool active
; // true if the page is currently active
78 class WXDLLIMPEXP_AUI wxAuiTabContainerButton
81 int id
; // button's id
82 int cur_state
; // current state (normal, hover, pressed)
83 wxBitmap bitmap
; // button's bitmap
84 wxRect rect
; // button's hit rectangle
89 WX_DECLARE_USER_EXPORTED_OBJARRAY(wxAuiNotebookPage
, wxAuiNotebookPageArray
, WXDLLIMPEXP_AUI
);
90 WX_DECLARE_USER_EXPORTED_OBJARRAY(wxAuiTabContainerButton
, wxAuiTabContainerButtonArray
, WXDLLIMPEXP_AUI
);
94 class WXDLLIMPEXP_AUI wxAuiTabContainer
99 virtual ~wxAuiTabContainer();
101 bool AddPage(wxWindow
* page
, const wxAuiNotebookPage
& info
);
102 bool InsertPage(wxWindow
* page
, const wxAuiNotebookPage
& info
, size_t idx
);
103 bool RemovePage(wxWindow
* page
);
104 bool SetActivePage(wxWindow
* page
);
105 bool SetActivePage(size_t page
);
106 void SetNoneActive();
107 int GetActivePage() const;
108 bool TabHitTest(int x
, int y
, wxWindow
** hit
) const;
109 bool ButtonHitTest(int x
, int y
, wxAuiTabContainerButton
** hit
) const;
110 wxWindow
* GetWindowFromIdx(size_t idx
) const;
111 int GetIdxFromWindow(wxWindow
* page
) const;
112 size_t GetPageCount() const;
113 wxAuiNotebookPage
& GetPage(size_t idx
);
114 wxAuiNotebookPageArray
& GetPages();
115 void SetNormalFont(const wxFont
& normal_font
);
116 void SetSelectedFont(const wxFont
& selected_font
);
117 void SetMeasuringFont(const wxFont
& measuring_font
);
119 void SetRect(const wxRect
& rect
);
120 void AddButton(int id
, const wxBitmap
& bmp
);
124 virtual void Render(wxDC
* dc
);
126 virtual void DrawTab(wxDC
* dc
,
127 const wxRect
& in_rect
,
128 const wxString
& caption
,
134 wxAuiNotebookPageArray m_pages
;
135 wxAuiTabContainerButtonArray m_buttons
;
137 wxFont m_normal_font
;
138 wxFont m_selected_font
;
139 wxFont m_measuring_font
;
140 wxPen m_normal_bkpen
;
141 wxPen m_selected_bkpen
;
142 wxBrush m_normal_bkbrush
;
143 wxBrush m_selected_bkbrush
;
149 class WXDLLIMPEXP_AUI wxAuiTabCtrl
: public wxControl
,
150 public wxAuiTabContainer
154 wxAuiTabCtrl(wxWindow
* parent
,
155 wxWindowID id
= wxID_ANY
,
156 const wxPoint
& pos
= wxDefaultPosition
,
157 const wxSize
& size
= wxDefaultSize
,
162 void OnPaint(wxPaintEvent
& evt
);
163 void OnEraseBackground(wxEraseEvent
& evt
);
164 void OnSize(wxSizeEvent
& evt
);
165 void OnLeftDown(wxMouseEvent
& evt
);
166 void OnLeftUp(wxMouseEvent
& evt
);
167 void OnMotion(wxMouseEvent
& evt
);
168 void OnLeaveWindow(wxMouseEvent
& evt
);
175 wxAuiTabContainerButton
* m_hover_button
;
178 DECLARE_EVENT_TABLE()
185 class WXDLLIMPEXP_AUI wxAuiMultiNotebook
: public wxControl
190 wxAuiMultiNotebook();
192 wxAuiMultiNotebook(wxWindow
* parent
,
193 wxWindowID id
= wxID_ANY
,
194 const wxPoint
& pos
= wxDefaultPosition
,
195 const wxSize
& size
= wxDefaultSize
,
198 virtual ~wxAuiMultiNotebook();
200 bool Create(wxWindow
* parent
,
201 wxWindowID id
= wxID_ANY
,
202 const wxPoint
& pos
= wxDefaultPosition
,
203 const wxSize
& size
= wxDefaultSize
,
206 bool AddPage(wxWindow
* page
,
207 const wxString
& caption
,
209 const wxBitmap
& bitmap
= wxNullBitmap
);
211 bool InsertPage(size_t page_idx
,
213 const wxString
& caption
,
215 const wxBitmap
& bitmap
= wxNullBitmap
);
217 bool DeletePage(size_t page
);
218 bool RemovePage(size_t page
);
220 bool SetPageText(size_t page
, const wxString
& text
);
221 size_t SetSelection(size_t new_page
);
222 int GetSelection() const;
223 size_t GetPageCount() const;
224 wxWindow
* GetPage(size_t page_idx
) const;
228 wxAuiTabCtrl
* GetTabCtrlFromPoint(const wxPoint
& pt
);
229 wxWindow
* GetTabFrameFromTabCtrl(wxWindow
* tab_ctrl
);
230 wxAuiTabCtrl
* GetActiveTabCtrl();
231 bool FindTab(wxWindow
* page
, wxAuiTabCtrl
** ctrl
, int* idx
);
232 void RemoveEmptyTabFrames();
239 void OnChildFocus(wxChildFocusEvent
& evt
);
240 void OnRender(wxFrameManagerEvent
& evt
);
241 void OnEraseBackground(wxEraseEvent
& evt
);
242 void OnSize(wxSizeEvent
& evt
);
243 void OnTabClicked(wxCommandEvent
& evt
);
244 void OnTabBeginDrag(wxCommandEvent
& evt
);
245 void OnTabDragMotion(wxCommandEvent
& evt
);
246 void OnTabEndDrag(wxCommandEvent
& evt
);
247 void OnTabButton(wxCommandEvent
& evt
);
251 wxFrameManager m_mgr
;
252 wxAuiTabContainer m_tabs
;
254 int m_tab_id_counter
;
255 wxWindow
* m_dummy_wnd
;
257 wxFont m_selected_font
;
258 wxFont m_normal_font
;
259 int m_tab_ctrl_height
;
262 DECLARE_EVENT_TABLE()
269 // wx event machinery
273 BEGIN_DECLARE_EVENT_TYPES()
274 DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_AUI
, wxEVT_COMMAND_AUINOTEBOOK_PAGE_CHANGED
, 0)
275 DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_AUI
, wxEVT_COMMAND_AUINOTEBOOK_PAGE_CHANGING
, 0)
276 DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_AUI
, wxEVT_COMMAND_AUINOTEBOOK_BUTTON
, 0)
277 DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_AUI
, wxEVT_COMMAND_AUINOTEBOOK_BEGIN_DRAG
, 0)
278 DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_AUI
, wxEVT_COMMAND_AUINOTEBOOK_END_DRAG
, 0)
279 DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_AUI
, wxEVT_COMMAND_AUINOTEBOOK_DRAG_MOTION
, 0)
280 END_DECLARE_EVENT_TYPES()
282 typedef void (wxEvtHandler::*wxAuiNotebookEventFunction
)(wxAuiNotebookEvent
&);
284 #define wxAuiNotebookEventHandler(func) \
285 (wxObjectEventFunction)(wxEventFunction)wxStaticCastEvent(wxAuiNotebookEventFunction, &func)
287 #define EVT_AUINOTEBOOK_PAGE_CHANGED(winid, fn) \
288 wx__DECLARE_EVT1(wxEVT_COMMAND_AUINOTEBOOK_PAGE_CHANGED, winid, wxAuiNotebookEventHandler(fn))
289 #define EVT_AUINOTEBOOK_PAGE_CHANGING(winid, fn) \
290 wx__DECLARE_EVT1(wxEVT_COMMAND_AUINOTEBOOK_PAGE_CHANGING, winid, wxAuiNotebookEventHandler(fn))
291 #define EVT_AUINOTEBOOK_PAGE_BUTTON(winid, fn) \
292 wx__DECLARE_EVT1(wxEVT_COMMAND_AUINOTEBOOK_BUTTON, winid, wxAuiNotebookEventHandler(fn))
293 #define EVT_AUINOTEBOOK_BEGIN_DRAG(winid, fn) \
294 wx__DECLARE_EVT1(wxEVT_COMMAND_AUINOTEBOOK_BEGIN_DRAG, winid, wxAuiNotebookEventHandler(fn))
295 #define EVT_AUINOTEBOOK_END_DRAG(winid, fn) \
296 wx__DECLARE_EVT1(wxEVT_COMMAND_AUINOTEBOOK_END_DRAG, winid, wxAuiNotebookEventHandler(fn))
297 #define EVT_AUINOTEBOOK_DRAG_MOTION(winid, fn) \
298 wx__DECLARE_EVT1(wxEVT_COMMAND_AUINOTEBOOK_DRAG_MOTION, winid, wxAuiNotebookEventHandler(fn))
302 // wxpython/swig event work
303 %constant wxEventType wxEVT_COMMAND_AUINOTEBOOK_PAGE_CHANGED
;
304 %constant wxEventType wxEVT_COMMAND_AUINOTEBOOK_PAGE_CHANGING
;
305 %constant wxEventType wxEVT_COMMAND_AUINOTEBOOK_BUTTON
;
306 %constant wxEventType wxEVT_COMMAND_AUINOTEBOOK_BEGIN_DRAG
;
307 %constant wxEventType wxEVT_COMMAND_AUINOTEBOOK_END_DRAG
;
308 %constant wxEventType wxEVT_COMMAND_AUINOTEBOOK_DRAG_MOTION
;
311 EVT_AUINOTEBOOK_PAGE_CHANGED
= wx
.PyEventBinder( wxEVT_COMMAND_AUINOTEBOOK_PAGE_CHANGED
, 1 )
312 EVT_AUINOTEBOOK_PAGE_CHANGING
= wx
.PyEventBinder( wxEVT_COMMAND_AUINOTEBOOK_PAGE_CHANGING
, 1 )
313 EVT_AUINOTEBOOK_BUTTON
= wx
.PyEventBinder( wxEVT_COMMAND_AUINOTEBOOK_BUTTON
, 1 )
314 EVT_AUINOTEBOOK_BEGIN_DRAG
= wx
.PyEventBinder( wxEVT_COMMAND_AUINOTEBOOK_BEGIN_DRAG
, 1 )
315 EVT_AUINOTEBOOK_END_DRAG
= wx
.PyEventBinder( wxEVT_COMMAND_AUINOTEBOOK_END_DRAG
, 1 )
316 EVT_AUINOTEBOOK_DRAG_MOTION
= wx
.PyEventBinder( wxEVT_COMMAND_AUINOTEBOOK_DRAG_MOTION
, 1 )
322 #endif // _WX_AUINOTEBOOK_H_