1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: framemanager.h
3 // Purpose: wxaui: wx advanced user interface - docking window manager
4 // Author: Benjamin I. Williams
8 // Copyright: (C) Copyright 2005, Kirix Corporation, All Rights Reserved.
9 // Licence: wxWindows Library Licence, Version 3.1
10 ///////////////////////////////////////////////////////////////////////////////
12 #ifndef _WX_FRAMEMANAGER_H_
13 #define _WX_FRAMEMANAGER_H_
15 // ----------------------------------------------------------------------------
17 // ----------------------------------------------------------------------------
23 enum WXDLLIMPEXP_AUI wxFrameManagerDock
28 wxAUI_DOCK_BOTTOM
= 3,
30 wxAUI_DOCK_CENTER
= 5,
31 wxAUI_DOCK_CENTRE
= wxAUI_DOCK_CENTER
34 enum WXDLLIMPEXP_AUI wxFrameManagerOption
36 wxAUI_MGR_ALLOW_FLOATING
= 1 << 0,
37 wxAUI_MGR_ALLOW_ACTIVE_PANE
= 1 << 1,
38 wxAUI_MGR_TRANSPARENT_DRAG
= 1 << 2,
39 wxAUI_MGR_TRANSPARENT_HINT
= 1 << 3,
40 wxAUI_MGR_TRANSPARENT_HINT_FADE
= 1 << 4,
42 wxAUI_MGR_DEFAULT
= wxAUI_MGR_ALLOW_FLOATING
|
43 wxAUI_MGR_TRANSPARENT_HINT
|
44 wxAUI_MGR_TRANSPARENT_HINT_FADE
47 enum WXDLLIMPEXP_AUI wxPaneDockArtSetting
49 wxAUI_ART_SASH_SIZE
= 0,
50 wxAUI_ART_CAPTION_SIZE
= 1,
51 wxAUI_ART_GRIPPER_SIZE
= 2,
52 wxAUI_ART_PANE_BORDER_SIZE
= 3,
53 wxAUI_ART_PANE_BUTTON_SIZE
= 4,
54 wxAUI_ART_BACKGROUND_COLOUR
= 5,
55 wxAUI_ART_SASH_COLOUR
= 6,
56 wxAUI_ART_ACTIVE_CAPTION_COLOUR
= 7,
57 wxAUI_ART_ACTIVE_CAPTION_GRADIENT_COLOUR
= 8,
58 wxAUI_ART_INACTIVE_CAPTION_COLOUR
= 9,
59 wxAUI_ART_INACTIVE_CAPTION_GRADIENT_COLOUR
= 10,
60 wxAUI_ART_ACTIVE_CAPTION_TEXT_COLOUR
= 11,
61 wxAUI_ART_INACTIVE_CAPTION_TEXT_COLOUR
= 12,
62 wxAUI_ART_BORDER_COLOUR
= 13,
63 wxAUI_ART_GRIPPER_COLOUR
= 14,
64 wxAUI_ART_CAPTION_FONT
= 15,
65 wxAUI_ART_GRADIENT_TYPE
= 16
68 enum WXDLLIMPEXP_AUI wxPaneDockArtGradients
70 wxAUI_GRADIENT_NONE
= 0,
71 wxAUI_GRADIENT_VERTICAL
= 1,
72 wxAUI_GRADIENT_HORIZONTAL
= 2
75 enum WXDLLIMPEXP_AUI wxPaneButtonState
77 wxAUI_BUTTON_STATE_NORMAL
= 0,
78 wxAUI_BUTTON_STATE_HOVER
= 1,
79 wxAUI_BUTTON_STATE_PRESSED
= 2
82 enum WXDLLIMPEXP_AUI wxPaneInsertLevel
84 wxAUI_INSERT_PANE
= 0,
91 // forwards and array declarations
97 class wxFrameManagerEvent
;
99 WX_DECLARE_OBJARRAY(wxDockInfo
, wxDockInfoArray
);
100 WX_DECLARE_OBJARRAY(wxDockUIPart
, wxDockUIPartArray
);
101 WX_DECLARE_OBJARRAY(wxPaneButton
, wxPaneButtonArray
);
102 WX_DECLARE_OBJARRAY(wxPaneInfo
, wxPaneInfoArray
);
103 WX_DEFINE_ARRAY_PTR(wxPaneInfo
*, wxPaneInfoPtrArray
);
104 WX_DEFINE_ARRAY_PTR(wxDockInfo
*, wxDockInfoPtrArray
);
106 extern wxDockInfo wxNullDockInfo
;
107 extern wxPaneInfo wxNullPaneInfo
;
112 class WXDLLIMPEXP_AUI wxPaneInfo
121 dock_direction
= wxAUI_DOCK_LEFT
;
125 floating_pos
= wxDefaultPosition
;
126 floating_size
= wxDefaultSize
;
127 best_size
= wxDefaultSize
;
128 min_size
= wxDefaultSize
;
129 max_size
= wxDefaultSize
;
135 wxPaneInfo(const wxPaneInfo
& c
)
142 dock_direction
= c
.dock_direction
;
143 dock_layer
= c
.dock_layer
;
144 dock_row
= c
.dock_row
;
145 dock_pos
= c
.dock_pos
;
146 best_size
= c
.best_size
;
147 min_size
= c
.min_size
;
148 max_size
= c
.max_size
;
149 floating_pos
= c
.floating_pos
;
150 floating_size
= c
.floating_size
;
151 dock_proportion
= c
.dock_proportion
;
156 wxPaneInfo
& operator=(const wxPaneInfo
& c
)
163 dock_direction
= c
.dock_direction
;
164 dock_layer
= c
.dock_layer
;
165 dock_row
= c
.dock_row
;
166 dock_pos
= c
.dock_pos
;
167 best_size
= c
.best_size
;
168 min_size
= c
.min_size
;
169 max_size
= c
.max_size
;
170 floating_pos
= c
.floating_pos
;
171 floating_size
= c
.floating_size
;
172 dock_proportion
= c
.dock_proportion
;
178 bool IsOk() const { return (window
!= NULL
) ? true : false; }
179 bool IsFixed() const { return !HasFlag(optionResizable
); }
180 bool IsResizable() const { return HasFlag(optionResizable
); }
181 bool IsShown() const { return !HasFlag(optionHidden
); }
182 bool IsFloating() const { return HasFlag(optionFloating
); }
183 bool IsDocked() const { return !HasFlag(optionFloating
); }
184 bool IsToolbar() const { return HasFlag(optionToolbar
); }
185 bool IsTopDockable() const { return HasFlag(optionTopDockable
); }
186 bool IsBottomDockable() const { return HasFlag(optionBottomDockable
); }
187 bool IsLeftDockable() const { return HasFlag(optionLeftDockable
); }
188 bool IsRightDockable() const { return HasFlag(optionRightDockable
); }
189 bool IsFloatable() const { return HasFlag(optionFloatable
); }
190 bool IsMovable() const { return HasFlag(optionMovable
); }
191 bool HasCaption() const { return HasFlag(optionCaption
); }
192 bool HasGripper() const { return HasFlag(optionGripper
); }
193 bool HasBorder() const { return HasFlag(optionPaneBorder
); }
194 bool HasCloseButton() const { return HasFlag(buttonClose
); }
195 bool HasMaximizeButton() const { return HasFlag(buttonMaximize
); }
196 bool HasMinimizeButton() const { return HasFlag(buttonMinimize
); }
197 bool HasPinButton() const { return HasFlag(buttonPin
); }
198 bool HasGripperTop() const { return HasFlag(optionGripperTop
); }
200 wxPaneInfo
& Window(wxWindow
* w
) { window
= w
; return *this; }
201 wxPaneInfo
& Name(const wxString
& n
) { name
= n
; return *this; }
202 wxPaneInfo
& Caption(const wxString
& c
) { caption
= c
; return *this; }
203 wxPaneInfo
& Left() { dock_direction
= wxAUI_DOCK_LEFT
; return *this; }
204 wxPaneInfo
& Right() { dock_direction
= wxAUI_DOCK_RIGHT
; return *this; }
205 wxPaneInfo
& Top() { dock_direction
= wxAUI_DOCK_TOP
; return *this; }
206 wxPaneInfo
& Bottom() { dock_direction
= wxAUI_DOCK_BOTTOM
; return *this; }
207 wxPaneInfo
& Center() { dock_direction
= wxAUI_DOCK_CENTER
; return *this; }
208 wxPaneInfo
& Centre() { dock_direction
= wxAUI_DOCK_CENTRE
; return *this; }
209 wxPaneInfo
& Direction(int direction
) { dock_direction
= direction
; return *this; }
210 wxPaneInfo
& Layer(int layer
) { dock_layer
= layer
; return *this; }
211 wxPaneInfo
& Row(int row
) { dock_row
= row
; return *this; }
212 wxPaneInfo
& Position(int pos
) { dock_pos
= pos
; return *this; }
213 wxPaneInfo
& BestSize(const wxSize
& size
) { best_size
= size
; return *this; }
214 wxPaneInfo
& MinSize(const wxSize
& size
) { min_size
= size
; return *this; }
215 wxPaneInfo
& MaxSize(const wxSize
& size
) { max_size
= size
; return *this; }
216 wxPaneInfo
& BestSize(int x
, int y
) { best_size
.Set(x
,y
); return *this; }
217 wxPaneInfo
& MinSize(int x
, int y
) { min_size
.Set(x
,y
); return *this; }
218 wxPaneInfo
& MaxSize(int x
, int y
) { max_size
.Set(x
,y
); return *this; }
219 wxPaneInfo
& FloatingPosition(const wxPoint
& pos
) { floating_pos
= pos
; return *this; }
220 wxPaneInfo
& FloatingPosition(int x
, int y
) { floating_pos
.x
= x
; floating_pos
.y
= y
; return *this; }
221 wxPaneInfo
& FloatingSize(const wxSize
& size
) { floating_size
= size
; return *this; }
222 wxPaneInfo
& FloatingSize(int x
, int y
) { floating_size
.Set(x
,y
); return *this; }
223 wxPaneInfo
& Fixed() { return SetFlag(optionResizable
, false); }
224 wxPaneInfo
& Resizable(bool resizable
= true) { return SetFlag(optionResizable
, resizable
); }
225 wxPaneInfo
& Dock() { return SetFlag(optionFloating
, false); }
226 wxPaneInfo
& Float() { return SetFlag(optionFloating
, true); }
227 wxPaneInfo
& Hide() { return SetFlag(optionHidden
, true); }
228 wxPaneInfo
& Show(bool show
= true) { return SetFlag(optionHidden
, !show
); }
229 wxPaneInfo
& CaptionVisible(bool visible
= true) { return SetFlag(optionCaption
, visible
); }
230 wxPaneInfo
& PaneBorder(bool visible
= true) { return SetFlag(optionPaneBorder
, visible
); }
231 wxPaneInfo
& Gripper(bool visible
= true) { return SetFlag(optionGripper
, visible
); }
232 wxPaneInfo
& GripperTop(bool attop
= true) { return SetFlag(optionGripperTop
, attop
); }
233 wxPaneInfo
& CloseButton(bool visible
= true) { return SetFlag(buttonClose
, visible
); }
234 wxPaneInfo
& MaximizeButton(bool visible
= true) { return SetFlag(buttonMaximize
, visible
); }
235 wxPaneInfo
& MinimizeButton(bool visible
= true) { return SetFlag(buttonMinimize
, visible
); }
236 wxPaneInfo
& PinButton(bool visible
= true) { return SetFlag(buttonPin
, visible
); }
237 wxPaneInfo
& DestroyOnClose(bool b
= true) { return SetFlag(optionDestroyOnClose
, b
); }
238 wxPaneInfo
& TopDockable(bool b
= true) { return SetFlag(optionTopDockable
, b
); }
239 wxPaneInfo
& BottomDockable(bool b
= true) { return SetFlag(optionBottomDockable
, b
); }
240 wxPaneInfo
& LeftDockable(bool b
= true) { return SetFlag(optionLeftDockable
, b
); }
241 wxPaneInfo
& RightDockable(bool b
= true) { return SetFlag(optionRightDockable
, b
); }
242 wxPaneInfo
& Floatable(bool b
= true) { return SetFlag(optionFloatable
, b
); }
243 wxPaneInfo
& Movable(bool b
= true) { return SetFlag(optionMovable
, b
); }
244 wxPaneInfo
& Dockable(bool b
= true)
246 return TopDockable(b
).BottomDockable(b
).LeftDockable(b
).RightDockable(b
);
249 wxPaneInfo
& DefaultPane()
251 state
|= optionTopDockable
| optionBottomDockable
|
252 optionLeftDockable
| optionRightDockable
|
253 optionFloatable
| optionMovable
| optionResizable
|
254 optionCaption
| optionPaneBorder
| buttonClose
;
258 wxPaneInfo
& CentrePane() { return CenterPane(); }
259 wxPaneInfo
& CenterPane()
262 return Center().PaneBorder().Resizable();
265 wxPaneInfo
& ToolbarPane()
268 state
|= (optionToolbar
| optionGripper
);
269 state
&= ~(optionResizable
| optionCaption
);
275 wxPaneInfo
& SetFlag(unsigned int flag
, bool option_state
)
284 bool HasFlag(unsigned int flag
) const
286 return (state
& flag
) ? true:false;
293 optionFloating
= 1 << 0,
294 optionHidden
= 1 << 1,
295 optionLeftDockable
= 1 << 2,
296 optionRightDockable
= 1 << 3,
297 optionTopDockable
= 1 << 4,
298 optionBottomDockable
= 1 << 5,
299 optionFloatable
= 1 << 6,
300 optionMovable
= 1 << 7,
301 optionResizable
= 1 << 8,
302 optionPaneBorder
= 1 << 9,
303 optionCaption
= 1 << 10,
304 optionGripper
= 1 << 11,
305 optionDestroyOnClose
= 1 << 12,
306 optionToolbar
= 1 << 13,
307 optionActive
= 1 << 14,
308 optionGripperTop
= 1 << 15,
310 buttonClose
= 1 << 24,
311 buttonMaximize
= 1 << 25,
312 buttonMinimize
= 1 << 26,
314 buttonCustom1
= 1 << 28,
315 buttonCustom2
= 1 << 29,
316 buttonCustom3
= 1 << 30,
317 actionPane
= 1 << 31 // used internally
321 wxString name
; // name of the pane
322 wxString caption
; // caption displayed on the window
324 wxWindow
* window
; // window that is in this pane
325 wxWindow
* frame
; // floating frame window that holds the pane
326 unsigned int state
; // a combination of wxPaneState values
328 int dock_direction
; // dock direction (top, bottom, left, right, center)
329 int dock_layer
; // layer number (0 = innermost layer)
330 int dock_row
; // row number on the docking bar (0 = first row)
331 int dock_pos
; // position inside the row (0 = first position)
333 wxSize best_size
; // size that the layout engine will prefer
334 wxSize min_size
; // minimum size the pane window can tolerate
335 wxSize max_size
; // maximum size the pane window can tolerate
337 wxPoint floating_pos
; // position while floating
338 wxSize floating_size
; // size while floating
339 int dock_proportion
; // proportion while docked
341 wxPaneButtonArray buttons
; // buttons on the pane
343 wxRect rect
; // current rectangle (populated by wxAUI)
350 class WXDLLIMPEXP_AUI wxFrameManager
: public wxEvtHandler
352 friend class wxFloatingPane
;
356 wxFrameManager(wxFrame
* frame
= NULL
,
357 unsigned int flags
= wxAUI_MGR_DEFAULT
);
358 virtual ~wxFrameManager();
361 void SetFlags(unsigned int flags
);
362 unsigned int GetFlags() const;
364 void SetFrame(wxFrame
* frame
);
365 wxFrame
* GetFrame() const;
367 void SetArtProvider(wxDockArt
* art_provider
);
368 wxDockArt
* GetArtProvider() const;
370 wxPaneInfo
& GetPane(wxWindow
* window
);
371 wxPaneInfo
& GetPane(const wxString
& name
);
372 wxPaneInfoArray
& GetAllPanes();
374 bool AddPane(wxWindow
* window
,
375 const wxPaneInfo
& pane_info
);
377 bool AddPane(wxWindow
* window
,
378 int direction
= wxLEFT
,
379 const wxString
& caption
= wxEmptyString
);
381 bool InsertPane(wxWindow
* window
,
382 const wxPaneInfo
& pane_info
,
383 int insert_level
= wxAUI_INSERT_PANE
);
385 bool DetachPane(wxWindow
* window
);
387 wxString
SavePerspective();
389 bool LoadPerspective(const wxString
& perspective
,
396 void DrawHintRect(wxWindow
* pane_window
,
398 const wxPoint
& offset
);
400 void DoFrameLayout();
402 void LayoutAddPane(wxSizer
* container
,
405 wxDockUIPartArray
& uiparts
,
408 void LayoutAddDock(wxSizer
* container
,
410 wxDockUIPartArray
& uiparts
,
413 wxSizer
* LayoutAll(wxPaneInfoArray
& panes
,
414 wxDockInfoArray
& docks
,
415 wxDockUIPartArray
& uiparts
,
416 bool spacer_only
= false);
418 bool DoDrop(wxDockInfoArray
& docks
,
419 wxPaneInfoArray
& panes
,
422 const wxPoint
& action_offset
= wxPoint(0,0));
424 wxPaneInfo
& LookupPane(wxWindow
* window
);
425 wxPaneInfo
& LookupPane(const wxString
& name
);
426 wxDockUIPart
* HitTest(int x
, int y
);
427 wxDockUIPart
* GetPanePart(wxWindow
* pane
);
428 int GetDockPixelOffset(wxPaneInfo
& test
);
429 void OnFloatingPaneMoveStart(wxWindow
* window
);
430 void OnFloatingPaneMoving(wxWindow
* window
);
431 void OnFloatingPaneMoved(wxWindow
* window
);
432 void OnFloatingPaneActivated(wxWindow
* window
);
433 void OnFloatingPaneClosed(wxWindow
* window
);
434 void OnFloatingPaneResized(wxWindow
* window
, const wxSize
& size
);
435 void Render(wxDC
* dc
);
436 void Repaint(wxDC
* dc
= NULL
);
437 void ProcessMgrEvent(wxFrameManagerEvent
& event
);
438 void UpdateButtonOnScreen(wxDockUIPart
* button_ui_part
,
439 const wxMouseEvent
& event
);
440 void GetPanePositionsAndSizes(wxDockInfo
& dock
,
441 wxArrayInt
& positions
,
443 void ShowHint(const wxRect
& rect
);
450 void OnPaint(wxPaintEvent
& event
);
451 void OnEraseBackground(wxEraseEvent
& event
);
452 void OnSize(wxSizeEvent
& event
);
453 void OnSetCursor(wxSetCursorEvent
& event
);
454 void OnLeftDown(wxMouseEvent
& event
);
455 void OnLeftUp(wxMouseEvent
& event
);
456 void OnMotion(wxMouseEvent
& event
);
457 void OnLeaveWindow(wxMouseEvent
& event
);
458 void OnPaneButton(wxFrameManagerEvent
& event
);
459 void OnChildFocus(wxChildFocusEvent
& event
);
460 void OnHintFadeTimer(wxTimerEvent
& event
);
470 actionDragToolbarPane
,
471 actionDragFloatingPane
476 wxFrame
* m_frame
; // the frame being managed
477 wxDockArt
* m_art
; // dock art object which does all drawing
478 unsigned int m_flags
; // manager flags wxAUI_MGR_*
480 wxPaneInfoArray m_panes
; // array of panes structures
481 wxDockInfoArray m_docks
; // array of docks structures
482 wxDockUIPartArray m_uiparts
; // array of UI parts (captions, buttons, etc)
484 int m_action
; // current mouse action
485 wxPoint m_action_start
; // position where the action click started
486 wxPoint m_action_offset
; // offset from upper left of the item clicked
487 wxDockUIPart
* m_action_part
; // ptr to the part the action happened to
488 wxWindow
* m_action_window
; // action frame or window (NULL if none)
489 wxRect m_action_hintrect
; // hint rectangle for the action
490 wxDockUIPart
* m_hover_button
;// button uipart being hovered over
491 wxRect m_last_hint
; // last hint rectangle
492 wxPoint m_last_mouse_move
; // last mouse move position (see OnMotion)
494 wxWindow
* m_hint_wnd
; // transparent hint window (for now, only msw)
495 wxTimer m_hint_fadetimer
; // transparent fade timer (for now, only msw)
496 int m_hint_fadeamt
; // transparent fade amount (for now, only msw)
498 DECLARE_EVENT_TABLE()
503 // event declarations/classes
505 class WXDLLIMPEXP_AUI wxFrameManagerEvent
: public wxEvent
508 wxFrameManagerEvent(wxEventType type
) : wxEvent(0, type
)
514 wxFrameManagerEvent(const wxFrameManagerEvent
& c
) : wxEvent(c
)
520 wxEvent
*Clone() const { return new wxFrameManagerEvent(*this); }
522 void SetPane(wxPaneInfo
* p
) { pane
= p
; }
523 void SetButton(int b
) { button
= b
; }
524 wxPaneInfo
* GetPane() { return pane
; }
525 int GetButton() { return button
; }
533 class WXDLLIMPEXP_AUI wxDockInfo
548 wxDockInfo(const wxDockInfo
& c
)
550 dock_direction
= c
.dock_direction
;
551 dock_layer
= c
.dock_layer
;
552 dock_row
= c
.dock_row
;
554 min_size
= c
.min_size
;
555 resizable
= c
.resizable
;
562 wxDockInfo
& operator=(const wxDockInfo
& c
)
564 dock_direction
= c
.dock_direction
;
565 dock_layer
= c
.dock_layer
;
566 dock_row
= c
.dock_row
;
568 min_size
= c
.min_size
;
569 resizable
= c
.resizable
;
577 bool IsOk() const { return (dock_direction
!= 0) ? true : false; }
578 bool IsHorizontal() const { return (dock_direction
== wxAUI_DOCK_TOP
||
579 dock_direction
== wxAUI_DOCK_BOTTOM
) ? true:false; }
580 bool IsVertical() const { return (dock_direction
== wxAUI_DOCK_LEFT
||
581 dock_direction
== wxAUI_DOCK_RIGHT
||
582 dock_direction
== wxAUI_DOCK_CENTER
) ? true:false; }
584 wxPaneInfoPtrArray panes
; // array of panes
585 wxRect rect
; // current rectangle
586 int dock_direction
; // dock direction (top, bottom, left, right, center)
587 int dock_layer
; // layer number (0 = innermost layer)
588 int dock_row
; // row number on the docking bar (0 = first row)
589 int size
; // size of the dock
590 int min_size
; // minimum size of a dock (0 if there is no min)
591 bool resizable
; // flag indicating whether the dock is resizable
592 bool toolbar
; // flag indicating dock contains only toolbars
593 bool fixed
; // flag indicating that the dock operates on
594 // absolute coordinates as opposed to proportional
598 class WXDLLIMPEXP_AUI wxDockUIPart
614 int type
; // ui part type (see enum above)
615 int orientation
; // orientation (either wxHORIZONTAL or wxVERTICAL)
616 wxDockInfo
* dock
; // which dock the item is associated with
617 wxPaneInfo
* pane
; // which pane the item is associated with
618 wxPaneButton
* button
; // which pane button the item is associated with
619 wxSizer
* cont_sizer
; // the part's containing sizer
620 wxSizerItem
* sizer_item
; // the sizer item of the part
621 wxRect rect
; // client coord rectangle of the part itself
625 class WXDLLIMPEXP_AUI wxPaneButton
628 int button_id
; // id of the button (e.g. buttonClose)
634 // wx event machinery
637 // right now the only event that works is wxEVT_AUI_PANEBUTTON. A full
638 // spectrum of events will be implemented in the next incremental version
640 BEGIN_DECLARE_EVENT_TYPES()
641 DECLARE_EVENT_TYPE(wxEVT_AUI_PANEBUTTON
, 0)
642 END_DECLARE_EVENT_TYPES()
644 typedef void (wxEvtHandler::*wxFrameManagerEventFunction
)(wxFrameManagerEvent
&);
646 #define wxFrameManagerEventHandler(func) \
647 (wxObjectEventFunction)(wxEventFunction)wxStaticCastEvent(wxFrameManagerEventFunction, &func)
649 #define EVT_AUI_PANEBUTTON(func) \
650 wx__DECLARE_EVT0(wxEVT_AUI_PANEBUTTON, wxFrameManagerEventHandler(func))
653 #endif //_WX_FRAMEMANAGER_H_