]>
Commit | Line | Data |
---|---|---|
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" | |
4107600f | 27 | #include "wx/control.h" |
a3219eea BW |
28 | |
29 | ||
3f69756e BW |
30 | // tab art class |
31 | ||
32 | ||
0b13400f | 33 | class WXDLLIMPEXP_AUI wxTabArt |
3f69756e BW |
34 | { |
35 | public: | |
36 | ||
488e50ee BW |
37 | wxTabArt() { } |
38 | virtual ~wxTabArt() { } | |
a4c8fc23 BW |
39 | |
40 | virtual void SetNormalFont(const wxFont& font) = 0; | |
41 | virtual void SetSelectedFont(const wxFont& font) = 0; | |
42 | virtual void SetMeasuringFont(const wxFont& font) = 0; | |
488e50ee | 43 | |
3f69756e BW |
44 | virtual void DrawBackground( |
45 | wxDC* dc, | |
46 | const wxRect& rect) = 0; | |
47 | ||
48 | virtual void DrawTab(wxDC* dc, | |
49 | const wxRect& in_rect, | |
50 | const wxString& caption, | |
51 | bool active, | |
52 | wxRect* out_rect, | |
53 | int* x_extent) = 0; | |
4953f8cf BW |
54 | |
55 | virtual void DrawButton( | |
56 | wxDC* dc, | |
57 | const wxRect& in_rect, | |
58 | int bitmap_id, | |
59 | int button_state, | |
60 | int orientation, | |
61 | const wxBitmap& bitmap_override, | |
62 | wxRect* out_rect) = 0; | |
63 | ||
64 | virtual wxSize GetTabSize( | |
65 | wxDC* dc, | |
66 | const wxString& caption, | |
67 | bool active, | |
68 | int* x_extent) = 0; | |
a4c8fc23 BW |
69 | |
70 | virtual int GetBestTabCtrlSize(wxWindow* wnd) = 0; | |
3f69756e BW |
71 | }; |
72 | ||
73 | ||
0b13400f | 74 | class WXDLLIMPEXP_AUI wxDefaultTabArt : public wxTabArt |
3f69756e BW |
75 | { |
76 | ||
77 | public: | |
78 | ||
79 | wxDefaultTabArt(); | |
488e50ee | 80 | virtual ~wxDefaultTabArt(); |
3f69756e | 81 | |
a4c8fc23 BW |
82 | void SetNormalFont(const wxFont& font); |
83 | void SetSelectedFont(const wxFont& font); | |
84 | void SetMeasuringFont(const wxFont& font); | |
85 | ||
3f69756e BW |
86 | void DrawBackground( |
87 | wxDC* dc, | |
88 | const wxRect& rect); | |
89 | ||
90 | void DrawTab(wxDC* dc, | |
91 | const wxRect& in_rect, | |
92 | const wxString& caption, | |
93 | bool active, | |
94 | wxRect* out_rect, | |
95 | int* x_extent); | |
4953f8cf BW |
96 | |
97 | void DrawButton( | |
98 | wxDC* dc, | |
99 | const wxRect& in_rect, | |
100 | int bitmap_id, | |
101 | int button_state, | |
102 | int orientation, | |
103 | const wxBitmap& bitmap_override, | |
104 | wxRect* out_rect); | |
105 | ||
106 | wxSize GetTabSize( | |
107 | wxDC* dc, | |
108 | const wxString& caption, | |
109 | bool active, | |
110 | int* x_extent); | |
a4c8fc23 BW |
111 | |
112 | int GetBestTabCtrlSize(wxWindow* wnd); | |
113 | ||
3f69756e BW |
114 | private: |
115 | ||
116 | wxFont m_normal_font; | |
117 | wxFont m_selected_font; | |
118 | wxFont m_measuring_font; | |
119 | wxPen m_normal_bkpen; | |
120 | wxPen m_selected_bkpen; | |
121 | wxBrush m_normal_bkbrush; | |
122 | wxBrush m_selected_bkbrush; | |
123 | wxBrush m_bkbrush; | |
4953f8cf BW |
124 | wxBitmap m_active_close_bmp; |
125 | wxBitmap m_disabled_close_bmp; | |
126 | wxBitmap m_active_left_bmp; | |
127 | wxBitmap m_disabled_left_bmp; | |
128 | wxBitmap m_active_right_bmp; | |
129 | wxBitmap m_disabled_right_bmp; | |
3f69756e BW |
130 | }; |
131 | ||
132 | ||
133 | ||
a3219eea BW |
134 | // event declarations/classes |
135 | ||
136 | class WXDLLIMPEXP_AUI wxAuiNotebookEvent : public wxNotifyEvent | |
137 | { | |
138 | public: | |
139 | wxAuiNotebookEvent(wxEventType command_type = wxEVT_NULL, | |
140 | int win_id = 0) | |
141 | : wxNotifyEvent(command_type, win_id) | |
142 | { | |
143 | } | |
144 | #ifndef SWIG | |
145 | wxAuiNotebookEvent(const wxAuiNotebookEvent& c) : wxNotifyEvent(c) | |
146 | { | |
147 | old_selection = c.old_selection; | |
148 | selection = c.selection; | |
149 | } | |
150 | #endif | |
151 | wxEvent *Clone() const { return new wxAuiNotebookEvent(*this); } | |
152 | ||
153 | void SetSelection(int s) { selection = s; } | |
154 | void SetOldSelection(int s) { old_selection = s; } | |
155 | int GetSelection() const { return selection; } | |
156 | int GetOldSelection() const { return old_selection; } | |
4444d148 | 157 | |
a3219eea BW |
158 | public: |
159 | int old_selection; | |
160 | int selection; | |
4444d148 | 161 | |
a3219eea BW |
162 | #ifndef SWIG |
163 | private: | |
164 | DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxAuiNotebookEvent) | |
165 | #endif | |
166 | }; | |
167 | ||
168 | ||
169 | ||
170 | ||
171 | ||
172 | class WXDLLIMPEXP_AUI wxAuiNotebookPage | |
173 | { | |
174 | public: | |
175 | wxWindow* window; // page's associated window | |
176 | wxString caption; // caption displayed on the tab | |
177 | wxBitmap bitmap; // tab's bitmap | |
178 | wxRect rect; // tab's hit rectangle | |
179 | bool active; // true if the page is currently active | |
180 | }; | |
181 | ||
182 | class WXDLLIMPEXP_AUI wxAuiTabContainerButton | |
183 | { | |
184 | public: | |
185 | int id; // button's id | |
4953f8cf | 186 | int cur_state; // current state (normal, hover, pressed, etc.) |
b6418695 | 187 | int location; // buttons location (wxLEFT or wxRIGHT) |
4953f8cf BW |
188 | wxBitmap bitmap; // button's hover bitmap |
189 | wxBitmap dis_bitmap; // button's disabled bitmap | |
a3219eea BW |
190 | wxRect rect; // button's hit rectangle |
191 | }; | |
192 | ||
193 | ||
d91fa282 | 194 | #ifndef SWIG |
a3219eea BW |
195 | WX_DECLARE_USER_EXPORTED_OBJARRAY(wxAuiNotebookPage, wxAuiNotebookPageArray, WXDLLIMPEXP_AUI); |
196 | WX_DECLARE_USER_EXPORTED_OBJARRAY(wxAuiTabContainerButton, wxAuiTabContainerButtonArray, WXDLLIMPEXP_AUI); | |
d91fa282 | 197 | #endif |
a3219eea BW |
198 | |
199 | ||
200 | class WXDLLIMPEXP_AUI wxAuiTabContainer | |
201 | { | |
202 | public: | |
203 | ||
204 | wxAuiTabContainer(); | |
9fabaac4 | 205 | virtual ~wxAuiTabContainer(); |
a3219eea | 206 | |
3f69756e BW |
207 | void SetArtProvider(wxTabArt* art); |
208 | wxTabArt* GetArtProvider(); | |
209 | ||
a3219eea BW |
210 | bool AddPage(wxWindow* page, const wxAuiNotebookPage& info); |
211 | bool InsertPage(wxWindow* page, const wxAuiNotebookPage& info, size_t idx); | |
212 | bool RemovePage(wxWindow* page); | |
213 | bool SetActivePage(wxWindow* page); | |
214 | bool SetActivePage(size_t page); | |
215 | void SetNoneActive(); | |
216 | int GetActivePage() const; | |
217 | bool TabHitTest(int x, int y, wxWindow** hit) const; | |
218 | bool ButtonHitTest(int x, int y, wxAuiTabContainerButton** hit) const; | |
219 | wxWindow* GetWindowFromIdx(size_t idx) const; | |
220 | int GetIdxFromWindow(wxWindow* page) const; | |
221 | size_t GetPageCount() const; | |
222 | wxAuiNotebookPage& GetPage(size_t idx); | |
223 | wxAuiNotebookPageArray& GetPages(); | |
224 | void SetNormalFont(const wxFont& normal_font); | |
225 | void SetSelectedFont(const wxFont& selected_font); | |
226 | void SetMeasuringFont(const wxFont& measuring_font); | |
227 | void DoShowHide(); | |
228 | void SetRect(const wxRect& rect); | |
4953f8cf BW |
229 | void AddButton(int id, |
230 | int location, | |
231 | const wxBitmap& normal_bitmap = wxNullBitmap, | |
232 | const wxBitmap& disabled_bitmap = wxNullBitmap); | |
4444d148 | 233 | |
4953f8cf BW |
234 | size_t GetTabOffset() const; |
235 | void SetTabOffset(size_t offset); | |
236 | ||
a3219eea BW |
237 | protected: |
238 | ||
4444d148 | 239 | virtual void Render(wxDC* dc); |
a3219eea | 240 | |
a3219eea BW |
241 | private: |
242 | ||
3f69756e | 243 | wxTabArt* m_art; |
a3219eea BW |
244 | wxAuiNotebookPageArray m_pages; |
245 | wxAuiTabContainerButtonArray m_buttons; | |
246 | wxRect m_rect; | |
4953f8cf | 247 | size_t m_tab_offset; |
a3219eea BW |
248 | }; |
249 | ||
250 | ||
251 | ||
252 | class WXDLLIMPEXP_AUI wxAuiTabCtrl : public wxControl, | |
253 | public wxAuiTabContainer | |
254 | { | |
255 | public: | |
256 | ||
257 | wxAuiTabCtrl(wxWindow* parent, | |
d91fa282 | 258 | wxWindowID id = wxID_ANY, |
a3219eea BW |
259 | const wxPoint& pos = wxDefaultPosition, |
260 | const wxSize& size = wxDefaultSize, | |
261 | long style = 0); | |
4444d148 | 262 | |
a3219eea BW |
263 | protected: |
264 | ||
265 | void OnPaint(wxPaintEvent& evt); | |
266 | void OnEraseBackground(wxEraseEvent& evt); | |
267 | void OnSize(wxSizeEvent& evt); | |
268 | void OnLeftDown(wxMouseEvent& evt); | |
269 | void OnLeftUp(wxMouseEvent& evt); | |
270 | void OnMotion(wxMouseEvent& evt); | |
271 | void OnLeaveWindow(wxMouseEvent& evt); | |
4953f8cf | 272 | void OnButton(wxAuiNotebookEvent& evt); |
4444d148 | 273 | |
4953f8cf | 274 | |
a3219eea | 275 | protected: |
4444d148 | 276 | |
a3219eea BW |
277 | wxPoint m_click_pt; |
278 | int m_click_tab; | |
279 | bool m_is_dragging; | |
280 | wxAuiTabContainerButton* m_hover_button; | |
281 | ||
d91fa282 | 282 | #ifndef SWIG |
a3219eea | 283 | DECLARE_EVENT_TABLE() |
d91fa282 | 284 | #endif |
a3219eea BW |
285 | }; |
286 | ||
287 | ||
288 | ||
289 | ||
290 | class WXDLLIMPEXP_AUI wxAuiMultiNotebook : public wxControl | |
291 | { | |
292 | ||
293 | public: | |
294 | ||
295 | wxAuiMultiNotebook(); | |
4444d148 | 296 | |
a3219eea | 297 | wxAuiMultiNotebook(wxWindow* parent, |
d91fa282 | 298 | wxWindowID id = wxID_ANY, |
a3219eea BW |
299 | const wxPoint& pos = wxDefaultPosition, |
300 | const wxSize& size = wxDefaultSize, | |
301 | long style = 0); | |
4444d148 | 302 | |
a3219eea BW |
303 | virtual ~wxAuiMultiNotebook(); |
304 | ||
305 | bool Create(wxWindow* parent, | |
d91fa282 | 306 | wxWindowID id = wxID_ANY, |
a3219eea BW |
307 | const wxPoint& pos = wxDefaultPosition, |
308 | const wxSize& size = wxDefaultSize, | |
4444d148 | 309 | long style = 0); |
a3219eea BW |
310 | |
311 | bool AddPage(wxWindow* page, | |
312 | const wxString& caption, | |
313 | bool select = false, | |
314 | const wxBitmap& bitmap = wxNullBitmap); | |
4444d148 | 315 | |
a3219eea BW |
316 | bool InsertPage(size_t page_idx, |
317 | wxWindow* page, | |
318 | const wxString& caption, | |
319 | bool select = false, | |
320 | const wxBitmap& bitmap = wxNullBitmap); | |
4444d148 | 321 | |
a3219eea BW |
322 | bool DeletePage(size_t page); |
323 | bool RemovePage(size_t page); | |
4444d148 | 324 | |
a3219eea BW |
325 | bool SetPageText(size_t page, const wxString& text); |
326 | size_t SetSelection(size_t new_page); | |
327 | int GetSelection() const; | |
328 | size_t GetPageCount() const; | |
329 | wxWindow* GetPage(size_t page_idx) const; | |
4444d148 | 330 | |
3f69756e BW |
331 | void SetArtProvider(wxTabArt* art); |
332 | wxTabArt* GetArtProvider(); | |
333 | ||
a3219eea | 334 | protected: |
4444d148 | 335 | |
a3219eea BW |
336 | wxAuiTabCtrl* GetTabCtrlFromPoint(const wxPoint& pt); |
337 | wxWindow* GetTabFrameFromTabCtrl(wxWindow* tab_ctrl); | |
338 | wxAuiTabCtrl* GetActiveTabCtrl(); | |
339 | bool FindTab(wxWindow* page, wxAuiTabCtrl** ctrl, int* idx); | |
340 | void RemoveEmptyTabFrames(); | |
4444d148 | 341 | |
a3219eea BW |
342 | protected: |
343 | ||
344 | void DoSizing(); | |
345 | void InitNotebook(); | |
4444d148 | 346 | |
a3219eea BW |
347 | void OnChildFocus(wxChildFocusEvent& evt); |
348 | void OnRender(wxFrameManagerEvent& evt); | |
349 | void OnEraseBackground(wxEraseEvent& evt); | |
350 | void OnSize(wxSizeEvent& evt); | |
351 | void OnTabClicked(wxCommandEvent& evt); | |
352 | void OnTabBeginDrag(wxCommandEvent& evt); | |
353 | void OnTabDragMotion(wxCommandEvent& evt); | |
354 | void OnTabEndDrag(wxCommandEvent& evt); | |
355 | void OnTabButton(wxCommandEvent& evt); | |
4953f8cf | 356 | |
a3219eea BW |
357 | protected: |
358 | ||
359 | wxFrameManager m_mgr; | |
360 | wxAuiTabContainer m_tabs; | |
361 | int m_curpage; | |
362 | int m_tab_id_counter; | |
363 | wxWindow* m_dummy_wnd; | |
4444d148 | 364 | |
a3219eea BW |
365 | wxFont m_selected_font; |
366 | wxFont m_normal_font; | |
da5e85d9 | 367 | int m_tab_ctrl_height; |
4444d148 | 368 | |
d91fa282 | 369 | #ifndef SWIG |
a3219eea | 370 | DECLARE_EVENT_TABLE() |
d91fa282 | 371 | #endif |
a3219eea BW |
372 | }; |
373 | ||
374 | ||
375 | ||
376 | ||
377 | // wx event machinery | |
378 | ||
379 | #ifndef SWIG | |
380 | ||
381 | BEGIN_DECLARE_EVENT_TYPES() | |
382 | DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_AUI, wxEVT_COMMAND_AUINOTEBOOK_PAGE_CHANGED, 0) | |
383 | DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_AUI, wxEVT_COMMAND_AUINOTEBOOK_PAGE_CHANGING, 0) | |
384 | DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_AUI, wxEVT_COMMAND_AUINOTEBOOK_BUTTON, 0) | |
385 | DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_AUI, wxEVT_COMMAND_AUINOTEBOOK_BEGIN_DRAG, 0) | |
386 | DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_AUI, wxEVT_COMMAND_AUINOTEBOOK_END_DRAG, 0) | |
387 | DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_AUI, wxEVT_COMMAND_AUINOTEBOOK_DRAG_MOTION, 0) | |
388 | END_DECLARE_EVENT_TYPES() | |
389 | ||
390 | typedef void (wxEvtHandler::*wxAuiNotebookEventFunction)(wxAuiNotebookEvent&); | |
391 | ||
392 | #define wxAuiNotebookEventHandler(func) \ | |
393 | (wxObjectEventFunction)(wxEventFunction)wxStaticCastEvent(wxAuiNotebookEventFunction, &func) | |
394 | ||
395 | #define EVT_AUINOTEBOOK_PAGE_CHANGED(winid, fn) \ | |
396 | wx__DECLARE_EVT1(wxEVT_COMMAND_AUINOTEBOOK_PAGE_CHANGED, winid, wxAuiNotebookEventHandler(fn)) | |
397 | #define EVT_AUINOTEBOOK_PAGE_CHANGING(winid, fn) \ | |
398 | wx__DECLARE_EVT1(wxEVT_COMMAND_AUINOTEBOOK_PAGE_CHANGING, winid, wxAuiNotebookEventHandler(fn)) | |
4953f8cf | 399 | #define EVT_AUINOTEBOOK_BUTTON(winid, fn) \ |
a3219eea BW |
400 | wx__DECLARE_EVT1(wxEVT_COMMAND_AUINOTEBOOK_BUTTON, winid, wxAuiNotebookEventHandler(fn)) |
401 | #define EVT_AUINOTEBOOK_BEGIN_DRAG(winid, fn) \ | |
402 | wx__DECLARE_EVT1(wxEVT_COMMAND_AUINOTEBOOK_BEGIN_DRAG, winid, wxAuiNotebookEventHandler(fn)) | |
403 | #define EVT_AUINOTEBOOK_END_DRAG(winid, fn) \ | |
404 | wx__DECLARE_EVT1(wxEVT_COMMAND_AUINOTEBOOK_END_DRAG, winid, wxAuiNotebookEventHandler(fn)) | |
405 | #define EVT_AUINOTEBOOK_DRAG_MOTION(winid, fn) \ | |
406 | wx__DECLARE_EVT1(wxEVT_COMMAND_AUINOTEBOOK_DRAG_MOTION, winid, wxAuiNotebookEventHandler(fn)) | |
4444d148 | 407 | |
a3219eea BW |
408 | #else |
409 | ||
410 | // wxpython/swig event work | |
d91fa282 RD |
411 | %constant wxEventType wxEVT_COMMAND_AUINOTEBOOK_PAGE_CHANGED; |
412 | %constant wxEventType wxEVT_COMMAND_AUINOTEBOOK_PAGE_CHANGING; | |
413 | %constant wxEventType wxEVT_COMMAND_AUINOTEBOOK_BUTTON; | |
414 | %constant wxEventType wxEVT_COMMAND_AUINOTEBOOK_BEGIN_DRAG; | |
415 | %constant wxEventType wxEVT_COMMAND_AUINOTEBOOK_END_DRAG; | |
416 | %constant wxEventType wxEVT_COMMAND_AUINOTEBOOK_DRAG_MOTION; | |
417 | ||
418 | %pythoncode { | |
419 | EVT_AUINOTEBOOK_PAGE_CHANGED = wx.PyEventBinder( wxEVT_COMMAND_AUINOTEBOOK_PAGE_CHANGED, 1 ) | |
420 | EVT_AUINOTEBOOK_PAGE_CHANGING = wx.PyEventBinder( wxEVT_COMMAND_AUINOTEBOOK_PAGE_CHANGING, 1 ) | |
421 | EVT_AUINOTEBOOK_BUTTON = wx.PyEventBinder( wxEVT_COMMAND_AUINOTEBOOK_BUTTON, 1 ) | |
422 | EVT_AUINOTEBOOK_BEGIN_DRAG = wx.PyEventBinder( wxEVT_COMMAND_AUINOTEBOOK_BEGIN_DRAG, 1 ) | |
423 | EVT_AUINOTEBOOK_END_DRAG = wx.PyEventBinder( wxEVT_COMMAND_AUINOTEBOOK_END_DRAG, 1 ) | |
4444d148 | 424 | EVT_AUINOTEBOOK_DRAG_MOTION = wx.PyEventBinder( wxEVT_COMMAND_AUINOTEBOOK_DRAG_MOTION, 1 ) |
d91fa282 | 425 | } |
a3219eea BW |
426 | #endif |
427 | ||
428 | ||
429 | #endif // wxUSE_AUI | |
430 | #endif // _WX_AUINOTEBOOK_H_ |