X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/50acee04cdaf2fec9f3fa4cd0035ff2d9ed7d53a..3882e74621cd5833fddb432fe014bea66c16ee28:/include/wx/aui/framemanager.h diff --git a/include/wx/aui/framemanager.h b/include/wx/aui/framemanager.h index f1f5016377..cf6d9094c7 100644 --- a/include/wx/aui/framemanager.h +++ b/include/wx/aui/framemanager.h @@ -1,10 +1,10 @@ /////////////////////////////////////////////////////////////////////////////// -// Name: framemanager.h +// Name: wx/aui/framemanager.h // Purpose: wxaui: wx advanced user interface - docking window manager // Author: Benjamin I. Williams // Modified by: // Created: 2005-05-17 -// RCS-ID: +// RCS-ID: $Id$ // Copyright: (C) Copyright 2005, Kirix Corporation, All Rights Reserved. // Licence: wxWindows Library Licence, Version 3.1 /////////////////////////////////////////////////////////////////////////////// @@ -20,7 +20,13 @@ #if wxUSE_AUI -enum WXDLLIMPEXP_AUI wxFrameManagerDock +#include "wx/dynarray.h" +#include "wx/gdicmn.h" +#include "wx/window.h" +#include "wx/timer.h" +#include "wx/sizer.h" + +enum wxFrameManagerDock { wxAUI_DOCK_NONE = 0, wxAUI_DOCK_TOP = 1, @@ -31,20 +37,25 @@ enum WXDLLIMPEXP_AUI wxFrameManagerDock wxAUI_DOCK_CENTRE = wxAUI_DOCK_CENTER }; -enum WXDLLIMPEXP_AUI wxFrameManagerOption +enum wxFrameManagerOption { - wxAUI_MGR_ALLOW_FLOATING = 1 << 0, - wxAUI_MGR_ALLOW_ACTIVE_PANE = 1 << 1, - wxAUI_MGR_TRANSPARENT_DRAG = 1 << 2, - wxAUI_MGR_TRANSPARENT_HINT = 1 << 3, - wxAUI_MGR_TRANSPARENT_HINT_FADE = 1 << 4, + wxAUI_MGR_ALLOW_FLOATING = 1 << 0, + wxAUI_MGR_ALLOW_ACTIVE_PANE = 1 << 1, + wxAUI_MGR_TRANSPARENT_DRAG = 1 << 2, + wxAUI_MGR_TRANSPARENT_HINT = 1 << 3, + wxAUI_MGR_VENETIAN_BLINDS_HINT = 1 << 4, + wxAUI_MGR_RECTANGLE_HINT = 1 << 5, + wxAUI_MGR_HINT_FADE = 1 << 6, + wxAUI_MGR_NO_VENETIAN_BLINDS_FADE = 1 << 7, wxAUI_MGR_DEFAULT = wxAUI_MGR_ALLOW_FLOATING | wxAUI_MGR_TRANSPARENT_HINT | - wxAUI_MGR_TRANSPARENT_HINT_FADE + wxAUI_MGR_HINT_FADE | + wxAUI_MGR_NO_VENETIAN_BLINDS_FADE }; -enum WXDLLIMPEXP_AUI wxPaneDockArtSetting + +enum wxPaneDockArtSetting { wxAUI_ART_SASH_SIZE = 0, wxAUI_ART_CAPTION_SIZE = 1, @@ -65,21 +76,39 @@ enum WXDLLIMPEXP_AUI wxPaneDockArtSetting wxAUI_ART_GRADIENT_TYPE = 16 }; -enum WXDLLIMPEXP_AUI wxPaneDockArtGradients +enum wxPaneDockArtGradients { wxAUI_GRADIENT_NONE = 0, wxAUI_GRADIENT_VERTICAL = 1, wxAUI_GRADIENT_HORIZONTAL = 2 }; -enum WXDLLIMPEXP_AUI wxPaneButtonState +enum wxPaneButtonState +{ + wxAUI_BUTTON_STATE_NORMAL = 0, + wxAUI_BUTTON_STATE_HOVER = 1 << 1, + wxAUI_BUTTON_STATE_PRESSED = 1 << 2, + wxAUI_BUTTON_STATE_DISABLED = 1 << 3, + wxAUI_BUTTON_STATE_HIDDEN = 1 << 4 +}; + +enum wxAuiButtonId { - wxAUI_BUTTON_STATE_NORMAL = 0, - wxAUI_BUTTON_STATE_HOVER = 1, - wxAUI_BUTTON_STATE_PRESSED = 2 + wxAUI_BUTTON_CLOSE = 101, + wxAUI_BUTTON_MAXIMIZE = 102, + wxAUI_BUTTON_MINIMIZE = 103, + wxAUI_BUTTON_PIN = 104, + wxAUI_BUTTON_OPTIONS = 105, + wxAUI_BUTTON_LEFT = 106, + wxAUI_BUTTON_RIGHT = 107, + wxAUI_BUTTON_UP = 108, + wxAUI_BUTTON_DOWN = 109, + wxAUI_BUTTON_CUSTOM1 = 201, + wxAUI_BUTTON_CUSTOM2 = 202, + wxAUI_BUTTON_CUSTOM3 = 203 }; -enum WXDLLIMPEXP_AUI wxPaneInsertLevel +enum wxPaneInsertLevel { wxAUI_INSERT_PANE = 0, wxAUI_INSERT_ROW = 1, @@ -88,6 +117,7 @@ enum WXDLLIMPEXP_AUI wxPaneInsertLevel + // forwards and array declarations class wxDockUIPart; class wxPaneButton; @@ -96,16 +126,17 @@ class wxDockInfo; class wxDockArt; class wxFrameManagerEvent; -WX_DECLARE_OBJARRAY(wxDockInfo, wxDockInfoArray); -WX_DECLARE_OBJARRAY(wxDockUIPart, wxDockUIPartArray); -WX_DECLARE_OBJARRAY(wxPaneButton, wxPaneButtonArray); -WX_DECLARE_OBJARRAY(wxPaneInfo, wxPaneInfoArray); -WX_DEFINE_ARRAY_PTR(wxPaneInfo*, wxPaneInfoPtrArray); -WX_DEFINE_ARRAY_PTR(wxDockInfo*, wxDockInfoPtrArray); - -extern wxDockInfo wxNullDockInfo; -extern wxPaneInfo wxNullPaneInfo; +#ifndef SWIG +WX_DECLARE_USER_EXPORTED_OBJARRAY(wxDockInfo, wxDockInfoArray, WXDLLIMPEXP_AUI); +WX_DECLARE_USER_EXPORTED_OBJARRAY(wxDockUIPart, wxDockUIPartArray, WXDLLIMPEXP_AUI); +WX_DECLARE_USER_EXPORTED_OBJARRAY(wxPaneButton, wxPaneButtonArray, WXDLLIMPEXP_AUI); +WX_DECLARE_USER_EXPORTED_OBJARRAY(wxPaneInfo, wxPaneInfoArray, WXDLLIMPEXP_AUI); +WX_DEFINE_USER_EXPORTED_ARRAY_PTR(wxPaneInfo*, wxPaneInfoPtrArray, class WXDLLIMPEXP_AUI); +WX_DEFINE_USER_EXPORTED_ARRAY_PTR(wxDockInfo*, wxDockInfoPtrArray, class WXDLLIMPEXP_AUI); +#endif // SWIG +extern WXDLLIMPEXP_AUI wxDockInfo wxNullDockInfo; +extern WXDLLIMPEXP_AUI wxPaneInfo wxNullPaneInfo; @@ -128,10 +159,13 @@ public: min_size = wxDefaultSize; max_size = wxDefaultSize; dock_proportion = 0; - + DefaultPane(); } + ~wxPaneInfo() {} + +#ifndef SWIG wxPaneInfo(const wxPaneInfo& c) { name = c.name; @@ -174,6 +208,20 @@ public: rect = c.rect; return *this; } +#endif // SWIG + + // Write the safe parts of a newly loaded PaneInfo structure "source" into "this" + // used on loading perspectives etc. + void SafeSet(wxPaneInfo source) + { + // note source is not passed by reference so we can overwrite, to keep the + // unsafe bits of "dest" + source.window = window; + source.frame = frame; + source.buttons = buttons; + // now assign + *this = source; + } bool IsOk() const { return (window != NULL) ? true : false; } bool IsFixed() const { return !HasFlag(optionResizable); } @@ -188,6 +236,7 @@ public: bool IsRightDockable() const { return HasFlag(optionRightDockable); } bool IsFloatable() const { return HasFlag(optionFloatable); } bool IsMovable() const { return HasFlag(optionMovable); } + bool IsDestroyOnClose() const { return HasFlag(optionDestroyOnClose); } bool HasCaption() const { return HasFlag(optionCaption); } bool HasGripper() const { return HasFlag(optionGripper); } bool HasBorder() const { return HasFlag(optionPaneBorder); } @@ -196,7 +245,10 @@ public: bool HasMinimizeButton() const { return HasFlag(buttonMinimize); } bool HasPinButton() const { return HasFlag(buttonPin); } bool HasGripperTop() const { return HasFlag(optionGripperTop); } - + +#ifdef SWIG + %typemap(out) wxPaneInfo& { $result = $self; Py_INCREF($result); } +#endif wxPaneInfo& Window(wxWindow* w) { window = w; return *this; } wxPaneInfo& Name(const wxString& n) { name = n; return *this; } wxPaneInfo& Caption(const wxString& c) { caption = c; return *this; } @@ -230,7 +282,7 @@ public: wxPaneInfo& PaneBorder(bool visible = true) { return SetFlag(optionPaneBorder, visible); } wxPaneInfo& Gripper(bool visible = true) { return SetFlag(optionGripper, visible); } wxPaneInfo& GripperTop(bool attop = true) { return SetFlag(optionGripperTop, attop); } - wxPaneInfo& CloseButton(bool visible = true) { return SetFlag(buttonClose, visible); } + wxPaneInfo& CloseButton(bool visible = true) { return SetFlag(buttonClose, visible); } wxPaneInfo& MaximizeButton(bool visible = true) { return SetFlag(buttonMaximize, visible); } wxPaneInfo& MinimizeButton(bool visible = true) { return SetFlag(buttonMinimize, visible); } wxPaneInfo& PinButton(bool visible = true) { return SetFlag(buttonPin, visible); } @@ -238,7 +290,7 @@ public: wxPaneInfo& TopDockable(bool b = true) { return SetFlag(optionTopDockable, b); } wxPaneInfo& BottomDockable(bool b = true) { return SetFlag(optionBottomDockable, b); } wxPaneInfo& LeftDockable(bool b = true) { return SetFlag(optionLeftDockable, b); } - wxPaneInfo& RightDockable(bool b = true) { return SetFlag(optionRightDockable, b); } + wxPaneInfo& RightDockable(bool b = true) { return SetFlag(optionRightDockable, b); } wxPaneInfo& Floatable(bool b = true) { return SetFlag(optionFloatable, b); } wxPaneInfo& Movable(bool b = true) { return SetFlag(optionMovable, b); } wxPaneInfo& Dockable(bool b = true) @@ -254,14 +306,14 @@ public: optionCaption | optionPaneBorder | buttonClose; return *this; } - + wxPaneInfo& CentrePane() { return CenterPane(); } wxPaneInfo& CenterPane() { state = 0; return Center().PaneBorder().Resizable(); } - + wxPaneInfo& ToolbarPane() { DefaultPane(); @@ -280,12 +332,16 @@ public: state &= ~flag; return *this; } - + bool HasFlag(unsigned int flag) const { return (state & flag) ? true:false; } +#ifdef SWIG + %typemap(out) wxPaneInfo& ; +#endif + public: enum wxPaneState @@ -305,7 +361,7 @@ public: optionDestroyOnClose = 1 << 12, optionToolbar = 1 << 13, optionActive = 1 << 14, - optionGripperTop = 1 << 15, + optionGripperTop = 1 << 15, buttonClose = 1 << 24, buttonMaximize = 1 << 25, @@ -322,7 +378,7 @@ public: wxString caption; // caption displayed on the window wxWindow* window; // window that is in this pane - wxWindow* frame; // floating frame window that holds the pane + wxFrame* frame; // floating frame window that holds the pane unsigned int state; // a combination of wxPaneState values int dock_direction; // dock direction (top, bottom, left, right, center) @@ -345,7 +401,7 @@ public: - +class WXDLLIMPEXP_AUI wxFloatingPane; class WXDLLIMPEXP_AUI wxFrameManager : public wxEvtHandler { @@ -353,17 +409,20 @@ friend class wxFloatingPane; public: - wxFrameManager(wxFrame* frame = NULL, + wxFrameManager(wxWindow* managed_wnd = NULL, unsigned int flags = wxAUI_MGR_DEFAULT); virtual ~wxFrameManager(); void UnInit(); - + void SetFlags(unsigned int flags); unsigned int GetFlags() const; - - void SetFrame(wxFrame* frame); - wxFrame* GetFrame() const; - + + void SetManagedWindow(wxWindow* managed_wnd); + wxWindow* GetManagedWindow() const; + +#ifdef SWIG + %disownarg( wxDockArt* art_provider ); +#endif void SetArtProvider(wxDockArt* art_provider); wxDockArt* GetArtProvider() const; @@ -374,29 +433,54 @@ public: bool AddPane(wxWindow* window, const wxPaneInfo& pane_info); + bool AddPane(wxWindow* window, + const wxPaneInfo& pane_info, + const wxPoint& drop_pos); + bool AddPane(wxWindow* window, int direction = wxLEFT, const wxString& caption = wxEmptyString); - + bool InsertPane(wxWindow* window, - const wxPaneInfo& pane_info, + const wxPaneInfo& insert_location, int insert_level = wxAUI_INSERT_PANE); - + bool DetachPane(wxWindow* window); + + void ClosePane(wxPaneInfo& pane_info); + + wxString SavePaneInfo(wxPaneInfo& pane); + void LoadPaneInfo(wxString pane_part, wxPaneInfo &pane); wxString SavePerspective(); - + bool LoadPerspective(const wxString& perspective, bool update = true); - + void Update(); -private: + +public: + virtual wxFloatingPane* CreateFloatingFrame(wxWindow* parent, const wxPaneInfo& p); void DrawHintRect(wxWindow* pane_window, - const wxPoint& pt, - const wxPoint& offset); + const wxPoint& pt, + const wxPoint& offset); + virtual void ShowHint(const wxRect& rect); + virtual void HideHint(); +public: + + // deprecated -- please use SetManagedWindow() and + // and GetManagedWindow() instead + + wxDEPRECATED( void SetFrame(wxFrame* frame) ); + wxDEPRECATED( wxFrame* GetFrame() const ); + +protected: + + void UpdateHintWindowConfig(); + void DoFrameLayout(); void LayoutAddPane(wxSizer* container, @@ -415,6 +499,9 @@ private: wxDockUIPartArray& uiparts, bool spacer_only = false); + virtual bool ProcessDockResult(wxPaneInfo& target, + const wxPaneInfo& new_pos); + bool DoDrop(wxDockInfoArray& docks, wxPaneInfoArray& panes, wxPaneInfo& drop, @@ -427,10 +514,10 @@ private: wxDockUIPart* GetPanePart(wxWindow* pane); int GetDockPixelOffset(wxPaneInfo& test); void OnFloatingPaneMoveStart(wxWindow* window); - void OnFloatingPaneMoving(wxWindow* window); - void OnFloatingPaneMoved(wxWindow* window); + void OnFloatingPaneMoving(wxWindow* window, wxDirection dir ); + void OnFloatingPaneMoved(wxWindow* window, wxDirection dir); void OnFloatingPaneActivated(wxWindow* window); - void OnFloatingPaneClosed(wxWindow* window); + void OnFloatingPaneClosed(wxWindow* window, wxCloseEvent& evt); void OnFloatingPaneResized(wxWindow* window, const wxSize& size); void Render(wxDC* dc); void Repaint(wxDC* dc = NULL); @@ -440,26 +527,29 @@ private: void GetPanePositionsAndSizes(wxDockInfo& dock, wxArrayInt& positions, wxArrayInt& sizes); - void ShowHint(const wxRect& rect); - void HideHint(); - void RemoveHint(); -private: - // events - void OnPaint(wxPaintEvent& event); - void OnEraseBackground(wxEraseEvent& event); - void OnSize(wxSizeEvent& event); - void OnSetCursor(wxSetCursorEvent& event); - void OnLeftDown(wxMouseEvent& event); - void OnLeftUp(wxMouseEvent& event); - void OnMotion(wxMouseEvent& event); - void OnLeaveWindow(wxMouseEvent& event); - void OnPaneButton(wxFrameManagerEvent& event); - void OnChildFocus(wxChildFocusEvent& event); - void OnHintFadeTimer(wxTimerEvent& event); +public: -private: + // public events (which can be invoked externally) + void OnRender(wxFrameManagerEvent& evt); + void OnPaneButton(wxFrameManagerEvent& evt); + +protected: + + // protected events + void OnPaint(wxPaintEvent& evt); + void OnEraseBackground(wxEraseEvent& evt); + void OnSize(wxSizeEvent& evt); + void OnSetCursor(wxSetCursorEvent& evt); + void OnLeftDown(wxMouseEvent& evt); + void OnLeftUp(wxMouseEvent& evt); + void OnMotion(wxMouseEvent& evt); + void OnLeaveWindow(wxMouseEvent& evt); + void OnChildFocus(wxChildFocusEvent& evt); + void OnHintFadeTimer(wxTimerEvent& evt); + +protected: enum { @@ -471,9 +561,9 @@ private: actionDragFloatingPane }; -private: +protected: - wxFrame* m_frame; // the frame being managed + wxWindow* m_frame; // the window being managed wxDockArt* m_art; // dock art object which does all drawing unsigned int m_flags; // manager flags wxAUI_MGR_* @@ -487,15 +577,20 @@ private: wxDockUIPart* m_action_part; // ptr to the part the action happened to wxWindow* m_action_window; // action frame or window (NULL if none) wxRect m_action_hintrect; // hint rectangle for the action + bool m_skipping; + wxRect m_last_rect; wxDockUIPart* m_hover_button;// button uipart being hovered over wxRect m_last_hint; // last hint rectangle wxPoint m_last_mouse_move; // last mouse move position (see OnMotion) - wxWindow* m_hint_wnd; // transparent hint window (for now, only msw) - wxTimer m_hint_fadetimer; // transparent fade timer (for now, only msw) - int m_hint_fadeamt; // transparent fade amount (for now, only msw) - + wxFrame* m_hint_wnd; // transparent hint window, if supported by platform + wxTimer m_hint_fadetimer; // transparent fade timer + wxByte m_hint_fadeamt; // transparent fade amount + wxByte m_hint_fademax; // maximum value of hint fade + +#ifndef SWIG DECLARE_EVENT_TABLE() +#endif // SWIG }; @@ -505,28 +600,50 @@ private: class WXDLLIMPEXP_AUI wxFrameManagerEvent : public wxEvent { public: - wxFrameManagerEvent(wxEventType type) : wxEvent(0, type) + wxFrameManagerEvent(wxEventType type=wxEVT_NULL) : wxEvent(0, type) { pane = NULL; button = 0; + veto_flag = false; + canveto_flag = true; + dc = NULL; } - +#ifndef SWIG wxFrameManagerEvent(const wxFrameManagerEvent& c) : wxEvent(c) { pane = c.pane; button = c.button; + veto_flag = c.veto_flag; + canveto_flag = c.canveto_flag; + dc = c.dc; } - +#endif wxEvent *Clone() const { return new wxFrameManagerEvent(*this); } void SetPane(wxPaneInfo* p) { pane = p; } void SetButton(int b) { button = b; } + void SetDC(wxDC* pdc) { dc = pdc; } + wxPaneInfo* GetPane() { return pane; } int GetButton() { return button; } - + wxDC* GetDC() { return dc; } + + void Veto(bool veto = true) { veto_flag = veto; } + bool GetVeto() const { return veto_flag; } + void SetCanVeto(bool can_veto) { canveto_flag = can_veto; } + bool CanVeto() const { return canveto_flag && veto_flag; } + public: wxPaneInfo* pane; int button; + bool veto_flag; + bool canveto_flag; + wxDC* dc; + +#ifndef SWIG +private: + DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxFrameManagerEvent) +#endif }; @@ -545,6 +662,7 @@ public: toolbar = false; } +#ifndef SWIG wxDockInfo(const wxDockInfo& c) { dock_direction = c.dock_direction; @@ -573,6 +691,7 @@ public: rect = c.rect; return *this; } +#endif // SWIG bool IsOk() const { return (dock_direction != 0) ? true : false; } bool IsHorizontal() const { return (dock_direction == wxAUI_DOCK_TOP || @@ -608,7 +727,7 @@ public: typePaneSizer, typeBackground, typePaneBorder, - typePaneButton, + typePaneButton }; int type; // ui part type (see enum above) @@ -630,15 +749,13 @@ public: - +#ifndef SWIG // wx event machinery - -// right now the only event that works is wxEVT_AUI_PANEBUTTON. A full -// spectrum of events will be implemented in the next incremental version - BEGIN_DECLARE_EVENT_TYPES() - DECLARE_EVENT_TYPE(wxEVT_AUI_PANEBUTTON, 0) + DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_AUI, wxEVT_AUI_PANEBUTTON, 0) + DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_AUI, wxEVT_AUI_PANECLOSE, 0) + DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_AUI, wxEVT_AUI_RENDER, 0) END_DECLARE_EVENT_TYPES() typedef void (wxEvtHandler::*wxFrameManagerEventFunction)(wxFrameManagerEvent&); @@ -648,6 +765,23 @@ typedef void (wxEvtHandler::*wxFrameManagerEventFunction)(wxFrameManagerEvent&); #define EVT_AUI_PANEBUTTON(func) \ wx__DECLARE_EVT0(wxEVT_AUI_PANEBUTTON, wxFrameManagerEventHandler(func)) +#define EVT_AUI_PANECLOSE(func) \ + wx__DECLARE_EVT0(wxEVT_AUI_PANECLOSE, wxFrameManagerEventHandler(func)) +#define EVT_AUI_RENDER(func) \ + wx__DECLARE_EVT0(wxEVT_AUI_RENDER, wxFrameManagerEventHandler(func)) + +#else + +%constant wxEventType wxEVT_AUI_PANEBUTTON; +%constant wxEventType wxEVT_AUI_PANECLOSE; +%constant wxEventType wxEVT_AUI_RENDER; + +%pythoncode { + EVT_AUI_PANEBUTTON = wx.PyEventBinder( wxEVT_AUI_PANEBUTTON ) + EVT_AUI_PANECLOSE = wx.PyEventBinder( wxEVT_AUI_PANECLOSE ) + EVT_AUI_RENDER = wx.PyEventBinder( wxEVT_AUI_RENDER ) +} +#endif // SWIG #endif // wxUSE_AUI #endif //_WX_FRAMEMANAGER_H_