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"
37 virtual void DrawBackground(
39 const wxRect
& rect
) = 0;
41 virtual void DrawTab(wxDC
* dc
,
42 const wxRect
& in_rect
,
43 const wxString
& caption
,
48 virtual void SetNormalFont(const wxFont
& font
) = 0;
49 virtual void SetSelectedFont(const wxFont
& font
) = 0;
50 virtual void SetMeasuringFont(const wxFont
& font
) = 0;
54 class wxDefaultTabArt
: public wxTabArt
65 void DrawTab(wxDC
* dc
,
66 const wxRect
& in_rect
,
67 const wxString
& caption
,
72 void SetNormalFont(const wxFont
& font
);
73 void SetSelectedFont(const wxFont
& font
);
74 void SetMeasuringFont(const wxFont
& font
);
79 wxFont m_selected_font
;
80 wxFont m_measuring_font
;
82 wxPen m_selected_bkpen
;
83 wxBrush m_normal_bkbrush
;
84 wxBrush m_selected_bkbrush
;
90 // event declarations/classes
92 class WXDLLIMPEXP_AUI wxAuiNotebookEvent
: public wxNotifyEvent
95 wxAuiNotebookEvent(wxEventType command_type
= wxEVT_NULL
,
97 : wxNotifyEvent(command_type
, win_id
)
101 wxAuiNotebookEvent(const wxAuiNotebookEvent
& c
) : wxNotifyEvent(c
)
103 old_selection
= c
.old_selection
;
104 selection
= c
.selection
;
107 wxEvent
*Clone() const { return new wxAuiNotebookEvent(*this); }
109 void SetSelection(int s
) { selection
= s
; }
110 void SetOldSelection(int s
) { old_selection
= s
; }
111 int GetSelection() const { return selection
; }
112 int GetOldSelection() const { return old_selection
; }
120 DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxAuiNotebookEvent
)
128 class WXDLLIMPEXP_AUI wxAuiNotebookPage
131 wxWindow
* window
; // page's associated window
132 wxString caption
; // caption displayed on the tab
133 wxBitmap bitmap
; // tab's bitmap
134 wxRect rect
; // tab's hit rectangle
135 bool active
; // true if the page is currently active
138 class WXDLLIMPEXP_AUI wxAuiTabContainerButton
141 int id
; // button's id
142 int cur_state
; // current state (normal, hover, pressed)
143 wxBitmap bitmap
; // button's bitmap
144 wxRect rect
; // button's hit rectangle
149 WX_DECLARE_USER_EXPORTED_OBJARRAY(wxAuiNotebookPage
, wxAuiNotebookPageArray
, WXDLLIMPEXP_AUI
);
150 WX_DECLARE_USER_EXPORTED_OBJARRAY(wxAuiTabContainerButton
, wxAuiTabContainerButtonArray
, WXDLLIMPEXP_AUI
);
154 class WXDLLIMPEXP_AUI wxAuiTabContainer
159 virtual ~wxAuiTabContainer();
161 void SetArtProvider(wxTabArt
* art
);
162 wxTabArt
* GetArtProvider();
164 bool AddPage(wxWindow
* page
, const wxAuiNotebookPage
& info
);
165 bool InsertPage(wxWindow
* page
, const wxAuiNotebookPage
& info
, size_t idx
);
166 bool RemovePage(wxWindow
* page
);
167 bool SetActivePage(wxWindow
* page
);
168 bool SetActivePage(size_t page
);
169 void SetNoneActive();
170 int GetActivePage() const;
171 bool TabHitTest(int x
, int y
, wxWindow
** hit
) const;
172 bool ButtonHitTest(int x
, int y
, wxAuiTabContainerButton
** hit
) const;
173 wxWindow
* GetWindowFromIdx(size_t idx
) const;
174 int GetIdxFromWindow(wxWindow
* page
) const;
175 size_t GetPageCount() const;
176 wxAuiNotebookPage
& GetPage(size_t idx
);
177 wxAuiNotebookPageArray
& GetPages();
178 void SetNormalFont(const wxFont
& normal_font
);
179 void SetSelectedFont(const wxFont
& selected_font
);
180 void SetMeasuringFont(const wxFont
& measuring_font
);
182 void SetRect(const wxRect
& rect
);
183 void AddButton(int id
, const wxBitmap
& bmp
);
187 virtual void Render(wxDC
* dc
);
192 wxAuiNotebookPageArray m_pages
;
193 wxAuiTabContainerButtonArray m_buttons
;
199 class WXDLLIMPEXP_AUI wxAuiTabCtrl
: public wxControl
,
200 public wxAuiTabContainer
204 wxAuiTabCtrl(wxWindow
* parent
,
205 wxWindowID id
= wxID_ANY
,
206 const wxPoint
& pos
= wxDefaultPosition
,
207 const wxSize
& size
= wxDefaultSize
,
212 void OnPaint(wxPaintEvent
& evt
);
213 void OnEraseBackground(wxEraseEvent
& evt
);
214 void OnSize(wxSizeEvent
& evt
);
215 void OnLeftDown(wxMouseEvent
& evt
);
216 void OnLeftUp(wxMouseEvent
& evt
);
217 void OnMotion(wxMouseEvent
& evt
);
218 void OnLeaveWindow(wxMouseEvent
& evt
);
225 wxAuiTabContainerButton
* m_hover_button
;
228 DECLARE_EVENT_TABLE()
235 class WXDLLIMPEXP_AUI wxAuiMultiNotebook
: public wxControl
240 wxAuiMultiNotebook();
242 wxAuiMultiNotebook(wxWindow
* parent
,
243 wxWindowID id
= wxID_ANY
,
244 const wxPoint
& pos
= wxDefaultPosition
,
245 const wxSize
& size
= wxDefaultSize
,
248 virtual ~wxAuiMultiNotebook();
250 bool Create(wxWindow
* parent
,
251 wxWindowID id
= wxID_ANY
,
252 const wxPoint
& pos
= wxDefaultPosition
,
253 const wxSize
& size
= wxDefaultSize
,
256 bool AddPage(wxWindow
* page
,
257 const wxString
& caption
,
259 const wxBitmap
& bitmap
= wxNullBitmap
);
261 bool InsertPage(size_t page_idx
,
263 const wxString
& caption
,
265 const wxBitmap
& bitmap
= wxNullBitmap
);
267 bool DeletePage(size_t page
);
268 bool RemovePage(size_t page
);
270 bool SetPageText(size_t page
, const wxString
& text
);
271 size_t SetSelection(size_t new_page
);
272 int GetSelection() const;
273 size_t GetPageCount() const;
274 wxWindow
* GetPage(size_t page_idx
) const;
276 void SetArtProvider(wxTabArt
* art
);
277 wxTabArt
* GetArtProvider();
281 wxAuiTabCtrl
* GetTabCtrlFromPoint(const wxPoint
& pt
);
282 wxWindow
* GetTabFrameFromTabCtrl(wxWindow
* tab_ctrl
);
283 wxAuiTabCtrl
* GetActiveTabCtrl();
284 bool FindTab(wxWindow
* page
, wxAuiTabCtrl
** ctrl
, int* idx
);
285 void RemoveEmptyTabFrames();
292 void OnChildFocus(wxChildFocusEvent
& evt
);
293 void OnRender(wxFrameManagerEvent
& evt
);
294 void OnEraseBackground(wxEraseEvent
& evt
);
295 void OnSize(wxSizeEvent
& evt
);
296 void OnTabClicked(wxCommandEvent
& evt
);
297 void OnTabBeginDrag(wxCommandEvent
& evt
);
298 void OnTabDragMotion(wxCommandEvent
& evt
);
299 void OnTabEndDrag(wxCommandEvent
& evt
);
300 void OnTabButton(wxCommandEvent
& evt
);
304 wxFrameManager m_mgr
;
305 wxAuiTabContainer m_tabs
;
307 int m_tab_id_counter
;
308 wxWindow
* m_dummy_wnd
;
310 wxFont m_selected_font
;
311 wxFont m_normal_font
;
312 int m_tab_ctrl_height
;
315 DECLARE_EVENT_TABLE()
322 // wx event machinery
326 BEGIN_DECLARE_EVENT_TYPES()
327 DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_AUI
, wxEVT_COMMAND_AUINOTEBOOK_PAGE_CHANGED
, 0)
328 DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_AUI
, wxEVT_COMMAND_AUINOTEBOOK_PAGE_CHANGING
, 0)
329 DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_AUI
, wxEVT_COMMAND_AUINOTEBOOK_BUTTON
, 0)
330 DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_AUI
, wxEVT_COMMAND_AUINOTEBOOK_BEGIN_DRAG
, 0)
331 DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_AUI
, wxEVT_COMMAND_AUINOTEBOOK_END_DRAG
, 0)
332 DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_AUI
, wxEVT_COMMAND_AUINOTEBOOK_DRAG_MOTION
, 0)
333 END_DECLARE_EVENT_TYPES()
335 typedef void (wxEvtHandler::*wxAuiNotebookEventFunction
)(wxAuiNotebookEvent
&);
337 #define wxAuiNotebookEventHandler(func) \
338 (wxObjectEventFunction)(wxEventFunction)wxStaticCastEvent(wxAuiNotebookEventFunction, &func)
340 #define EVT_AUINOTEBOOK_PAGE_CHANGED(winid, fn) \
341 wx__DECLARE_EVT1(wxEVT_COMMAND_AUINOTEBOOK_PAGE_CHANGED, winid, wxAuiNotebookEventHandler(fn))
342 #define EVT_AUINOTEBOOK_PAGE_CHANGING(winid, fn) \
343 wx__DECLARE_EVT1(wxEVT_COMMAND_AUINOTEBOOK_PAGE_CHANGING, winid, wxAuiNotebookEventHandler(fn))
344 #define EVT_AUINOTEBOOK_PAGE_BUTTON(winid, fn) \
345 wx__DECLARE_EVT1(wxEVT_COMMAND_AUINOTEBOOK_BUTTON, winid, wxAuiNotebookEventHandler(fn))
346 #define EVT_AUINOTEBOOK_BEGIN_DRAG(winid, fn) \
347 wx__DECLARE_EVT1(wxEVT_COMMAND_AUINOTEBOOK_BEGIN_DRAG, winid, wxAuiNotebookEventHandler(fn))
348 #define EVT_AUINOTEBOOK_END_DRAG(winid, fn) \
349 wx__DECLARE_EVT1(wxEVT_COMMAND_AUINOTEBOOK_END_DRAG, winid, wxAuiNotebookEventHandler(fn))
350 #define EVT_AUINOTEBOOK_DRAG_MOTION(winid, fn) \
351 wx__DECLARE_EVT1(wxEVT_COMMAND_AUINOTEBOOK_DRAG_MOTION, winid, wxAuiNotebookEventHandler(fn))
355 // wxpython/swig event work
356 %constant wxEventType wxEVT_COMMAND_AUINOTEBOOK_PAGE_CHANGED
;
357 %constant wxEventType wxEVT_COMMAND_AUINOTEBOOK_PAGE_CHANGING
;
358 %constant wxEventType wxEVT_COMMAND_AUINOTEBOOK_BUTTON
;
359 %constant wxEventType wxEVT_COMMAND_AUINOTEBOOK_BEGIN_DRAG
;
360 %constant wxEventType wxEVT_COMMAND_AUINOTEBOOK_END_DRAG
;
361 %constant wxEventType wxEVT_COMMAND_AUINOTEBOOK_DRAG_MOTION
;
364 EVT_AUINOTEBOOK_PAGE_CHANGED
= wx
.PyEventBinder( wxEVT_COMMAND_AUINOTEBOOK_PAGE_CHANGED
, 1 )
365 EVT_AUINOTEBOOK_PAGE_CHANGING
= wx
.PyEventBinder( wxEVT_COMMAND_AUINOTEBOOK_PAGE_CHANGING
, 1 )
366 EVT_AUINOTEBOOK_BUTTON
= wx
.PyEventBinder( wxEVT_COMMAND_AUINOTEBOOK_BUTTON
, 1 )
367 EVT_AUINOTEBOOK_BEGIN_DRAG
= wx
.PyEventBinder( wxEVT_COMMAND_AUINOTEBOOK_BEGIN_DRAG
, 1 )
368 EVT_AUINOTEBOOK_END_DRAG
= wx
.PyEventBinder( wxEVT_COMMAND_AUINOTEBOOK_END_DRAG
, 1 )
369 EVT_AUINOTEBOOK_DRAG_MOTION
= wx
.PyEventBinder( wxEVT_COMMAND_AUINOTEBOOK_DRAG_MOTION
, 1 )
375 #endif // _WX_AUINOTEBOOK_H_