📄 controlbar.h
字号:
/////////////////////////////////////////////////////////////////////////////// Name: controlbar.h// Purpose: Central header file for control-bar related classes//// Author: Aleksandras Gluchovas <mailto:alex@soften.ktu.lt>// Modified by:// Created: 06/09/98// RCS-ID: $Id: controlbar.h,v 1.24 2005/09/23 12:46:56 MR Exp $// Copyright: (c) Aleksandras Gluchovas// Licence: wxWindows licence/////////////////////////////////////////////////////////////////////////////#ifndef __CONTROLBAR_G__#define __CONTROLBAR_G__#include "wx/defs.h"#include "wx/string.h"#include "wx/pen.h"#include "wx/window.h"#include "wx/dynarray.h"#include "wx/fl/fldefs.h"#define WXCONTROLBAR_VERSION 1.3// forward declarationsclass WXDLLIMPEXP_FL wxFrameLayout;class WXDLLIMPEXP_FL cbDockPane;class WXDLLIMPEXP_FL cbUpdatesManagerBase;class WXDLLIMPEXP_FL cbBarDimHandlerBase;class WXDLLIMPEXP_FL cbPluginBase;class WXDLLIMPEXP_FL cbPluginEvent;class WXDLLIMPEXP_FL cbPaneDrawPlugin;class WXDLLIMPEXP_FL cbBarInfo;class WXDLLIMPEXP_FL cbRowInfo;class WXDLLIMPEXP_FL cbDimInfo;class WXDLLIMPEXP_FL cbCommonPaneProperties;typedef cbBarInfo* BarInfoPtrT;typedef cbRowInfo* RowInfoPtrT;WXFL_DEFINE_ARRAY_PTR( BarInfoPtrT, BarArrayT );WXFL_DEFINE_ARRAY_PTR( RowInfoPtrT, RowArrayT );// control bar states#define wxCBAR_DOCKED_HORIZONTALLY 0#define wxCBAR_DOCKED_VERTICALLY 1#define wxCBAR_FLOATING 2#define wxCBAR_HIDDEN 3// the states are enumerated above#define MAX_BAR_STATES 4// control bar alignments#if !defined(FL_ALIGN_TOP)#define FL_ALIGN_TOP 0#define FL_ALIGN_BOTTOM 1#define FL_ALIGN_LEFT 2#define FL_ALIGN_RIGHT 3#endif// one pane for each alignment#define MAX_PANES 4// masks for each pane#define FL_ALIGN_TOP_PANE 0x0001#define FL_ALIGN_BOTTOM_PANE 0x0002#define FL_ALIGN_LEFT_PANE 0x0004#define FL_ALIGN_RIGHT_PANE 0x0008#define wxALL_PANES 0x000F// enumeration of hittest results, see cbDockPane::HitTestPaneItems(..)enum CB_HITTEST_RESULT{ CB_NO_ITEMS_HITTED, CB_UPPER_ROW_HANDLE_HITTED, CB_LOWER_ROW_HANDLE_HITTED, CB_LEFT_BAR_HANDLE_HITTED, CB_RIGHT_BAR_HANDLE_HITTED, CB_BAR_CONTENT_HITTED};/*Helper class, used for spying for unhandled mouse events on control barsand forwarding them to the frame layout.*/class WXDLLIMPEXP_FL cbBarSpy : public wxEvtHandler{public: DECLARE_DYNAMIC_CLASS( cbBarSpy ) wxFrameLayout* mpLayout; wxWindow* mpBarWnd;public: // Default constructor. cbBarSpy(void); // Constructor, taking a parent pane. cbBarSpy( wxFrameLayout* pPanel ); // Sets the bar window. void SetBarWindow( wxWindow* pWnd ); // Performs special event processing. virtual bool ProcessEvent(wxEvent& event);};/*wxFrameLayout manages containment and docking of control bars,which can be docked along the top, bottom, right, or left side of theparent frame.*/class WXDLLIMPEXP_FL wxFrameLayout : public wxEvtHandler{public: // Default constructor, used only for serialization. wxFrameLayout(); // Constructor, taking parent window, the (MDI) client of the parent if there // is one, and flag specifying whether to activate the layout. wxFrameLayout( wxWindow* pParentFrame, wxWindow* pFrameClient = NULL, bool activateNow = true ); // Destructor. It does not destroy the bar windows. virtual ~wxFrameLayout(); // Enables floating behaviour. By default floating of control bars is on. virtual void EnableFloating( bool enable = true ); // Activate can be called after some other layout has been deactivated, // and this one must take over the current contents of the frame window. // // Effectively hooks itself to the frame window, re-displays all non-hidden // bar windows and repaints the decorations. virtual void Activate(); // Deactivate unhooks itself from frame window, and hides all non-hidden windows. // // Note: two frame layouts should not be active at the same time in the // same frame window, since it would cause messy overlapping of bar windows // from both layouts. virtual void Deactivate(); // Hides the bar windows, and also the client window if present. void HideBarWindows(); // Destroys the bar windows. virtual void DestroyBarWindows(); // Passes the client window (e.g. MDI client window) to be controlled by // frame layout, the size and position of which should be adjusted to be // surrounded by controlbar panes, whenever the frame is resized or the dimensions // of control panes change. void SetFrameClient( wxWindow* pFrameClient ); // Returns the frame client, or NULL if not present. wxWindow* GetFrameClient(); // Returns the parent frame. wxWindow& GetParentFrame() { return *mpFrame; } // Returns an array of panes. Used by update managers. cbDockPane** GetPanesArray() { return mPanes; } // Returns a pane for the given alignment. See pane alignment types. cbDockPane* GetPane( int alignment ) { return mPanes[alignment]; } // Adds bar information to the frame layout. The appearance of the layout is not refreshed // immediately; RefreshNow() can be called if necessary. // // Notes: the argument pBarWnd can by NULL, resulting in bar decorations to be drawn // around the empty rectangle (filled with default background colour). // Argument dimInfo can be reused for adding any number of bars, since // it is not used directly - instead its members are copied. If the dimensions // handler is present, its instance is shared (reference counted). The dimension // handler should always be allocated on the heap. // pBarWnd is the window to be managed. // dimInfo contains dimension information. // alignment is a value such as FL_ALIGN_TOP. // rowNo is the vertical position or row in the pane (if in docked state). // columnPos is the horizontal position within the row in pixels (if in docked state). // name is a name by which the bar can be referred in layout customization dialogs. // If spyEvents is true, input events for the bar should be "spyed" in order // to forward unhandled mouse clicks to the frame layout, for example to enable // easy draggablity of toolbars just by clicking on their interior regions. // For widgets like text/tree control this value should be false, // since there's no certain way to detect whether the event was actually handled. // state is the initial state, such as wxCBAR_DOCKED_HORIZONTALLY, // wxCBAR_FLOATING, wxCBAR_HIDDEN. virtual void AddBar( wxWindow* pBarWnd, const cbDimInfo& dimInfo, // defaults: int alignment = FL_ALIGN_TOP, int rowNo = 0, int columnPos = 0, const wxString& name = wxT("bar"), bool spyEvents = false, int state = wxCBAR_DOCKED_HORIZONTALLY ); // ReddockBar can be used for repositioning existing bars. The given bar is first removed // from the pane it currently belongs to, and inserted into the pane, which "matches" // the given rectangular area. If pToPane is not NULL, the bar is docked to this given pane. // To dock a bar which is floating, use the wxFrameLayout::DockBar method. virtual bool RedockBar( cbBarInfo* pBar, const wxRect& shapeInParent, cbDockPane* pToPane = NULL, bool updateNow = true ); // Finds the bar in the framelayout, by name. cbBarInfo* FindBarByName( const wxString& name ); // Finds the bar in the framelayout, by window. cbBarInfo* FindBarByWindow( const wxWindow* pWnd ); // Gets an array of bars. BarArrayT& GetBars(); // Changes the bar's docking state (see possible control bar states). void SetBarState( cbBarInfo* pBar, int newStatem, bool updateNow ); // Toggles the bar between visible and hidden. void InverseVisibility( cbBarInfo* pBar ); // Reflects changes in bar information structure visually. // For example, moves the bar, changes its dimension information, // or changes the pane to which it is docked. void ApplyBarProperties( cbBarInfo* pBar ); // Removes the bar from the layout permanently, and hides its corresponding window if present. void RemoveBar( cbBarInfo* pBar ); // Recalculates the layout of panes, and all bars/rows in each pane. virtual void RecalcLayout( bool repositionBarsNow = false ); // Returns the client height. int GetClientHeight(); // Returns the client width. int GetClientWidth(); // Returns the client's rectangle. wxRect& GetClientRect() { return mClntWndBounds; } // Returns a reference to the updates manager. // Note: in future, the updates manager will become a normal plugin. cbUpdatesManagerBase& GetUpdatesManager(); // Destroys the previous manager if any, and sets the new one. void SetUpdatesManager( cbUpdatesManagerBase* pUMgr ); // Gets the pane properties for the given alignment. virtual void GetPaneProperties( cbCommonPaneProperties& props, int alignment = FL_ALIGN_TOP ); // Sets the pane properties for the given alignment. // Note: changing properties of panes does not result immediate on-screen update. virtual void SetPaneProperties( const cbCommonPaneProperties& props, int paneMask = wxALL_PANES ); // Sets the margins for the given panes. // The margins should go into cbCommonPaneProperties in the future. // // Note: this method should be called before any custom plugins are attached. virtual void SetMargins( int top, int bottom, int left, int right, int paneMask = wxALL_PANES ); // Sets the pane background colour. virtual void SetPaneBackground( const wxColour& colour ); // Recalculates layout and performs on-screen update of all panes. void RefreshNow( bool recalcLayout = true ); // Event handler for a size event. void OnSize ( wxSizeEvent& event ); // Event handler for a left down button event. void OnLButtonDown( wxMouseEvent& event ); // Event handler for a left doubleclick button event. void OnLDblClick ( wxMouseEvent& event ); // Event handler for a left button up event. void OnLButtonUp ( wxMouseEvent& event ); // Event handler for a right button down event. void OnRButtonDown( wxMouseEvent& event ); // Event handler for a right button up event. void OnRButtonUp ( wxMouseEvent& event ); // Event handler for a mouse move event. void OnMouseMove ( wxMouseEvent& event ); // This function should be used instead of passing the event to the ProcessEvent method // of the top-level plugin directly. This method checks if events are currently // captured and ensures that plugin-event is routed correctly. virtual void FirePluginEvent( cbPluginEvent& event ); // Captures user input events for the given plugin. // Input events are: mouse movement, mouse clicks, keyboard input. virtual void CaptureEventsForPlugin ( cbPluginBase* pPlugin ); // Releases user input events for the given plugin. // Input events are: mouse movement, mouse clicks, keyboard input virtual void ReleaseEventsFromPlugin( cbPluginBase* pPlugin ); // Called by plugins; also captures the mouse in the parent frame. void CaptureEventsForPane( cbDockPane* toPane ); // Called by plugins; also releases mouse in the parent frame. void ReleaseEventsFromPane( cbDockPane* fromPane ); // Returns the current top-level plugin (the one that receives events first, // except if input events are currently captured by some other plugin). virtual cbPluginBase& GetTopPlugin(); // Hooking custom plugins to frame layout. // // Note: when hooking one plugin on top of the other, // use SetNextHandler or similar methods // of wxEvtHandler class to compose the chain of plugins, // than pass the left-most handler in this chain to // the above methods (assuming that events are delegated // from left-most towards right-most handler). // // This secenario is very inconvenient and "low-level", // so use the Add/Push/PopPlugin methods instead. virtual void SetTopPlugin( cbPluginBase* pPlugin ); // Similar to wxWindow's "push/pop-event-handler" methods, execept // that the plugin is deleted upon "popping". virtual void PushPlugin( cbPluginBase* pPugin );
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -