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"
33 class WXDLLIMPEXP_AUI wxTabArt
38 virtual ~wxTabArt() { }
40 virtual void DrawBackground(
42 const wxRect
& rect
) = 0;
44 virtual void DrawTab(wxDC
* dc
,
45 const wxRect
& in_rect
,
46 const wxString
& caption
,
51 virtual void SetNormalFont(const wxFont
& font
) = 0;
52 virtual void SetSelectedFont(const wxFont
& font
) = 0;
53 virtual void SetMeasuringFont(const wxFont
& font
) = 0;
57 class WXDLLIMPEXP_AUI wxDefaultTabArt
: public wxTabArt
63 virtual ~wxDefaultTabArt();
69 void DrawTab(wxDC
* dc
,
70 const wxRect
& in_rect
,
71 const wxString
& caption
,
76 void SetNormalFont(const wxFont
& font
);
77 void SetSelectedFont(const wxFont
& font
);
78 void SetMeasuringFont(const wxFont
& font
);
83 wxFont m_selected_font
;
84 wxFont m_measuring_font
;
86 wxPen m_selected_bkpen
;
87 wxBrush m_normal_bkbrush
;
88 wxBrush m_selected_bkbrush
;
94 // event declarations/classes
96 class WXDLLIMPEXP_AUI wxAuiNotebookEvent
: public wxNotifyEvent
99 wxAuiNotebookEvent(wxEventType command_type
= wxEVT_NULL
,
101 : wxNotifyEvent(command_type
, win_id
)
105 wxAuiNotebookEvent(const wxAuiNotebookEvent
& c
) : wxNotifyEvent(c
)
107 old_selection
= c
.old_selection
;
108 selection
= c
.selection
;
111 wxEvent
*Clone() const { return new wxAuiNotebookEvent(*this); }
113 void SetSelection(int s
) { selection
= s
; }
114 void SetOldSelection(int s
) { old_selection
= s
; }
115 int GetSelection() const { return selection
; }
116 int GetOldSelection() const { return old_selection
; }
124 DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxAuiNotebookEvent
)
132 class WXDLLIMPEXP_AUI wxAuiNotebookPage
135 wxWindow
* window
; // page's associated window
136 wxString caption
; // caption displayed on the tab
137 wxBitmap bitmap
; // tab's bitmap
138 wxRect rect
; // tab's hit rectangle
139 bool active
; // true if the page is currently active
142 class WXDLLIMPEXP_AUI wxAuiTabContainerButton
145 int id
; // button's id
146 int cur_state
; // current state (normal, hover, pressed)
147 int location
; // buttons location (wxLEFT or wxRIGHT)
148 wxBitmap bitmap
; // button's bitmap
149 wxRect rect
; // button's hit rectangle
154 WX_DECLARE_USER_EXPORTED_OBJARRAY(wxAuiNotebookPage
, wxAuiNotebookPageArray
, WXDLLIMPEXP_AUI
);
155 WX_DECLARE_USER_EXPORTED_OBJARRAY(wxAuiTabContainerButton
, wxAuiTabContainerButtonArray
, WXDLLIMPEXP_AUI
);
159 class WXDLLIMPEXP_AUI wxAuiTabContainer
164 virtual ~wxAuiTabContainer();
166 void SetArtProvider(wxTabArt
* art
);
167 wxTabArt
* GetArtProvider();
169 bool AddPage(wxWindow
* page
, const wxAuiNotebookPage
& info
);
170 bool InsertPage(wxWindow
* page
, const wxAuiNotebookPage
& info
, size_t idx
);
171 bool RemovePage(wxWindow
* page
);
172 bool SetActivePage(wxWindow
* page
);
173 bool SetActivePage(size_t page
);
174 void SetNoneActive();
175 int GetActivePage() const;
176 bool TabHitTest(int x
, int y
, wxWindow
** hit
) const;
177 bool ButtonHitTest(int x
, int y
, wxAuiTabContainerButton
** hit
) const;
178 wxWindow
* GetWindowFromIdx(size_t idx
) const;
179 int GetIdxFromWindow(wxWindow
* page
) const;
180 size_t GetPageCount() const;
181 wxAuiNotebookPage
& GetPage(size_t idx
);
182 wxAuiNotebookPageArray
& GetPages();
183 void SetNormalFont(const wxFont
& normal_font
);
184 void SetSelectedFont(const wxFont
& selected_font
);
185 void SetMeasuringFont(const wxFont
& measuring_font
);
187 void SetRect(const wxRect
& rect
);
188 void AddButton(int id
, int location
, const wxBitmap
& bmp
);
192 virtual void Render(wxDC
* dc
);
197 wxAuiNotebookPageArray m_pages
;
198 wxAuiTabContainerButtonArray m_buttons
;
204 class WXDLLIMPEXP_AUI wxAuiTabCtrl
: public wxControl
,
205 public wxAuiTabContainer
209 wxAuiTabCtrl(wxWindow
* parent
,
210 wxWindowID id
= wxID_ANY
,
211 const wxPoint
& pos
= wxDefaultPosition
,
212 const wxSize
& size
= wxDefaultSize
,
217 void OnPaint(wxPaintEvent
& evt
);
218 void OnEraseBackground(wxEraseEvent
& evt
);
219 void OnSize(wxSizeEvent
& evt
);
220 void OnLeftDown(wxMouseEvent
& evt
);
221 void OnLeftUp(wxMouseEvent
& evt
);
222 void OnMotion(wxMouseEvent
& evt
);
223 void OnLeaveWindow(wxMouseEvent
& evt
);
230 wxAuiTabContainerButton
* m_hover_button
;
233 DECLARE_EVENT_TABLE()
240 class WXDLLIMPEXP_AUI wxAuiMultiNotebook
: public wxControl
245 wxAuiMultiNotebook();
247 wxAuiMultiNotebook(wxWindow
* parent
,
248 wxWindowID id
= wxID_ANY
,
249 const wxPoint
& pos
= wxDefaultPosition
,
250 const wxSize
& size
= wxDefaultSize
,
253 virtual ~wxAuiMultiNotebook();
255 bool Create(wxWindow
* parent
,
256 wxWindowID id
= wxID_ANY
,
257 const wxPoint
& pos
= wxDefaultPosition
,
258 const wxSize
& size
= wxDefaultSize
,
261 bool AddPage(wxWindow
* page
,
262 const wxString
& caption
,
264 const wxBitmap
& bitmap
= wxNullBitmap
);
266 bool InsertPage(size_t page_idx
,
268 const wxString
& caption
,
270 const wxBitmap
& bitmap
= wxNullBitmap
);
272 bool DeletePage(size_t page
);
273 bool RemovePage(size_t page
);
275 bool SetPageText(size_t page
, const wxString
& text
);
276 size_t SetSelection(size_t new_page
);
277 int GetSelection() const;
278 size_t GetPageCount() const;
279 wxWindow
* GetPage(size_t page_idx
) const;
281 void SetArtProvider(wxTabArt
* art
);
282 wxTabArt
* GetArtProvider();
286 wxAuiTabCtrl
* GetTabCtrlFromPoint(const wxPoint
& pt
);
287 wxWindow
* GetTabFrameFromTabCtrl(wxWindow
* tab_ctrl
);
288 wxAuiTabCtrl
* GetActiveTabCtrl();
289 bool FindTab(wxWindow
* page
, wxAuiTabCtrl
** ctrl
, int* idx
);
290 void RemoveEmptyTabFrames();
297 void OnChildFocus(wxChildFocusEvent
& evt
);
298 void OnRender(wxFrameManagerEvent
& evt
);
299 void OnEraseBackground(wxEraseEvent
& evt
);
300 void OnSize(wxSizeEvent
& evt
);
301 void OnTabClicked(wxCommandEvent
& evt
);
302 void OnTabBeginDrag(wxCommandEvent
& evt
);
303 void OnTabDragMotion(wxCommandEvent
& evt
);
304 void OnTabEndDrag(wxCommandEvent
& evt
);
305 void OnTabButton(wxCommandEvent
& evt
);
309 wxFrameManager m_mgr
;
310 wxAuiTabContainer m_tabs
;
312 int m_tab_id_counter
;
313 wxWindow
* m_dummy_wnd
;
315 wxFont m_selected_font
;
316 wxFont m_normal_font
;
317 int m_tab_ctrl_height
;
320 DECLARE_EVENT_TABLE()
327 // wx event machinery
331 BEGIN_DECLARE_EVENT_TYPES()
332 DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_AUI
, wxEVT_COMMAND_AUINOTEBOOK_PAGE_CHANGED
, 0)
333 DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_AUI
, wxEVT_COMMAND_AUINOTEBOOK_PAGE_CHANGING
, 0)
334 DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_AUI
, wxEVT_COMMAND_AUINOTEBOOK_BUTTON
, 0)
335 DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_AUI
, wxEVT_COMMAND_AUINOTEBOOK_BEGIN_DRAG
, 0)
336 DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_AUI
, wxEVT_COMMAND_AUINOTEBOOK_END_DRAG
, 0)
337 DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_AUI
, wxEVT_COMMAND_AUINOTEBOOK_DRAG_MOTION
, 0)
338 END_DECLARE_EVENT_TYPES()
340 typedef void (wxEvtHandler::*wxAuiNotebookEventFunction
)(wxAuiNotebookEvent
&);
342 #define wxAuiNotebookEventHandler(func) \
343 (wxObjectEventFunction)(wxEventFunction)wxStaticCastEvent(wxAuiNotebookEventFunction, &func)
345 #define EVT_AUINOTEBOOK_PAGE_CHANGED(winid, fn) \
346 wx__DECLARE_EVT1(wxEVT_COMMAND_AUINOTEBOOK_PAGE_CHANGED, winid, wxAuiNotebookEventHandler(fn))
347 #define EVT_AUINOTEBOOK_PAGE_CHANGING(winid, fn) \
348 wx__DECLARE_EVT1(wxEVT_COMMAND_AUINOTEBOOK_PAGE_CHANGING, winid, wxAuiNotebookEventHandler(fn))
349 #define EVT_AUINOTEBOOK_PAGE_BUTTON(winid, fn) \
350 wx__DECLARE_EVT1(wxEVT_COMMAND_AUINOTEBOOK_BUTTON, winid, wxAuiNotebookEventHandler(fn))
351 #define EVT_AUINOTEBOOK_BEGIN_DRAG(winid, fn) \
352 wx__DECLARE_EVT1(wxEVT_COMMAND_AUINOTEBOOK_BEGIN_DRAG, winid, wxAuiNotebookEventHandler(fn))
353 #define EVT_AUINOTEBOOK_END_DRAG(winid, fn) \
354 wx__DECLARE_EVT1(wxEVT_COMMAND_AUINOTEBOOK_END_DRAG, winid, wxAuiNotebookEventHandler(fn))
355 #define EVT_AUINOTEBOOK_DRAG_MOTION(winid, fn) \
356 wx__DECLARE_EVT1(wxEVT_COMMAND_AUINOTEBOOK_DRAG_MOTION, winid, wxAuiNotebookEventHandler(fn))
360 // wxpython/swig event work
361 %constant wxEventType wxEVT_COMMAND_AUINOTEBOOK_PAGE_CHANGED
;
362 %constant wxEventType wxEVT_COMMAND_AUINOTEBOOK_PAGE_CHANGING
;
363 %constant wxEventType wxEVT_COMMAND_AUINOTEBOOK_BUTTON
;
364 %constant wxEventType wxEVT_COMMAND_AUINOTEBOOK_BEGIN_DRAG
;
365 %constant wxEventType wxEVT_COMMAND_AUINOTEBOOK_END_DRAG
;
366 %constant wxEventType wxEVT_COMMAND_AUINOTEBOOK_DRAG_MOTION
;
369 EVT_AUINOTEBOOK_PAGE_CHANGED
= wx
.PyEventBinder( wxEVT_COMMAND_AUINOTEBOOK_PAGE_CHANGED
, 1 )
370 EVT_AUINOTEBOOK_PAGE_CHANGING
= wx
.PyEventBinder( wxEVT_COMMAND_AUINOTEBOOK_PAGE_CHANGING
, 1 )
371 EVT_AUINOTEBOOK_BUTTON
= wx
.PyEventBinder( wxEVT_COMMAND_AUINOTEBOOK_BUTTON
, 1 )
372 EVT_AUINOTEBOOK_BEGIN_DRAG
= wx
.PyEventBinder( wxEVT_COMMAND_AUINOTEBOOK_BEGIN_DRAG
, 1 )
373 EVT_AUINOTEBOOK_END_DRAG
= wx
.PyEventBinder( wxEVT_COMMAND_AUINOTEBOOK_END_DRAG
, 1 )
374 EVT_AUINOTEBOOK_DRAG_MOTION
= wx
.PyEventBinder( wxEVT_COMMAND_AUINOTEBOOK_DRAG_MOTION
, 1 )
380 #endif // _WX_AUINOTEBOOK_H_