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