1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: wx/aui/notebook.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 // ----------------------------------------------------------------------------
21 #include "wx/aui/framemanager.h"
22 #include "wx/aui/dockart.h"
23 #include "wx/aui/floatpane.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
88 WX_DECLARE_USER_EXPORTED_OBJARRAY(wxAuiNotebookPage
, wxAuiNotebookPageArray
, WXDLLIMPEXP_AUI
);
89 WX_DECLARE_USER_EXPORTED_OBJARRAY(wxAuiTabContainerButton
, wxAuiTabContainerButtonArray
, WXDLLIMPEXP_AUI
);
93 class WXDLLIMPEXP_AUI wxAuiTabContainer
98 virtual ~wxAuiTabContainer();
100 bool AddPage(wxWindow
* page
, const wxAuiNotebookPage
& info
);
101 bool InsertPage(wxWindow
* page
, const wxAuiNotebookPage
& info
, size_t idx
);
102 bool RemovePage(wxWindow
* page
);
103 bool SetActivePage(wxWindow
* page
);
104 bool SetActivePage(size_t page
);
105 void SetNoneActive();
106 int GetActivePage() const;
107 bool TabHitTest(int x
, int y
, wxWindow
** hit
) const;
108 bool ButtonHitTest(int x
, int y
, wxAuiTabContainerButton
** hit
) const;
109 wxWindow
* GetWindowFromIdx(size_t idx
) const;
110 int GetIdxFromWindow(wxWindow
* page
) const;
111 size_t GetPageCount() const;
112 wxAuiNotebookPage
& GetPage(size_t idx
);
113 wxAuiNotebookPageArray
& GetPages();
114 void SetNormalFont(const wxFont
& normal_font
);
115 void SetSelectedFont(const wxFont
& selected_font
);
116 void SetMeasuringFont(const wxFont
& measuring_font
);
118 void SetRect(const wxRect
& rect
);
119 void AddButton(int id
, const wxBitmap
& bmp
);
123 virtual void Render(wxDC
* dc
);
125 virtual void DrawTab(wxDC
* dc
,
126 const wxRect
& in_rect
,
127 const wxString
& caption
,
133 wxAuiNotebookPageArray m_pages
;
134 wxAuiTabContainerButtonArray m_buttons
;
136 wxFont m_normal_font
;
137 wxFont m_selected_font
;
138 wxFont m_measuring_font
;
139 wxPen m_normal_bkpen
;
140 wxPen m_selected_bkpen
;
141 wxBrush m_normal_bkbrush
;
142 wxBrush m_selected_bkbrush
;
148 class WXDLLIMPEXP_AUI wxAuiTabCtrl
: public wxControl
,
149 public wxAuiTabContainer
153 wxAuiTabCtrl(wxWindow
* parent
,
155 const wxPoint
& pos
= wxDefaultPosition
,
156 const wxSize
& size
= wxDefaultSize
,
161 void OnPaint(wxPaintEvent
& evt
);
162 void OnEraseBackground(wxEraseEvent
& evt
);
163 void OnSize(wxSizeEvent
& evt
);
164 void OnLeftDown(wxMouseEvent
& evt
);
165 void OnLeftUp(wxMouseEvent
& evt
);
166 void OnMotion(wxMouseEvent
& evt
);
167 void OnLeaveWindow(wxMouseEvent
& evt
);
174 wxAuiTabContainerButton
* m_hover_button
;
176 DECLARE_EVENT_TABLE()
182 class WXDLLIMPEXP_AUI wxAuiMultiNotebook
: public wxControl
187 wxAuiMultiNotebook();
189 wxAuiMultiNotebook(wxWindow
* parent
,
191 const wxPoint
& pos
= wxDefaultPosition
,
192 const wxSize
& size
= wxDefaultSize
,
195 virtual ~wxAuiMultiNotebook();
197 bool Create(wxWindow
* parent
,
199 const wxPoint
& pos
= wxDefaultPosition
,
200 const wxSize
& size
= wxDefaultSize
,
203 bool AddPage(wxWindow
* page
,
204 const wxString
& caption
,
206 const wxBitmap
& bitmap
= wxNullBitmap
);
208 bool InsertPage(size_t page_idx
,
210 const wxString
& caption
,
212 const wxBitmap
& bitmap
= wxNullBitmap
);
214 bool DeletePage(size_t page
);
215 bool RemovePage(size_t page
);
217 bool SetPageText(size_t page
, const wxString
& text
);
218 size_t SetSelection(size_t new_page
);
219 int GetSelection() const;
220 size_t GetPageCount() const;
221 wxWindow
* GetPage(size_t page_idx
) const;
225 wxAuiTabCtrl
* GetTabCtrlFromPoint(const wxPoint
& pt
);
226 wxWindow
* GetTabFrameFromTabCtrl(wxWindow
* tab_ctrl
);
227 wxAuiTabCtrl
* GetActiveTabCtrl();
228 bool FindTab(wxWindow
* page
, wxAuiTabCtrl
** ctrl
, int* idx
);
229 void RemoveEmptyTabFrames();
236 void OnChildFocus(wxChildFocusEvent
& evt
);
237 void OnRender(wxFrameManagerEvent
& evt
);
238 void OnEraseBackground(wxEraseEvent
& evt
);
239 void OnSize(wxSizeEvent
& evt
);
240 void OnTabClicked(wxCommandEvent
& evt
);
241 void OnTabBeginDrag(wxCommandEvent
& evt
);
242 void OnTabDragMotion(wxCommandEvent
& evt
);
243 void OnTabEndDrag(wxCommandEvent
& evt
);
244 void OnTabButton(wxCommandEvent
& evt
);
248 wxFrameManager m_mgr
;
249 wxAuiTabContainer m_tabs
;
251 int m_tab_id_counter
;
252 wxWindow
* m_dummy_wnd
;
254 wxFont m_selected_font
;
255 wxFont m_normal_font
;
256 int m_tab_ctrl_height
;
258 DECLARE_EVENT_TABLE()
264 // wx event machinery
268 BEGIN_DECLARE_EVENT_TYPES()
269 DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_AUI
, wxEVT_COMMAND_AUINOTEBOOK_PAGE_CHANGED
, 0)
270 DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_AUI
, wxEVT_COMMAND_AUINOTEBOOK_PAGE_CHANGING
, 0)
271 DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_AUI
, wxEVT_COMMAND_AUINOTEBOOK_BUTTON
, 0)
272 DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_AUI
, wxEVT_COMMAND_AUINOTEBOOK_BEGIN_DRAG
, 0)
273 DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_AUI
, wxEVT_COMMAND_AUINOTEBOOK_END_DRAG
, 0)
274 DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_AUI
, wxEVT_COMMAND_AUINOTEBOOK_DRAG_MOTION
, 0)
275 END_DECLARE_EVENT_TYPES()
277 typedef void (wxEvtHandler
::*wxAuiNotebookEventFunction
)(wxAuiNotebookEvent
&);
279 #define wxAuiNotebookEventHandler(func) \
280 (wxObjectEventFunction)(wxEventFunction)wxStaticCastEvent(wxAuiNotebookEventFunction, &func)
282 #define EVT_AUINOTEBOOK_PAGE_CHANGED(winid, fn) \
283 wx__DECLARE_EVT1(wxEVT_COMMAND_AUINOTEBOOK_PAGE_CHANGED, winid, wxAuiNotebookEventHandler(fn))
284 #define EVT_AUINOTEBOOK_PAGE_CHANGING(winid, fn) \
285 wx__DECLARE_EVT1(wxEVT_COMMAND_AUINOTEBOOK_PAGE_CHANGING, winid, wxAuiNotebookEventHandler(fn))
286 #define EVT_AUINOTEBOOK_PAGE_BUTTON(winid, fn) \
287 wx__DECLARE_EVT1(wxEVT_COMMAND_AUINOTEBOOK_BUTTON, winid, wxAuiNotebookEventHandler(fn))
288 #define EVT_AUINOTEBOOK_BEGIN_DRAG(winid, fn) \
289 wx__DECLARE_EVT1(wxEVT_COMMAND_AUINOTEBOOK_BEGIN_DRAG, winid, wxAuiNotebookEventHandler(fn))
290 #define EVT_AUINOTEBOOK_END_DRAG(winid, fn) \
291 wx__DECLARE_EVT1(wxEVT_COMMAND_AUINOTEBOOK_END_DRAG, winid, wxAuiNotebookEventHandler(fn))
292 #define EVT_AUINOTEBOOK_DRAG_MOTION(winid, fn) \
293 wx__DECLARE_EVT1(wxEVT_COMMAND_AUINOTEBOOK_DRAG_MOTION, winid, wxAuiNotebookEventHandler(fn))
297 // wxpython/swig event work
304 #endif // _WX_AUINOTEBOOK_H_