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