Missing headers.
[wxWidgets.git] / include / wx / aui / auibook.h
1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: wx/aui/auibook.h
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"
21
22 #if wxUSE_AUI
23
24 #include "wx/aui/framemanager.h"
25 #include "wx/aui/dockart.h"
26 #include "wx/aui/floatpane.h"
27 #include "wx/control.h"
28
29
30 // event declarations/classes
31
32 class WXDLLIMPEXP_AUI wxAuiNotebookEvent : public wxNotifyEvent
33 {
34 public:
35 wxAuiNotebookEvent(wxEventType command_type = wxEVT_NULL,
36 int win_id = 0)
37 : wxNotifyEvent(command_type, win_id)
38 {
39 }
40 #ifndef SWIG
41 wxAuiNotebookEvent(const wxAuiNotebookEvent& c) : wxNotifyEvent(c)
42 {
43 old_selection = c.old_selection;
44 selection = c.selection;
45 }
46 #endif
47 wxEvent *Clone() const { return new wxAuiNotebookEvent(*this); }
48
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; }
53
54 public:
55 int old_selection;
56 int selection;
57
58 #ifndef SWIG
59 private:
60 DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxAuiNotebookEvent)
61 #endif
62 };
63
64
65
66
67
68 class WXDLLIMPEXP_AUI wxAuiNotebookPage
69 {
70 public:
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
76 };
77
78 class WXDLLIMPEXP_AUI wxAuiTabContainerButton
79 {
80 public:
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
85 };
86
87
88 #ifndef SWIG
89 WX_DECLARE_USER_EXPORTED_OBJARRAY(wxAuiNotebookPage, wxAuiNotebookPageArray, WXDLLIMPEXP_AUI);
90 WX_DECLARE_USER_EXPORTED_OBJARRAY(wxAuiTabContainerButton, wxAuiTabContainerButtonArray, WXDLLIMPEXP_AUI);
91 #endif
92
93
94 class WXDLLIMPEXP_AUI wxAuiTabContainer
95 {
96 public:
97
98 wxAuiTabContainer();
99 virtual ~wxAuiTabContainer();
100
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);
118 void DoShowHide();
119 void SetRect(const wxRect& rect);
120 void AddButton(int id, const wxBitmap& bmp);
121
122 protected:
123
124 virtual void Render(wxDC* dc);
125
126 virtual void DrawTab(wxDC* dc,
127 const wxRect& in_rect,
128 const wxString& caption,
129 bool active,
130 wxRect* out_rect,
131 int* x_extent);
132 private:
133
134 wxAuiNotebookPageArray m_pages;
135 wxAuiTabContainerButtonArray m_buttons;
136 wxRect m_rect;
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;
144 wxBrush m_bkbrush;
145 };
146
147
148
149 class WXDLLIMPEXP_AUI wxAuiTabCtrl : public wxControl,
150 public wxAuiTabContainer
151 {
152 public:
153
154 wxAuiTabCtrl(wxWindow* parent,
155 wxWindowID id = wxID_ANY,
156 const wxPoint& pos = wxDefaultPosition,
157 const wxSize& size = wxDefaultSize,
158 long style = 0);
159
160 protected:
161
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);
169
170 protected:
171
172 wxPoint m_click_pt;
173 int m_click_tab;
174 bool m_is_dragging;
175 wxAuiTabContainerButton* m_hover_button;
176
177 #ifndef SWIG
178 DECLARE_EVENT_TABLE()
179 #endif
180 };
181
182
183
184
185 class WXDLLIMPEXP_AUI wxAuiMultiNotebook : public wxControl
186 {
187
188 public:
189
190 wxAuiMultiNotebook();
191
192 wxAuiMultiNotebook(wxWindow* parent,
193 wxWindowID id = wxID_ANY,
194 const wxPoint& pos = wxDefaultPosition,
195 const wxSize& size = wxDefaultSize,
196 long style = 0);
197
198 virtual ~wxAuiMultiNotebook();
199
200 bool Create(wxWindow* parent,
201 wxWindowID id = wxID_ANY,
202 const wxPoint& pos = wxDefaultPosition,
203 const wxSize& size = wxDefaultSize,
204 long style = 0);
205
206 bool AddPage(wxWindow* page,
207 const wxString& caption,
208 bool select = false,
209 const wxBitmap& bitmap = wxNullBitmap);
210
211 bool InsertPage(size_t page_idx,
212 wxWindow* page,
213 const wxString& caption,
214 bool select = false,
215 const wxBitmap& bitmap = wxNullBitmap);
216
217 bool DeletePage(size_t page);
218 bool RemovePage(size_t page);
219
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;
225
226 protected:
227
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();
233
234 protected:
235
236 void DoSizing();
237 void InitNotebook();
238
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);
248
249 protected:
250
251 wxFrameManager m_mgr;
252 wxAuiTabContainer m_tabs;
253 int m_curpage;
254 int m_tab_id_counter;
255 wxWindow* m_dummy_wnd;
256
257 wxFont m_selected_font;
258 wxFont m_normal_font;
259 int m_tab_ctrl_height;
260
261 #ifndef SWIG
262 DECLARE_EVENT_TABLE()
263 #endif
264 };
265
266
267
268
269 // wx event machinery
270
271 #ifndef SWIG
272
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()
281
282 typedef void (wxEvtHandler::*wxAuiNotebookEventFunction)(wxAuiNotebookEvent&);
283
284 #define wxAuiNotebookEventHandler(func) \
285 (wxObjectEventFunction)(wxEventFunction)wxStaticCastEvent(wxAuiNotebookEventFunction, &func)
286
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))
299
300 #else
301
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;
309
310 %pythoncode {
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 )
317 }
318 #endif
319
320
321 #endif // wxUSE_AUI
322 #endif // _WX_AUINOTEBOOK_H_