]>
Commit | Line | Data |
---|---|---|
a3219eea BW |
1 | /////////////////////////////////////////////////////////////////////////////// |
2 | // Name: wx/aui/notebook.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 | #include "wx/aui/framemanager.h" | |
22 | #include "wx/aui/dockart.h" | |
23 | #include "wx/aui/floatpane.h" | |
24 | ||
25 | ||
26 | #if wxUSE_AUI | |
27 | ||
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 | WX_DECLARE_USER_EXPORTED_OBJARRAY(wxAuiNotebookPage, wxAuiNotebookPageArray, WXDLLIMPEXP_AUI); | |
89 | WX_DECLARE_USER_EXPORTED_OBJARRAY(wxAuiTabContainerButton, wxAuiTabContainerButtonArray, WXDLLIMPEXP_AUI); | |
90 | ||
91 | ||
92 | ||
93 | class WXDLLIMPEXP_AUI wxAuiTabContainer | |
94 | { | |
95 | public: | |
96 | ||
97 | wxAuiTabContainer(); | |
98 | ||
99 | bool AddPage(wxWindow* page, const wxAuiNotebookPage& info); | |
100 | bool InsertPage(wxWindow* page, const wxAuiNotebookPage& info, size_t idx); | |
101 | bool RemovePage(wxWindow* page); | |
102 | bool SetActivePage(wxWindow* page); | |
103 | bool SetActivePage(size_t page); | |
104 | void SetNoneActive(); | |
105 | int GetActivePage() const; | |
106 | bool TabHitTest(int x, int y, wxWindow** hit) const; | |
107 | bool ButtonHitTest(int x, int y, wxAuiTabContainerButton** hit) const; | |
108 | wxWindow* GetWindowFromIdx(size_t idx) const; | |
109 | int GetIdxFromWindow(wxWindow* page) const; | |
110 | size_t GetPageCount() const; | |
111 | wxAuiNotebookPage& GetPage(size_t idx); | |
112 | wxAuiNotebookPageArray& GetPages(); | |
113 | void SetNormalFont(const wxFont& normal_font); | |
114 | void SetSelectedFont(const wxFont& selected_font); | |
115 | void SetMeasuringFont(const wxFont& measuring_font); | |
116 | void DoShowHide(); | |
117 | void SetRect(const wxRect& rect); | |
118 | void AddButton(int id, const wxBitmap& bmp); | |
119 | ||
120 | protected: | |
121 | ||
122 | virtual void Render(wxDC* dc); | |
123 | ||
124 | virtual void DrawTab(wxDC* dc, | |
125 | const wxRect& in_rect, | |
126 | const wxString& caption, | |
127 | bool active, | |
128 | wxRect* out_rect, | |
129 | int* x_extent); | |
130 | private: | |
131 | ||
132 | wxAuiNotebookPageArray m_pages; | |
133 | wxAuiTabContainerButtonArray m_buttons; | |
134 | wxRect m_rect; | |
135 | wxFont m_normal_font; | |
136 | wxFont m_selected_font; | |
137 | wxFont m_measuring_font; | |
138 | wxPen m_normal_bkpen; | |
139 | wxPen m_selected_bkpen; | |
140 | wxBrush m_normal_bkbrush; | |
141 | wxBrush m_selected_bkbrush; | |
142 | wxBrush m_bkbrush; | |
143 | }; | |
144 | ||
145 | ||
146 | ||
147 | class WXDLLIMPEXP_AUI wxAuiTabCtrl : public wxControl, | |
148 | public wxAuiTabContainer | |
149 | { | |
150 | public: | |
151 | ||
152 | wxAuiTabCtrl(wxWindow* parent, | |
153 | wxWindowID id, | |
154 | const wxPoint& pos = wxDefaultPosition, | |
155 | const wxSize& size = wxDefaultSize, | |
156 | long style = 0); | |
157 | ||
158 | protected: | |
159 | ||
160 | void OnPaint(wxPaintEvent& evt); | |
161 | void OnEraseBackground(wxEraseEvent& evt); | |
162 | void OnSize(wxSizeEvent& evt); | |
163 | void OnLeftDown(wxMouseEvent& evt); | |
164 | void OnLeftUp(wxMouseEvent& evt); | |
165 | void OnMotion(wxMouseEvent& evt); | |
166 | void OnLeaveWindow(wxMouseEvent& evt); | |
167 | ||
168 | protected: | |
169 | ||
170 | wxPoint m_click_pt; | |
171 | int m_click_tab; | |
172 | bool m_is_dragging; | |
173 | wxAuiTabContainerButton* m_hover_button; | |
174 | ||
175 | DECLARE_EVENT_TABLE() | |
176 | }; | |
177 | ||
178 | ||
179 | ||
180 | ||
181 | class WXDLLIMPEXP_AUI wxAuiMultiNotebook : public wxControl | |
182 | { | |
183 | ||
184 | public: | |
185 | ||
186 | wxAuiMultiNotebook(); | |
187 | ||
188 | wxAuiMultiNotebook(wxWindow* parent, | |
189 | wxWindowID id, | |
190 | const wxPoint& pos = wxDefaultPosition, | |
191 | const wxSize& size = wxDefaultSize, | |
192 | long style = 0); | |
193 | ||
194 | virtual ~wxAuiMultiNotebook(); | |
195 | ||
196 | bool Create(wxWindow* parent, | |
197 | wxWindowID id, | |
198 | const wxPoint& pos = wxDefaultPosition, | |
199 | const wxSize& size = wxDefaultSize, | |
200 | long style = 0); | |
201 | ||
202 | bool AddPage(wxWindow* page, | |
203 | const wxString& caption, | |
204 | bool select = false, | |
205 | const wxBitmap& bitmap = wxNullBitmap); | |
206 | ||
207 | bool InsertPage(size_t page_idx, | |
208 | wxWindow* page, | |
209 | const wxString& caption, | |
210 | bool select = false, | |
211 | const wxBitmap& bitmap = wxNullBitmap); | |
212 | ||
213 | bool DeletePage(size_t page); | |
214 | bool RemovePage(size_t page); | |
215 | ||
216 | bool SetPageText(size_t page, const wxString& text); | |
217 | size_t SetSelection(size_t new_page); | |
218 | int GetSelection() const; | |
219 | size_t GetPageCount() const; | |
220 | wxWindow* GetPage(size_t page_idx) const; | |
221 | ||
222 | protected: | |
223 | ||
224 | wxAuiTabCtrl* GetTabCtrlFromPoint(const wxPoint& pt); | |
225 | wxWindow* GetTabFrameFromTabCtrl(wxWindow* tab_ctrl); | |
226 | wxAuiTabCtrl* GetActiveTabCtrl(); | |
227 | bool FindTab(wxWindow* page, wxAuiTabCtrl** ctrl, int* idx); | |
228 | void RemoveEmptyTabFrames(); | |
229 | ||
230 | protected: | |
231 | ||
232 | void DoSizing(); | |
233 | void InitNotebook(); | |
234 | ||
235 | void OnChildFocus(wxChildFocusEvent& evt); | |
236 | void OnRender(wxFrameManagerEvent& evt); | |
237 | void OnEraseBackground(wxEraseEvent& evt); | |
238 | void OnSize(wxSizeEvent& evt); | |
239 | void OnTabClicked(wxCommandEvent& evt); | |
240 | void OnTabBeginDrag(wxCommandEvent& evt); | |
241 | void OnTabDragMotion(wxCommandEvent& evt); | |
242 | void OnTabEndDrag(wxCommandEvent& evt); | |
243 | void OnTabButton(wxCommandEvent& evt); | |
244 | ||
245 | protected: | |
246 | ||
247 | wxFrameManager m_mgr; | |
248 | wxAuiTabContainer m_tabs; | |
249 | int m_curpage; | |
250 | int m_tab_id_counter; | |
251 | wxWindow* m_dummy_wnd; | |
252 | ||
253 | wxFont m_selected_font; | |
254 | wxFont m_normal_font; | |
255 | ||
256 | DECLARE_EVENT_TABLE() | |
257 | }; | |
258 | ||
259 | ||
260 | ||
261 | ||
262 | // wx event machinery | |
263 | ||
264 | #ifndef SWIG | |
265 | ||
266 | BEGIN_DECLARE_EVENT_TYPES() | |
267 | DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_AUI, wxEVT_COMMAND_AUINOTEBOOK_PAGE_CHANGED, 0) | |
268 | DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_AUI, wxEVT_COMMAND_AUINOTEBOOK_PAGE_CHANGING, 0) | |
269 | DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_AUI, wxEVT_COMMAND_AUINOTEBOOK_BUTTON, 0) | |
270 | DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_AUI, wxEVT_COMMAND_AUINOTEBOOK_BEGIN_DRAG, 0) | |
271 | DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_AUI, wxEVT_COMMAND_AUINOTEBOOK_END_DRAG, 0) | |
272 | DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_AUI, wxEVT_COMMAND_AUINOTEBOOK_DRAG_MOTION, 0) | |
273 | END_DECLARE_EVENT_TYPES() | |
274 | ||
275 | typedef void (wxEvtHandler::*wxAuiNotebookEventFunction)(wxAuiNotebookEvent&); | |
276 | ||
277 | #define wxAuiNotebookEventHandler(func) \ | |
278 | (wxObjectEventFunction)(wxEventFunction)wxStaticCastEvent(wxAuiNotebookEventFunction, &func) | |
279 | ||
280 | #define EVT_AUINOTEBOOK_PAGE_CHANGED(winid, fn) \ | |
281 | wx__DECLARE_EVT1(wxEVT_COMMAND_AUINOTEBOOK_PAGE_CHANGED, winid, wxAuiNotebookEventHandler(fn)) | |
282 | #define EVT_AUINOTEBOOK_PAGE_CHANGING(winid, fn) \ | |
283 | wx__DECLARE_EVT1(wxEVT_COMMAND_AUINOTEBOOK_PAGE_CHANGING, winid, wxAuiNotebookEventHandler(fn)) | |
284 | #define EVT_AUINOTEBOOK_PAGE_BUTTON(winid, fn) \ | |
285 | wx__DECLARE_EVT1(wxEVT_COMMAND_AUINOTEBOOK_BUTTON, winid, wxAuiNotebookEventHandler(fn)) | |
286 | #define EVT_AUINOTEBOOK_BEGIN_DRAG(winid, fn) \ | |
287 | wx__DECLARE_EVT1(wxEVT_COMMAND_AUINOTEBOOK_BEGIN_DRAG, winid, wxAuiNotebookEventHandler(fn)) | |
288 | #define EVT_AUINOTEBOOK_END_DRAG(winid, fn) \ | |
289 | wx__DECLARE_EVT1(wxEVT_COMMAND_AUINOTEBOOK_END_DRAG, winid, wxAuiNotebookEventHandler(fn)) | |
290 | #define EVT_AUINOTEBOOK_DRAG_MOTION(winid, fn) \ | |
291 | wx__DECLARE_EVT1(wxEVT_COMMAND_AUINOTEBOOK_DRAG_MOTION, winid, wxAuiNotebookEventHandler(fn)) | |
292 | ||
293 | #else | |
294 | ||
295 | // wxpython/swig event work | |
296 | ||
297 | ||
298 | #endif | |
299 | ||
300 | ||
301 | #endif // wxUSE_AUI | |
302 | #endif // _WX_AUINOTEBOOK_H_ |