]> git.saurik.com Git - wxWidgets.git/blame - include/wx/aui/auibook.h
don't use static buffer needing a critical section to protect it for logging; this...
[wxWidgets.git] / include / wx / aui / auibook.h
CommitLineData
a3219eea 1///////////////////////////////////////////////////////////////////////////////
4444d148 2// Name: wx/aui/auibook.h
a3219eea
BW
3// Purpose: wxaui: wx advanced user interface - notebook
4// Author: Benjamin I. Williams
5// Modified by:
6// Created: 2006-06-28
7// Copyright: (C) Copyright 2006, Kirix Corporation, All Rights Reserved.
8// Licence: wxWindows Library Licence, Version 3.1
9///////////////////////////////////////////////////////////////////////////////
10
11
12
13#ifndef _WX_AUINOTEBOOK_H_
14#define _WX_AUINOTEBOOK_H_
15
16// ----------------------------------------------------------------------------
17// headers
18// ----------------------------------------------------------------------------
19
20#include "wx/defs.h"
a3219eea
BW
21
22#if wxUSE_AUI
23
4444d148
WS
24#include "wx/aui/framemanager.h"
25#include "wx/aui/dockart.h"
26#include "wx/aui/floatpane.h"
a3219eea
BW
27
28
29// event declarations/classes
30
31class WXDLLIMPEXP_AUI wxAuiNotebookEvent : public wxNotifyEvent
32{
33public:
34 wxAuiNotebookEvent(wxEventType command_type = wxEVT_NULL,
35 int win_id = 0)
36 : wxNotifyEvent(command_type, win_id)
37 {
38 }
39#ifndef SWIG
40 wxAuiNotebookEvent(const wxAuiNotebookEvent& c) : wxNotifyEvent(c)
41 {
42 old_selection = c.old_selection;
43 selection = c.selection;
44 }
45#endif
46 wxEvent *Clone() const { return new wxAuiNotebookEvent(*this); }
47
48 void SetSelection(int s) { selection = s; }
49 void SetOldSelection(int s) { old_selection = s; }
50 int GetSelection() const { return selection; }
51 int GetOldSelection() const { return old_selection; }
4444d148 52
a3219eea
BW
53public:
54 int old_selection;
55 int selection;
4444d148 56
a3219eea
BW
57#ifndef SWIG
58private:
59 DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxAuiNotebookEvent)
60#endif
61};
62
63
64
65
66
67class WXDLLIMPEXP_AUI wxAuiNotebookPage
68{
69public:
70 wxWindow* window; // page's associated window
71 wxString caption; // caption displayed on the tab
72 wxBitmap bitmap; // tab's bitmap
73 wxRect rect; // tab's hit rectangle
74 bool active; // true if the page is currently active
75};
76
77class WXDLLIMPEXP_AUI wxAuiTabContainerButton
78{
79public:
80 int id; // button's id
81 int cur_state; // current state (normal, hover, pressed)
82 wxBitmap bitmap; // button's bitmap
83 wxRect rect; // button's hit rectangle
84};
85
86
d91fa282 87#ifndef SWIG
a3219eea
BW
88WX_DECLARE_USER_EXPORTED_OBJARRAY(wxAuiNotebookPage, wxAuiNotebookPageArray, WXDLLIMPEXP_AUI);
89WX_DECLARE_USER_EXPORTED_OBJARRAY(wxAuiTabContainerButton, wxAuiTabContainerButtonArray, WXDLLIMPEXP_AUI);
d91fa282 90#endif
a3219eea
BW
91
92
93class WXDLLIMPEXP_AUI wxAuiTabContainer
94{
95public:
96
97 wxAuiTabContainer();
9fabaac4 98 virtual ~wxAuiTabContainer();
a3219eea
BW
99
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);
117 void DoShowHide();
118 void SetRect(const wxRect& rect);
119 void AddButton(int id, const wxBitmap& bmp);
4444d148 120
a3219eea
BW
121protected:
122
4444d148 123 virtual void Render(wxDC* dc);
a3219eea
BW
124
125 virtual void DrawTab(wxDC* dc,
126 const wxRect& in_rect,
127 const wxString& caption,
128 bool active,
129 wxRect* out_rect,
4444d148 130 int* x_extent);
a3219eea
BW
131private:
132
133 wxAuiNotebookPageArray m_pages;
134 wxAuiTabContainerButtonArray m_buttons;
135 wxRect m_rect;
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;
143 wxBrush m_bkbrush;
144};
145
146
147
148class WXDLLIMPEXP_AUI wxAuiTabCtrl : public wxControl,
149 public wxAuiTabContainer
150{
151public:
152
153 wxAuiTabCtrl(wxWindow* parent,
d91fa282 154 wxWindowID id = wxID_ANY,
a3219eea
BW
155 const wxPoint& pos = wxDefaultPosition,
156 const wxSize& size = wxDefaultSize,
157 long style = 0);
4444d148 158
a3219eea
BW
159protected:
160
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);
4444d148 168
a3219eea 169protected:
4444d148 170
a3219eea
BW
171 wxPoint m_click_pt;
172 int m_click_tab;
173 bool m_is_dragging;
174 wxAuiTabContainerButton* m_hover_button;
175
d91fa282 176#ifndef SWIG
a3219eea 177 DECLARE_EVENT_TABLE()
d91fa282 178#endif
a3219eea
BW
179};
180
181
182
183
184class WXDLLIMPEXP_AUI wxAuiMultiNotebook : public wxControl
185{
186
187public:
188
189 wxAuiMultiNotebook();
4444d148 190
a3219eea 191 wxAuiMultiNotebook(wxWindow* parent,
d91fa282 192 wxWindowID id = wxID_ANY,
a3219eea
BW
193 const wxPoint& pos = wxDefaultPosition,
194 const wxSize& size = wxDefaultSize,
195 long style = 0);
4444d148 196
a3219eea
BW
197 virtual ~wxAuiMultiNotebook();
198
199 bool Create(wxWindow* parent,
d91fa282 200 wxWindowID id = wxID_ANY,
a3219eea
BW
201 const wxPoint& pos = wxDefaultPosition,
202 const wxSize& size = wxDefaultSize,
4444d148 203 long style = 0);
a3219eea
BW
204
205 bool AddPage(wxWindow* page,
206 const wxString& caption,
207 bool select = false,
208 const wxBitmap& bitmap = wxNullBitmap);
4444d148 209
a3219eea
BW
210 bool InsertPage(size_t page_idx,
211 wxWindow* page,
212 const wxString& caption,
213 bool select = false,
214 const wxBitmap& bitmap = wxNullBitmap);
4444d148 215
a3219eea
BW
216 bool DeletePage(size_t page);
217 bool RemovePage(size_t page);
4444d148 218
a3219eea
BW
219 bool SetPageText(size_t page, const wxString& text);
220 size_t SetSelection(size_t new_page);
221 int GetSelection() const;
222 size_t GetPageCount() const;
223 wxWindow* GetPage(size_t page_idx) const;
4444d148 224
a3219eea 225protected:
4444d148 226
a3219eea
BW
227 wxAuiTabCtrl* GetTabCtrlFromPoint(const wxPoint& pt);
228 wxWindow* GetTabFrameFromTabCtrl(wxWindow* tab_ctrl);
229 wxAuiTabCtrl* GetActiveTabCtrl();
230 bool FindTab(wxWindow* page, wxAuiTabCtrl** ctrl, int* idx);
231 void RemoveEmptyTabFrames();
4444d148 232
a3219eea
BW
233protected:
234
235 void DoSizing();
236 void InitNotebook();
4444d148 237
a3219eea
BW
238 void OnChildFocus(wxChildFocusEvent& evt);
239 void OnRender(wxFrameManagerEvent& evt);
240 void OnEraseBackground(wxEraseEvent& evt);
241 void OnSize(wxSizeEvent& evt);
242 void OnTabClicked(wxCommandEvent& evt);
243 void OnTabBeginDrag(wxCommandEvent& evt);
244 void OnTabDragMotion(wxCommandEvent& evt);
245 void OnTabEndDrag(wxCommandEvent& evt);
246 void OnTabButton(wxCommandEvent& evt);
247
248protected:
249
250 wxFrameManager m_mgr;
251 wxAuiTabContainer m_tabs;
252 int m_curpage;
253 int m_tab_id_counter;
254 wxWindow* m_dummy_wnd;
4444d148 255
a3219eea
BW
256 wxFont m_selected_font;
257 wxFont m_normal_font;
da5e85d9 258 int m_tab_ctrl_height;
4444d148 259
d91fa282 260#ifndef SWIG
a3219eea 261 DECLARE_EVENT_TABLE()
d91fa282 262#endif
a3219eea
BW
263};
264
265
266
267
268// wx event machinery
269
270#ifndef SWIG
271
272BEGIN_DECLARE_EVENT_TYPES()
273 DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_AUI, wxEVT_COMMAND_AUINOTEBOOK_PAGE_CHANGED, 0)
274 DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_AUI, wxEVT_COMMAND_AUINOTEBOOK_PAGE_CHANGING, 0)
275 DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_AUI, wxEVT_COMMAND_AUINOTEBOOK_BUTTON, 0)
276 DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_AUI, wxEVT_COMMAND_AUINOTEBOOK_BEGIN_DRAG, 0)
277 DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_AUI, wxEVT_COMMAND_AUINOTEBOOK_END_DRAG, 0)
278 DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_AUI, wxEVT_COMMAND_AUINOTEBOOK_DRAG_MOTION, 0)
279END_DECLARE_EVENT_TYPES()
280
281typedef void (wxEvtHandler::*wxAuiNotebookEventFunction)(wxAuiNotebookEvent&);
282
283#define wxAuiNotebookEventHandler(func) \
284 (wxObjectEventFunction)(wxEventFunction)wxStaticCastEvent(wxAuiNotebookEventFunction, &func)
285
286#define EVT_AUINOTEBOOK_PAGE_CHANGED(winid, fn) \
287 wx__DECLARE_EVT1(wxEVT_COMMAND_AUINOTEBOOK_PAGE_CHANGED, winid, wxAuiNotebookEventHandler(fn))
288#define EVT_AUINOTEBOOK_PAGE_CHANGING(winid, fn) \
289 wx__DECLARE_EVT1(wxEVT_COMMAND_AUINOTEBOOK_PAGE_CHANGING, winid, wxAuiNotebookEventHandler(fn))
290#define EVT_AUINOTEBOOK_PAGE_BUTTON(winid, fn) \
291 wx__DECLARE_EVT1(wxEVT_COMMAND_AUINOTEBOOK_BUTTON, winid, wxAuiNotebookEventHandler(fn))
292#define EVT_AUINOTEBOOK_BEGIN_DRAG(winid, fn) \
293 wx__DECLARE_EVT1(wxEVT_COMMAND_AUINOTEBOOK_BEGIN_DRAG, winid, wxAuiNotebookEventHandler(fn))
294#define EVT_AUINOTEBOOK_END_DRAG(winid, fn) \
295 wx__DECLARE_EVT1(wxEVT_COMMAND_AUINOTEBOOK_END_DRAG, winid, wxAuiNotebookEventHandler(fn))
296#define EVT_AUINOTEBOOK_DRAG_MOTION(winid, fn) \
297 wx__DECLARE_EVT1(wxEVT_COMMAND_AUINOTEBOOK_DRAG_MOTION, winid, wxAuiNotebookEventHandler(fn))
4444d148 298
a3219eea
BW
299#else
300
301// wxpython/swig event work
d91fa282
RD
302%constant wxEventType wxEVT_COMMAND_AUINOTEBOOK_PAGE_CHANGED;
303%constant wxEventType wxEVT_COMMAND_AUINOTEBOOK_PAGE_CHANGING;
304%constant wxEventType wxEVT_COMMAND_AUINOTEBOOK_BUTTON;
305%constant wxEventType wxEVT_COMMAND_AUINOTEBOOK_BEGIN_DRAG;
306%constant wxEventType wxEVT_COMMAND_AUINOTEBOOK_END_DRAG;
307%constant wxEventType wxEVT_COMMAND_AUINOTEBOOK_DRAG_MOTION;
308
309%pythoncode {
310 EVT_AUINOTEBOOK_PAGE_CHANGED = wx.PyEventBinder( wxEVT_COMMAND_AUINOTEBOOK_PAGE_CHANGED, 1 )
311 EVT_AUINOTEBOOK_PAGE_CHANGING = wx.PyEventBinder( wxEVT_COMMAND_AUINOTEBOOK_PAGE_CHANGING, 1 )
312 EVT_AUINOTEBOOK_BUTTON = wx.PyEventBinder( wxEVT_COMMAND_AUINOTEBOOK_BUTTON, 1 )
313 EVT_AUINOTEBOOK_BEGIN_DRAG = wx.PyEventBinder( wxEVT_COMMAND_AUINOTEBOOK_BEGIN_DRAG, 1 )
314 EVT_AUINOTEBOOK_END_DRAG = wx.PyEventBinder( wxEVT_COMMAND_AUINOTEBOOK_END_DRAG, 1 )
4444d148 315 EVT_AUINOTEBOOK_DRAG_MOTION = wx.PyEventBinder( wxEVT_COMMAND_AUINOTEBOOK_DRAG_MOTION, 1 )
d91fa282 316}
a3219eea
BW
317#endif
318
319
320#endif // wxUSE_AUI
321#endif // _WX_AUINOTEBOOK_H_