1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: Central header file for control-bar related classes
5 // Author: Aleksandras Gluchovas <mailto:alex@soften.ktu.lt>
9 // Copyright: (c) Aleksandras Gluchovas
10 // Licence: wxWindows license
11 /////////////////////////////////////////////////////////////////////////////
13 #ifndef __CONTROLBAR_G__
14 #define __CONTROLBAR_G__
17 #pragma interface "controlbar.h"
21 #include "wx/string.h"
22 #include "wx/window.h"
23 #include "wx/dynarray.h"
25 #define WXCONTROLBAR_VERSION 1.3
27 // forward declarations
32 class cbUpdatesManagerBase
;
33 class cbBarDimHandlerBase
;
36 class cbPaneDrawPlugin
;
41 class cbCommonPaneProperties
;
43 typedef cbBarInfo
* BarInfoPtrT
;
44 typedef cbRowInfo
* RowInfoPtrT
;
46 WX_DEFINE_ARRAY( BarInfoPtrT
, BarArrayT
);
47 WX_DEFINE_ARRAY( RowInfoPtrT
, RowArrayT
);
51 #define wxCBAR_DOCKED_HORIZONTALLY 0
52 #define wxCBAR_DOCKED_VERTICALLY 1
53 #define wxCBAR_FLOATING 2
54 #define wxCBAR_HIDDEN 3
56 // the states are enumerated above
57 #define MAX_BAR_STATES 4
59 // control bar alignments
61 #if !defined(FL_ALIGN_TOP)
63 #define FL_ALIGN_TOP 0
64 #define FL_ALIGN_BOTTOM 1
65 #define FL_ALIGN_LEFT 2
66 #define FL_ALIGN_RIGHT 3
70 // one pane for each alignment
73 // masks for each pane
75 #define FL_ALIGN_TOP_PANE 0x0001
76 #define FL_ALIGN_BOTTOM_PANE 0x0002
77 #define FL_ALIGN_LEFT_PANE 0x0004
78 #define FL_ALIGN_RIGHT_PANE 0x0008
80 #define wxALL_PANES 0x000F
82 // enumeration of hittest results, see cbDockPane::HitTestPaneItems(..)
84 enum CB_HITTEST_RESULT
88 CB_UPPER_ROW_HANDLE_HITTED
,
89 CB_LOWER_ROW_HANDLE_HITTED
,
90 CB_LEFT_BAR_HANDLE_HITTED
,
91 CB_RIGHT_BAR_HANDLE_HITTED
,
95 // FIXME:: somehow in debug v. original wxASSERT's are not compiled in...
98 //#define wxASSERT(x) if ( !(x) ) throw;
101 Helper class, used for spying for unhandled mouse events on control bars
102 and forwarding them to the frame layout.
105 class cbBarSpy
: public wxEvtHandler
108 DECLARE_DYNAMIC_CLASS( cbBarSpy
)
110 wxFrameLayout
* mpLayout
;
114 // Default constructor.
118 // Constructor, taking a parent pane.
120 cbBarSpy( wxFrameLayout
* pPanel
);
122 // Sets the bar window.
124 void SetBarWindow( wxWindow
* pWnd
);
126 // Performs special event processing.
128 virtual bool ProcessEvent(wxEvent
& event
);
132 wxFrameLayout manages containment and docking of control bars,
133 which can be docked along the top, bottom, right, or left side of the
137 class wxFrameLayout
: public wxEvtHandler
140 // Default constructor, used only for serialization.
144 // Constructor, taking parent window, the (MDI) client of the parent if there
145 // is one, and flag specifying whether to activate the layout.
147 wxFrameLayout( wxWindow
* pParentFrame
,
148 wxWindow
* pFrameClient
= NULL
,
149 bool activateNow
= TRUE
);
151 // Destructor. It does not destroy the bar windows.
153 virtual ~wxFrameLayout();
155 // Enables floating behaviour. By default floating of control bars is on.
157 virtual void EnableFloating( bool enable
= TRUE
);
159 // Activate can be called after some other layout has been deactivated,
160 // and this one must take over the current contents of the frame window.
162 // Effectively hooks itself to the frame window, re-displays all non-hidden
163 // bar windows and repaints the decorations.
165 virtual void Activate();
167 // Deactivate unhooks itself from frame window, and hides all non-hidden windows.
169 // Note: two frame layouts should not be active at the same time in the
170 // same frame window, since it would cause messy overlapping of bar windows
171 // from both layouts.
173 virtual void Deactivate();
175 // Hides the bar windows, and also the client window if present.
177 void HideBarWindows();
179 // Destroys the bar windows.
181 virtual void DestroyBarWindows();
183 // Passes the client window (e.g. MDI client window) to be controlled by
184 // frame layout, the size and position of which should be adjusted to be
185 // surrounded by controlbar panes, whenever the frame is resized or the dimensions
186 // of control panes change.
188 void SetFrameClient( wxWindow
* pFrameClient
);
190 // Returns the frame client, or NULL if not present.
192 wxWindow
* GetFrameClient();
194 // Returns the parent frame.
196 wxWindow
& GetParentFrame() { return *mpFrame
; }
198 // Returns an array of panes. Used by update managers.
200 cbDockPane
** GetPanesArray() { return mPanes
; }
202 // Returns a pane for the given alignment. See pane alignment types.
204 cbDockPane
* GetPane( int alignment
)
206 { return mPanes
[alignment
]; }
208 // Adds bar information to the frame layout. The appearance of the layout is not refreshed
209 // immediately; RefreshNow() can be called if necessary.
211 // Notes: the argument pBarWnd can by NULL, resulting in bar decorations to be drawn
212 // around the empty rectangle (filled with default background colour).
213 // Argument dimInfo can be reused for adding any number of bars, since
214 // it is not used directly - instead its members are copied. If the dimensions
215 // handler is present, its instance is shared (reference counted). The dimension
216 // handler should always be allocated on the heap.
218 // pBarWnd is the window to be managed.
220 // dimInfo contains dimension information.
222 // alignment is a value such as FL_ALIGN_TOP.
224 // rowNo is the vertical position or row in the pane (if in docked state).
226 // columnPos is the horizontal position within the row in pixels (if in docked state).
228 // name is a name by which the bar can be referred in layout customization dialogs.
230 // If spyEvents is TRUE, input events for the bar should be "spyed" in order
231 // to forward unhandled mouse clicks to the frame layout, for example to enable
232 // easy draggablity of toolbars just by clicking on their interior regions.
233 // For widgets like text/tree control this value should be FALSE,
234 // since there's no certain way to detect whether the event was actually handled.
236 // state is the initial state, such as wxCBAR_DOCKED_HORIZONTALLY,
237 // wxCBAR_FLOATING, wxCBAR_HIDDEN.
239 virtual void AddBar( wxWindow
* pBarWnd
,
240 const cbDimInfo
& dimInfo
,
243 int alignment
= FL_ALIGN_TOP
,
246 const wxString
& name
="bar",
247 bool spyEvents
= FALSE
,
248 int state
= wxCBAR_DOCKED_HORIZONTALLY
251 // ReddockBar can be used for repositioning existing bars. The given bar is first removed
252 // from the pane it currently belongs to, and inserted into the pane, which "matches"
253 // the given rectangular area. If pToPane is not NULL, the bar is docked to this given pane.
254 // To dock a bar which is floating, use the wxFrameLayout::DockBar method.
256 virtual bool RedockBar( cbBarInfo
* pBar
, const wxRect
& shapeInParent
,
257 cbDockPane
* pToPane
= NULL
, bool updateNow
= TRUE
);
259 // Finds the bar in the framelayout, by name.
261 cbBarInfo
* FindBarByName( const wxString
& name
);
263 // Finds the bar in the framelayout, by window.
265 cbBarInfo
* FindBarByWindow( const wxWindow
* pWnd
);
267 // Gets an array of bars.
269 BarArrayT
& GetBars();
271 // Changes the bar's docking state (see possible control bar states).
273 void SetBarState( cbBarInfo
* pBar
, int newStatem
, bool updateNow
);
275 // Toggles the bar between visible and hidden.
277 void InverseVisibility( cbBarInfo
* pBar
);
279 // Reflects changes in bar information structure visually.
280 // For example, moves the bar, changes its dimension information,
281 // or changes the pane to which it is docked.
283 void ApplyBarProperties( cbBarInfo
* pBar
);
285 // Removes the bar from the layout permanently, and hides its corresponding window if present.
287 void RemoveBar( cbBarInfo
* pBar
);
289 // Recalculates the layout of panes, and all bars/rows in each pane.
291 virtual void RecalcLayout( bool repositionBarsNow
= FALSE
);
293 // Returns the client height.
295 int GetClientHeight();
297 // Returns the client width.
299 int GetClientWidth();
301 // Returns the client's rectangle.
303 wxRect
& GetClientRect() { return mClntWndBounds
; }
305 // Returns a reference to the updates manager.
306 // Note: in future, the updates manager will become a normal plugin.
308 cbUpdatesManagerBase
& GetUpdatesManager();
310 // Destroys the previous manager if any, and sets the new one.
312 void SetUpdatesManager( cbUpdatesManagerBase
* pUMgr
);
314 // Gets the pane properties for the given alignment.
316 virtual void GetPaneProperties( cbCommonPaneProperties
& props
, int alignment
= FL_ALIGN_TOP
);
318 // Sets the pane properties for the given alignment.
319 // Note: changing properties of panes does not result immediate on-screen update.
321 virtual void SetPaneProperties( const cbCommonPaneProperties
& props
,
322 int paneMask
= wxALL_PANES
);
324 // Sets the margins for the given panes.
325 // The margins should go into cbCommonPaneProperties in the future.
327 // Note: this method should be called before any custom plugins are attached.
329 virtual void SetMargins( int top
, int bottom
, int left
, int right
,
330 int paneMask
= wxALL_PANES
);
332 // Sets the pane background colour.
334 virtual void SetPaneBackground( const wxColour
& colour
);
336 // Recalculates layout and performs on-screen update of all panes.
338 void RefreshNow( bool recalcLayout
= TRUE
);
340 // Event handler for a size event.
342 void OnSize ( wxSizeEvent
& event
);
344 // Event handler for a left down button event.
346 void OnLButtonDown( wxMouseEvent
& event
);
348 // Event handler for a left doubleclick button event.
350 void OnLDblClick ( wxMouseEvent
& event
);
352 // Event handler for a left button up event.
354 void OnLButtonUp ( wxMouseEvent
& event
);
356 // Event handler for a right button down event.
358 void OnRButtonDown( wxMouseEvent
& event
);
360 // Event handler for a right button up event.
362 void OnRButtonUp ( wxMouseEvent
& event
);
364 // Event handler for a mouse move event.
366 void OnMouseMove ( wxMouseEvent
& event
);
368 // This function should be used instead of passing the event to the ProcessEvent method
369 // of the top-level plugin directly. This method checks if events are currently
370 // captured and ensures that plugin-event is routed correctly.
372 virtual void FirePluginEvent( cbPluginEvent
& event
);
374 // Captures user input events for the given plugin.
375 // Input events are: mouse movement, mouse clicks, keyboard input.
377 virtual void CaptureEventsForPlugin ( cbPluginBase
* pPlugin
);
379 // Releases user input events for the given plugin.
380 // Input events are: mouse movement, mouse clicks, keyboard input
382 virtual void ReleaseEventsFromPlugin( cbPluginBase
* pPlugin
);
384 // Called by plugins; also captures the mouse in the parent frame.
386 void CaptureEventsForPane( cbDockPane
* toPane
);
388 // Called by plugins; also releases mouse in the parent frame.
390 void ReleaseEventsFromPane( cbDockPane
* fromPane
);
392 // Returns the current top-level plugin (the one that receives events first,
393 // except if input events are currently captured by some other plugin).
395 virtual cbPluginBase
& GetTopPlugin();
397 // Hooking custom plugins to frame layout.
399 // Note: when hooking one plugin on top of the other,
400 // use SetNextHandler or similar methods
401 // of wxEvtHandler class to compose the chain of plugins,
402 // than pass the left-most handler in this chain to
403 // the above methods (assuming that events are delegated
404 // from left-most towards right-most handler).
406 // This secenario is very inconvenient and "low-level",
407 // so use the Add/Push/PopPlugin methods instead.
409 virtual void SetTopPlugin( cbPluginBase
* pPlugin
);
411 // Similar to wxWindow's "push/pop-event-handler" methods, execept
412 // that the plugin is deleted upon "popping".
414 virtual void PushPlugin( cbPluginBase
* pPugin
);
416 // Similar to wxWindow's "push/pop-event-handler" methods, execept
417 // that the plugin is deleted upon "popping".
419 virtual void PopPlugin();
422 virtual void PopAllPlugins();
424 // Adds the default plugins. These are cbPaneDrawPlugin, cbRowLayoutPlugin, cbBarDragPlugin,
425 // cbAntiflickerPlugin, cbSimpleCustomizePlugin.
427 // This method is automatically invoked if no plugins were found upon
428 // firing of the first plugin-event, i.e. when wxFrameLayout configures itself.
430 virtual void PushDefaultPlugins();
432 // An advanced methods for plugin configuration using their
433 // dynamic class information, for example CLASSINFO(pluginClass).
435 // First checks if the plugin of the given class is already "hooked up".
436 // If not, adds it to the top of the plugins chain.
438 virtual void AddPlugin( wxClassInfo
* pPlInfo
, int paneMask
= wxALL_PANES
);
440 // First checks if the plugin of the given class is already hooked.
441 // If so, removes it, and then inserts it into the chain
442 // before the plugin of the class given by pNextPlInfo.
444 // Note: this method is handy in some cases where the order
445 // of the plugin-chain could be important, for example when one plugin overrides
446 // some functionality of another already-hooked plugin,
447 // so that the former plugin should be hooked before the one
448 // whose functionality is being overridden.
450 virtual void AddPluginBefore( wxClassInfo
* pNextPlInfo
, wxClassInfo
* pPlInfo
,
451 int paneMask
= wxALL_PANES
);
453 // Checks if the plugin of the given class is hooked, and removes
456 virtual void RemovePlugin( wxClassInfo
* pPlInfo
);
458 // Finds a plugin with the given class, or returns NULL if a plugin of the given
459 // class is not hooked.
461 virtual cbPluginBase
* FindPlugin( wxClassInfo
* pPlInfo
);
463 // Returns true if there is a top plugin.
467 DECLARE_EVENT_TABLE()
468 DECLARE_DYNAMIC_CLASS( wxFrameLayout
)
470 public: /* protected really, acessed only by plugins and serializers */
472 friend class cbDockPane
;
473 friend class wxBarHandler
;
475 wxWindow
* mpFrame
; // parent frame
476 wxWindow
* mpFrameClient
; // client window
477 cbDockPane
* mPanes
[MAX_PANES
]; // panes in the panel
480 wxCursor
* mpHorizCursor
;
481 wxCursor
* mpVertCursor
;
482 wxCursor
* mpNormalCursor
;
483 wxCursor
* mpDragCursor
;
484 wxCursor
* mpNECursor
; // no-entry cursor
486 // pens for decoration and shades
488 wxPen mDarkPen
; // default wxSYS_COLOUR_3DSHADOW
489 wxPen mLightPen
; // default wxSYS_COLOUR_3DHILIGHT
490 wxPen mGrayPen
; // default wxSYS_COLOUR_3DFACE
491 wxPen mBlackPen
; // default wxColour( 0, 0, 0)
492 wxPen mBorderPen
; // default wxSYS_COLOUR_3DFACE
494 wxPen mNullPen
; // transparent pen
496 // pane to which the all mouse input is currently directed (caputred)
498 cbDockPane
* mpPaneInFocus
;
500 // pane, from which mouse pointer had just left
502 cbDockPane
* mpLRUPane
;
504 // bounds of client window in parent frame's coordinates
506 wxRect mClntWndBounds
;
507 wxRect mPrevClntWndBounds
;
510 wxPoint mNextFloatedWndPos
;
511 wxSize mFloatingPosStep
;
513 // current plugin (right-most) plugin which receives events first
515 cbPluginBase
* mpTopPlugin
;
517 // plugin, which currently has captured all input events, otherwise NULL
519 cbPluginBase
* mpCaputesInput
;
521 // list of event handlers which are "pushed" onto each bar, to catch
522 // mouse events which are not handled by bars, and froward them to the ,
523 // frome-layout and further to plugins
527 // list of top-most frames which contain floated bars
529 wxList mFloatedFrames
;
531 // linked list of references to all bars (docked/floated/hidden)
535 // FOR NOW:: dirty stuff...
536 bool mClientWndRefreshPending
;
538 bool mCheckFocusWhenIdle
;
540 public: /* protected really (accessed only by plugins) */
542 // refrence to custom updates manager
543 cbUpdatesManagerBase
* mpUpdatesMgr
;
545 // Called to apply the calculated layout to window objects.
547 void PositionClientWindow();
549 // Called to apply the calculated layout to window objects.
551 void PositionPanes();
553 // Creates the cursors.
555 void CreateCursors();
557 // Applies the calculated layout to a floating bar.
559 void RepositionFloatedBar( cbBarInfo
* pBar
);
561 // Applies the state to the window objects.
563 void DoSetBarState( cbBarInfo
* pBar
);
565 // The purpose of this function is unknown.
567 bool LocateBar( cbBarInfo
* pBarInfo
,
569 cbDockPane
** ppPane
);
572 // Returns TRUE if the position is within the given pane.
574 bool HitTestPane( cbDockPane
* pPane
, int x
, int y
);
576 // Returns the pane for which the rectangle hit test succeeds, giving
577 // preference to the given pane if supplied.
579 cbDockPane
* HitTestPanes( const wxRect
& rect
, cbDockPane
* pCurPane
);
581 // Returns the pane to which the given bar belongs.
583 cbDockPane
* GetBarPane( cbBarInfo
* pBar
);
585 // Delegated from "bar-spy".
586 void ForwardMouseEvent( wxMouseEvent
& event
,
590 // Routes the mouse event to the appropriate pane.
592 void RouteMouseEvent( wxMouseEvent
& event
, int pluginEvtType
);
594 // Shows all floated windows.
596 void ShowFloatedWindows( bool show
);
598 // Unhooks the layout from the frame.
600 void UnhookFromFrame();
602 // Hooks the layout up to the frame (pushes the layout onto the
603 // frame's event handler stack).
605 void HookUpToFrame();
607 // Returns TRUE if the platform allows reparenting. This may not return TRUE
608 // for all platforms. Reparenting allows control bars to be floated.
612 // Reparents pChild to have parent pNewParent.
614 void ReparentWindow( wxWindow
* pChild
, wxWindow
* pNewParent
);
616 // Returns the previous client window rectangle.
618 wxRect
& GetPrevClientRect() { return mPrevClntWndBounds
; }
620 // Handles paint events, calling PaintPane for each pane.
622 void OnPaint( wxPaintEvent
& event
);
624 // Handles background erase events. Currently does nothing.
626 void OnEraseBackground( wxEraseEvent
& event
);
628 // Handles focus kill events. Currently does nothing.
630 void OnKillFocus( wxFocusEvent
& event
);
632 // Handles focus set events. Currently does nothing.
634 void OnSetFocus( wxFocusEvent
& event
);
636 // Handles activation events. Currently does nothing.
638 void OnActivate( wxActivateEvent
& event
);
640 // Handles idle events.
642 void OnIdle( wxIdleEvent
& event
);
644 // Returns a new cbGCUpdatesMgr object.
646 virtual cbUpdatesManagerBase
* CreateUpdatesManager();
650 A structure that is present in each item of layout,
651 used by any particular updates-manager to store
652 auxiliary information to be used by its updating algorithm.
655 class cbUpdateMgrData
: public wxObject
657 DECLARE_DYNAMIC_CLASS( cbUpdateMgrData
)
659 wxRect mPrevBounds
; // previous state of layout item (in parent frame's coordinates)
661 bool mIsDirty
; // overrides result of current-against-previous bounds comparison,
662 // i.e. requires item to be updated, regardless of it's current area
664 wxObject
* mpCustomData
; // any custom data stored by specific updates mgr.
666 // Default constructor. Is-dirty flag is set TRUE initially.
670 // Store the item state.
672 void StoreItemState( const wxRect
& boundsInParent
);
674 // Set the dirty flag.
676 void SetDirty( bool isDirty
= TRUE
);
680 void SetCustomData( wxObject
* pCustomData
);
682 // Returns the is-dirty flag.
684 inline bool IsDirty() { return mIsDirty
; }
688 Abstract interface for bar-size handler classes.
689 These objects receive notifications whenever the docking
690 state of the bar is changed, thus they provide the possibility
691 to adjust the values in cbDimInfo::mSizes accordingly.
692 Specific handlers can be hooked up to specific types of bar.
695 class cbBarDimHandlerBase
: public wxObject
697 DECLARE_ABSTRACT_CLASS( cbBarDimHandlerBase
)
700 int mRefCount
; // since one dim-handler can be assigned
701 // to multiple bars, it's instance is
705 // initial reference count is 0, since handler is not used, until the
706 // first invocation of AddRef()
708 cbBarDimHandlerBase();
713 // "bar-state-changes" notification
714 virtual void OnChangeBarState(cbBarInfo
* pBar
, int newState
) = 0;
715 virtual void OnResizeBar( cbBarInfo
* pBar
, const wxSize
& given
, wxSize
& preferred
) = 0;
718 /* helper classes (used internally by wxFrameLayout class) */
720 // holds and manages information about bar dimensions
722 class cbDimInfo
: public wxObject
724 DECLARE_DYNAMIC_CLASS( cbDimInfo
)
726 wxSize mSizes
[MAX_BAR_STATES
]; // preferred sizes for each possible bar state
728 wxRect mBounds
[MAX_BAR_STATES
]; // saved positions and sizes for each
729 // possible state, values contain (-1)s if
730 // not initialized yet
732 int mLRUPane
; // pane to which this bar was docked before it was floated
733 // (FL_ALIGN_TOP,FL_ALIGN_BOTTOM,..)
735 // top/bottom gap, separates decorations
736 // from the bar's actual window, filled
737 // with frame's beckground color, default: 0
741 // left/right gap, separates decorations
742 // from the bar's actual window, filled
743 // with frame's beckground colour, default: 0
745 int mHorizGap
; // NOTE:: gaps are given in frame's coord. orientation
747 // TRUE, if vertical/horizotal dimensions cannot be mannualy adjusted
748 // by user using resizing handles. If FALSE, the frame-layout
749 // *automatically* places resizing handles among not-fixed bars
753 cbBarDimHandlerBase
* mpHandler
; // NULL, if no handler present
759 cbDimInfo( cbBarDimHandlerBase
* pDimHandler
,
760 bool isFixed
// (see comments on mIsFixed member)
763 cbDimInfo( int dh_x
, int dh_y
, // dims when docked horizontally
764 int dv_x
, int dv_y
, // dims when docked vertically
765 int f_x
, int f_y
, // dims when floating
767 bool isFixed
= TRUE
,// (see comments on mIsFixed member)
768 int horizGap
= 6, // (see comments on mHorizGap member)
769 int vertGap
= 6, // -/-
771 cbBarDimHandlerBase
* pDimHandler
= NULL
774 cbDimInfo( int x
, int y
,
777 cbBarDimHandlerBase
* pDimHandler
= NULL
780 const cbDimInfo
& operator=( const cbDimInfo
& other
);
782 // destroys handler automatically, if present
785 inline cbBarDimHandlerBase
* GetDimHandler() { return mpHandler
; }
788 WX_DEFINE_ARRAY(float, cbArrayFloat
);
790 class cbRowInfo
: public wxObject
792 DECLARE_DYNAMIC_CLASS( cbRowInfo
)
795 BarArrayT mBars
; // row content
797 // row flags (set up according to row-relations)
799 bool mHasUpperHandle
;
800 bool mHasLowerHandle
;
801 bool mHasOnlyFixedBars
;
802 int mNotFixedBarsCnt
;
808 // stores precalculated row's bounds in parent frame's coordinates
809 wxRect mBoundsInParent
;
811 // info stored for updates-manager
812 cbUpdateMgrData mUMgrData
;
817 cbBarInfo
* mpExpandedBar
; // NULL, if non of the bars is currently expanded
819 cbArrayFloat mSavedRatios
; // length-ratios bofore some of the bars was expanded
826 // convenience method
828 inline cbBarInfo
* GetFirstBar()
830 { return mBars
.GetCount() ? mBars
[0] : NULL
; }
833 class cbBarInfo
: public wxObject
835 DECLARE_DYNAMIC_CLASS( cbBarInfo
)
837 // textual name, by which this bar is refered in layout-customization dialogs
840 // stores bar's bounds in pane's coordinates
843 // stores precalculated bar's bounds in parent frame's coordinates
844 wxRect mBoundsInParent
;
846 // back-ref to the row, which contains this bar
849 // are set up according to the types of the surrounding bars in the row
851 bool mHasRightHandle
;
853 cbDimInfo mDimInfo
; // preferred sizes for each, control bar state
855 int mState
; // (see definition of controlbar states)
857 int mAlignment
; // alignment of the pane to which this
858 // bar is currently placed
860 int mRowNo
; // row, into which this bar would be placed,
861 // when in the docking state
863 wxWindow
* mpBarWnd
; // the actual window object, NULL if no window
864 // is attached to the control bar (possible!)
866 double mLenRatio
; // length ratio among not-fixed-size bars
868 wxPoint mPosIfFloated
; // stored last position when bar was in "floated" state
869 // poistion is stored in parent-window's coordinates
871 cbUpdateMgrData mUMgrData
; // info stored for updates-manager
873 cbBarInfo
* mpNext
; // next. bar in the row
874 cbBarInfo
* mpPrev
; // prev. bar in the row
881 inline bool IsFixed() const { return mDimInfo
.mIsFixed
; }
883 inline bool IsExpanded() const { return this == mpRow
->mpExpandedBar
; }
886 // used for storing original bar's postions in the row, when the "non-destructive-friction"
887 // option is turned ON
889 class cbBarShapeData
: public wxObject
896 // used for traversing through all bars of all rows in the pane
905 wxBarIterator( RowArrayT
& rows
);
908 bool Next(); // TRUE, if next bar is available
910 cbBarInfo
& BarInfo();
912 // returns reference to currently traversed row
913 cbRowInfo
& RowInfo();
916 /* structure holds configuration options,
917 * which are usually the same for all panes in
921 class cbCommonPaneProperties
: public wxObject
923 DECLARE_DYNAMIC_CLASS( cbCommonPaneProperties
)
925 // look-and-feel configuration
927 bool mRealTimeUpdatesOn
; // default: ON
928 bool mOutOfPaneDragOn
; // default: ON
929 bool mExactDockPredictionOn
; // default: OFF
930 bool mNonDestructFirctionOn
; // default: OFF
932 bool mShow3DPaneBorderOn
; // default: ON
934 // FOR NOW:: the below properties are reserved for the "future"
936 bool mBarFloatingOn
; // default: OFF
937 bool mRowProportionsOn
; // default: OFF
938 bool mColProportionsOn
; // default: ON
939 bool mBarCollapseIconsOn
; // default: OFF
940 bool mBarDragHintsOn
; // default: OFF
942 // minimal dimensions for not-fixed bars in this pane (16x16 default)
946 // width/height of resizing sash
948 int mResizeHandleSize
;
950 cbCommonPaneProperties(void);
953 /* class manages containment and control of control-bars
954 * along one of the four edges of the parent frame
957 class cbDockPane
: public wxObject
960 DECLARE_DYNAMIC_CLASS( cbDockPane
)
962 // look-and-feel configuration for this pane
963 cbCommonPaneProperties mProps
;
965 // pane margins (in frame's coordinate-syst. orientation)
967 int mLeftMargin
; // default: 2 pixels
968 int mRightMargin
; // default: 2 pixels
969 int mTopMargin
; // default: 2 pixels
970 int mBottomMargin
; // default: 2 pixels
973 // position of the pane in frame's coordinates
974 wxRect mBoundsInParent
;
976 // pane width and height in pane's coordinates
982 // info stored for updates-manager
983 cbUpdateMgrData mUMgrData
;
985 public: /* protected really */
988 wxFrameLayout
* mpLayout
; // back-ref
990 // transient properties
992 wxList mRowShapeData
; // shapes of bars of recently modified row,
993 // stored when in "non-destructive-firction" mode
994 cbRowInfo
* mpStoredRow
; // row-info for which the shapes are stored
996 friend class wxFrameLayout
;
998 public: /* protected really (accessed only by plugins) */
1000 cbRowInfo
* GetRow( int row
);
1002 int GetRowIndex( cbRowInfo
* pRow
);
1004 // return -1, if row is not present at given vertical position
1005 int GetRowAt( int paneY
);
1006 int GetRowAt( int upperY
, int lowerY
);
1008 // re-setups flags in the row-information structure, so that
1009 // the would match the changed state of row-items correctly
1010 void SyncRowFlags( cbRowInfo
* pRow
);
1012 // layout "AI" helpers:
1014 bool IsFixedSize( cbBarInfo
* pInfo
);
1015 int GetNotFixedBarsCount( cbRowInfo
* pRow
);
1017 int GetRowWidth( wxList
* pRow
);
1019 int GetRowY( cbRowInfo
* pRow
);
1021 bool HasNotFixedRowsAbove( cbRowInfo
* pRow
);
1022 bool HasNotFixedRowsBelow( cbRowInfo
* pRow
);
1023 bool HasNotFixedBarsLeft ( cbBarInfo
* pBar
);
1024 bool HasNotFixedBarsRight( cbBarInfo
* pBar
);
1026 virtual void CalcLengthRatios( cbRowInfo
* pInRow
);
1027 virtual void RecalcRowLayout( cbRowInfo
* pRow
);
1029 virtual void ExpandBar( cbBarInfo
* pBar
);
1030 virtual void ContractBar( cbBarInfo
* pBar
);
1032 void InitLinksForRow( cbRowInfo
* pRow
);
1033 void InitLinksForRows();
1035 // coordinate translation between parent's frame and this pane
1037 void FrameToPane( int* x
, int* y
);
1038 void PaneToFrame( int* x
, int* y
);
1039 void FrameToPane( wxRect
* pRect
);
1040 void PaneToFrame( wxRect
* pRect
);
1042 inline bool HasPoint( const wxPoint
& pos
, int x
, int y
, int width
, int height
);
1044 int GetMinimalRowHeight( cbRowInfo
* pRow
);
1046 // given row height includes height of row handles, if present
1047 void SetRowHeight( cbRowInfo
* pRow
, int newHeight
);
1049 void DoInsertBar( cbBarInfo
* pBar
, int rowNo
);
1051 public: /* protected really (accessed only by plugins) */
1053 // methods for incramental on-screen refreshing of the pane
1054 // (simply, they are wrappers around corresponding plugin-events)
1056 virtual void PaintBarDecorations( cbBarInfo
* pBar
, wxDC
& dc
);
1057 virtual void PaintBarHandles( cbBarInfo
* pBar
, wxDC
& dc
);
1058 virtual void PaintBar( cbBarInfo
* pBar
, wxDC
& dc
);
1059 virtual void PaintRowHandles( cbRowInfo
* pRow
, wxDC
& dc
);
1060 virtual void PaintRowBackground ( cbRowInfo
* pRow
, wxDC
& dc
);
1061 virtual void PaintRowDecorations( cbRowInfo
* pRow
, wxDC
& dc
);
1062 virtual void PaintRow( cbRowInfo
* pRow
, wxDC
& dc
);
1063 virtual void PaintPaneBackground( wxDC
& dc
);
1064 virtual void PaintPaneDecorations( wxDC
& dc
);
1065 virtual void PaintPane( wxDC
& dc
);
1066 virtual void SizeBar( cbBarInfo
* pBar
);
1067 virtual void SizeRowObjects( cbRowInfo
* pRow
);
1068 virtual void SizePaneObjects();
1070 virtual wxDC
* StartDrawInArea ( const wxRect
& area
);
1071 virtual void FinishDrawInArea( const wxRect
& area
);
1073 public: /* public members */
1077 cbDockPane( int alignment
, wxFrameLayout
* pPanel
);
1079 // sets pane's margins in frame's coordinate orientations
1080 void SetMargins( int top
, int bottom
, int left
, int right
);
1082 virtual ~cbDockPane();
1084 // does not destroys the info bar , only removes it's reference
1087 virtual void RemoveBar( cbBarInfo
* pBar
);
1089 // rect given in the parent frame's coordinates
1091 virtual void InsertBar( cbBarInfo
* pBar
, const wxRect
& atRect
);
1093 // inserts bar into the given row, with dimensions and position
1094 // stored in pBarInfo->mBounds. Returns the node of inserted bar
1096 virtual void InsertBar( cbBarInfo
* pBar
, cbRowInfo
* pIntoRow
);
1098 // inserts bar, sets its position according to the preferred settings
1099 // given in (*pBarInfo) structure
1101 virtual void InsertBar( cbBarInfo
* pBarInfo
);
1103 // does not destroy the row object, only removes the corresponding
1104 // node from this pane
1105 virtual void RemoveRow( cbRowInfo
* pRow
);
1107 // does not refresh the inserted row immediately,
1108 // if pBeforeRowNode arg. is NULL, row is appended to the end of pane's row list
1109 virtual void InsertRow( cbRowInfo
* pRow
, cbRowInfo
* pBeforeRow
);
1111 // sets pane's width in pane's coordinates (including margins)
1112 void SetPaneWidth(int width
);
1114 // set the position and dims. of the pane in parent frame's coordinates
1115 void SetBoundsInParent( const wxRect
& rect
);
1117 inline wxRect
& GetRealRect() { return mBoundsInParent
; }
1119 // used by updates-managers
1120 inline RowArrayT
& GetRowList() { return mRows
; }
1122 // convenience method
1124 inline cbRowInfo
* GetFirstRow()
1126 { return mRows
.GetCount() ? mRows
[0] : NULL
; }
1128 // TRUE, if the given bar node presents in this pane
1130 bool BarPresent( cbBarInfo
* pBar
);
1132 // retuns height, in pane's coordinates
1133 int GetPaneHeight();
1137 bool MatchesMask( int paneMask
);
1139 inline bool IsHorizontal()
1141 return (mAlignment
== FL_ALIGN_TOP
||
1142 mAlignment
== FL_ALIGN_BOTTOM
);
1145 virtual void RecalcLayout();
1147 virtual int GetDockingState();
1149 // returns result of hit-testing items in the pane,
1150 // see CB_HITTEST_RESULTS enumeration
1152 virtual int HitTestPaneItems( const wxPoint
& pos
, // position in pane's coordinates
1157 void GetBarResizeRange( cbBarInfo
* pBar
, int* from
, int *till
, bool forLeftHandle
);
1158 void GetRowResizeRange( cbRowInfo
* pRow
, int* from
, int* till
, bool forUpperHandle
);
1160 cbBarInfo
* GetBarInfoByWindow( wxWindow
* pBarWnd
);
1162 public: /* protected really (accessed only by plugins) */
1164 // row/bar resizing related helper-methods
1166 void DrawVertHandle ( wxDC
& dc
, int x
, int y
, int height
);
1167 void DrawHorizHandle( wxDC
& dc
, int x
, int y
, int width
);
1169 void ResizeRow( cbRowInfo
* pRow
, int ofs
, bool forUpperHandle
);
1170 void ResizeBar( cbBarInfo
* pBar
, int ofs
, bool forLeftHandle
);
1172 // cbBarShapeData objects will be placed to given pLst (see comments on cbBarShapeData)
1174 void GetRowShapeData( cbRowInfo
* pRow
, wxList
* pLst
);
1176 // sets the shape to the given row, using the data provided in pLst
1177 void SetRowShapeData( cbRowInfo
* pRowNode
, wxList
* pLst
);
1181 * class declares abstract interface for optimized logic, which should refresh
1182 * areas of frame layout - that actually need to be updated. Should be extended,
1183 * to implement custom updating strategy
1186 class cbUpdatesManagerBase
: public wxObject
1188 DECLARE_ABSTRACT_CLASS( cbUpdatesManagerBase
)
1190 public: /* protected really, accessed by serializer (if any) */
1192 wxFrameLayout
* mpLayout
;
1195 cbUpdatesManagerBase(void)
1198 cbUpdatesManagerBase( wxFrameLayout
* pPanel
)
1199 : mpLayout( pPanel
) {}
1201 virtual ~cbUpdatesManagerBase() {}
1203 void SetLayout( wxFrameLayout
* pLayout
) { mpLayout
= pLayout
; }
1205 // notificiactions received from frame-layout (in the order, in which
1206 // they usually would be invoked). Custom updates-managers may utilize
1207 // these notifications to implement more "fine-grained" updating strategy
1209 virtual void OnStartChanges() = 0;
1211 virtual void OnRowWillChange( cbRowInfo
* pRow
, cbDockPane
* pInPane
) {}
1212 virtual void OnBarWillChange( cbBarInfo
* pBar
, cbRowInfo
* pInRow
, cbDockPane
* pInPane
) {}
1213 virtual void OnPaneMarginsWillChange( cbDockPane
* pPane
) {}
1214 virtual void OnPaneWillChange( cbDockPane
* pPane
) {}
1216 virtual void OnFinishChanges() {}
1218 // refreshes parts of the frame layout, which need an update
1219 virtual void UpdateNow() = 0;
1222 /*------------------------------------------------------------
1223 * "API" for developing custom plugins of Frame Layout Engine
1224 * TODO:: documentation
1225 *------------------------------------------------------------
1228 // base class for all control-bar plugin events
1230 class cbPluginEvent
: public wxEvent
1232 // NOTE:: plugin-event does not need to be a dynamic class
1235 cbDockPane
* mpPane
; // NULL, if event is not addressed to any specific pane
1238 // FOR NOW FOR NOW:: all-in-one plugin event structure
1240 wxNode* mpObjNodeAux;
1247 // Not used, but required
1248 virtual wxEvent
* Clone() const { return NULL
; }
1250 #if wxCHECK_VERSION(2,3,0)
1251 cbPluginEvent( wxEventType eventType
, cbDockPane
* pPane
)
1254 { m_eventType
= eventType
; }
1256 cbPluginEvent( int eventType
, cbDockPane
* pPane
)
1259 { m_eventType
= eventType
; }
1263 // event types handled by plugins
1265 #if wxCHECK_VERSION(2,3,0)
1267 extern wxEventType cbEVT_PL_LEFT_DOWN
;
1268 extern wxEventType cbEVT_PL_LEFT_UP
;
1269 extern wxEventType cbEVT_PL_RIGHT_DOWN
;
1270 extern wxEventType cbEVT_PL_RIGHT_UP
;
1271 extern wxEventType cbEVT_PL_MOTION
;
1273 extern wxEventType cbEVT_PL_LEFT_DCLICK
;
1275 extern wxEventType cbEVT_PL_LAYOUT_ROW
;
1276 extern wxEventType cbEVT_PL_RESIZE_ROW
;
1277 extern wxEventType cbEVT_PL_LAYOUT_ROWS
;
1278 extern wxEventType cbEVT_PL_INSERT_BAR
;
1279 extern wxEventType cbEVT_PL_RESIZE_BAR
;
1280 extern wxEventType cbEVT_PL_REMOVE_BAR
;
1281 extern wxEventType cbEVT_PL_SIZE_BAR_WND
;
1283 extern wxEventType cbEVT_PL_DRAW_BAR_DECOR
;
1284 extern wxEventType cbEVT_PL_DRAW_ROW_DECOR
;
1285 extern wxEventType cbEVT_PL_DRAW_PANE_DECOR
;
1286 extern wxEventType cbEVT_PL_DRAW_BAR_HANDLES
;
1287 extern wxEventType cbEVT_PL_DRAW_ROW_HANDLES
;
1288 extern wxEventType cbEVT_PL_DRAW_ROW_BKGROUND
;
1289 extern wxEventType cbEVT_PL_DRAW_PANE_BKGROUND
;
1291 extern wxEventType cbEVT_PL_START_BAR_DRAGGING
;
1292 extern wxEventType cbEVT_PL_DRAW_HINT_RECT
;
1294 extern wxEventType cbEVT_PL_START_DRAW_IN_AREA
;
1295 extern wxEventType cbEVT_PL_FINISH_DRAW_IN_AREA
;
1297 extern wxEventType cbEVT_PL_CUSTOMIZE_BAR
;
1298 extern wxEventType cbEVT_PL_CUSTOMIZE_LAYOUT
;
1300 extern wxEventType wxCUSTOM_CB_PLUGIN_EVENTS_START_AT
;
1304 #define cbEVT_PL_LEFT_DOWN 0
1305 #define cbEVT_PL_LEFT_UP 1
1306 #define cbEVT_PL_RIGHT_DOWN 2
1307 #define cbEVT_PL_RIGHT_UP 3
1308 #define cbEVT_PL_MOTION 4
1310 #define cbEVT_PL_LEFT_DCLICK 5
1312 #define cbEVT_PL_LAYOUT_ROW 6
1313 #define cbEVT_PL_RESIZE_ROW 7
1314 #define cbEVT_PL_LAYOUT_ROWS 8
1315 #define cbEVT_PL_INSERT_BAR 9
1316 #define cbEVT_PL_RESIZE_BAR 10
1317 #define cbEVT_PL_REMOVE_BAR 11
1318 #define cbEVT_PL_SIZE_BAR_WND 12
1320 #define cbEVT_PL_DRAW_BAR_DECOR 13
1321 #define cbEVT_PL_DRAW_ROW_DECOR 14
1322 #define cbEVT_PL_DRAW_PANE_DECOR 15
1323 #define cbEVT_PL_DRAW_BAR_HANDLES 16
1324 #define cbEVT_PL_DRAW_ROW_HANDLES 17
1325 #define cbEVT_PL_DRAW_ROW_BKGROUND 18
1326 #define cbEVT_PL_DRAW_PANE_BKGROUND 19
1328 #define cbEVT_PL_START_BAR_DRAGGING 20
1329 #define cbEVT_PL_DRAW_HINT_RECT 21
1331 #define cbEVT_PL_START_DRAW_IN_AREA 22
1332 #define cbEVT_PL_FINISH_DRAW_IN_AREA 23
1334 #define cbEVT_PL_CUSTOMIZE_BAR 24
1335 #define cbEVT_PL_CUSTOMIZE_LAYOUT 25
1337 #define wxCUSTOM_CB_PLUGIN_EVENTS_START_AT 100
1339 #endif // wxCHECK_VERSION(2,3,0) else
1341 // forward decls, separated by categories
1343 class cbLeftDownEvent
;
1344 class cbLeftUpEvent
;
1345 class cbRightDownEvent
;
1346 class cbRightUpEvent
;
1347 class cbMotionEvent
;
1348 class cbLeftDClickEvent
;
1350 class cbLayoutRowEvent
;
1351 class cbResizeRowEvent
;
1352 class cbLayoutRowsEvent
;
1353 class cbInsertBarEvent
;
1354 class cbResizeBarEvent
;
1355 class cbRemoveBarEvent
;
1356 class cbSizeBarWndEvent
;
1358 class cbDrawBarDecorEvent
;
1359 class cbDrawRowDecorEvent
;
1360 class cbDrawPaneDecorEvent
;
1361 class cbDrawBarHandlesEvent
;
1362 class cbDrawRowHandlesEvent
;
1363 class cbDrawRowBkGroundEvent
;
1364 class cbDrawPaneBkGroundEvent
;
1366 class cbStartBarDraggingEvent
;
1367 class cbDrawHintRectEvent
;
1369 class cbStartDrawInAreaEvent
;
1370 class cbFinishDrawInAreaEvent
;
1372 class cbCustomizeBarEvent
;
1373 class cbCustomizeLayoutEvent
;
1375 // defs. for handler-methods
1377 typedef void (wxEvtHandler::*cbLeftDownHandler
)(cbLeftDownEvent
&);
1378 typedef void (wxEvtHandler::*cbLeftUpHandler
)(cbLeftUpEvent
&);
1379 typedef void (wxEvtHandler::*cbRightDownHandler
)(cbRightDownEvent
&);
1380 typedef void (wxEvtHandler::*cbRightUpHandler
)(cbRightUpEvent
&);
1381 typedef void (wxEvtHandler::*cbMotionHandler
)(cbMotionEvent
&);
1382 typedef void (wxEvtHandler::*cbLeftDClickHandler
)(cbLeftDClickEvent
&);
1384 typedef void (wxEvtHandler::*cbLayoutRowHandler
)(cbLayoutRowEvent
&);
1385 typedef void (wxEvtHandler::*cbResizeRowHandler
)(cbResizeRowEvent
&);
1386 typedef void (wxEvtHandler::*cbLayoutRowsHandler
)(cbLayoutRowsEvent
&);
1387 typedef void (wxEvtHandler::*cbInsertBarHandler
)(cbInsertBarEvent
&);
1388 typedef void (wxEvtHandler::*cbResizeBarHandler
)(cbResizeBarEvent
&);
1389 typedef void (wxEvtHandler::*cbRemoveBarHandler
)(cbRemoveBarEvent
&);
1390 typedef void (wxEvtHandler::*cbSizeBarWndHandler
)(cbSizeBarWndEvent
&);
1392 typedef void (wxEvtHandler::*cbDrawBarDecorHandler
)(cbDrawBarDecorEvent
&);
1393 typedef void (wxEvtHandler::*cbDrawRowDecorHandler
)(cbDrawRowDecorEvent
&);
1394 typedef void (wxEvtHandler::*cbDrawPaneDecorHandler
)(cbDrawPaneDecorEvent
&);
1395 typedef void (wxEvtHandler::*cbDrawBarHandlesHandler
)(cbDrawBarHandlesEvent
&);
1396 typedef void (wxEvtHandler::*cbDrawRowHandlesHandler
)(cbDrawRowHandlesEvent
&);
1397 typedef void (wxEvtHandler::*cbDrawRowBkGroundHandler
)(cbDrawRowBkGroundEvent
&);
1398 typedef void (wxEvtHandler::*cbDrawPaneBkGroundHandler
)(cbDrawPaneBkGroundEvent
&);
1400 typedef void (wxEvtHandler::*cbStartBarDraggingHandler
)(cbStartBarDraggingEvent
&);
1401 typedef void (wxEvtHandler::*cbDrawHintRectHandler
)(cbDrawHintRectEvent
&);
1403 typedef void (wxEvtHandler::*cbStartDrawInAreaHandler
)(cbStartDrawInAreaEvent
&);
1404 typedef void (wxEvtHandler::*cbFinishDrawInAreaHandler
)(cbFinishDrawInAreaEvent
&);
1406 typedef void (wxEvtHandler::*cbCustomizeBarHandler
)(cbCustomizeBarEvent
&);
1407 typedef void (wxEvtHandler::*cbCustomizeLayoutHandler
)(cbCustomizeLayoutEvent
&);
1409 // macros for creating event table entries for plugin-events
1411 #if wxCHECK_VERSION(2,3,0)
1412 #define EVT_PL_LEFT_DOWN(func) wxEventTableEntry( cbEVT_PL_LEFT_DOWN, -1, -1, (wxObjectEventFunction) (wxEventFunction) (cbLeftDownHandler ) & func, (wxObject *) NULL ),
1413 #define EVT_PL_LEFT_UP(func) wxEventTableEntry( cbEVT_PL_LEFT_UP, -1, -1, (wxObjectEventFunction) (wxEventFunction) (cbLeftUpHandler ) & func, (wxObject *) NULL ),
1414 #define EVT_PL_RIGHT_DOWN(func) wxEventTableEntry( cbEVT_PL_RIGHT_DOWN, -1, -1, (wxObjectEventFunction) (wxEventFunction) (cbRightDownHandler ) & func, (wxObject *) NULL ),
1415 #define EVT_PL_RIGHT_UP(func) wxEventTableEntry( cbEVT_PL_RIGHT_UP, -1, -1, (wxObjectEventFunction) (wxEventFunction) (cbRightUpHandler ) & func, (wxObject *) NULL ),
1416 #define EVT_PL_MOTION(func) wxEventTableEntry( cbEVT_PL_MOTION, -1, -1, (wxObjectEventFunction) (wxEventFunction) (cbMotionHandler ) & func, (wxObject *) NULL ),
1417 #define EVT_PL_LEFT_DCLICK(func) wxEventTableEntry( cbEVT_PL_LEFT_DCLICK, -1, -1, (wxObjectEventFunction) (wxEventFunction) (cbLeftDClickHandler ) & func, (wxObject *) NULL ),
1419 #define EVT_PL_LAYOUT_ROW(func) wxEventTableEntry( cbEVT_PL_LAYOUT_ROW, -1, -1, (wxObjectEventFunction) (wxEventFunction) (cbLayoutRowHandler ) & func, (wxObject *) NULL ),
1420 #define EVT_PL_RESIZE_ROW(func) wxEventTableEntry( cbEVT_PL_RESIZE_ROW, -1, -1, (wxObjectEventFunction) (wxEventFunction) (cbResizeRowHandler ) & func, (wxObject *) NULL ),
1421 #define EVT_PL_LAYOUT_ROWS(func) wxEventTableEntry( cbEVT_PL_LAYOUT_ROWS, -1, -1, (wxObjectEventFunction) (wxEventFunction) (cbLayoutRowsHandler ) & func, (wxObject *) NULL ),
1422 #define EVT_PL_INSERT_BAR(func) wxEventTableEntry( cbEVT_PL_INSERT_BAR, -1, -1, (wxObjectEventFunction) (wxEventFunction) (cbInsertBarHandler ) & func, (wxObject *) NULL ),
1423 #define EVT_PL_RESIZE_BAR(func) wxEventTableEntry( cbEVT_PL_RESIZE_BAR, -1, -1, (wxObjectEventFunction) (wxEventFunction) (cbResizeBarHandler ) & func, (wxObject *) NULL ),
1424 #define EVT_PL_REMOVE_BAR(func) wxEventTableEntry( cbEVT_PL_REMOVE_BAR, -1, -1, (wxObjectEventFunction) (wxEventFunction) (cbRemoveBarHandler ) & func, (wxObject *) NULL ),
1425 #define EVT_PL_SIZE_BAR_WND(func) wxEventTableEntry( cbEVT_PL_SIZE_BAR_WND, -1, -1, (wxObjectEventFunction) (wxEventFunction) (cbSizeBarWndHandler ) & func, (wxObject *) NULL ),
1427 #define EVT_PL_DRAW_BAR_DECOR(func) wxEventTableEntry( cbEVT_PL_DRAW_BAR_DECOR, -1, -1, (wxObjectEventFunction) (wxEventFunction) (cbDrawBarDecorHandler ) & func, (wxObject *) NULL ),
1428 #define EVT_PL_DRAW_ROW_DECOR(func) wxEventTableEntry( cbEVT_PL_DRAW_ROW_DECOR, -1, -1, (wxObjectEventFunction) (wxEventFunction) (cbDrawRowDecorHandler ) & func, (wxObject *) NULL ),
1429 #define EVT_PL_DRAW_PANE_DECOR(func) wxEventTableEntry( cbEVT_PL_DRAW_PANE_DECOR, -1, -1, (wxObjectEventFunction) (wxEventFunction) (cbDrawPaneDecorHandler ) & func, (wxObject *) NULL ),
1430 #define EVT_PL_DRAW_BAR_HANDLES(func) wxEventTableEntry( cbEVT_PL_DRAW_BAR_HANDLES, -1, -1, (wxObjectEventFunction) (wxEventFunction) (cbDrawBarHandlesHandler ) & func, (wxObject *) NULL ),
1431 #define EVT_PL_DRAW_ROW_HANDLES(func) wxEventTableEntry( cbEVT_PL_DRAW_ROW_HANDLES, -1, -1, (wxObjectEventFunction) (wxEventFunction) (cbDrawRowHandlesHandler ) & func, (wxObject *) NULL ),
1432 #define EVT_PL_DRAW_ROW_BKGROUND(func) wxEventTableEntry( cbEVT_PL_DRAW_ROW_BKGROUND, -1, -1, (wxObjectEventFunction) (wxEventFunction) (cbDrawRowBkGroundHandler ) & func, (wxObject *) NULL ),
1433 #define EVT_PL_DRAW_PANE_BKGROUND(func) wxEventTableEntry( cbEVT_PL_DRAW_PANE_BKGROUND, -1, -1, (wxObjectEventFunction) (wxEventFunction) (cbDrawPaneBkGroundHandler) & func, (wxObject *) NULL ),
1435 #define EVT_PL_START_BAR_DRAGGING(func) wxEventTableEntry( cbEVT_PL_START_BAR_DRAGGING, -1, -1, (wxObjectEventFunction) (wxEventFunction) (cbStartBarDraggingHandler) & func, (wxObject *) NULL ),
1436 #define EVT_PL_DRAW_HINT_RECT(func) wxEventTableEntry( cbEVT_PL_DRAW_HINT_RECT, -1, -1, (wxObjectEventFunction) (wxEventFunction) (cbDrawHintRectHandler ) & func, (wxObject *) NULL ),
1439 #define EVT_PL_START_DRAW_IN_AREA(func) wxEventTableEntry( cbEVT_PL_START_DRAW_IN_AREA, -1, -1, (wxObjectEventFunction) (wxEventFunction) (cbStartDrawInAreaHandler) & func, (wxObject *) NULL ),
1440 #define EVT_PL_FINISH_DRAW_IN_AREA(func) wxEventTableEntry( cbEVT_PL_FINISH_DRAW_IN_AREA, -1, -1, (wxObjectEventFunction) (wxEventFunction) (cbFinishDrawInAreaHandler) & func, (wxObject *) NULL ),
1442 #define EVT_PL_CUSTOMIZE_BAR(func) wxEventTableEntry( cbEVT_PL_CUSTOMIZE_BAR, -1, -1, (wxObjectEventFunction) (wxEventFunction) (cbCustomizeBarHandler) & func, (wxObject *) NULL ),
1443 #define EVT_PL_CUSTOMIZE_LAYOUT(func) wxEventTableEntry( cbEVT_PL_CUSTOMIZE_LAYOUT, -1, -1, (wxObjectEventFunction) (wxEventFunction) (cbCustomizeLayoutHandler) & func, (wxObject *) NULL ),
1445 #define EVT_PL_LEFT_DOWN(func) { cbEVT_PL_LEFT_DOWN, -1, -1, (wxObjectEventFunction) (wxEventFunction) (cbLeftDownHandler ) & func },
1446 #define EVT_PL_LEFT_UP(func) { cbEVT_PL_LEFT_UP, -1, -1, (wxObjectEventFunction) (wxEventFunction) (cbLeftUpHandler ) & func },
1447 #define EVT_PL_RIGHT_DOWN(func) { cbEVT_PL_RIGHT_DOWN, -1, -1, (wxObjectEventFunction) (wxEventFunction) (cbRightDownHandler ) & func },
1448 #define EVT_PL_RIGHT_UP(func) { cbEVT_PL_RIGHT_UP, -1, -1, (wxObjectEventFunction) (wxEventFunction) (cbRightUpHandler ) & func },
1449 #define EVT_PL_MOTION(func) { cbEVT_PL_MOTION, -1, -1, (wxObjectEventFunction) (wxEventFunction) (cbMotionHandler ) & func },
1450 #define EVT_PL_LEFT_DCLICK(func) { cbEVT_PL_LEFT_DCLICK, -1, -1, (wxObjectEventFunction) (wxEventFunction) (cbLeftDClickHandler ) & func },
1452 #define EVT_PL_LAYOUT_ROW(func) { cbEVT_PL_LAYOUT_ROW, -1, -1, (wxObjectEventFunction) (wxEventFunction) (cbLayoutRowHandler ) & func },
1453 #define EVT_PL_RESIZE_ROW(func) { cbEVT_PL_RESIZE_ROW, -1, -1, (wxObjectEventFunction) (wxEventFunction) (cbResizeRowHandler ) & func },
1454 #define EVT_PL_LAYOUT_ROWS(func) { cbEVT_PL_LAYOUT_ROWS, -1, -1, (wxObjectEventFunction) (wxEventFunction) (cbLayoutRowsHandler ) & func },
1455 #define EVT_PL_INSERT_BAR(func) { cbEVT_PL_INSERT_BAR, -1, -1, (wxObjectEventFunction) (wxEventFunction) (cbInsertBarHandler ) & func },
1456 #define EVT_PL_RESIZE_BAR(func) { cbEVT_PL_RESIZE_BAR, -1, -1, (wxObjectEventFunction) (wxEventFunction) (cbResizeBarHandler ) & func },
1457 #define EVT_PL_REMOVE_BAR(func) { cbEVT_PL_REMOVE_BAR, -1, -1, (wxObjectEventFunction) (wxEventFunction) (cbRemoveBarHandler ) & func },
1458 #define EVT_PL_SIZE_BAR_WND(func) { cbEVT_PL_SIZE_BAR_WND, -1, -1, (wxObjectEventFunction) (wxEventFunction) (cbSizeBarWndHandler ) & func },
1460 #define EVT_PL_DRAW_BAR_DECOR(func) { cbEVT_PL_DRAW_BAR_DECOR, -1, -1, (wxObjectEventFunction) (wxEventFunction) (cbDrawBarDecorHandler ) & func },
1461 #define EVT_PL_DRAW_ROW_DECOR(func) { cbEVT_PL_DRAW_ROW_DECOR, -1, -1, (wxObjectEventFunction) (wxEventFunction) (cbDrawRowDecorHandler ) & func },
1462 #define EVT_PL_DRAW_PANE_DECOR(func) { cbEVT_PL_DRAW_PANE_DECOR, -1, -1, (wxObjectEventFunction) (wxEventFunction) (cbDrawPaneDecorHandler ) & func },
1463 #define EVT_PL_DRAW_BAR_HANDLES(func) { cbEVT_PL_DRAW_BAR_HANDLES, -1, -1, (wxObjectEventFunction) (wxEventFunction) (cbDrawBarHandlesHandler ) & func },
1464 #define EVT_PL_DRAW_ROW_HANDLES(func) { cbEVT_PL_DRAW_ROW_HANDLES, -1, -1, (wxObjectEventFunction) (wxEventFunction) (cbDrawRowHandlesHandler ) & func },
1465 #define EVT_PL_DRAW_ROW_BKGROUND(func) { cbEVT_PL_DRAW_ROW_BKGROUND, -1, -1, (wxObjectEventFunction) (wxEventFunction) (cbDrawRowBkGroundHandler ) & func },
1466 #define EVT_PL_DRAW_PANE_BKGROUND(func) { cbEVT_PL_DRAW_PANE_BKGROUND, -1, -1, (wxObjectEventFunction) (wxEventFunction) (cbDrawPaneBkGroundHandler) & func },
1468 #define EVT_PL_START_BAR_DRAGGING(func) { cbEVT_PL_START_BAR_DRAGGING, -1, -1, (wxObjectEventFunction) (wxEventFunction) (cbStartBarDraggingHandler) & func },
1469 #define EVT_PL_DRAW_HINT_RECT(func) { cbEVT_PL_DRAW_HINT_RECT, -1, -1, (wxObjectEventFunction) (wxEventFunction) (cbDrawHintRectHandler ) & func },
1471 #define EVT_PL_START_DRAW_IN_AREA(func) { cbEVT_PL_START_DRAW_IN_AREA, -1, -1, (wxObjectEventFunction) (wxEventFunction) (cbStartDrawInAreaHandler) & func },
1472 #define EVT_PL_FINISH_DRAW_IN_AREA(func) { cbEVT_PL_FINISH_DRAW_IN_AREA, -1, -1, (wxObjectEventFunction) (wxEventFunction) (cbFinishDrawInAreaHandler) & func },
1474 #define EVT_PL_CUSTOMIZE_BAR(func) { cbEVT_PL_CUSTOMIZE_BAR, -1, -1, (wxObjectEventFunction) (wxEventFunction) (cbCustomizeBarHandler) & func },
1475 #define EVT_PL_CUSTOMIZE_LAYOUT(func) { cbEVT_PL_CUSTOMIZE_LAYOUT, -1, -1, (wxObjectEventFunction) (wxEventFunction) (cbCustomizeLayoutHandler) & func },
1478 * abstract base class for all control-bar related plugins
1481 class cbPluginBase
: public wxEvtHandler
1483 DECLARE_ABSTRACT_CLASS( cbPluginBase
)
1486 wxFrameLayout
* mpLayout
; // back-reference to the frame layout
1488 // specifies panes, for which this plugin receives events
1489 // (see pane masks definitions)
1492 bool mIsReady
; // is TRUE, when plugin is ready to handle events
1498 mPaneMask( wxALL_PANES
),
1502 cbPluginBase( wxFrameLayout
* pPanel
, int paneMask
= wxALL_PANES
)
1504 : mpLayout ( pPanel
),
1505 mPaneMask( paneMask
),
1509 inline int GetPaneMask() { return mPaneMask
; }
1511 // NOTE:: pointer positions of mouse-events sent to plugins
1512 // are always in pane's coordinates (pane's to which
1513 // this plugin is hooked)
1515 // destroys the whole plugin chain of connected plagins
1516 virtual ~cbPluginBase();
1518 // override this method to do plugin-specific initialization
1519 // (at this point plugin is already attached to the frame layout,
1520 // and pane masks are set)
1521 virtual void OnInitPlugin() { mIsReady
= TRUE
; }
1523 bool IsReady() { return mIsReady
; }
1525 // overriden, to determine whether the target pane specified in the
1526 // event, matches the pane mask of this plugin (specific plugins
1527 // do not override this method)
1529 virtual bool ProcessEvent(wxEvent
& event
);
1532 /*** event classes, for each corresponding event type (24 currnetly...uhh) ***/
1534 // mouse-events category
1536 class cbLeftDownEvent
: public cbPluginEvent
1541 cbLeftDownEvent( const wxPoint
& pos
, cbDockPane
* pPane
)
1543 : cbPluginEvent( cbEVT_PL_LEFT_DOWN
, pPane
),
1548 class cbLeftUpEvent
: public cbPluginEvent
1553 cbLeftUpEvent( const wxPoint
& pos
, cbDockPane
* pPane
)
1555 : cbPluginEvent( cbEVT_PL_LEFT_UP
, pPane
),
1560 class cbRightDownEvent
: public cbPluginEvent
1565 cbRightDownEvent( const wxPoint
& pos
, cbDockPane
* pPane
)
1567 : cbPluginEvent( cbEVT_PL_RIGHT_DOWN
, pPane
),
1572 class cbRightUpEvent
: public cbPluginEvent
1577 cbRightUpEvent( const wxPoint
& pos
, cbDockPane
* pPane
)
1579 : cbPluginEvent( cbEVT_PL_RIGHT_UP
, pPane
),
1584 class cbMotionEvent
: public cbPluginEvent
1589 cbMotionEvent( const wxPoint
& pos
, cbDockPane
* pPane
)
1591 : cbPluginEvent( cbEVT_PL_MOTION
, pPane
),
1596 class cbLeftDClickEvent
: public cbPluginEvent
1601 cbLeftDClickEvent( const wxPoint
& pos
, cbDockPane
* pPane
)
1603 : cbPluginEvent( cbEVT_PL_LEFT_DCLICK
, pPane
),
1608 // bar/row events category
1610 class cbLayoutRowEvent
: public cbPluginEvent
1615 cbLayoutRowEvent( cbRowInfo
* pRow
, cbDockPane
* pPane
)
1617 : cbPluginEvent( cbEVT_PL_LAYOUT_ROW
, pPane
),
1622 class cbResizeRowEvent
: public cbPluginEvent
1627 bool mForUpperHandle
;
1629 cbResizeRowEvent( cbRowInfo
* pRow
, int handleOfs
, bool forUpperHandle
, cbDockPane
* pPane
)
1631 : cbPluginEvent( cbEVT_PL_RESIZE_ROW
, pPane
),
1633 mHandleOfs( handleOfs
),
1634 mForUpperHandle( forUpperHandle
)
1638 class cbLayoutRowsEvent
: public cbPluginEvent
1642 cbLayoutRowsEvent( cbDockPane
* pPane
)
1644 : cbPluginEvent( cbEVT_PL_LAYOUT_ROWS
, pPane
)
1648 class cbInsertBarEvent
: public cbPluginEvent
1654 cbInsertBarEvent( cbBarInfo
* pBar
, cbRowInfo
* pIntoRow
, cbDockPane
* pPane
)
1656 : cbPluginEvent( cbEVT_PL_INSERT_BAR
, pPane
),
1663 class cbResizeBarEvent
: public cbPluginEvent
1669 cbResizeBarEvent( cbBarInfo
* pBar
, cbRowInfo
* pRow
, cbDockPane
* pPane
)
1671 : cbPluginEvent( cbEVT_PL_RESIZE_BAR
, pPane
),
1677 class cbRemoveBarEvent
: public cbPluginEvent
1682 cbRemoveBarEvent( cbBarInfo
* pBar
, cbDockPane
* pPane
)
1684 : cbPluginEvent( cbEVT_PL_REMOVE_BAR
, pPane
),
1689 class cbSizeBarWndEvent
: public cbPluginEvent
1693 wxRect mBoundsInParent
;
1695 cbSizeBarWndEvent( cbBarInfo
* pBar
, cbDockPane
* pPane
)
1697 : cbPluginEvent( cbEVT_PL_SIZE_BAR_WND
, pPane
),
1699 mBoundsInParent( pBar
->mBoundsInParent
)
1703 class cbDrawBarDecorEvent
: public cbPluginEvent
1708 wxRect mBoundsInParent
;
1710 cbDrawBarDecorEvent( cbBarInfo
* pBar
, wxDC
& dc
, cbDockPane
* pPane
)
1712 : cbPluginEvent( cbEVT_PL_DRAW_BAR_DECOR
, pPane
),
1715 mBoundsInParent( pBar
->mBoundsInParent
)
1719 class cbDrawRowDecorEvent
: public cbPluginEvent
1725 cbDrawRowDecorEvent( cbRowInfo
* pRow
, wxDC
& dc
, cbDockPane
* pPane
)
1727 : cbPluginEvent( cbEVT_PL_DRAW_ROW_DECOR
, pPane
),
1733 class cbDrawPaneDecorEvent
: public cbPluginEvent
1738 cbDrawPaneDecorEvent( wxDC
& dc
, cbDockPane
* pPane
)
1740 : cbPluginEvent( cbEVT_PL_DRAW_PANE_DECOR
, pPane
),
1745 class cbDrawBarHandlesEvent
: public cbPluginEvent
1751 cbDrawBarHandlesEvent( cbBarInfo
* pBar
, wxDC
& dc
, cbDockPane
* pPane
)
1753 : cbPluginEvent( cbEVT_PL_DRAW_BAR_HANDLES
, pPane
),
1759 class cbDrawRowHandlesEvent
: public cbPluginEvent
1765 cbDrawRowHandlesEvent( cbRowInfo
* pRow
, wxDC
& dc
, cbDockPane
* pPane
)
1767 : cbPluginEvent( cbEVT_PL_DRAW_ROW_HANDLES
, pPane
),
1773 class cbDrawRowBkGroundEvent
: public cbPluginEvent
1779 cbDrawRowBkGroundEvent( cbRowInfo
* pRow
, wxDC
& dc
, cbDockPane
* pPane
)
1781 : cbPluginEvent( cbEVT_PL_DRAW_ROW_BKGROUND
, pPane
),
1787 class cbDrawPaneBkGroundEvent
: public cbPluginEvent
1792 cbDrawPaneBkGroundEvent( wxDC
& dc
, cbDockPane
* pPane
)
1794 : cbPluginEvent( cbEVT_PL_DRAW_PANE_BKGROUND
, pPane
),
1799 class cbStartBarDraggingEvent
: public cbPluginEvent
1803 wxPoint mPos
; // is given in frame's coordinates
1805 cbStartBarDraggingEvent( cbBarInfo
* pBar
, const wxPoint
& pos
, cbDockPane
* pPane
)
1807 : cbPluginEvent( cbEVT_PL_START_BAR_DRAGGING
, pPane
),
1813 class cbDrawHintRectEvent
: public cbPluginEvent
1816 wxRect mRect
; // is given in frame's coordinates
1819 bool mLastTime
; // indicates that this event finishes "session" of on-screen drawing,
1820 // thus associated resources can be freed now
1821 bool mEraseRect
; // does not have any impact, if recangle is drawn using XOR-mask
1823 bool mIsInClient
;// in cleint area hint could be drawn differently,
1824 // e.g. with fat/hatched border
1827 cbDrawHintRectEvent( const wxRect
& rect
, bool isInClient
, bool eraseRect
, bool lastTime
)
1829 : cbPluginEvent( cbEVT_PL_DRAW_HINT_RECT
, 0 ),
1831 mLastTime ( lastTime
),
1832 mEraseRect ( eraseRect
),
1833 mIsInClient( isInClient
)
1837 class cbStartDrawInAreaEvent
: public cbPluginEvent
1841 wxDC
** mppDc
; // points to pointer, where the reference
1842 // to the obtained buffer-context should be placed
1844 cbStartDrawInAreaEvent( const wxRect
& area
, wxDC
** ppDCForArea
, cbDockPane
* pPane
)
1846 : cbPluginEvent( cbEVT_PL_START_DRAW_IN_AREA
, pPane
),
1848 mppDc( ppDCForArea
)
1852 class cbFinishDrawInAreaEvent
: public cbPluginEvent
1857 cbFinishDrawInAreaEvent( const wxRect
& area
, cbDockPane
* pPane
)
1859 : cbPluginEvent( cbEVT_PL_FINISH_DRAW_IN_AREA
, pPane
),
1864 class cbCustomizeBarEvent
: public cbPluginEvent
1867 wxPoint mClickPos
; // in parent frame's coordinates
1870 cbCustomizeBarEvent( cbBarInfo
* pBar
, const wxPoint
& clickPos
, cbDockPane
* pPane
)
1872 : cbPluginEvent( cbEVT_PL_CUSTOMIZE_BAR
, pPane
),
1873 mClickPos( clickPos
),
1878 class cbCustomizeLayoutEvent
: public cbPluginEvent
1881 wxPoint mClickPos
; // in parent frame's coordinates
1883 cbCustomizeLayoutEvent( const wxPoint
& clickPos
)
1885 : cbPluginEvent( cbEVT_PL_CUSTOMIZE_LAYOUT
, 0 ),
1886 mClickPos( clickPos
)
1890 #endif /* __CONTROLBAR_G__ */