]>
Commit | Line | Data |
---|---|---|
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 | // tab art class | |
31 | ||
32 | ||
33 | class WXDLLIMPEXP_AUI wxTabArt | |
34 | { | |
35 | public: | |
36 | ||
37 | wxTabArt() { } | |
38 | virtual ~wxTabArt() { } | |
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; | |
43 | ||
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; | |
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; | |
69 | ||
70 | virtual int GetBestTabCtrlSize(wxWindow* wnd) = 0; | |
71 | }; | |
72 | ||
73 | ||
74 | class WXDLLIMPEXP_AUI wxDefaultTabArt : public wxTabArt | |
75 | { | |
76 | ||
77 | public: | |
78 | ||
79 | wxDefaultTabArt(); | |
80 | virtual ~wxDefaultTabArt(); | |
81 | ||
82 | void SetNormalFont(const wxFont& font); | |
83 | void SetSelectedFont(const wxFont& font); | |
84 | void SetMeasuringFont(const wxFont& font); | |
85 | ||
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); | |
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); | |
111 | ||
112 | int GetBestTabCtrlSize(wxWindow* wnd); | |
113 | ||
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; | |
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; | |
130 | }; | |
131 | ||
132 | ||
133 | ||
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; m_commandInt = s; } | |
154 | void SetOldSelection(int s) { old_selection = s; } | |
155 | int GetSelection() const { return selection; } | |
156 | int GetOldSelection() const { return old_selection; } | |
157 | ||
158 | public: | |
159 | int old_selection; | |
160 | int selection; | |
161 | ||
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 | |
186 | int cur_state; // current state (normal, hover, pressed, etc.) | |
187 | int location; // buttons location (wxLEFT or wxRIGHT) | |
188 | wxBitmap bitmap; // button's hover bitmap | |
189 | wxBitmap dis_bitmap; // button's disabled bitmap | |
190 | wxRect rect; // button's hit rectangle | |
191 | }; | |
192 | ||
193 | ||
194 | #ifndef SWIG | |
195 | WX_DECLARE_USER_EXPORTED_OBJARRAY(wxAuiNotebookPage, wxAuiNotebookPageArray, WXDLLIMPEXP_AUI); | |
196 | WX_DECLARE_USER_EXPORTED_OBJARRAY(wxAuiTabContainerButton, wxAuiTabContainerButtonArray, WXDLLIMPEXP_AUI); | |
197 | #endif | |
198 | ||
199 | ||
200 | class WXDLLIMPEXP_AUI wxAuiTabContainer | |
201 | { | |
202 | public: | |
203 | ||
204 | wxAuiTabContainer(); | |
205 | virtual ~wxAuiTabContainer(); | |
206 | ||
207 | void SetArtProvider(wxTabArt* art); | |
208 | wxTabArt* GetArtProvider(); | |
209 | ||
210 | bool AddPage(wxWindow* page, const wxAuiNotebookPage& info); | |
211 | bool InsertPage(wxWindow* page, const wxAuiNotebookPage& info, size_t idx); | |
212 | bool MovePage(wxWindow* page, size_t new_idx); | |
213 | bool RemovePage(wxWindow* page); | |
214 | bool SetActivePage(wxWindow* page); | |
215 | bool SetActivePage(size_t page); | |
216 | void SetNoneActive(); | |
217 | int GetActivePage() const; | |
218 | bool TabHitTest(int x, int y, wxWindow** hit) const; | |
219 | bool ButtonHitTest(int x, int y, wxAuiTabContainerButton** hit) const; | |
220 | wxWindow* GetWindowFromIdx(size_t idx) const; | |
221 | int GetIdxFromWindow(wxWindow* page) const; | |
222 | size_t GetPageCount() const; | |
223 | wxAuiNotebookPage& GetPage(size_t idx); | |
224 | wxAuiNotebookPageArray& GetPages(); | |
225 | void SetNormalFont(const wxFont& normal_font); | |
226 | void SetSelectedFont(const wxFont& selected_font); | |
227 | void SetMeasuringFont(const wxFont& measuring_font); | |
228 | void DoShowHide(); | |
229 | void SetRect(const wxRect& rect); | |
230 | void AddButton(int id, | |
231 | int location, | |
232 | const wxBitmap& normal_bitmap = wxNullBitmap, | |
233 | const wxBitmap& disabled_bitmap = wxNullBitmap); | |
234 | ||
235 | size_t GetTabOffset() const; | |
236 | void SetTabOffset(size_t offset); | |
237 | ||
238 | protected: | |
239 | ||
240 | virtual void Render(wxDC* dc); | |
241 | ||
242 | private: | |
243 | ||
244 | wxTabArt* m_art; | |
245 | wxAuiNotebookPageArray m_pages; | |
246 | wxAuiTabContainerButtonArray m_buttons; | |
247 | wxRect m_rect; | |
248 | size_t m_tab_offset; | |
249 | }; | |
250 | ||
251 | ||
252 | ||
253 | class WXDLLIMPEXP_AUI wxAuiTabCtrl : public wxControl, | |
254 | public wxAuiTabContainer | |
255 | { | |
256 | public: | |
257 | ||
258 | wxAuiTabCtrl(wxWindow* parent, | |
259 | wxWindowID id = wxID_ANY, | |
260 | const wxPoint& pos = wxDefaultPosition, | |
261 | const wxSize& size = wxDefaultSize, | |
262 | long style = 0); | |
263 | ||
264 | ~wxAuiTabCtrl(); | |
265 | ||
266 | protected: | |
267 | ||
268 | void OnPaint(wxPaintEvent& evt); | |
269 | void OnEraseBackground(wxEraseEvent& evt); | |
270 | void OnSize(wxSizeEvent& evt); | |
271 | void OnLeftDown(wxMouseEvent& evt); | |
272 | void OnLeftUp(wxMouseEvent& evt); | |
273 | void OnMotion(wxMouseEvent& evt); | |
274 | void OnLeaveWindow(wxMouseEvent& evt); | |
275 | void OnButton(wxAuiNotebookEvent& evt); | |
276 | ||
277 | ||
278 | protected: | |
279 | ||
280 | wxPoint m_click_pt; | |
281 | wxWindow* m_click_tab; | |
282 | bool m_is_dragging; | |
283 | wxAuiTabContainerButton* m_hover_button; | |
284 | ||
285 | #ifndef SWIG | |
286 | DECLARE_EVENT_TABLE() | |
287 | #endif | |
288 | }; | |
289 | ||
290 | ||
291 | ||
292 | ||
293 | class WXDLLIMPEXP_AUI wxAuiMultiNotebook : public wxControl | |
294 | { | |
295 | ||
296 | public: | |
297 | ||
298 | wxAuiMultiNotebook(); | |
299 | ||
300 | wxAuiMultiNotebook(wxWindow* parent, | |
301 | wxWindowID id = wxID_ANY, | |
302 | const wxPoint& pos = wxDefaultPosition, | |
303 | const wxSize& size = wxDefaultSize, | |
304 | long style = 0); | |
305 | ||
306 | virtual ~wxAuiMultiNotebook(); | |
307 | ||
308 | bool Create(wxWindow* parent, | |
309 | wxWindowID id = wxID_ANY, | |
310 | const wxPoint& pos = wxDefaultPosition, | |
311 | const wxSize& size = wxDefaultSize, | |
312 | long style = 0); | |
313 | ||
314 | bool AddPage(wxWindow* page, | |
315 | const wxString& caption, | |
316 | bool select = false, | |
317 | const wxBitmap& bitmap = wxNullBitmap); | |
318 | ||
319 | bool InsertPage(size_t page_idx, | |
320 | wxWindow* page, | |
321 | const wxString& caption, | |
322 | bool select = false, | |
323 | const wxBitmap& bitmap = wxNullBitmap); | |
324 | ||
325 | bool DeletePage(size_t page); | |
326 | bool RemovePage(size_t page); | |
327 | ||
328 | bool SetPageText(size_t page, const wxString& text); | |
329 | size_t SetSelection(size_t new_page); | |
330 | int GetSelection() const; | |
331 | size_t GetPageCount() const; | |
332 | wxWindow* GetPage(size_t page_idx) const; | |
333 | ||
334 | void SetArtProvider(wxTabArt* art); | |
335 | wxTabArt* GetArtProvider(); | |
336 | ||
337 | protected: | |
338 | ||
339 | wxAuiTabCtrl* GetTabCtrlFromPoint(const wxPoint& pt); | |
340 | wxWindow* GetTabFrameFromTabCtrl(wxWindow* tab_ctrl); | |
341 | wxAuiTabCtrl* GetActiveTabCtrl(); | |
342 | bool FindTab(wxWindow* page, wxAuiTabCtrl** ctrl, int* idx); | |
343 | void RemoveEmptyTabFrames(); | |
344 | ||
345 | protected: | |
346 | ||
347 | void DoSizing(); | |
348 | void InitNotebook(); | |
349 | ||
350 | void OnChildFocus(wxChildFocusEvent& evt); | |
351 | void OnRender(wxFrameManagerEvent& evt); | |
352 | void OnEraseBackground(wxEraseEvent& evt); | |
353 | void OnSize(wxSizeEvent& evt); | |
354 | void OnTabClicked(wxCommandEvent& evt); | |
355 | void OnTabBeginDrag(wxCommandEvent& evt); | |
356 | void OnTabDragMotion(wxCommandEvent& evt); | |
357 | void OnTabEndDrag(wxCommandEvent& evt); | |
358 | void OnTabButton(wxCommandEvent& evt); | |
359 | ||
360 | protected: | |
361 | ||
362 | wxFrameManager m_mgr; | |
363 | wxAuiTabContainer m_tabs; | |
364 | int m_curpage; | |
365 | int m_tab_id_counter; | |
366 | wxWindow* m_dummy_wnd; | |
367 | ||
368 | wxFont m_selected_font; | |
369 | wxFont m_normal_font; | |
370 | int m_tab_ctrl_height; | |
371 | ||
372 | int m_last_drag_x; | |
373 | ||
374 | #ifndef SWIG | |
375 | DECLARE_EVENT_TABLE() | |
376 | #endif | |
377 | }; | |
378 | ||
379 | ||
380 | ||
381 | ||
382 | // wx event machinery | |
383 | ||
384 | #ifndef SWIG | |
385 | ||
386 | BEGIN_DECLARE_EVENT_TYPES() | |
387 | DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_AUI, wxEVT_COMMAND_AUINOTEBOOK_PAGE_CHANGED, 0) | |
388 | DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_AUI, wxEVT_COMMAND_AUINOTEBOOK_PAGE_CHANGING, 0) | |
389 | DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_AUI, wxEVT_COMMAND_AUINOTEBOOK_BUTTON, 0) | |
390 | DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_AUI, wxEVT_COMMAND_AUINOTEBOOK_BEGIN_DRAG, 0) | |
391 | DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_AUI, wxEVT_COMMAND_AUINOTEBOOK_END_DRAG, 0) | |
392 | DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_AUI, wxEVT_COMMAND_AUINOTEBOOK_DRAG_MOTION, 0) | |
393 | END_DECLARE_EVENT_TYPES() | |
394 | ||
395 | typedef void (wxEvtHandler::*wxAuiNotebookEventFunction)(wxAuiNotebookEvent&); | |
396 | ||
397 | #define wxAuiNotebookEventHandler(func) \ | |
398 | (wxObjectEventFunction)(wxEventFunction)wxStaticCastEvent(wxAuiNotebookEventFunction, &func) | |
399 | ||
400 | #define EVT_AUINOTEBOOK_PAGE_CHANGED(winid, fn) \ | |
401 | wx__DECLARE_EVT1(wxEVT_COMMAND_AUINOTEBOOK_PAGE_CHANGED, winid, wxAuiNotebookEventHandler(fn)) | |
402 | #define EVT_AUINOTEBOOK_PAGE_CHANGING(winid, fn) \ | |
403 | wx__DECLARE_EVT1(wxEVT_COMMAND_AUINOTEBOOK_PAGE_CHANGING, winid, wxAuiNotebookEventHandler(fn)) | |
404 | #define EVT_AUINOTEBOOK_BUTTON(winid, fn) \ | |
405 | wx__DECLARE_EVT1(wxEVT_COMMAND_AUINOTEBOOK_BUTTON, winid, wxAuiNotebookEventHandler(fn)) | |
406 | #define EVT_AUINOTEBOOK_BEGIN_DRAG(winid, fn) \ | |
407 | wx__DECLARE_EVT1(wxEVT_COMMAND_AUINOTEBOOK_BEGIN_DRAG, winid, wxAuiNotebookEventHandler(fn)) | |
408 | #define EVT_AUINOTEBOOK_END_DRAG(winid, fn) \ | |
409 | wx__DECLARE_EVT1(wxEVT_COMMAND_AUINOTEBOOK_END_DRAG, winid, wxAuiNotebookEventHandler(fn)) | |
410 | #define EVT_AUINOTEBOOK_DRAG_MOTION(winid, fn) \ | |
411 | wx__DECLARE_EVT1(wxEVT_COMMAND_AUINOTEBOOK_DRAG_MOTION, winid, wxAuiNotebookEventHandler(fn)) | |
412 | ||
413 | #else | |
414 | ||
415 | // wxpython/swig event work | |
416 | %constant wxEventType wxEVT_COMMAND_AUINOTEBOOK_PAGE_CHANGED; | |
417 | %constant wxEventType wxEVT_COMMAND_AUINOTEBOOK_PAGE_CHANGING; | |
418 | %constant wxEventType wxEVT_COMMAND_AUINOTEBOOK_BUTTON; | |
419 | %constant wxEventType wxEVT_COMMAND_AUINOTEBOOK_BEGIN_DRAG; | |
420 | %constant wxEventType wxEVT_COMMAND_AUINOTEBOOK_END_DRAG; | |
421 | %constant wxEventType wxEVT_COMMAND_AUINOTEBOOK_DRAG_MOTION; | |
422 | ||
423 | %pythoncode { | |
424 | EVT_AUINOTEBOOK_PAGE_CHANGED = wx.PyEventBinder( wxEVT_COMMAND_AUINOTEBOOK_PAGE_CHANGED, 1 ) | |
425 | EVT_AUINOTEBOOK_PAGE_CHANGING = wx.PyEventBinder( wxEVT_COMMAND_AUINOTEBOOK_PAGE_CHANGING, 1 ) | |
426 | EVT_AUINOTEBOOK_BUTTON = wx.PyEventBinder( wxEVT_COMMAND_AUINOTEBOOK_BUTTON, 1 ) | |
427 | EVT_AUINOTEBOOK_BEGIN_DRAG = wx.PyEventBinder( wxEVT_COMMAND_AUINOTEBOOK_BEGIN_DRAG, 1 ) | |
428 | EVT_AUINOTEBOOK_END_DRAG = wx.PyEventBinder( wxEVT_COMMAND_AUINOTEBOOK_END_DRAG, 1 ) | |
429 | EVT_AUINOTEBOOK_DRAG_MOTION = wx.PyEventBinder( wxEVT_COMMAND_AUINOTEBOOK_DRAG_MOTION, 1 ) | |
430 | } | |
431 | #endif | |
432 | ||
433 | ||
434 | #endif // wxUSE_AUI | |
435 | #endif // _WX_AUINOTEBOOK_H_ |