]>
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 | ||
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; } | |
4444d148 | 53 | |
a3219eea BW |
54 | public: |
55 | int old_selection; | |
56 | int selection; | |
4444d148 | 57 | |
a3219eea BW |
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 | ||
d91fa282 | 88 | #ifndef SWIG |
a3219eea BW |
89 | WX_DECLARE_USER_EXPORTED_OBJARRAY(wxAuiNotebookPage, wxAuiNotebookPageArray, WXDLLIMPEXP_AUI); |
90 | WX_DECLARE_USER_EXPORTED_OBJARRAY(wxAuiTabContainerButton, wxAuiTabContainerButtonArray, WXDLLIMPEXP_AUI); | |
d91fa282 | 91 | #endif |
a3219eea BW |
92 | |
93 | ||
94 | class WXDLLIMPEXP_AUI wxAuiTabContainer | |
95 | { | |
96 | public: | |
97 | ||
98 | wxAuiTabContainer(); | |
9fabaac4 | 99 | virtual ~wxAuiTabContainer(); |
a3219eea BW |
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); | |
4444d148 | 121 | |
a3219eea BW |
122 | protected: |
123 | ||
4444d148 | 124 | virtual void Render(wxDC* dc); |
a3219eea BW |
125 | |
126 | virtual void DrawTab(wxDC* dc, | |
127 | const wxRect& in_rect, | |
128 | const wxString& caption, | |
129 | bool active, | |
130 | wxRect* out_rect, | |
4444d148 | 131 | int* x_extent); |
a3219eea BW |
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, | |
d91fa282 | 155 | wxWindowID id = wxID_ANY, |
a3219eea BW |
156 | const wxPoint& pos = wxDefaultPosition, |
157 | const wxSize& size = wxDefaultSize, | |
158 | long style = 0); | |
4444d148 | 159 | |
a3219eea BW |
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); | |
4444d148 | 169 | |
a3219eea | 170 | protected: |
4444d148 | 171 | |
a3219eea BW |
172 | wxPoint m_click_pt; |
173 | int m_click_tab; | |
174 | bool m_is_dragging; | |
175 | wxAuiTabContainerButton* m_hover_button; | |
176 | ||
d91fa282 | 177 | #ifndef SWIG |
a3219eea | 178 | DECLARE_EVENT_TABLE() |
d91fa282 | 179 | #endif |
a3219eea BW |
180 | }; |
181 | ||
182 | ||
183 | ||
184 | ||
185 | class WXDLLIMPEXP_AUI wxAuiMultiNotebook : public wxControl | |
186 | { | |
187 | ||
188 | public: | |
189 | ||
190 | wxAuiMultiNotebook(); | |
4444d148 | 191 | |
a3219eea | 192 | wxAuiMultiNotebook(wxWindow* parent, |
d91fa282 | 193 | wxWindowID id = wxID_ANY, |
a3219eea BW |
194 | const wxPoint& pos = wxDefaultPosition, |
195 | const wxSize& size = wxDefaultSize, | |
196 | long style = 0); | |
4444d148 | 197 | |
a3219eea BW |
198 | virtual ~wxAuiMultiNotebook(); |
199 | ||
200 | bool Create(wxWindow* parent, | |
d91fa282 | 201 | wxWindowID id = wxID_ANY, |
a3219eea BW |
202 | const wxPoint& pos = wxDefaultPosition, |
203 | const wxSize& size = wxDefaultSize, | |
4444d148 | 204 | long style = 0); |
a3219eea BW |
205 | |
206 | bool AddPage(wxWindow* page, | |
207 | const wxString& caption, | |
208 | bool select = false, | |
209 | const wxBitmap& bitmap = wxNullBitmap); | |
4444d148 | 210 | |
a3219eea BW |
211 | bool InsertPage(size_t page_idx, |
212 | wxWindow* page, | |
213 | const wxString& caption, | |
214 | bool select = false, | |
215 | const wxBitmap& bitmap = wxNullBitmap); | |
4444d148 | 216 | |
a3219eea BW |
217 | bool DeletePage(size_t page); |
218 | bool RemovePage(size_t page); | |
4444d148 | 219 | |
a3219eea BW |
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; | |
4444d148 | 225 | |
a3219eea | 226 | protected: |
4444d148 | 227 | |
a3219eea BW |
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(); | |
4444d148 | 233 | |
a3219eea BW |
234 | protected: |
235 | ||
236 | void DoSizing(); | |
237 | void InitNotebook(); | |
4444d148 | 238 | |
a3219eea BW |
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; | |
4444d148 | 256 | |
a3219eea BW |
257 | wxFont m_selected_font; |
258 | wxFont m_normal_font; | |
da5e85d9 | 259 | int m_tab_ctrl_height; |
4444d148 | 260 | |
d91fa282 | 261 | #ifndef SWIG |
a3219eea | 262 | DECLARE_EVENT_TABLE() |
d91fa282 | 263 | #endif |
a3219eea BW |
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)) | |
4444d148 | 299 | |
a3219eea BW |
300 | #else |
301 | ||
302 | // wxpython/swig event work | |
d91fa282 RD |
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 ) | |
4444d148 | 316 | EVT_AUINOTEBOOK_DRAG_MOTION = wx.PyEventBinder( wxEVT_COMMAND_AUINOTEBOOK_DRAG_MOTION, 1 ) |
d91fa282 | 317 | } |
a3219eea BW |
318 | #endif |
319 | ||
320 | ||
321 | #endif // wxUSE_AUI | |
322 | #endif // _WX_AUINOTEBOOK_H_ |