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