]>
Commit | Line | Data |
---|---|---|
1 | /////////////////////////////////////////////////////////////////////////////// | |
2 | // Name: wx/aui/framemanager.h | |
3 | // Purpose: wxaui: wx advanced user interface - docking window manager | |
4 | // Author: Benjamin I. Williams | |
5 | // Modified by: | |
6 | // Created: 2005-05-17 | |
7 | // RCS-ID: $Id$ | |
8 | // Copyright: (C) Copyright 2005, Kirix Corporation, All Rights Reserved. | |
9 | // Licence: wxWindows Library Licence, Version 3.1 | |
10 | /////////////////////////////////////////////////////////////////////////////// | |
11 | ||
12 | #ifndef _WX_FRAMEMANAGER_H_ | |
13 | #define _WX_FRAMEMANAGER_H_ | |
14 | ||
15 | // ---------------------------------------------------------------------------- | |
16 | // headers | |
17 | // ---------------------------------------------------------------------------- | |
18 | ||
19 | #include "wx/defs.h" | |
20 | ||
21 | #if wxUSE_AUI | |
22 | ||
23 | #include "wx/dynarray.h" | |
24 | #include "wx/gdicmn.h" | |
25 | #include "wx/window.h" | |
26 | #include "wx/timer.h" | |
27 | #include "wx/sizer.h" | |
28 | #include "wx/bitmap.h" | |
29 | ||
30 | enum wxAuiManagerDock | |
31 | { | |
32 | wxAUI_DOCK_NONE = 0, | |
33 | wxAUI_DOCK_TOP = 1, | |
34 | wxAUI_DOCK_RIGHT = 2, | |
35 | wxAUI_DOCK_BOTTOM = 3, | |
36 | wxAUI_DOCK_LEFT = 4, | |
37 | wxAUI_DOCK_CENTER = 5, | |
38 | wxAUI_DOCK_CENTRE = wxAUI_DOCK_CENTER | |
39 | }; | |
40 | ||
41 | enum wxAuiManagerOption | |
42 | { | |
43 | wxAUI_MGR_ALLOW_FLOATING = 1 << 0, | |
44 | wxAUI_MGR_ALLOW_ACTIVE_PANE = 1 << 1, | |
45 | wxAUI_MGR_TRANSPARENT_DRAG = 1 << 2, | |
46 | wxAUI_MGR_TRANSPARENT_HINT = 1 << 3, | |
47 | wxAUI_MGR_VENETIAN_BLINDS_HINT = 1 << 4, | |
48 | wxAUI_MGR_RECTANGLE_HINT = 1 << 5, | |
49 | wxAUI_MGR_HINT_FADE = 1 << 6, | |
50 | wxAUI_MGR_NO_VENETIAN_BLINDS_FADE = 1 << 7, | |
51 | wxAUI_MGR_LIVE_RESIZE = 1 << 8, | |
52 | ||
53 | wxAUI_MGR_DEFAULT = wxAUI_MGR_ALLOW_FLOATING | | |
54 | wxAUI_MGR_TRANSPARENT_HINT | | |
55 | wxAUI_MGR_HINT_FADE | | |
56 | wxAUI_MGR_NO_VENETIAN_BLINDS_FADE | |
57 | }; | |
58 | ||
59 | ||
60 | enum wxAuiPaneDockArtSetting | |
61 | { | |
62 | wxAUI_DOCKART_SASH_SIZE = 0, | |
63 | wxAUI_DOCKART_CAPTION_SIZE = 1, | |
64 | wxAUI_DOCKART_GRIPPER_SIZE = 2, | |
65 | wxAUI_DOCKART_PANE_BORDER_SIZE = 3, | |
66 | wxAUI_DOCKART_PANE_BUTTON_SIZE = 4, | |
67 | wxAUI_DOCKART_BACKGROUND_COLOUR = 5, | |
68 | wxAUI_DOCKART_SASH_COLOUR = 6, | |
69 | wxAUI_DOCKART_ACTIVE_CAPTION_COLOUR = 7, | |
70 | wxAUI_DOCKART_ACTIVE_CAPTION_GRADIENT_COLOUR = 8, | |
71 | wxAUI_DOCKART_INACTIVE_CAPTION_COLOUR = 9, | |
72 | wxAUI_DOCKART_INACTIVE_CAPTION_GRADIENT_COLOUR = 10, | |
73 | wxAUI_DOCKART_ACTIVE_CAPTION_TEXT_COLOUR = 11, | |
74 | wxAUI_DOCKART_INACTIVE_CAPTION_TEXT_COLOUR = 12, | |
75 | wxAUI_DOCKART_BORDER_COLOUR = 13, | |
76 | wxAUI_DOCKART_GRIPPER_COLOUR = 14, | |
77 | wxAUI_DOCKART_CAPTION_FONT = 15, | |
78 | wxAUI_DOCKART_GRADIENT_TYPE = 16 | |
79 | }; | |
80 | ||
81 | enum wxAuiPaneDockArtGradients | |
82 | { | |
83 | wxAUI_GRADIENT_NONE = 0, | |
84 | wxAUI_GRADIENT_VERTICAL = 1, | |
85 | wxAUI_GRADIENT_HORIZONTAL = 2 | |
86 | }; | |
87 | ||
88 | enum wxAuiPaneButtonState | |
89 | { | |
90 | wxAUI_BUTTON_STATE_NORMAL = 0, | |
91 | wxAUI_BUTTON_STATE_HOVER = 1 << 1, | |
92 | wxAUI_BUTTON_STATE_PRESSED = 1 << 2, | |
93 | wxAUI_BUTTON_STATE_DISABLED = 1 << 3, | |
94 | wxAUI_BUTTON_STATE_HIDDEN = 1 << 4, | |
95 | wxAUI_BUTTON_STATE_CHECKED = 1 << 5 | |
96 | }; | |
97 | ||
98 | enum wxAuiButtonId | |
99 | { | |
100 | wxAUI_BUTTON_CLOSE = 101, | |
101 | wxAUI_BUTTON_MAXIMIZE_RESTORE = 102, | |
102 | wxAUI_BUTTON_MINIMIZE = 103, | |
103 | wxAUI_BUTTON_PIN = 104, | |
104 | wxAUI_BUTTON_OPTIONS = 105, | |
105 | wxAUI_BUTTON_WINDOWLIST = 106, | |
106 | wxAUI_BUTTON_LEFT = 107, | |
107 | wxAUI_BUTTON_RIGHT = 108, | |
108 | wxAUI_BUTTON_UP = 109, | |
109 | wxAUI_BUTTON_DOWN = 110, | |
110 | wxAUI_BUTTON_CUSTOM1 = 201, | |
111 | wxAUI_BUTTON_CUSTOM2 = 202, | |
112 | wxAUI_BUTTON_CUSTOM3 = 203 | |
113 | }; | |
114 | ||
115 | enum wxAuiPaneInsertLevel | |
116 | { | |
117 | wxAUI_INSERT_PANE = 0, | |
118 | wxAUI_INSERT_ROW = 1, | |
119 | wxAUI_INSERT_DOCK = 2 | |
120 | }; | |
121 | ||
122 | ||
123 | ||
124 | ||
125 | // forwards and array declarations | |
126 | class wxAuiDockUIPart; | |
127 | class wxAuiPaneButton; | |
128 | class wxAuiPaneInfo; | |
129 | class wxAuiDockInfo; | |
130 | class wxAuiDockArt; | |
131 | class wxAuiManagerEvent; | |
132 | ||
133 | #ifndef SWIG | |
134 | WX_DECLARE_USER_EXPORTED_OBJARRAY(wxAuiDockInfo, wxAuiDockInfoArray, WXDLLIMPEXP_AUI); | |
135 | WX_DECLARE_USER_EXPORTED_OBJARRAY(wxAuiDockUIPart, wxAuiDockUIPartArray, WXDLLIMPEXP_AUI); | |
136 | WX_DECLARE_USER_EXPORTED_OBJARRAY(wxAuiPaneButton, wxAuiPaneButtonArray, WXDLLIMPEXP_AUI); | |
137 | WX_DECLARE_USER_EXPORTED_OBJARRAY(wxAuiPaneInfo, wxAuiPaneInfoArray, WXDLLIMPEXP_AUI); | |
138 | WX_DEFINE_USER_EXPORTED_ARRAY_PTR(wxAuiPaneInfo*, wxAuiPaneInfoPtrArray, class WXDLLIMPEXP_AUI); | |
139 | WX_DEFINE_USER_EXPORTED_ARRAY_PTR(wxAuiDockInfo*, wxAuiDockInfoPtrArray, class WXDLLIMPEXP_AUI); | |
140 | #endif // SWIG | |
141 | ||
142 | extern WXDLLIMPEXP_AUI wxAuiDockInfo wxAuiNullDockInfo; | |
143 | extern WXDLLIMPEXP_AUI wxAuiPaneInfo wxAuiNullPaneInfo; | |
144 | ||
145 | ||
146 | ||
147 | class WXDLLIMPEXP_AUI wxAuiPaneInfo | |
148 | { | |
149 | public: | |
150 | ||
151 | wxAuiPaneInfo() | |
152 | { | |
153 | window = NULL; | |
154 | frame = NULL; | |
155 | state = 0; | |
156 | dock_direction = wxAUI_DOCK_LEFT; | |
157 | dock_layer = 0; | |
158 | dock_row = 0; | |
159 | dock_pos = 0; | |
160 | floating_pos = wxDefaultPosition; | |
161 | floating_size = wxDefaultSize; | |
162 | best_size = wxDefaultSize; | |
163 | min_size = wxDefaultSize; | |
164 | max_size = wxDefaultSize; | |
165 | dock_proportion = 0; | |
166 | ||
167 | DefaultPane(); | |
168 | } | |
169 | ||
170 | ~wxAuiPaneInfo() {} | |
171 | ||
172 | #ifndef SWIG | |
173 | wxAuiPaneInfo(const wxAuiPaneInfo& c) | |
174 | { | |
175 | name = c.name; | |
176 | caption = c.caption; | |
177 | icon = c.icon; | |
178 | window = c.window; | |
179 | frame = c.frame; | |
180 | state = c.state; | |
181 | dock_direction = c.dock_direction; | |
182 | dock_layer = c.dock_layer; | |
183 | dock_row = c.dock_row; | |
184 | dock_pos = c.dock_pos; | |
185 | best_size = c.best_size; | |
186 | min_size = c.min_size; | |
187 | max_size = c.max_size; | |
188 | floating_pos = c.floating_pos; | |
189 | floating_size = c.floating_size; | |
190 | dock_proportion = c.dock_proportion; | |
191 | buttons = c.buttons; | |
192 | rect = c.rect; | |
193 | } | |
194 | ||
195 | wxAuiPaneInfo& operator=(const wxAuiPaneInfo& c) | |
196 | { | |
197 | name = c.name; | |
198 | caption = c.caption; | |
199 | window = c.window; | |
200 | frame = c.frame; | |
201 | state = c.state; | |
202 | dock_direction = c.dock_direction; | |
203 | dock_layer = c.dock_layer; | |
204 | dock_row = c.dock_row; | |
205 | dock_pos = c.dock_pos; | |
206 | best_size = c.best_size; | |
207 | min_size = c.min_size; | |
208 | max_size = c.max_size; | |
209 | floating_pos = c.floating_pos; | |
210 | floating_size = c.floating_size; | |
211 | dock_proportion = c.dock_proportion; | |
212 | buttons = c.buttons; | |
213 | rect = c.rect; | |
214 | return *this; | |
215 | } | |
216 | #endif // SWIG | |
217 | ||
218 | // Write the safe parts of a newly loaded PaneInfo structure "source" into "this" | |
219 | // used on loading perspectives etc. | |
220 | void SafeSet(wxAuiPaneInfo source) | |
221 | { | |
222 | // note source is not passed by reference so we can overwrite, to keep the | |
223 | // unsafe bits of "dest" | |
224 | source.window = window; | |
225 | source.frame = frame; | |
226 | source.buttons = buttons; | |
227 | wxCHECK_RET(source.IsValid(), | |
228 | "window settings and pane settings are incompatible"); | |
229 | // now assign | |
230 | *this = source; | |
231 | } | |
232 | ||
233 | bool IsOk() const { return window != NULL; } | |
234 | bool IsFixed() const { return !HasFlag(optionResizable); } | |
235 | bool IsResizable() const { return HasFlag(optionResizable); } | |
236 | bool IsShown() const { return !HasFlag(optionHidden); } | |
237 | bool IsFloating() const { return HasFlag(optionFloating); } | |
238 | bool IsDocked() const { return !HasFlag(optionFloating); } | |
239 | bool IsToolbar() const { return HasFlag(optionToolbar); } | |
240 | bool IsTopDockable() const { return HasFlag(optionTopDockable); } | |
241 | bool IsBottomDockable() const { return HasFlag(optionBottomDockable); } | |
242 | bool IsLeftDockable() const { return HasFlag(optionLeftDockable); } | |
243 | bool IsRightDockable() const { return HasFlag(optionRightDockable); } | |
244 | bool IsDockable() const | |
245 | { | |
246 | return HasFlag(optionTopDockable | optionBottomDockable | | |
247 | optionLeftDockable | optionRightDockable); | |
248 | } | |
249 | bool IsFloatable() const { return HasFlag(optionFloatable); } | |
250 | bool IsMovable() const { return HasFlag(optionMovable); } | |
251 | bool IsDestroyOnClose() const { return HasFlag(optionDestroyOnClose); } | |
252 | bool IsMaximized() const { return HasFlag(optionMaximized); } | |
253 | bool HasCaption() const { return HasFlag(optionCaption); } | |
254 | bool HasGripper() const { return HasFlag(optionGripper); } | |
255 | bool HasBorder() const { return HasFlag(optionPaneBorder); } | |
256 | bool HasCloseButton() const { return HasFlag(buttonClose); } | |
257 | bool HasMaximizeButton() const { return HasFlag(buttonMaximize); } | |
258 | bool HasMinimizeButton() const { return HasFlag(buttonMinimize); } | |
259 | bool HasPinButton() const { return HasFlag(buttonPin); } | |
260 | bool HasGripperTop() const { return HasFlag(optionGripperTop); } | |
261 | ||
262 | #ifdef SWIG | |
263 | %typemap(out) wxAuiPaneInfo& { $result = $self; Py_INCREF($result); } | |
264 | #endif | |
265 | wxAuiPaneInfo& Window(wxWindow* w) | |
266 | { | |
267 | wxAuiPaneInfo test(*this); | |
268 | test.window = w; | |
269 | wxCHECK_MSG(test.IsValid(), *this, | |
270 | "window settings and pane settings are incompatible"); | |
271 | *this = test; | |
272 | return *this; | |
273 | } | |
274 | wxAuiPaneInfo& Name(const wxString& n) { name = n; return *this; } | |
275 | wxAuiPaneInfo& Caption(const wxString& c) { caption = c; return *this; } | |
276 | wxAuiPaneInfo& Icon(const wxBitmap& b) { icon = b; return *this; } | |
277 | wxAuiPaneInfo& Left() { dock_direction = wxAUI_DOCK_LEFT; return *this; } | |
278 | wxAuiPaneInfo& Right() { dock_direction = wxAUI_DOCK_RIGHT; return *this; } | |
279 | wxAuiPaneInfo& Top() { dock_direction = wxAUI_DOCK_TOP; return *this; } | |
280 | wxAuiPaneInfo& Bottom() { dock_direction = wxAUI_DOCK_BOTTOM; return *this; } | |
281 | wxAuiPaneInfo& Center() { dock_direction = wxAUI_DOCK_CENTER; return *this; } | |
282 | wxAuiPaneInfo& Centre() { dock_direction = wxAUI_DOCK_CENTRE; return *this; } | |
283 | wxAuiPaneInfo& Direction(int direction) { dock_direction = direction; return *this; } | |
284 | wxAuiPaneInfo& Layer(int layer) { dock_layer = layer; return *this; } | |
285 | wxAuiPaneInfo& Row(int row) { dock_row = row; return *this; } | |
286 | wxAuiPaneInfo& Position(int pos) { dock_pos = pos; return *this; } | |
287 | wxAuiPaneInfo& BestSize(const wxSize& size) { best_size = size; return *this; } | |
288 | wxAuiPaneInfo& MinSize(const wxSize& size) { min_size = size; return *this; } | |
289 | wxAuiPaneInfo& MaxSize(const wxSize& size) { max_size = size; return *this; } | |
290 | wxAuiPaneInfo& BestSize(int x, int y) { best_size.Set(x,y); return *this; } | |
291 | wxAuiPaneInfo& MinSize(int x, int y) { min_size.Set(x,y); return *this; } | |
292 | wxAuiPaneInfo& MaxSize(int x, int y) { max_size.Set(x,y); return *this; } | |
293 | wxAuiPaneInfo& FloatingPosition(const wxPoint& pos) { floating_pos = pos; return *this; } | |
294 | wxAuiPaneInfo& FloatingPosition(int x, int y) { floating_pos.x = x; floating_pos.y = y; return *this; } | |
295 | wxAuiPaneInfo& FloatingSize(const wxSize& size) { floating_size = size; return *this; } | |
296 | wxAuiPaneInfo& FloatingSize(int x, int y) { floating_size.Set(x,y); return *this; } | |
297 | wxAuiPaneInfo& Fixed() { return SetFlag(optionResizable, false); } | |
298 | wxAuiPaneInfo& Resizable(bool resizable = true) { return SetFlag(optionResizable, resizable); } | |
299 | wxAuiPaneInfo& Dock() { return SetFlag(optionFloating, false); } | |
300 | wxAuiPaneInfo& Float() { return SetFlag(optionFloating, true); } | |
301 | wxAuiPaneInfo& Hide() { return SetFlag(optionHidden, true); } | |
302 | wxAuiPaneInfo& Show(bool show = true) { return SetFlag(optionHidden, !show); } | |
303 | wxAuiPaneInfo& CaptionVisible(bool visible = true) { return SetFlag(optionCaption, visible); } | |
304 | wxAuiPaneInfo& Maximize() { return SetFlag(optionMaximized, true); } | |
305 | wxAuiPaneInfo& Restore() { return SetFlag(optionMaximized, false); } | |
306 | wxAuiPaneInfo& PaneBorder(bool visible = true) { return SetFlag(optionPaneBorder, visible); } | |
307 | wxAuiPaneInfo& Gripper(bool visible = true) { return SetFlag(optionGripper, visible); } | |
308 | wxAuiPaneInfo& GripperTop(bool attop = true) { return SetFlag(optionGripperTop, attop); } | |
309 | wxAuiPaneInfo& CloseButton(bool visible = true) { return SetFlag(buttonClose, visible); } | |
310 | wxAuiPaneInfo& MaximizeButton(bool visible = true) { return SetFlag(buttonMaximize, visible); } | |
311 | wxAuiPaneInfo& MinimizeButton(bool visible = true) { return SetFlag(buttonMinimize, visible); } | |
312 | wxAuiPaneInfo& PinButton(bool visible = true) { return SetFlag(buttonPin, visible); } | |
313 | wxAuiPaneInfo& DestroyOnClose(bool b = true) { return SetFlag(optionDestroyOnClose, b); } | |
314 | wxAuiPaneInfo& TopDockable(bool b = true) { return SetFlag(optionTopDockable, b); } | |
315 | wxAuiPaneInfo& BottomDockable(bool b = true) { return SetFlag(optionBottomDockable, b); } | |
316 | wxAuiPaneInfo& LeftDockable(bool b = true) { return SetFlag(optionLeftDockable, b); } | |
317 | wxAuiPaneInfo& RightDockable(bool b = true) { return SetFlag(optionRightDockable, b); } | |
318 | wxAuiPaneInfo& Floatable(bool b = true) { return SetFlag(optionFloatable, b); } | |
319 | wxAuiPaneInfo& Movable(bool b = true) { return SetFlag(optionMovable, b); } | |
320 | wxAuiPaneInfo& DockFixed(bool b = true) { return SetFlag(optionDockFixed, b); } | |
321 | ||
322 | wxAuiPaneInfo& Dockable(bool b = true) | |
323 | { | |
324 | return TopDockable(b).BottomDockable(b).LeftDockable(b).RightDockable(b); | |
325 | } | |
326 | ||
327 | wxAuiPaneInfo& DefaultPane() | |
328 | { | |
329 | wxAuiPaneInfo test(*this); | |
330 | test.state |= optionTopDockable | optionBottomDockable | | |
331 | optionLeftDockable | optionRightDockable | | |
332 | optionFloatable | optionMovable | optionResizable | | |
333 | optionCaption | optionPaneBorder | buttonClose; | |
334 | wxCHECK_MSG(test.IsValid(), *this, | |
335 | "window settings and pane settings are incompatible"); | |
336 | *this = test; | |
337 | return *this; | |
338 | } | |
339 | ||
340 | wxAuiPaneInfo& CentrePane() { return CenterPane(); } | |
341 | wxAuiPaneInfo& CenterPane() | |
342 | { | |
343 | state = 0; | |
344 | return Center().PaneBorder().Resizable(); | |
345 | } | |
346 | ||
347 | wxAuiPaneInfo& ToolbarPane() | |
348 | { | |
349 | DefaultPane(); | |
350 | state |= (optionToolbar | optionGripper); | |
351 | state &= ~(optionResizable | optionCaption); | |
352 | if (dock_layer == 0) | |
353 | dock_layer = 10; | |
354 | return *this; | |
355 | } | |
356 | ||
357 | wxAuiPaneInfo& SetFlag(int flag, bool option_state) | |
358 | { | |
359 | wxAuiPaneInfo test(*this); | |
360 | if (option_state) | |
361 | test.state |= flag; | |
362 | else | |
363 | test.state &= ~flag; | |
364 | wxCHECK_MSG(test.IsValid(), *this, | |
365 | "window settings and pane settings are incompatible"); | |
366 | *this = test; | |
367 | return *this; | |
368 | } | |
369 | ||
370 | bool HasFlag(int flag) const | |
371 | { | |
372 | return (state & flag) != 0; | |
373 | } | |
374 | ||
375 | #ifdef SWIG | |
376 | %typemap(out) wxAuiPaneInfo& ; | |
377 | #endif | |
378 | ||
379 | public: | |
380 | ||
381 | // NOTE: You can add and subtract flags from this list, | |
382 | // but do not change the values of the flags, because | |
383 | // they are stored in a binary integer format in the | |
384 | // perspective string. If you really need to change the | |
385 | // values around, you'll have to ensure backwards-compatibility | |
386 | // in the perspective loading code. | |
387 | enum wxAuiPaneState | |
388 | { | |
389 | optionFloating = 1 << 0, | |
390 | optionHidden = 1 << 1, | |
391 | optionLeftDockable = 1 << 2, | |
392 | optionRightDockable = 1 << 3, | |
393 | optionTopDockable = 1 << 4, | |
394 | optionBottomDockable = 1 << 5, | |
395 | optionFloatable = 1 << 6, | |
396 | optionMovable = 1 << 7, | |
397 | optionResizable = 1 << 8, | |
398 | optionPaneBorder = 1 << 9, | |
399 | optionCaption = 1 << 10, | |
400 | optionGripper = 1 << 11, | |
401 | optionDestroyOnClose = 1 << 12, | |
402 | optionToolbar = 1 << 13, | |
403 | optionActive = 1 << 14, | |
404 | optionGripperTop = 1 << 15, | |
405 | optionMaximized = 1 << 16, | |
406 | optionDockFixed = 1 << 17, | |
407 | ||
408 | buttonClose = 1 << 21, | |
409 | buttonMaximize = 1 << 22, | |
410 | buttonMinimize = 1 << 23, | |
411 | buttonPin = 1 << 24, | |
412 | ||
413 | buttonCustom1 = 1 << 26, | |
414 | buttonCustom2 = 1 << 27, | |
415 | buttonCustom3 = 1 << 28, | |
416 | ||
417 | savedHiddenState = 1 << 30, // used internally | |
418 | actionPane = 1 << 31 // used internally | |
419 | }; | |
420 | ||
421 | public: | |
422 | wxString name; // name of the pane | |
423 | wxString caption; // caption displayed on the window | |
424 | wxBitmap icon; // icon of the pane, may be invalid | |
425 | ||
426 | wxWindow* window; // window that is in this pane | |
427 | wxFrame* frame; // floating frame window that holds the pane | |
428 | unsigned int state; // a combination of wxPaneState values | |
429 | ||
430 | int dock_direction; // dock direction (top, bottom, left, right, center) | |
431 | int dock_layer; // layer number (0 = innermost layer) | |
432 | int dock_row; // row number on the docking bar (0 = first row) | |
433 | int dock_pos; // position inside the row (0 = first position) | |
434 | ||
435 | wxSize best_size; // size that the layout engine will prefer | |
436 | wxSize min_size; // minimum size the pane window can tolerate | |
437 | wxSize max_size; // maximum size the pane window can tolerate | |
438 | ||
439 | wxPoint floating_pos; // position while floating | |
440 | wxSize floating_size; // size while floating | |
441 | int dock_proportion; // proportion while docked | |
442 | ||
443 | wxAuiPaneButtonArray buttons; // buttons on the pane | |
444 | ||
445 | ||
446 | wxRect rect; // current rectangle (populated by wxAUI) | |
447 | ||
448 | bool IsValid() const; | |
449 | }; | |
450 | ||
451 | ||
452 | ||
453 | class WXDLLIMPEXP_FWD_AUI wxAuiFloatingFrame; | |
454 | ||
455 | class WXDLLIMPEXP_AUI wxAuiManager : public wxEvtHandler | |
456 | { | |
457 | friend class wxAuiFloatingFrame; | |
458 | ||
459 | public: | |
460 | ||
461 | wxAuiManager(wxWindow* managedWnd = NULL, | |
462 | unsigned int flags = wxAUI_MGR_DEFAULT); | |
463 | virtual ~wxAuiManager(); | |
464 | void UnInit(); | |
465 | ||
466 | void SetFlags(unsigned int flags); | |
467 | unsigned int GetFlags() const; | |
468 | ||
469 | void SetManagedWindow(wxWindow* managedWnd); | |
470 | wxWindow* GetManagedWindow() const; | |
471 | ||
472 | static wxAuiManager* GetManager(wxWindow* window); | |
473 | ||
474 | void SetArtProvider(wxAuiDockArt* artProvider); | |
475 | wxAuiDockArt* GetArtProvider() const; | |
476 | ||
477 | wxAuiPaneInfo& GetPane(wxWindow* window); | |
478 | wxAuiPaneInfo& GetPane(const wxString& name); | |
479 | wxAuiPaneInfoArray& GetAllPanes(); | |
480 | ||
481 | bool AddPane(wxWindow* window, | |
482 | const wxAuiPaneInfo& paneInfo); | |
483 | ||
484 | bool AddPane(wxWindow* window, | |
485 | const wxAuiPaneInfo& paneInfo, | |
486 | const wxPoint& dropPos); | |
487 | ||
488 | bool AddPane(wxWindow* window, | |
489 | int direction = wxLEFT, | |
490 | const wxString& caption = wxEmptyString); | |
491 | ||
492 | bool InsertPane(wxWindow* window, | |
493 | const wxAuiPaneInfo& insertLocation, | |
494 | int insertLevel = wxAUI_INSERT_PANE); | |
495 | ||
496 | bool DetachPane(wxWindow* window); | |
497 | ||
498 | void Update(); | |
499 | ||
500 | wxString SavePaneInfo(wxAuiPaneInfo& pane); | |
501 | void LoadPaneInfo(wxString panePart, wxAuiPaneInfo &pane); | |
502 | wxString SavePerspective(); | |
503 | bool LoadPerspective(const wxString& perspective, bool update = true); | |
504 | ||
505 | void SetDockSizeConstraint(double widthPct, double heightPct); | |
506 | void GetDockSizeConstraint(double* widthPct, double* heightPct) const; | |
507 | ||
508 | void ClosePane(wxAuiPaneInfo& paneInfo); | |
509 | void MaximizePane(wxAuiPaneInfo& paneInfo); | |
510 | void RestorePane(wxAuiPaneInfo& paneInfo); | |
511 | void RestoreMaximizedPane(); | |
512 | ||
513 | public: | |
514 | ||
515 | virtual wxAuiFloatingFrame* CreateFloatingFrame(wxWindow* parent, const wxAuiPaneInfo& p); | |
516 | virtual bool CanDockPanel(const wxAuiPaneInfo & p); | |
517 | ||
518 | void StartPaneDrag( | |
519 | wxWindow* paneWindow, | |
520 | const wxPoint& offset); | |
521 | ||
522 | wxRect CalculateHintRect( | |
523 | wxWindow* paneWindow, | |
524 | const wxPoint& pt, | |
525 | const wxPoint& offset); | |
526 | ||
527 | void DrawHintRect( | |
528 | wxWindow* paneWindow, | |
529 | const wxPoint& pt, | |
530 | const wxPoint& offset); | |
531 | ||
532 | virtual void ShowHint(const wxRect& rect); | |
533 | virtual void HideHint(); | |
534 | ||
535 | void OnHintActivate(wxActivateEvent& event); | |
536 | ||
537 | public: | |
538 | ||
539 | // deprecated -- please use SetManagedWindow() and | |
540 | // and GetManagedWindow() instead | |
541 | ||
542 | wxDEPRECATED( void SetFrame(wxFrame* frame) ); | |
543 | wxDEPRECATED( wxFrame* GetFrame() const ); | |
544 | ||
545 | protected: | |
546 | ||
547 | void UpdateHintWindowConfig(); | |
548 | ||
549 | void DoFrameLayout(); | |
550 | ||
551 | void LayoutAddPane(wxSizer* container, | |
552 | wxAuiDockInfo& dock, | |
553 | wxAuiPaneInfo& pane, | |
554 | wxAuiDockUIPartArray& uiparts, | |
555 | bool spacerOnly); | |
556 | ||
557 | void LayoutAddDock(wxSizer* container, | |
558 | wxAuiDockInfo& dock, | |
559 | wxAuiDockUIPartArray& uiParts, | |
560 | bool spacerOnly); | |
561 | ||
562 | wxSizer* LayoutAll(wxAuiPaneInfoArray& panes, | |
563 | wxAuiDockInfoArray& docks, | |
564 | wxAuiDockUIPartArray & uiParts, | |
565 | bool spacerOnly = false); | |
566 | ||
567 | virtual bool ProcessDockResult(wxAuiPaneInfo& target, | |
568 | const wxAuiPaneInfo& newPos); | |
569 | ||
570 | bool DoDrop(wxAuiDockInfoArray& docks, | |
571 | wxAuiPaneInfoArray& panes, | |
572 | wxAuiPaneInfo& drop, | |
573 | const wxPoint& pt, | |
574 | const wxPoint& actionOffset = wxPoint(0,0)); | |
575 | ||
576 | wxAuiDockUIPart* HitTest(int x, int y); | |
577 | wxAuiDockUIPart* GetPanePart(wxWindow* pane); | |
578 | int GetDockPixelOffset(wxAuiPaneInfo& test); | |
579 | void OnFloatingPaneMoveStart(wxWindow* window); | |
580 | void OnFloatingPaneMoving(wxWindow* window, wxDirection dir ); | |
581 | void OnFloatingPaneMoved(wxWindow* window, wxDirection dir); | |
582 | void OnFloatingPaneActivated(wxWindow* window); | |
583 | void OnFloatingPaneClosed(wxWindow* window, wxCloseEvent& evt); | |
584 | void OnFloatingPaneResized(wxWindow* window, const wxRect& rect); | |
585 | void Render(wxDC* dc); | |
586 | void Repaint(wxDC* dc = NULL); | |
587 | void ProcessMgrEvent(wxAuiManagerEvent& event); | |
588 | void UpdateButtonOnScreen(wxAuiDockUIPart* buttonUiPart, | |
589 | const wxMouseEvent& event); | |
590 | void GetPanePositionsAndSizes(wxAuiDockInfo& dock, | |
591 | wxArrayInt& positions, | |
592 | wxArrayInt& sizes); | |
593 | ||
594 | /// Ends a resize action, or for live update, resizes the sash | |
595 | bool DoEndResizeAction(wxMouseEvent& event); | |
596 | ||
597 | void SetActivePane(wxWindow* active_pane); | |
598 | ||
599 | public: | |
600 | ||
601 | // public events (which can be invoked externally) | |
602 | void OnRender(wxAuiManagerEvent& evt); | |
603 | void OnPaneButton(wxAuiManagerEvent& evt); | |
604 | ||
605 | protected: | |
606 | ||
607 | // protected events | |
608 | void OnPaint(wxPaintEvent& evt); | |
609 | void OnEraseBackground(wxEraseEvent& evt); | |
610 | void OnSize(wxSizeEvent& evt); | |
611 | void OnSetCursor(wxSetCursorEvent& evt); | |
612 | void OnLeftDown(wxMouseEvent& evt); | |
613 | void OnLeftUp(wxMouseEvent& evt); | |
614 | void OnMotion(wxMouseEvent& evt); | |
615 | void OnCaptureLost(wxMouseCaptureLostEvent& evt); | |
616 | void OnLeaveWindow(wxMouseEvent& evt); | |
617 | void OnChildFocus(wxChildFocusEvent& evt); | |
618 | void OnHintFadeTimer(wxTimerEvent& evt); | |
619 | void OnFindManager(wxAuiManagerEvent& evt); | |
620 | ||
621 | protected: | |
622 | ||
623 | enum | |
624 | { | |
625 | actionNone = 0, | |
626 | actionResize, | |
627 | actionClickButton, | |
628 | actionClickCaption, | |
629 | actionDragToolbarPane, | |
630 | actionDragFloatingPane | |
631 | }; | |
632 | ||
633 | protected: | |
634 | ||
635 | wxWindow* m_frame; // the window being managed | |
636 | wxAuiDockArt* m_art; // dock art object which does all drawing | |
637 | unsigned int m_flags; // manager flags wxAUI_MGR_* | |
638 | ||
639 | wxAuiPaneInfoArray m_panes; // array of panes structures | |
640 | wxAuiDockInfoArray m_docks; // array of docks structures | |
641 | wxAuiDockUIPartArray m_uiParts; // array of UI parts (captions, buttons, etc) | |
642 | ||
643 | int m_action; // current mouse action | |
644 | wxPoint m_actionStart; // position where the action click started | |
645 | wxPoint m_actionOffset; // offset from upper left of the item clicked | |
646 | wxAuiDockUIPart* m_actionPart; // ptr to the part the action happened to | |
647 | wxWindow* m_actionWindow; // action frame or window (NULL if none) | |
648 | wxRect m_actionHintRect; // hint rectangle for the action | |
649 | wxRect m_lastRect; | |
650 | wxAuiDockUIPart* m_hoverButton;// button uipart being hovered over | |
651 | wxRect m_lastHint; // last hint rectangle | |
652 | wxPoint m_lastMouseMove; // last mouse move position (see OnMotion) | |
653 | int m_currentDragItem; | |
654 | bool m_skipping; | |
655 | bool m_hasMaximized; | |
656 | ||
657 | double m_dockConstraintX; // 0.0 .. 1.0; max pct of window width a dock can consume | |
658 | double m_dockConstraintY; // 0.0 .. 1.0; max pct of window height a dock can consume | |
659 | ||
660 | wxFrame* m_hintWnd; // transparent hint window, if supported by platform | |
661 | wxTimer m_hintFadeTimer; // transparent fade timer | |
662 | wxByte m_hintFadeAmt; // transparent fade amount | |
663 | wxByte m_hintFadeMax; // maximum value of hint fade | |
664 | ||
665 | void* m_reserved; | |
666 | ||
667 | #ifndef SWIG | |
668 | DECLARE_EVENT_TABLE() | |
669 | DECLARE_CLASS(wxAuiManager) | |
670 | #endif // SWIG | |
671 | }; | |
672 | ||
673 | ||
674 | ||
675 | // event declarations/classes | |
676 | ||
677 | class WXDLLIMPEXP_AUI wxAuiManagerEvent : public wxEvent | |
678 | { | |
679 | public: | |
680 | wxAuiManagerEvent(wxEventType type=wxEVT_NULL) : wxEvent(0, type) | |
681 | { | |
682 | manager = NULL; | |
683 | pane = NULL; | |
684 | button = 0; | |
685 | veto_flag = false; | |
686 | canveto_flag = true; | |
687 | dc = NULL; | |
688 | } | |
689 | #ifndef SWIG | |
690 | wxAuiManagerEvent(const wxAuiManagerEvent& c) : wxEvent(c) | |
691 | { | |
692 | manager = c.manager; | |
693 | pane = c.pane; | |
694 | button = c.button; | |
695 | veto_flag = c.veto_flag; | |
696 | canveto_flag = c.canveto_flag; | |
697 | dc = c.dc; | |
698 | } | |
699 | #endif | |
700 | wxEvent *Clone() const { return new wxAuiManagerEvent(*this); } | |
701 | ||
702 | void SetManager(wxAuiManager* mgr) { manager = mgr; } | |
703 | void SetPane(wxAuiPaneInfo* p) { pane = p; } | |
704 | void SetButton(int b) { button = b; } | |
705 | void SetDC(wxDC* pdc) { dc = pdc; } | |
706 | ||
707 | wxAuiManager* GetManager() const { return manager; } | |
708 | wxAuiPaneInfo* GetPane() const { return pane; } | |
709 | int GetButton() const { return button; } | |
710 | wxDC* GetDC() const { return dc; } | |
711 | ||
712 | void Veto(bool veto = true) { veto_flag = veto; } | |
713 | bool GetVeto() const { return veto_flag; } | |
714 | void SetCanVeto(bool can_veto) { canveto_flag = can_veto; } | |
715 | bool CanVeto() const { return canveto_flag && veto_flag; } | |
716 | ||
717 | public: | |
718 | wxAuiManager* manager; | |
719 | wxAuiPaneInfo* pane; | |
720 | int button; | |
721 | bool veto_flag; | |
722 | bool canveto_flag; | |
723 | wxDC* dc; | |
724 | ||
725 | #ifndef SWIG | |
726 | private: | |
727 | DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxAuiManagerEvent) | |
728 | #endif | |
729 | }; | |
730 | ||
731 | ||
732 | class WXDLLIMPEXP_AUI wxAuiDockInfo | |
733 | { | |
734 | public: | |
735 | wxAuiDockInfo() | |
736 | { | |
737 | dock_direction = 0; | |
738 | dock_layer = 0; | |
739 | dock_row = 0; | |
740 | size = 0; | |
741 | min_size = 0; | |
742 | resizable = true; | |
743 | fixed = false; | |
744 | toolbar = false; | |
745 | reserved1 = false; | |
746 | } | |
747 | ||
748 | #ifndef SWIG | |
749 | wxAuiDockInfo(const wxAuiDockInfo& c) | |
750 | { | |
751 | dock_direction = c.dock_direction; | |
752 | dock_layer = c.dock_layer; | |
753 | dock_row = c.dock_row; | |
754 | size = c.size; | |
755 | min_size = c.min_size; | |
756 | resizable = c.resizable; | |
757 | fixed = c.fixed; | |
758 | toolbar = c.toolbar; | |
759 | panes = c.panes; | |
760 | rect = c.rect; | |
761 | reserved1 = c.reserved1; | |
762 | } | |
763 | ||
764 | wxAuiDockInfo& operator=(const wxAuiDockInfo& c) | |
765 | { | |
766 | dock_direction = c.dock_direction; | |
767 | dock_layer = c.dock_layer; | |
768 | dock_row = c.dock_row; | |
769 | size = c.size; | |
770 | min_size = c.min_size; | |
771 | resizable = c.resizable; | |
772 | fixed = c.fixed; | |
773 | toolbar = c.toolbar; | |
774 | panes = c.panes; | |
775 | rect = c.rect; | |
776 | reserved1 = c.reserved1; | |
777 | return *this; | |
778 | } | |
779 | #endif // SWIG | |
780 | ||
781 | bool IsOk() const { return dock_direction != 0; } | |
782 | bool IsHorizontal() const { return dock_direction == wxAUI_DOCK_TOP || | |
783 | dock_direction == wxAUI_DOCK_BOTTOM; } | |
784 | bool IsVertical() const { return dock_direction == wxAUI_DOCK_LEFT || | |
785 | dock_direction == wxAUI_DOCK_RIGHT || | |
786 | dock_direction == wxAUI_DOCK_CENTER; } | |
787 | public: | |
788 | wxAuiPaneInfoPtrArray panes; // array of panes | |
789 | wxRect rect; // current rectangle | |
790 | int dock_direction; // dock direction (top, bottom, left, right, center) | |
791 | int dock_layer; // layer number (0 = innermost layer) | |
792 | int dock_row; // row number on the docking bar (0 = first row) | |
793 | int size; // size of the dock | |
794 | int min_size; // minimum size of a dock (0 if there is no min) | |
795 | bool resizable; // flag indicating whether the dock is resizable | |
796 | bool toolbar; // flag indicating dock contains only toolbars | |
797 | bool fixed; // flag indicating that the dock operates on | |
798 | // absolute coordinates as opposed to proportional | |
799 | bool reserved1; | |
800 | }; | |
801 | ||
802 | ||
803 | class WXDLLIMPEXP_AUI wxAuiDockUIPart | |
804 | { | |
805 | public: | |
806 | enum | |
807 | { | |
808 | typeCaption, | |
809 | typeGripper, | |
810 | typeDock, | |
811 | typeDockSizer, | |
812 | typePane, | |
813 | typePaneSizer, | |
814 | typeBackground, | |
815 | typePaneBorder, | |
816 | typePaneButton | |
817 | }; | |
818 | ||
819 | int type; // ui part type (see enum above) | |
820 | int orientation; // orientation (either wxHORIZONTAL or wxVERTICAL) | |
821 | wxAuiDockInfo* dock; // which dock the item is associated with | |
822 | wxAuiPaneInfo* pane; // which pane the item is associated with | |
823 | wxAuiPaneButton* button; // which pane button the item is associated with | |
824 | wxSizer* cont_sizer; // the part's containing sizer | |
825 | wxSizerItem* sizer_item; // the sizer item of the part | |
826 | wxRect rect; // client coord rectangle of the part itself | |
827 | }; | |
828 | ||
829 | ||
830 | class WXDLLIMPEXP_AUI wxAuiPaneButton | |
831 | { | |
832 | public: | |
833 | int button_id; // id of the button (e.g. buttonClose) | |
834 | }; | |
835 | ||
836 | ||
837 | ||
838 | #ifndef SWIG | |
839 | ||
840 | wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_AUI, wxEVT_AUI_PANE_BUTTON, wxAuiManagerEvent ); | |
841 | wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_AUI, wxEVT_AUI_PANE_CLOSE, wxAuiManagerEvent ); | |
842 | wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_AUI, wxEVT_AUI_PANE_MAXIMIZE, wxAuiManagerEvent ); | |
843 | wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_AUI, wxEVT_AUI_PANE_RESTORE, wxAuiManagerEvent ); | |
844 | wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_AUI, wxEVT_AUI_PANE_ACTIVATED, wxAuiManagerEvent ); | |
845 | wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_AUI, wxEVT_AUI_RENDER, wxAuiManagerEvent ); | |
846 | wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_AUI, wxEVT_AUI_FIND_MANAGER, wxAuiManagerEvent ); | |
847 | ||
848 | typedef void (wxEvtHandler::*wxAuiManagerEventFunction)(wxAuiManagerEvent&); | |
849 | ||
850 | #define wxAuiManagerEventHandler(func) \ | |
851 | wxEVENT_HANDLER_CAST(wxAuiManagerEventFunction, func) | |
852 | ||
853 | #define EVT_AUI_PANE_BUTTON(func) \ | |
854 | wx__DECLARE_EVT0(wxEVT_AUI_PANE_BUTTON, wxAuiManagerEventHandler(func)) | |
855 | #define EVT_AUI_PANE_CLOSE(func) \ | |
856 | wx__DECLARE_EVT0(wxEVT_AUI_PANE_CLOSE, wxAuiManagerEventHandler(func)) | |
857 | #define EVT_AUI_PANE_MAXIMIZE(func) \ | |
858 | wx__DECLARE_EVT0(wxEVT_AUI_PANE_MAXIMIZE, wxAuiManagerEventHandler(func)) | |
859 | #define EVT_AUI_PANE_RESTORE(func) \ | |
860 | wx__DECLARE_EVT0(wxEVT_AUI_PANE_RESTORE, wxAuiManagerEventHandler(func)) | |
861 | #define EVT_AUI_PANE_ACTIVATED(func) \ | |
862 | wx__DECLARE_EVT0(wxEVT_AUI_PANE_ACTIVATED, wxAuiManagerEventHandler(func)) | |
863 | #define EVT_AUI_RENDER(func) \ | |
864 | wx__DECLARE_EVT0(wxEVT_AUI_RENDER, wxAuiManagerEventHandler(func)) | |
865 | #define EVT_AUI_FIND_MANAGER(func) \ | |
866 | wx__DECLARE_EVT0(wxEVT_AUI_FIND_MANAGER, wxAuiManagerEventHandler(func)) | |
867 | ||
868 | #else | |
869 | ||
870 | %constant wxEventType wxEVT_AUI_PANE_BUTTON; | |
871 | %constant wxEventType wxEVT_AUI_PANE_CLOSE; | |
872 | %constant wxEventType wxEVT_AUI_PANE_MAXIMIZE; | |
873 | %constant wxEventType wxEVT_AUI_PANE_RESTORE; | |
874 | %constant wxEventType wxEVT_AUI_PANE_ACTIVATED; | |
875 | %constant wxEventType wxEVT_AUI_RENDER; | |
876 | %constant wxEventType wxEVT_AUI_FIND_MANAGER; | |
877 | ||
878 | %pythoncode { | |
879 | EVT_AUI_PANE_BUTTON = wx.PyEventBinder( wxEVT_AUI_PANE_BUTTON ) | |
880 | EVT_AUI_PANE_CLOSE = wx.PyEventBinder( wxEVT_AUI_PANE_CLOSE ) | |
881 | EVT_AUI_PANE_MAXIMIZE = wx.PyEventBinder( wxEVT_AUI_PANE_MAXIMIZE ) | |
882 | EVT_AUI_PANE_RESTORE = wx.PyEventBinder( wxEVT_AUI_PANE_RESTORE ) | |
883 | EVT_AUI_PANE_ACTIVATED = wx.PyEventBinder( wxEVT_AUI_PANE_ACTIVATED ) | |
884 | EVT_AUI_RENDER = wx.PyEventBinder( wxEVT_AUI_RENDER ) | |
885 | EVT_AUI_FIND_MANAGER = wx.PyEventBinder( wxEVT_AUI_FIND_MANAGER ) | |
886 | } | |
887 | #endif // SWIG | |
888 | ||
889 | #endif // wxUSE_AUI | |
890 | #endif //_WX_FRAMEMANAGER_H_ | |
891 |