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 licence
11 /////////////////////////////////////////////////////////////////////////////
13 #ifndef __CONTROLBAR_G__
14 #define __CONTROLBAR_G__
16 #if defined(__GNUG__) && !defined(__APPLE__)
17 #pragma interface "controlbar.h"
21 #include "wx/string.h"
22 #include "wx/window.h"
23 #include "wx/dynarray.h"
24 #include "wx/fl/fldefs.h"
26 #define WXCONTROLBAR_VERSION 1.3
28 // forward declarations
30 class WXDLLIMPEXP_FL wxFrameLayout
;
32 class WXDLLIMPEXP_FL cbDockPane
;
33 class WXDLLIMPEXP_FL cbUpdatesManagerBase
;
34 class WXDLLIMPEXP_FL cbBarDimHandlerBase
;
35 class WXDLLIMPEXP_FL cbPluginBase
;
36 class WXDLLIMPEXP_FL cbPluginEvent
;
37 class WXDLLIMPEXP_FL cbPaneDrawPlugin
;
39 class WXDLLIMPEXP_FL cbBarInfo
;
40 class WXDLLIMPEXP_FL cbRowInfo
;
41 class WXDLLIMPEXP_FL cbDimInfo
;
42 class WXDLLIMPEXP_FL cbCommonPaneProperties
;
44 typedef cbBarInfo
* BarInfoPtrT
;
45 typedef cbRowInfo
* RowInfoPtrT
;
47 WXFL_DEFINE_ARRAY_PTR( BarInfoPtrT
, BarArrayT
);
48 WXFL_DEFINE_ARRAY_PTR( RowInfoPtrT
, RowArrayT
);
52 #define wxCBAR_DOCKED_HORIZONTALLY 0
53 #define wxCBAR_DOCKED_VERTICALLY 1
54 #define wxCBAR_FLOATING 2
55 #define wxCBAR_HIDDEN 3
57 // the states are enumerated above
58 #define MAX_BAR_STATES 4
60 // control bar alignments
62 #if !defined(FL_ALIGN_TOP)
64 #define FL_ALIGN_TOP 0
65 #define FL_ALIGN_BOTTOM 1
66 #define FL_ALIGN_LEFT 2
67 #define FL_ALIGN_RIGHT 3
71 // one pane for each alignment
74 // masks for each pane
76 #define FL_ALIGN_TOP_PANE 0x0001
77 #define FL_ALIGN_BOTTOM_PANE 0x0002
78 #define FL_ALIGN_LEFT_PANE 0x0004
79 #define FL_ALIGN_RIGHT_PANE 0x0008
81 #define wxALL_PANES 0x000F
83 // enumeration of hittest results, see cbDockPane::HitTestPaneItems(..)
85 enum CB_HITTEST_RESULT
89 CB_UPPER_ROW_HANDLE_HITTED
,
90 CB_LOWER_ROW_HANDLE_HITTED
,
91 CB_LEFT_BAR_HANDLE_HITTED
,
92 CB_RIGHT_BAR_HANDLE_HITTED
,
97 Helper class, used for spying for unhandled mouse events on control bars
98 and forwarding them to the frame layout.
101 class WXDLLIMPEXP_FL cbBarSpy
: public wxEvtHandler
104 DECLARE_DYNAMIC_CLASS( cbBarSpy
)
106 wxFrameLayout
* mpLayout
;
110 // Default constructor.
114 // Constructor, taking a parent pane.
116 cbBarSpy( wxFrameLayout
* pPanel
);
118 // Sets the bar window.
120 void SetBarWindow( wxWindow
* pWnd
);
122 // Performs special event processing.
124 virtual bool ProcessEvent(wxEvent
& event
);
128 wxFrameLayout manages containment and docking of control bars,
129 which can be docked along the top, bottom, right, or left side of the
133 class WXDLLIMPEXP_FL wxFrameLayout
: public wxEvtHandler
136 // Default constructor, used only for serialization.
140 // Constructor, taking parent window, the (MDI) client of the parent if there
141 // is one, and flag specifying whether to activate the layout.
143 wxFrameLayout( wxWindow
* pParentFrame
,
144 wxWindow
* pFrameClient
= NULL
,
145 bool activateNow
= TRUE
);
147 // Destructor. It does not destroy the bar windows.
149 virtual ~wxFrameLayout();
151 // Enables floating behaviour. By default floating of control bars is on.
153 virtual void EnableFloating( bool enable
= TRUE
);
155 // Activate can be called after some other layout has been deactivated,
156 // and this one must take over the current contents of the frame window.
158 // Effectively hooks itself to the frame window, re-displays all non-hidden
159 // bar windows and repaints the decorations.
161 virtual void Activate();
163 // Deactivate unhooks itself from frame window, and hides all non-hidden windows.
165 // Note: two frame layouts should not be active at the same time in the
166 // same frame window, since it would cause messy overlapping of bar windows
167 // from both layouts.
169 virtual void Deactivate();
171 // Hides the bar windows, and also the client window if present.
173 void HideBarWindows();
175 // Destroys the bar windows.
177 virtual void DestroyBarWindows();
179 // Passes the client window (e.g. MDI client window) to be controlled by
180 // frame layout, the size and position of which should be adjusted to be
181 // surrounded by controlbar panes, whenever the frame is resized or the dimensions
182 // of control panes change.
184 void SetFrameClient( wxWindow
* pFrameClient
);
186 // Returns the frame client, or NULL if not present.
188 wxWindow
* GetFrameClient();
190 // Returns the parent frame.
192 wxWindow
& GetParentFrame() { return *mpFrame
; }
194 // Returns an array of panes. Used by update managers.
196 cbDockPane
** GetPanesArray() { return mPanes
; }
198 // Returns a pane for the given alignment. See pane alignment types.
200 cbDockPane
* GetPane( int alignment
)
202 { return mPanes
[alignment
]; }
204 // Adds bar information to the frame layout. The appearance of the layout is not refreshed
205 // immediately; RefreshNow() can be called if necessary.
207 // Notes: the argument pBarWnd can by NULL, resulting in bar decorations to be drawn
208 // around the empty rectangle (filled with default background colour).
209 // Argument dimInfo can be reused for adding any number of bars, since
210 // it is not used directly - instead its members are copied. If the dimensions
211 // handler is present, its instance is shared (reference counted). The dimension
212 // handler should always be allocated on the heap.
214 // pBarWnd is the window to be managed.
216 // dimInfo contains dimension information.
218 // alignment is a value such as FL_ALIGN_TOP.
220 // rowNo is the vertical position or row in the pane (if in docked state).
222 // columnPos is the horizontal position within the row in pixels (if in docked state).
224 // name is a name by which the bar can be referred in layout customization dialogs.
226 // If spyEvents is TRUE, input events for the bar should be "spyed" in order
227 // to forward unhandled mouse clicks to the frame layout, for example to enable
228 // easy draggablity of toolbars just by clicking on their interior regions.
229 // For widgets like text/tree control this value should be FALSE,
230 // since there's no certain way to detect whether the event was actually handled.
232 // state is the initial state, such as wxCBAR_DOCKED_HORIZONTALLY,
233 // wxCBAR_FLOATING, wxCBAR_HIDDEN.
235 virtual void AddBar( wxWindow
* pBarWnd
,
236 const cbDimInfo
& dimInfo
,
239 int alignment
= FL_ALIGN_TOP
,
242 const wxString
& name
= wxT("bar"),
243 bool spyEvents
= FALSE
,
244 int state
= wxCBAR_DOCKED_HORIZONTALLY
247 // ReddockBar can be used for repositioning existing bars. The given bar is first removed
248 // from the pane it currently belongs to, and inserted into the pane, which "matches"
249 // the given rectangular area. If pToPane is not NULL, the bar is docked to this given pane.
250 // To dock a bar which is floating, use the wxFrameLayout::DockBar method.
252 virtual bool RedockBar( cbBarInfo
* pBar
, const wxRect
& shapeInParent
,
253 cbDockPane
* pToPane
= NULL
, bool updateNow
= TRUE
);
255 // Finds the bar in the framelayout, by name.
257 cbBarInfo
* FindBarByName( const wxString
& name
);
259 // Finds the bar in the framelayout, by window.
261 cbBarInfo
* FindBarByWindow( const wxWindow
* pWnd
);
263 // Gets an array of bars.
265 BarArrayT
& GetBars();
267 // Changes the bar's docking state (see possible control bar states).
269 void SetBarState( cbBarInfo
* pBar
, int newStatem
, bool updateNow
);
271 // Toggles the bar between visible and hidden.
273 void InverseVisibility( cbBarInfo
* pBar
);
275 // Reflects changes in bar information structure visually.
276 // For example, moves the bar, changes its dimension information,
277 // or changes the pane to which it is docked.
279 void ApplyBarProperties( cbBarInfo
* pBar
);
281 // Removes the bar from the layout permanently, and hides its corresponding window if present.
283 void RemoveBar( cbBarInfo
* pBar
);
285 // Recalculates the layout of panes, and all bars/rows in each pane.
287 virtual void RecalcLayout( bool repositionBarsNow
= FALSE
);
289 // Returns the client height.
291 int GetClientHeight();
293 // Returns the client width.
295 int GetClientWidth();
297 // Returns the client's rectangle.
299 wxRect
& GetClientRect() { return mClntWndBounds
; }
301 // Returns a reference to the updates manager.
302 // Note: in future, the updates manager will become a normal plugin.
304 cbUpdatesManagerBase
& GetUpdatesManager();
306 // Destroys the previous manager if any, and sets the new one.
308 void SetUpdatesManager( cbUpdatesManagerBase
* pUMgr
);
310 // Gets the pane properties for the given alignment.
312 virtual void GetPaneProperties( cbCommonPaneProperties
& props
, int alignment
= FL_ALIGN_TOP
);
314 // Sets the pane properties for the given alignment.
315 // Note: changing properties of panes does not result immediate on-screen update.
317 virtual void SetPaneProperties( const cbCommonPaneProperties
& props
,
318 int paneMask
= wxALL_PANES
);
320 // Sets the margins for the given panes.
321 // The margins should go into cbCommonPaneProperties in the future.
323 // Note: this method should be called before any custom plugins are attached.
325 virtual void SetMargins( int top
, int bottom
, int left
, int right
,
326 int paneMask
= wxALL_PANES
);
328 // Sets the pane background colour.
330 virtual void SetPaneBackground( const wxColour
& colour
);
332 // Recalculates layout and performs on-screen update of all panes.
334 void RefreshNow( bool recalcLayout
= TRUE
);
336 // Event handler for a size event.
338 void OnSize ( wxSizeEvent
& event
);
340 // Event handler for a left down button event.
342 void OnLButtonDown( wxMouseEvent
& event
);
344 // Event handler for a left doubleclick button event.
346 void OnLDblClick ( wxMouseEvent
& event
);
348 // Event handler for a left button up event.
350 void OnLButtonUp ( wxMouseEvent
& event
);
352 // Event handler for a right button down event.
354 void OnRButtonDown( wxMouseEvent
& event
);
356 // Event handler for a right button up event.
358 void OnRButtonUp ( wxMouseEvent
& event
);
360 // Event handler for a mouse move event.
362 void OnMouseMove ( wxMouseEvent
& event
);
364 // This function should be used instead of passing the event to the ProcessEvent method
365 // of the top-level plugin directly. This method checks if events are currently
366 // captured and ensures that plugin-event is routed correctly.
368 virtual void FirePluginEvent( cbPluginEvent
& event
);
370 // Captures user input events for the given plugin.
371 // Input events are: mouse movement, mouse clicks, keyboard input.
373 virtual void CaptureEventsForPlugin ( cbPluginBase
* pPlugin
);
375 // Releases user input events for the given plugin.
376 // Input events are: mouse movement, mouse clicks, keyboard input
378 virtual void ReleaseEventsFromPlugin( cbPluginBase
* pPlugin
);
380 // Called by plugins; also captures the mouse in the parent frame.
382 void CaptureEventsForPane( cbDockPane
* toPane
);
384 // Called by plugins; also releases mouse in the parent frame.
386 void ReleaseEventsFromPane( cbDockPane
* fromPane
);
388 // Returns the current top-level plugin (the one that receives events first,
389 // except if input events are currently captured by some other plugin).
391 virtual cbPluginBase
& GetTopPlugin();
393 // Hooking custom plugins to frame layout.
395 // Note: when hooking one plugin on top of the other,
396 // use SetNextHandler or similar methods
397 // of wxEvtHandler class to compose the chain of plugins,
398 // than pass the left-most handler in this chain to
399 // the above methods (assuming that events are delegated
400 // from left-most towards right-most handler).
402 // This secenario is very inconvenient and "low-level",
403 // so use the Add/Push/PopPlugin methods instead.
405 virtual void SetTopPlugin( cbPluginBase
* pPlugin
);
407 // Similar to wxWindow's "push/pop-event-handler" methods, execept
408 // that the plugin is deleted upon "popping".
410 virtual void PushPlugin( cbPluginBase
* pPugin
);
412 // Similar to wxWindow's "push/pop-event-handler" methods, execept
413 // that the plugin is deleted upon "popping".
415 virtual void PopPlugin();
418 virtual void PopAllPlugins();
420 // Adds the default plugins. These are cbPaneDrawPlugin, cbRowLayoutPlugin, cbBarDragPlugin,
421 // cbAntiflickerPlugin, cbSimpleCustomizePlugin.
423 // This method is automatically invoked if no plugins were found upon
424 // firing of the first plugin-event, i.e. when wxFrameLayout configures itself.
426 virtual void PushDefaultPlugins();
428 // An advanced methods for plugin configuration using their
429 // dynamic class information, for example CLASSINFO(pluginClass).
431 // First checks if the plugin of the given class is already "hooked up".
432 // If not, adds it to the top of the plugins chain.
434 virtual void AddPlugin( wxClassInfo
* pPlInfo
, int paneMask
= wxALL_PANES
);
436 // First checks if the plugin of the given class is already hooked.
437 // If so, removes it, and then inserts it into the chain
438 // before the plugin of the class given by pNextPlInfo.
440 // Note: this method is handy in some cases where the order
441 // of the plugin-chain could be important, for example when one plugin overrides
442 // some functionality of another already-hooked plugin,
443 // so that the former plugin should be hooked before the one
444 // whose functionality is being overridden.
446 virtual void AddPluginBefore( wxClassInfo
* pNextPlInfo
, wxClassInfo
* pPlInfo
,
447 int paneMask
= wxALL_PANES
);
449 // Checks if the plugin of the given class is hooked, and removes
452 virtual void RemovePlugin( wxClassInfo
* pPlInfo
);
454 // Finds a plugin with the given class, or returns NULL if a plugin of the given
455 // class is not hooked.
457 virtual cbPluginBase
* FindPlugin( wxClassInfo
* pPlInfo
);
459 // Returns true if there is a top plugin.
463 DECLARE_EVENT_TABLE()
464 DECLARE_DYNAMIC_CLASS( wxFrameLayout
)
466 public: /* protected really, acessed only by plugins and serializers */
468 friend class cbDockPane
;
469 friend class wxBarHandler
;
471 wxWindow
* mpFrame
; // parent frame
472 wxWindow
* mpFrameClient
; // client window
473 cbDockPane
* mPanes
[MAX_PANES
]; // panes in the panel
476 wxCursor
* mpHorizCursor
;
477 wxCursor
* mpVertCursor
;
478 wxCursor
* mpNormalCursor
;
479 wxCursor
* mpDragCursor
;
480 wxCursor
* mpNECursor
; // no-entry cursor
482 // pens for decoration and shades
484 wxPen mDarkPen
; // default wxSYS_COLOUR_3DSHADOW
485 wxPen mLightPen
; // default wxSYS_COLOUR_3DHILIGHT
486 wxPen mGrayPen
; // default wxSYS_COLOUR_3DFACE
487 wxPen mBlackPen
; // default wxColour( 0, 0, 0)
488 wxPen mBorderPen
; // default wxSYS_COLOUR_3DFACE
490 wxPen mNullPen
; // transparent pen
492 // pane to which the all mouse input is currently directed (caputred)
494 cbDockPane
* mpPaneInFocus
;
496 // pane, from which mouse pointer had just left
498 cbDockPane
* mpLRUPane
;
500 // bounds of client window in parent frame's coordinates
502 wxRect mClntWndBounds
;
503 wxRect mPrevClntWndBounds
;
506 wxPoint mNextFloatedWndPos
;
507 wxSize mFloatingPosStep
;
509 // current plugin (right-most) plugin which receives events first
511 cbPluginBase
* mpTopPlugin
;
513 // plugin, which currently has captured all input events, otherwise NULL
515 cbPluginBase
* mpCaputesInput
;
517 // list of event handlers which are "pushed" onto each bar, to catch
518 // mouse events which are not handled by bars, and froward them to the ,
519 // frome-layout and further to plugins
523 // list of top-most frames which contain floated bars
525 wxList mFloatedFrames
;
527 // linked list of references to all bars (docked/floated/hidden)
531 // FOR NOW:: dirty stuff...
532 bool mClientWndRefreshPending
;
534 bool mCheckFocusWhenIdle
;
536 public: /* protected really (accessed only by plugins) */
538 // refrence to custom updates manager
539 cbUpdatesManagerBase
* mpUpdatesMgr
;
541 // Called to apply the calculated layout to window objects.
543 void PositionClientWindow();
545 // Called to apply the calculated layout to window objects.
547 void PositionPanes();
549 // Creates the cursors.
551 void CreateCursors();
553 // Applies the calculated layout to a floating bar.
555 void RepositionFloatedBar( cbBarInfo
* pBar
);
557 // Applies the state to the window objects.
559 void DoSetBarState( cbBarInfo
* pBar
);
561 // The purpose of this function is unknown.
563 bool LocateBar( cbBarInfo
* pBarInfo
,
565 cbDockPane
** ppPane
);
568 // Returns TRUE if the position is within the given pane.
570 bool HitTestPane( cbDockPane
* pPane
, int x
, int y
);
572 // Returns the pane for which the rectangle hit test succeeds, giving
573 // preference to the given pane if supplied.
575 cbDockPane
* HitTestPanes( const wxRect
& rect
, cbDockPane
* pCurPane
);
577 // Returns the pane to which the given bar belongs.
579 cbDockPane
* GetBarPane( cbBarInfo
* pBar
);
581 // Delegated from "bar-spy".
582 void ForwardMouseEvent( wxMouseEvent
& event
,
586 // Routes the mouse event to the appropriate pane.
588 void RouteMouseEvent( wxMouseEvent
& event
, int pluginEvtType
);
590 // Shows all floated windows.
592 void ShowFloatedWindows( bool show
);
594 // Unhooks the layout from the frame.
596 void UnhookFromFrame();
598 // Hooks the layout up to the frame (pushes the layout onto the
599 // frame's event handler stack).
601 void HookUpToFrame();
603 // Returns TRUE if the platform allows reparenting. This may not return TRUE
604 // for all platforms. Reparenting allows control bars to be floated.
608 // Reparents pChild to have parent pNewParent.
610 void ReparentWindow( wxWindow
* pChild
, wxWindow
* pNewParent
);
612 // Returns the previous client window rectangle.
614 wxRect
& GetPrevClientRect() { return mPrevClntWndBounds
; }
616 // Handles paint events, calling PaintPane for each pane.
618 void OnPaint( wxPaintEvent
& event
);
620 // Handles background erase events. Currently does nothing.
622 void OnEraseBackground( wxEraseEvent
& event
);
624 // Handles focus kill events. Currently does nothing.
626 void OnKillFocus( wxFocusEvent
& event
);
628 // Handles focus set events. Currently does nothing.
630 void OnSetFocus( wxFocusEvent
& event
);
632 // Handles activation events. Currently does nothing.
634 void OnActivate( wxActivateEvent
& event
);
636 // Handles idle events.
638 void OnIdle( wxIdleEvent
& event
);
640 // Returns a new cbGCUpdatesMgr object.
642 virtual cbUpdatesManagerBase
* CreateUpdatesManager();
646 A structure that is present in each item of layout,
647 used by any particular updates-manager to store
648 auxiliary information to be used by its updating algorithm.
651 class WXDLLIMPEXP_FL cbUpdateMgrData
: public wxObject
653 DECLARE_DYNAMIC_CLASS( cbUpdateMgrData
)
655 wxRect mPrevBounds
; // previous state of layout item (in parent frame's coordinates)
657 bool mIsDirty
; // overrides result of current-against-previous bounds comparison,
658 // i.e. requires item to be updated, regardless of it's current area
660 wxObject
* mpCustomData
; // any custom data stored by specific updates mgr.
662 // Default constructor. Is-dirty flag is set TRUE initially.
666 // Store the item state.
668 void StoreItemState( const wxRect
& boundsInParent
);
670 // Set the dirty flag.
672 void SetDirty( bool isDirty
= TRUE
);
676 void SetCustomData( wxObject
* pCustomData
);
678 // Returns the is-dirty flag.
680 inline bool IsDirty() { return mIsDirty
; }
684 Abstract interface for bar-size handler classes.
685 These objects receive notifications whenever the docking
686 state of the bar is changed, thus they provide the possibility
687 to adjust the values in cbDimInfo::mSizes accordingly.
688 Specific handlers can be hooked up to specific types of bar.
691 class WXDLLIMPEXP_FL cbBarDimHandlerBase
: public wxObject
693 DECLARE_ABSTRACT_CLASS( cbBarDimHandlerBase
)
696 int mRefCount
; // since one dim-handler can be assigned
697 // to multiple bars, it's instance is
701 // Default constructor. The initial reference count is 0, since
702 // the handler is not used until the first invocation of AddRef().
704 cbBarDimHandlerBase();
706 // Increments the reference count.
710 // Decrements the reference count, and if the count is at zero,
715 // Responds to "bar-state-changes" notifications.
717 virtual void OnChangeBarState(cbBarInfo
* pBar
, int newState
) = 0;
719 // Responds to bar resize notifications.
721 virtual void OnResizeBar( cbBarInfo
* pBar
, const wxSize
& given
, wxSize
& preferred
) = 0;
725 Helper class used internally by the wxFrameLayout class.
726 Holds and manages information about bar dimensions.
729 class WXDLLIMPEXP_FL cbDimInfo
: public wxObject
731 DECLARE_DYNAMIC_CLASS( cbDimInfo
)
733 wxSize mSizes
[MAX_BAR_STATES
]; // preferred sizes for each possible bar state
735 wxRect mBounds
[MAX_BAR_STATES
]; // saved positions and sizes for each
736 // possible state, values contain (-1)s if
737 // not initialized yet
739 int mLRUPane
; // pane to which this bar was docked before it was floated
740 // (FL_ALIGN_TOP,FL_ALIGN_BOTTOM,..)
742 // top/bottom gap, separates decorations
743 // from the bar's actual window, filled
744 // with frame's beckground color, default: 0
748 // left/right gap, separates decorations
749 // from the bar's actual wndow, filled
750 // with frame's beckground colour, default: 0
752 int mHorizGap
; // NOTE:: gaps are given in frame's coord. orientation
754 // TRUE, if vertical/horizontal dimensions cannot be mannualy adjusted
755 // by user using resizing handles. If FALSE, the frame-layout
756 // *automatically* places resizing handles among not-fixed bars
760 cbBarDimHandlerBase
* mpHandler
; // NULL, if no handler present
764 // Default constructor.
769 // isFixed is TRUE if vertical/horizontal dimensions cannot be manually adjusted
770 // by the user using resizing handles. If FALSE, the frame-layout
771 // automatically places resizing handles among bars that do are not fixed.
773 cbDimInfo( cbBarDimHandlerBase
* pDimHandler
,
774 bool isFixed
// (see comments on mIsFixed member)
777 // Constructor taking dimenstion information.
779 // dh_x, dh_y are the dimensions when docked horizontally.
781 // dv_x, dv_y are the dimensions when docked vertically.
783 // f_x, f_y are the dimensions when floating.
785 // For information on isFixed, see comments above.
787 // horizGap is the left/right gap, separating decorations
788 // from the bar's actual wndow, filled with the frame's background colour.
789 // The dimension is given in the frame's coordinates.
791 // vertGap is the top/bottom gap, separating decorations
792 // from the bar's actual wndow, filled with the frame's background colour.
793 // The dimension is given in the frame's coordinates.
795 cbDimInfo( int dh_x
, int dh_y
,
803 cbBarDimHandlerBase
* pDimHandler
= NULL
808 cbDimInfo( int x
, int y
,
811 cbBarDimHandlerBase
* pDimHandler
= NULL
814 // Destructor. Destroys handler automatically, if present.
818 // Assignment operator.
820 const cbDimInfo
& operator=( const cbDimInfo
& other
);
822 // Returns the handler, if any.
824 inline cbBarDimHandlerBase
* GetDimHandler() { return mpHandler
; }
827 // FIXME: this array definition compiles but probably doesn't do what was intended (GD)
828 WXFL_DEFINE_ARRAY_LONG(float, cbArrayFloat
);
831 Helper class used internally by the wxFrameLayout class.
832 Holds and manages information about bar rows.
835 class cbRowInfo
: public wxObject
837 DECLARE_DYNAMIC_CLASS( cbRowInfo
)
840 BarArrayT mBars
; // row content
842 // row flags (set up according to row-relations)
844 bool mHasUpperHandle
;
845 bool mHasLowerHandle
;
846 bool mHasOnlyFixedBars
;
847 int mNotFixedBarsCnt
;
853 // stores precalculated row's bounds in parent frame's coordinates
854 wxRect mBoundsInParent
;
856 // info stored for updates-manager
857 cbUpdateMgrData mUMgrData
;
862 cbBarInfo
* mpExpandedBar
; // NULL, if non of the bars is currently expanded
864 cbArrayFloat mSavedRatios
; // length-ratios bofore some of the bars was expanded
875 // Returns the first bar.
877 inline cbBarInfo
* GetFirstBar()
879 { return mBars
.GetCount() ? mBars
[0] : NULL
; }
883 Helper class used internally by the wxFrameLayout class.
884 Holds and manages bar information.
887 class cbBarInfo
: public wxObject
889 DECLARE_DYNAMIC_CLASS( cbBarInfo
)
891 // textual name, by which this bar is refered in layout-customization dialogs
894 // stores bar's bounds in pane's coordinates
897 // stores precalculated bar's bounds in parent frame's coordinates
898 wxRect mBoundsInParent
;
900 // back-ref to the row, which contains this bar
903 // are set up according to the types of the surrounding bars in the row
905 bool mHasRightHandle
;
907 // determines if this bar can float. The layout's setting as priority. For
908 // example, if the layout's mFloatingOn is false, this setting is irrelevant
909 // since nothing will float at all. If the layout's floating is on, use this
910 // setting to prevent specific bars from floating. In other words, all bars
911 // float by default and floating can be turned off on individual bars.
912 bool mFloatingOn
; // default: ON (which is also the layout's mFloatingOn default setting)
914 cbDimInfo mDimInfo
; // preferred sizes for each, control bar state
916 int mState
; // (see definition of controlbar states)
918 int mAlignment
; // alignment of the pane to which this
919 // bar is currently placed
921 int mRowNo
; // row, into which this bar would be placed,
922 // when in the docking state
924 wxWindow
* mpBarWnd
; // the actual window object, NULL if no window
925 // is attached to the control bar (possible!)
927 double mLenRatio
; // length ratio among not-fixed-size bars
929 wxPoint mPosIfFloated
; // stored last position when bar was in "floated" state
930 // poistion is stored in parent-window's coordinates
932 cbUpdateMgrData mUMgrData
; // info stored for updates-manager
934 cbBarInfo
* mpNext
; // next. bar in the row
935 cbBarInfo
* mpPrev
; // prev. bar in the row
946 // Returns TRUE if this bar is fixed.
948 inline bool IsFixed() const { return mDimInfo
.mIsFixed
; }
950 // Returns TRUE if this bar is expanded.
952 inline bool IsExpanded() const { return this == mpRow
->mpExpandedBar
; }
956 Used for storing the original bar's positions in the row, when the 'non-destructive-friction'
960 class cbBarShapeData
: public wxObject
968 Used for traversing through all bars of all rows in the pane.
978 // Constructor, taking row array.
980 wxBarIterator( RowArrayT
& rows
);
982 // Resets the iterator to the start of the first row.
986 // Advances the iterator and returns TRUE if a bar is available.
990 // Gets the current bar information.
992 cbBarInfo
& BarInfo();
994 // Returns a reference to the currently traversed row.
996 cbRowInfo
& RowInfo();
1000 A structure holding configuration options,
1001 which are usually the same for all panes in
1005 class cbCommonPaneProperties
: public wxObject
1007 DECLARE_DYNAMIC_CLASS( cbCommonPaneProperties
)
1009 // look-and-feel configuration
1011 bool mRealTimeUpdatesOn
; // default: ON
1012 bool mOutOfPaneDragOn
; // default: ON
1013 bool mExactDockPredictionOn
; // default: OFF
1014 bool mNonDestructFrictionOn
; // default: OFF
1016 bool mShow3DPaneBorderOn
; // default: ON
1018 // FOR NOW:: the below properties are reserved for the "future"
1020 bool mBarFloatingOn
; // default: OFF
1021 bool mRowProportionsOn
; // default: OFF
1022 bool mColProportionsOn
; // default: ON
1023 bool mBarCollapseIconsOn
; // default: OFF
1024 bool mBarDragHintsOn
; // default: OFF
1026 // minimal dimensions for not-fixed bars in this pane (16x16 default)
1030 // width/height of resizing sash
1032 int mResizeHandleSize
;
1034 // Default constructor.
1036 cbCommonPaneProperties(void);
1040 cbCommonPaneProperties(const cbCommonPaneProperties
&);
1042 // Assignment operator
1044 cbCommonPaneProperties
& operator=(const cbCommonPaneProperties
&);
1048 This class manages containment and control of control bars
1049 along one of the four edges of the parent frame.
1052 class cbDockPane
: public wxObject
1055 DECLARE_DYNAMIC_CLASS( cbDockPane
)
1057 // look-and-feel configuration for this pane
1058 cbCommonPaneProperties mProps
;
1060 // pane margins (in frame's coordinate-syst. orientation)
1062 int mLeftMargin
; // default: 2 pixels
1063 int mRightMargin
; // default: 2 pixels
1064 int mTopMargin
; // default: 2 pixels
1065 int mBottomMargin
; // default: 2 pixels
1068 // position of the pane in frame's coordinates
1069 wxRect mBoundsInParent
;
1071 // pane width and height in pane's coordinates
1077 // info stored for updates-manager
1078 cbUpdateMgrData mUMgrData
;
1080 public: /* protected really */
1083 wxFrameLayout
* mpLayout
; // back-ref
1085 // transient properties
1087 wxList mRowShapeData
; // shapes of bars of recently modified row,
1088 // stored when in "non-destructive-friction" mode
1089 cbRowInfo
* mpStoredRow
; // row-info for which the shapes are stored
1091 friend class wxFrameLayout
;
1093 public: /* protected really (accessed only by plugins) */
1095 // Returns the row info for a row index. Internal function called by plugins.
1097 cbRowInfo
* GetRow( int row
);
1099 // Returns the row index for the given row info. Internal function called by plugins.
1101 int GetRowIndex( cbRowInfo
* pRow
);
1103 // Returns the row at the given vertical position.
1104 // Returns -1 if the row is not present at given vertical position.
1105 // Internal function called by plugins.
1107 int GetRowAt( int paneY
);
1109 // Returns the row between the given vertical positions.
1110 // Returns -1 if the row is not present.
1111 // Internal function called by plugins.
1113 int GetRowAt( int upperY
, int lowerY
);
1115 // Sets up flags in the row information structure, so that
1116 // they match the changed state of row items correctly.
1117 // Internal function called by plugins.
1119 void SyncRowFlags( cbRowInfo
* pRow
);
1121 // Returns TRUE if the bar's dimension information indicates a fixed size.
1122 // Internal function called by plugins.
1124 bool IsFixedSize( cbBarInfo
* pInfo
);
1126 // Returns the number of bars whose size is not fixed.
1127 // Internal function called by plugins.
1129 int GetNotFixedBarsCount( cbRowInfo
* pRow
);
1131 // Gets the vertical position at the given row.
1132 // Internal function called by plugins.
1134 int GetRowY( cbRowInfo
* pRow
);
1136 // Returns TRUE if there are any variable-sized rows above this one.
1137 // Internal function called by plugins.
1139 bool HasNotFixedRowsAbove( cbRowInfo
* pRow
);
1141 // Returns TRUE if there are any variable-sized rows below this one.
1142 // Internal function called by plugins.
1144 bool HasNotFixedRowsBelow( cbRowInfo
* pRow
);
1146 // Returns TRUE if there are any variable-sized rows to the left of this one.
1147 // Internal function called by plugins.
1149 bool HasNotFixedBarsLeft ( cbBarInfo
* pBar
);
1151 // Returns TRUE if there are any variable-sized rows to the right of this one.
1152 // Internal function called by plugins.
1154 bool HasNotFixedBarsRight( cbBarInfo
* pBar
);
1156 // Calculate lengths.
1157 // Internal function called by plugins.
1159 virtual void CalcLengthRatios( cbRowInfo
* pInRow
);
1161 // Generates a cbLayoutRowEvent event to recalculate row layouts.
1162 // Internal function called by plugins.
1164 virtual void RecalcRowLayout( cbRowInfo
* pRow
);
1167 // Internal function called by plugins.
1169 virtual void ExpandBar( cbBarInfo
* pBar
);
1171 // Contracts the bar.
1172 // Internal function called by plugins.
1174 virtual void ContractBar( cbBarInfo
* pBar
);
1176 // Sets up links between bars.
1177 // Internal function called by plugins.
1179 void InitLinksForRow( cbRowInfo
* pRow
);
1181 // Sets up links between bars.
1182 // Internal function called by plugins.
1184 void InitLinksForRows();
1186 // Coordinate translation between parent's frame and this pane.
1187 // Internal function called by plugins.
1189 void FrameToPane( int* x
, int* y
);
1191 // Coordinate translation between parent's frame and this pane.
1192 // Internal function called by plugins.
1194 void PaneToFrame( int* x
, int* y
);
1196 // Coordinate translation between parent's frame and this pane.
1197 // Internal function called by plugins.
1199 void FrameToPane( wxRect
* pRect
);
1201 // Coordinate translation between parent's frame and this pane.
1202 // Internal function called by plugins.
1204 void PaneToFrame( wxRect
* pRect
);
1206 // Returns TRUE if pos is within the given rectangle.
1207 // Internal function called by plugins.
1209 inline bool HasPoint( const wxPoint
& pos
, int x
, int y
, int width
, int height
);
1211 // Returns the minimal row height for the given row.
1212 // Internal function called by plugins.
1214 int GetMinimalRowHeight( cbRowInfo
* pRow
);
1216 // Sets the row height for the given height. newHeight includes the height of row handles, if present.
1217 // Internal function called by plugins.
1219 void SetRowHeight( cbRowInfo
* pRow
, int newHeight
);
1221 // Inserts the bar at the given row number.
1222 // Internal function called by plugins.
1224 void DoInsertBar( cbBarInfo
* pBar
, int rowNo
);
1226 public: /* protected really (accessed only by plugins) */
1228 // Generates a cbDrawBarDecorEvent and sends it to the layout to paint the bar decorations.
1229 // Internal function called by plugins.
1231 virtual void PaintBarDecorations( cbBarInfo
* pBar
, wxDC
& dc
);
1233 // Generates a cbDrawBarHandlesEvent and sends it to the layout to paint the bar handles.
1234 // Internal function called by plugins.
1236 virtual void PaintBarHandles( cbBarInfo
* pBar
, wxDC
& dc
);
1238 // Calls PaintBarDecorations and PaintBarHandles.
1239 // Internal function called by plugins.
1241 virtual void PaintBar( cbBarInfo
* pBar
, wxDC
& dc
);
1243 // Generates cbDrawRowHandlesEvent and cbDrawRowDecorEvent and sends them to the layout.
1244 // Internal function called by plugins.
1246 virtual void PaintRowHandles( cbRowInfo
* pRow
, wxDC
& dc
);
1248 // Generates cbDrawRowBkGroundEvent and sends it to the layout.
1249 // Internal function called by plugins.
1251 virtual void PaintRowBackground ( cbRowInfo
* pRow
, wxDC
& dc
);
1253 // Calls PaintBarDecorations for each row.
1254 // Internal function called by plugins.
1256 virtual void PaintRowDecorations( cbRowInfo
* pRow
, wxDC
& dc
);
1258 // Calls PaintRowBackground, PaintRowDecorations, PaintRowHandles.
1259 // Internal function called by plugins.
1261 virtual void PaintRow( cbRowInfo
* pRow
, wxDC
& dc
);
1263 // Generates cbDrawPaneBkGroundEvent and sends it to the layout.
1264 // Internal function called by plugins.
1266 virtual void PaintPaneBackground( wxDC
& dc
);
1268 // Generates cbDrawPaneDecorEvent and sends it to the layout.
1269 // Internal function called by plugins.
1271 virtual void PaintPaneDecorations( wxDC
& dc
);
1273 // Paints the pane background, the row background and decorations,
1274 // and finally the pane decorations.
1275 // Internal function called by plugins.
1277 virtual void PaintPane( wxDC
& dc
);
1279 // Generates a cbSizeBarWndEvent and sends it to the layout.
1280 // Internal function called by plugins.
1282 virtual void SizeBar( cbBarInfo
* pBar
);
1284 // Calls SizeBar for each bar in the row.
1285 // Internal function called by plugins.
1287 virtual void SizeRowObjects( cbRowInfo
* pRow
);
1289 // Calls SizeRowObjects for each row.
1290 // Internal function called by plugins.
1292 virtual void SizePaneObjects();
1294 // Generates cbStartDrawInAreaEvent and sends it to the layout.
1295 // Internal function called by plugins.
1297 virtual wxDC
* StartDrawInArea ( const wxRect
& area
);
1299 // Generates cbFinishDrawInAreaEvent and sends it to the layout.
1300 // Internal function called by plugins.
1302 virtual void FinishDrawInArea( const wxRect
& area
);
1304 public: /* public members */
1306 // Default constructor.
1310 // Constructor, taking alignment and layout panel.
1312 cbDockPane( int alignment
, wxFrameLayout
* pPanel
);
1314 // Sets pane's margins in frame's coordinate orientations.
1316 void SetMargins( int top
, int bottom
, int left
, int right
);
1320 virtual ~cbDockPane();
1322 // Removes the bar from this pane. Does not destroy the bar.
1324 virtual void RemoveBar( cbBarInfo
* pBar
);
1326 // Inserts the bar into this pane. rect is given in the parent frame's coordinates.
1328 virtual void InsertBar( cbBarInfo
* pBar
, const wxRect
& rect
);
1330 // Inserts the bar into the given row, with dimensions and position
1331 // stored in pBarInfo->mBounds. Returns the node of inserted bar.
1333 virtual void InsertBar( cbBarInfo
* pBar
, cbRowInfo
* pIntoRow
);
1335 // Inserts bar and sets its position according to the preferred settings
1336 // given in pBarInfo.
1338 virtual void InsertBar( cbBarInfo
* pBarInfo
);
1340 // Removes the row from this pane. Does not destroy the row object.
1342 virtual void RemoveRow( cbRowInfo
* pRow
);
1344 // Inserts a row. Does not refresh the inserted row immediately.
1345 // If pBeforeRowNode is NULL, the row is appended to the end of pane's row list.
1347 virtual void InsertRow( cbRowInfo
* pRow
, cbRowInfo
* pBeforeRow
);
1349 // Sets pane's width in the pane's coordinates (including margins).
1351 void SetPaneWidth(int width
);
1353 // Set the position and dimensions of the pane in the parent frame's coordinates.
1355 void SetBoundsInParent( const wxRect
& rect
);
1357 // Returns the bounds of the pane, in parent coordinates.
1359 inline wxRect
& GetRealRect() { return mBoundsInParent
; }
1361 // Returns an array of rows. Used by updates-managers.
1363 inline RowArrayT
& GetRowList() { return mRows
; }
1365 // Returns the first row.
1367 inline cbRowInfo
* GetFirstRow()
1369 { return mRows
.GetCount() ? mRows
[0] : NULL
; }
1371 // Returns TRUE if the given bar is present in this pane.
1373 bool BarPresent( cbBarInfo
* pBar
);
1375 // Returns the height in the pane's coordinates.
1377 int GetPaneHeight();
1379 // Returns the alignment for this pane. The value is one of
1380 // FL_ALIGN_TOP, FL_ALIGN_BOTTOM, FL_ALIGN_LEFT, FL_ALIGN_RIGHT.
1384 // Returns TRUE if the given mask matches the pane's mask.
1386 bool MatchesMask( int paneMask
);
1388 // Returns TRUE if the pane is aligned to the top or bottom.
1390 inline bool IsHorizontal()
1392 return (mAlignment
== FL_ALIGN_TOP
||
1393 mAlignment
== FL_ALIGN_BOTTOM
);
1396 // Generates events to perform layout calculations.
1398 virtual void RecalcLayout();
1400 // Returns wxCBAR_DOCKED_HORIZONTALLY if the alignment is top or bottom,
1401 // or wxCBAR_DOCKED_VERTICALLY otherwise.
1403 virtual int GetDockingState();
1405 // Returns the result of hit-testing items in the pane.
1406 // See CB_HITTEST_RESULT enumerated type.
1407 // pos is the position in this pane's coordinates.
1409 virtual int HitTestPaneItems( const wxPoint
& pos
,
1414 // Returns the bar's resize range.
1416 void GetBarResizeRange( cbBarInfo
* pBar
, int* from
, int *till
, bool forLeftHandle
);
1418 // Returns the row's resize range.
1420 void GetRowResizeRange( cbRowInfo
* pRow
, int* from
, int* till
, bool forUpperHandle
);
1422 // Finds the bar information by corresponding window.
1424 cbBarInfo
* GetBarInfoByWindow( wxWindow
* pBarWnd
);
1426 public: /* protected really (accessed only by plugins) */
1428 // Row/bar resizing related helper-method.
1430 void DrawVertHandle ( wxDC
& dc
, int x
, int y
, int height
);
1432 // Row/bar resizing related helper-method.
1434 void DrawHorizHandle( wxDC
& dc
, int x
, int y
, int width
);
1436 // Row/bar resizing related helper-method.
1438 void ResizeRow( cbRowInfo
* pRow
, int ofs
, bool forUpperHandle
);
1440 // Row/bar resizing related helper-method.
1442 void ResizeBar( cbBarInfo
* pBar
, int ofs
, bool forLeftHandle
);
1444 // Returns row shape data.
1445 // cbBarShapeData objects will be added to the given pLst.
1446 // cbBarShapeData is used for storing the original bar's positions in the row,
1447 // when the 'non-destructive-friction' option is turned on.
1449 void GetRowShapeData( cbRowInfo
* pRow
, wxList
* pLst
);
1451 // Sets the shape data for the given row, using the data provided in pLst.
1452 // cbBarShapeData is used for storing the original bar's positions in the row,
1453 // when the 'non-destructive-friction' option is turned on.
1455 void SetRowShapeData( cbRowInfo
* pRowNode
, wxList
* pLst
);
1459 This class declares an abstract interface for optimized logic that should refresh
1460 areas of frame layout that actually need to be updated. This should be extended in future
1461 to implement a custom updating strategy.
1464 class cbUpdatesManagerBase
: public wxObject
1466 DECLARE_ABSTRACT_CLASS( cbUpdatesManagerBase
)
1468 public: /* protected really, accessed by serializer (if any) */
1470 wxFrameLayout
* mpLayout
;
1473 // Default constructor
1475 cbUpdatesManagerBase(void)
1478 // Constructor taking layout panel.
1480 cbUpdatesManagerBase( wxFrameLayout
* pPanel
)
1481 : mpLayout( pPanel
) {}
1485 virtual ~cbUpdatesManagerBase() {}
1487 // Sets the associated layout.
1489 void SetLayout( wxFrameLayout
* pLayout
) { mpLayout
= pLayout
; }
1491 // This function receives a notification from the frame layout (in the order in which
1492 // they would usually be invoked). Custom updates-managers may utilize
1493 // these notifications to implement a more fine-grained updating strategy.
1495 virtual void OnStartChanges() = 0;
1497 // This function receives a notification from the frame layout (in the order in which
1498 // they would usually be invoked). Custom updates-managers may utilize
1499 // these notifications to implement a more fine-grained updating strategy.
1501 virtual void OnRowWillChange( cbRowInfo
* pRow
, cbDockPane
* pInPane
) {}
1503 // This function receives a notification from the frame layout (in the order in which
1504 // they would usually be invoked). Custom updates-managers may utilize
1505 // these notifications to implement a more fine-grained updating strategy.
1507 virtual void OnBarWillChange( cbBarInfo
* pBar
, cbRowInfo
* pInRow
, cbDockPane
* pInPane
) {}
1509 // This function receives a notification from the frame layout (in the order in which
1510 // they would usually be invoked). Custom updates-managers may utilize
1511 // these notifications to implement a more fine-grained updating strategy.
1513 virtual void OnPaneMarginsWillChange( cbDockPane
* pPane
) {}
1515 // This function receives a notification from the frame layout (in the order in which
1516 // they would usually be invoked). Custom updates-managers may utilize
1517 // these notifications to implement a more fine-grained updating strategy.
1519 virtual void OnPaneWillChange( cbDockPane
* pPane
) {}
1521 // This function receives a notification from the frame layout (in the order in which
1522 // they would usually be invoked). Custom updates-managers may utilize
1523 // these notifications to implement a more fine-grained updating strategy.
1525 virtual void OnFinishChanges() {}
1527 // Refreshes parts of the frame layout that need an update.
1529 virtual void UpdateNow() = 0;
1533 Base class for all control-bar plugin events.
1534 This is not a dynamically-creatable class.
1537 class cbPluginEvent
: public wxEvent
1540 // NULL if event is not addressed to any specific pane.
1544 // Not used, but required.
1546 virtual wxEvent
* Clone() const { return NULL
; }
1548 // Constructor, taking event type and pane.
1550 cbPluginEvent( wxEventType eventType
, cbDockPane
* pPane
)
1553 { m_eventType
= eventType
; }
1556 // event types handled by plugins
1558 extern wxEventType cbEVT_PL_LEFT_DOWN
;
1559 extern wxEventType cbEVT_PL_LEFT_UP
;
1560 extern wxEventType cbEVT_PL_RIGHT_DOWN
;
1561 extern wxEventType cbEVT_PL_RIGHT_UP
;
1562 extern wxEventType cbEVT_PL_MOTION
;
1564 extern wxEventType cbEVT_PL_LEFT_DCLICK
;
1566 extern wxEventType cbEVT_PL_LAYOUT_ROW
;
1567 extern wxEventType cbEVT_PL_RESIZE_ROW
;
1568 extern wxEventType cbEVT_PL_LAYOUT_ROWS
;
1569 extern wxEventType cbEVT_PL_INSERT_BAR
;
1570 extern wxEventType cbEVT_PL_RESIZE_BAR
;
1571 extern wxEventType cbEVT_PL_REMOVE_BAR
;
1572 extern wxEventType cbEVT_PL_SIZE_BAR_WND
;
1574 extern wxEventType cbEVT_PL_DRAW_BAR_DECOR
;
1575 extern wxEventType cbEVT_PL_DRAW_ROW_DECOR
;
1576 extern wxEventType cbEVT_PL_DRAW_PANE_DECOR
;
1577 extern wxEventType cbEVT_PL_DRAW_BAR_HANDLES
;
1578 extern wxEventType cbEVT_PL_DRAW_ROW_HANDLES
;
1579 extern wxEventType cbEVT_PL_DRAW_ROW_BKGROUND
;
1580 extern wxEventType cbEVT_PL_DRAW_PANE_BKGROUND
;
1582 extern wxEventType cbEVT_PL_START_BAR_DRAGGING
;
1583 extern wxEventType cbEVT_PL_DRAW_HINT_RECT
;
1585 extern wxEventType cbEVT_PL_START_DRAW_IN_AREA
;
1586 extern wxEventType cbEVT_PL_FINISH_DRAW_IN_AREA
;
1588 extern wxEventType cbEVT_PL_CUSTOMIZE_BAR
;
1589 extern wxEventType cbEVT_PL_CUSTOMIZE_LAYOUT
;
1591 extern wxEventType wxCUSTOM_CB_PLUGIN_EVENTS_START_AT
;
1593 // Forward declarations, separated by categories.
1595 class cbLeftDownEvent
;
1596 class cbLeftUpEvent
;
1597 class cbRightDownEvent
;
1598 class cbRightUpEvent
;
1599 class cbMotionEvent
;
1600 class cbLeftDClickEvent
;
1602 class cbLayoutRowEvent
;
1603 class cbResizeRowEvent
;
1604 class cbLayoutRowsEvent
;
1605 class cbInsertBarEvent
;
1606 class cbResizeBarEvent
;
1607 class cbRemoveBarEvent
;
1608 class cbSizeBarWndEvent
;
1610 class cbDrawBarDecorEvent
;
1611 class cbDrawRowDecorEvent
;
1612 class cbDrawPaneDecorEvent
;
1613 class cbDrawBarHandlesEvent
;
1614 class cbDrawRowHandlesEvent
;
1615 class cbDrawRowBkGroundEvent
;
1616 class cbDrawPaneBkGroundEvent
;
1618 class cbStartBarDraggingEvent
;
1619 class cbDrawHintRectEvent
;
1621 class cbStartDrawInAreaEvent
;
1622 class cbFinishDrawInAreaEvent
;
1624 class cbCustomizeBarEvent
;
1625 class cbCustomizeLayoutEvent
;
1627 // Definitions for for handler-methods.
1629 typedef void (wxEvtHandler::*cbLeftDownHandler
)(cbLeftDownEvent
&);
1630 typedef void (wxEvtHandler::*cbLeftUpHandler
)(cbLeftUpEvent
&);
1631 typedef void (wxEvtHandler::*cbRightDownHandler
)(cbRightDownEvent
&);
1632 typedef void (wxEvtHandler::*cbRightUpHandler
)(cbRightUpEvent
&);
1633 typedef void (wxEvtHandler::*cbMotionHandler
)(cbMotionEvent
&);
1634 typedef void (wxEvtHandler::*cbLeftDClickHandler
)(cbLeftDClickEvent
&);
1636 typedef void (wxEvtHandler::*cbLayoutRowHandler
)(cbLayoutRowEvent
&);
1637 typedef void (wxEvtHandler::*cbResizeRowHandler
)(cbResizeRowEvent
&);
1638 typedef void (wxEvtHandler::*cbLayoutRowsHandler
)(cbLayoutRowsEvent
&);
1639 typedef void (wxEvtHandler::*cbInsertBarHandler
)(cbInsertBarEvent
&);
1640 typedef void (wxEvtHandler::*cbResizeBarHandler
)(cbResizeBarEvent
&);
1641 typedef void (wxEvtHandler::*cbRemoveBarHandler
)(cbRemoveBarEvent
&);
1642 typedef void (wxEvtHandler::*cbSizeBarWndHandler
)(cbSizeBarWndEvent
&);
1644 typedef void (wxEvtHandler::*cbDrawBarDecorHandler
)(cbDrawBarDecorEvent
&);
1645 typedef void (wxEvtHandler::*cbDrawRowDecorHandler
)(cbDrawRowDecorEvent
&);
1646 typedef void (wxEvtHandler::*cbDrawPaneDecorHandler
)(cbDrawPaneDecorEvent
&);
1647 typedef void (wxEvtHandler::*cbDrawBarHandlesHandler
)(cbDrawBarHandlesEvent
&);
1648 typedef void (wxEvtHandler::*cbDrawRowHandlesHandler
)(cbDrawRowHandlesEvent
&);
1649 typedef void (wxEvtHandler::*cbDrawRowBkGroundHandler
)(cbDrawRowBkGroundEvent
&);
1650 typedef void (wxEvtHandler::*cbDrawPaneBkGroundHandler
)(cbDrawPaneBkGroundEvent
&);
1652 typedef void (wxEvtHandler::*cbStartBarDraggingHandler
)(cbStartBarDraggingEvent
&);
1653 typedef void (wxEvtHandler::*cbDrawHintRectHandler
)(cbDrawHintRectEvent
&);
1655 typedef void (wxEvtHandler::*cbStartDrawInAreaHandler
)(cbStartDrawInAreaEvent
&);
1656 typedef void (wxEvtHandler::*cbFinishDrawInAreaHandler
)(cbFinishDrawInAreaEvent
&);
1658 typedef void (wxEvtHandler::*cbCustomizeBarHandler
)(cbCustomizeBarEvent
&);
1659 typedef void (wxEvtHandler::*cbCustomizeLayoutHandler
)(cbCustomizeLayoutEvent
&);
1661 // Macros for creating event table entries for plugin-events.
1663 #define EVT_PL_LEFT_DOWN(func) wxEventTableEntry( cbEVT_PL_LEFT_DOWN, -1, -1, (wxObjectEventFunction) (wxEventFunction) (cbLeftDownHandler ) & func, (wxObject *) NULL ),
1664 #define EVT_PL_LEFT_UP(func) wxEventTableEntry( cbEVT_PL_LEFT_UP, -1, -1, (wxObjectEventFunction) (wxEventFunction) (cbLeftUpHandler ) & func, (wxObject *) NULL ),
1665 #define EVT_PL_RIGHT_DOWN(func) wxEventTableEntry( cbEVT_PL_RIGHT_DOWN, -1, -1, (wxObjectEventFunction) (wxEventFunction) (cbRightDownHandler ) & func, (wxObject *) NULL ),
1666 #define EVT_PL_RIGHT_UP(func) wxEventTableEntry( cbEVT_PL_RIGHT_UP, -1, -1, (wxObjectEventFunction) (wxEventFunction) (cbRightUpHandler ) & func, (wxObject *) NULL ),
1667 #define EVT_PL_MOTION(func) wxEventTableEntry( cbEVT_PL_MOTION, -1, -1, (wxObjectEventFunction) (wxEventFunction) (cbMotionHandler ) & func, (wxObject *) NULL ),
1668 #define EVT_PL_LEFT_DCLICK(func) wxEventTableEntry( cbEVT_PL_LEFT_DCLICK, -1, -1, (wxObjectEventFunction) (wxEventFunction) (cbLeftDClickHandler ) & func, (wxObject *) NULL ),
1670 #define EVT_PL_LAYOUT_ROW(func) wxEventTableEntry( cbEVT_PL_LAYOUT_ROW, -1, -1, (wxObjectEventFunction) (wxEventFunction) (cbLayoutRowHandler ) & func, (wxObject *) NULL ),
1671 #define EVT_PL_RESIZE_ROW(func) wxEventTableEntry( cbEVT_PL_RESIZE_ROW, -1, -1, (wxObjectEventFunction) (wxEventFunction) (cbResizeRowHandler ) & func, (wxObject *) NULL ),
1672 #define EVT_PL_LAYOUT_ROWS(func) wxEventTableEntry( cbEVT_PL_LAYOUT_ROWS, -1, -1, (wxObjectEventFunction) (wxEventFunction) (cbLayoutRowsHandler ) & func, (wxObject *) NULL ),
1673 #define EVT_PL_INSERT_BAR(func) wxEventTableEntry( cbEVT_PL_INSERT_BAR, -1, -1, (wxObjectEventFunction) (wxEventFunction) (cbInsertBarHandler ) & func, (wxObject *) NULL ),
1674 #define EVT_PL_RESIZE_BAR(func) wxEventTableEntry( cbEVT_PL_RESIZE_BAR, -1, -1, (wxObjectEventFunction) (wxEventFunction) (cbResizeBarHandler ) & func, (wxObject *) NULL ),
1675 #define EVT_PL_REMOVE_BAR(func) wxEventTableEntry( cbEVT_PL_REMOVE_BAR, -1, -1, (wxObjectEventFunction) (wxEventFunction) (cbRemoveBarHandler ) & func, (wxObject *) NULL ),
1676 #define EVT_PL_SIZE_BAR_WND(func) wxEventTableEntry( cbEVT_PL_SIZE_BAR_WND, -1, -1, (wxObjectEventFunction) (wxEventFunction) (cbSizeBarWndHandler ) & func, (wxObject *) NULL ),
1678 #define EVT_PL_DRAW_BAR_DECOR(func) wxEventTableEntry( cbEVT_PL_DRAW_BAR_DECOR, -1, -1, (wxObjectEventFunction) (wxEventFunction) (cbDrawBarDecorHandler ) & func, (wxObject *) NULL ),
1679 #define EVT_PL_DRAW_ROW_DECOR(func) wxEventTableEntry( cbEVT_PL_DRAW_ROW_DECOR, -1, -1, (wxObjectEventFunction) (wxEventFunction) (cbDrawRowDecorHandler ) & func, (wxObject *) NULL ),
1680 #define EVT_PL_DRAW_PANE_DECOR(func) wxEventTableEntry( cbEVT_PL_DRAW_PANE_DECOR, -1, -1, (wxObjectEventFunction) (wxEventFunction) (cbDrawPaneDecorHandler ) & func, (wxObject *) NULL ),
1681 #define EVT_PL_DRAW_BAR_HANDLES(func) wxEventTableEntry( cbEVT_PL_DRAW_BAR_HANDLES, -1, -1, (wxObjectEventFunction) (wxEventFunction) (cbDrawBarHandlesHandler ) & func, (wxObject *) NULL ),
1682 #define EVT_PL_DRAW_ROW_HANDLES(func) wxEventTableEntry( cbEVT_PL_DRAW_ROW_HANDLES, -1, -1, (wxObjectEventFunction) (wxEventFunction) (cbDrawRowHandlesHandler ) & func, (wxObject *) NULL ),
1683 #define EVT_PL_DRAW_ROW_BKGROUND(func) wxEventTableEntry( cbEVT_PL_DRAW_ROW_BKGROUND, -1, -1, (wxObjectEventFunction) (wxEventFunction) (cbDrawRowBkGroundHandler ) & func, (wxObject *) NULL ),
1684 #define EVT_PL_DRAW_PANE_BKGROUND(func) wxEventTableEntry( cbEVT_PL_DRAW_PANE_BKGROUND, -1, -1, (wxObjectEventFunction) (wxEventFunction) (cbDrawPaneBkGroundHandler) & func, (wxObject *) NULL ),
1686 #define EVT_PL_START_BAR_DRAGGING(func) wxEventTableEntry( cbEVT_PL_START_BAR_DRAGGING, -1, -1, (wxObjectEventFunction) (wxEventFunction) (cbStartBarDraggingHandler) & func, (wxObject *) NULL ),
1687 #define EVT_PL_DRAW_HINT_RECT(func) wxEventTableEntry( cbEVT_PL_DRAW_HINT_RECT, -1, -1, (wxObjectEventFunction) (wxEventFunction) (cbDrawHintRectHandler ) & func, (wxObject *) NULL ),
1690 #define EVT_PL_START_DRAW_IN_AREA(func) wxEventTableEntry( cbEVT_PL_START_DRAW_IN_AREA, -1, -1, (wxObjectEventFunction) (wxEventFunction) (cbStartDrawInAreaHandler) & func, (wxObject *) NULL ),
1691 #define EVT_PL_FINISH_DRAW_IN_AREA(func) wxEventTableEntry( cbEVT_PL_FINISH_DRAW_IN_AREA, -1, -1, (wxObjectEventFunction) (wxEventFunction) (cbFinishDrawInAreaHandler) & func, (wxObject *) NULL ),
1693 #define EVT_PL_CUSTOMIZE_BAR(func) wxEventTableEntry( cbEVT_PL_CUSTOMIZE_BAR, -1, -1, (wxObjectEventFunction) (wxEventFunction) (cbCustomizeBarHandler) & func, (wxObject *) NULL ),
1694 #define EVT_PL_CUSTOMIZE_LAYOUT(func) wxEventTableEntry( cbEVT_PL_CUSTOMIZE_LAYOUT, -1, -1, (wxObjectEventFunction) (wxEventFunction) (cbCustomizeLayoutHandler) & func, (wxObject *) NULL ),
1697 Abstract base class for all control-bar related plugins.
1698 Note: pointer positions of mouse events sent to plugins
1699 are always in the pane's coordinates (the pane to which
1700 this plugin is hooked).
1703 class cbPluginBase
: public wxEvtHandler
1705 DECLARE_ABSTRACT_CLASS( cbPluginBase
)
1707 // Back-reference to the frame layout.
1709 wxFrameLayout
* mpLayout
;
1711 // Specifies panes for which this plugin receives events
1712 // (see pane masks definitions).
1716 // Is TRUE when plugin is ready to handle events.
1721 // Default constructor.
1726 mPaneMask( wxALL_PANES
),
1730 // Constructor taking layout panel and a mask.
1732 cbPluginBase( wxFrameLayout
* pPanel
, int paneMask
= wxALL_PANES
)
1734 : mpLayout ( pPanel
),
1735 mPaneMask( paneMask
),
1739 // Returns the pane mask.
1741 inline int GetPaneMask() { return mPaneMask
; }
1743 // Destructor. Destroys the whole plugin chain of connected plugins.
1745 virtual ~cbPluginBase();
1747 // Override this method to do plugin-specific initialization.
1748 // At this point plugin is already attached to the frame layout,
1749 // and pane masks are set.
1751 virtual void OnInitPlugin() { mIsReady
= TRUE
; }
1753 // Returns TRUE if the plugin is ready to receive events.
1755 bool IsReady() { return mIsReady
; }
1757 // Overridden to determine whether the target pane specified in the
1758 // event matches the pane mask of this plugin (specific plugins
1759 // do not override this method).
1761 virtual bool ProcessEvent(wxEvent
& event
);
1765 Class for mouse left down events.
1768 class cbLeftDownEvent
: public cbPluginEvent
1773 // Constructor, taking mouse position and pane.
1775 cbLeftDownEvent( const wxPoint
& pos
, cbDockPane
* pPane
)
1777 : cbPluginEvent( cbEVT_PL_LEFT_DOWN
, pPane
),
1783 Class for mouse left up events.
1786 class cbLeftUpEvent
: public cbPluginEvent
1791 // Constructor, taking mouse position and pane.
1793 cbLeftUpEvent( const wxPoint
& pos
, cbDockPane
* pPane
)
1795 : cbPluginEvent( cbEVT_PL_LEFT_UP
, pPane
),
1801 Class for mouse right down events.
1804 class cbRightDownEvent
: public cbPluginEvent
1809 // Constructor, taking mouse position and pane.
1811 cbRightDownEvent( const wxPoint
& pos
, cbDockPane
* pPane
)
1813 : cbPluginEvent( cbEVT_PL_RIGHT_DOWN
, pPane
),
1819 Class for mouse right up events.
1822 class cbRightUpEvent
: public cbPluginEvent
1827 // Constructor, taking mouse position and pane.
1829 cbRightUpEvent( const wxPoint
& pos
, cbDockPane
* pPane
)
1831 : cbPluginEvent( cbEVT_PL_RIGHT_UP
, pPane
),
1837 Class for mouse motion events.
1840 class cbMotionEvent
: public cbPluginEvent
1845 // Constructor, taking mouse position and pane.
1847 cbMotionEvent( const wxPoint
& pos
, cbDockPane
* pPane
)
1849 : cbPluginEvent( cbEVT_PL_MOTION
, pPane
),
1855 Class for mouse left double click events.
1858 class cbLeftDClickEvent
: public cbPluginEvent
1863 // Constructor, taking mouse position and pane.
1865 cbLeftDClickEvent( const wxPoint
& pos
, cbDockPane
* pPane
)
1867 : cbPluginEvent( cbEVT_PL_LEFT_DCLICK
, pPane
),
1873 Class for single row layout events.
1876 class cbLayoutRowEvent
: public cbPluginEvent
1881 // Constructor, taking row information and pane.
1883 cbLayoutRowEvent( cbRowInfo
* pRow
, cbDockPane
* pPane
)
1885 : cbPluginEvent( cbEVT_PL_LAYOUT_ROW
, pPane
),
1891 Class for row resize events.
1894 class cbResizeRowEvent
: public cbPluginEvent
1899 bool mForUpperHandle
;
1901 // Constructor, taking row information, two parameters of currently unknown use, and pane.
1903 cbResizeRowEvent( cbRowInfo
* pRow
, int handleOfs
, bool forUpperHandle
, cbDockPane
* pPane
)
1905 : cbPluginEvent( cbEVT_PL_RESIZE_ROW
, pPane
),
1907 mHandleOfs( handleOfs
),
1908 mForUpperHandle( forUpperHandle
)
1913 Class for multiple rows layout events.
1916 class cbLayoutRowsEvent
: public cbPluginEvent
1920 // Constructor, taking pane.
1922 cbLayoutRowsEvent( cbDockPane
* pPane
)
1924 : cbPluginEvent( cbEVT_PL_LAYOUT_ROWS
, pPane
)
1929 Class for bar insertion events.
1932 class cbInsertBarEvent
: public cbPluginEvent
1938 // Constructor, taking bar information, row information, and pane.
1940 cbInsertBarEvent( cbBarInfo
* pBar
, cbRowInfo
* pIntoRow
, cbDockPane
* pPane
)
1942 : cbPluginEvent( cbEVT_PL_INSERT_BAR
, pPane
),
1950 Class for bar resize events.
1953 class cbResizeBarEvent
: public cbPluginEvent
1959 // Constructor, taking bar information, row information, and pane.
1961 cbResizeBarEvent( cbBarInfo
* pBar
, cbRowInfo
* pRow
, cbDockPane
* pPane
)
1963 : cbPluginEvent( cbEVT_PL_RESIZE_BAR
, pPane
),
1970 Class for bar removal events.
1973 class cbRemoveBarEvent
: public cbPluginEvent
1978 // Constructor, taking bar information and pane.
1980 cbRemoveBarEvent( cbBarInfo
* pBar
, cbDockPane
* pPane
)
1982 : cbPluginEvent( cbEVT_PL_REMOVE_BAR
, pPane
),
1988 Class for bar window resize events.
1991 class cbSizeBarWndEvent
: public cbPluginEvent
1995 wxRect mBoundsInParent
;
1997 // Constructor, taking bar information and pane.
1999 cbSizeBarWndEvent( cbBarInfo
* pBar
, cbDockPane
* pPane
)
2001 : cbPluginEvent( cbEVT_PL_SIZE_BAR_WND
, pPane
),
2003 mBoundsInParent( pBar
->mBoundsInParent
)
2008 Class for bar decoration drawing events.
2011 class cbDrawBarDecorEvent
: public cbPluginEvent
2016 wxRect mBoundsInParent
;
2018 // Constructor, taking bar information, device context, and pane.
2020 cbDrawBarDecorEvent( cbBarInfo
* pBar
, wxDC
& dc
, cbDockPane
* pPane
)
2022 : cbPluginEvent( cbEVT_PL_DRAW_BAR_DECOR
, pPane
),
2025 mBoundsInParent( pBar
->mBoundsInParent
)
2030 Class for row decoration drawing events.
2033 class cbDrawRowDecorEvent
: public cbPluginEvent
2039 // Constructor, taking row information, device context, and pane.
2041 cbDrawRowDecorEvent( cbRowInfo
* pRow
, wxDC
& dc
, cbDockPane
* pPane
)
2043 : cbPluginEvent( cbEVT_PL_DRAW_ROW_DECOR
, pPane
),
2050 Class for pane decoration drawing events.
2053 class cbDrawPaneDecorEvent
: public cbPluginEvent
2058 // Constructor, taking device context and pane.
2060 cbDrawPaneDecorEvent( wxDC
& dc
, cbDockPane
* pPane
)
2062 : cbPluginEvent( cbEVT_PL_DRAW_PANE_DECOR
, pPane
),
2068 Class for bar handles drawing events.
2071 class cbDrawBarHandlesEvent
: public cbPluginEvent
2077 // Constructor, taking bar information, device context, and pane.
2079 cbDrawBarHandlesEvent( cbBarInfo
* pBar
, wxDC
& dc
, cbDockPane
* pPane
)
2081 : cbPluginEvent( cbEVT_PL_DRAW_BAR_HANDLES
, pPane
),
2088 Class for row handles drawing events.
2091 class cbDrawRowHandlesEvent
: public cbPluginEvent
2097 // Constructor, taking row information, device context, and pane.
2099 cbDrawRowHandlesEvent( cbRowInfo
* pRow
, wxDC
& dc
, cbDockPane
* pPane
)
2101 : cbPluginEvent( cbEVT_PL_DRAW_ROW_HANDLES
, pPane
),
2108 Class for row background drawing events.
2111 class cbDrawRowBkGroundEvent
: public cbPluginEvent
2117 // Constructor, taking row information, device context, and pane.
2119 cbDrawRowBkGroundEvent( cbRowInfo
* pRow
, wxDC
& dc
, cbDockPane
* pPane
)
2121 : cbPluginEvent( cbEVT_PL_DRAW_ROW_BKGROUND
, pPane
),
2128 Class for pane background drawing events.
2131 class cbDrawPaneBkGroundEvent
: public cbPluginEvent
2136 // Constructor, taking device context and pane.
2138 cbDrawPaneBkGroundEvent( wxDC
& dc
, cbDockPane
* pPane
)
2140 : cbPluginEvent( cbEVT_PL_DRAW_PANE_BKGROUND
, pPane
),
2146 Class for start-bar-dragging events.
2149 class cbStartBarDraggingEvent
: public cbPluginEvent
2153 wxPoint mPos
; // is given in frame's coordinates
2155 // Constructor, taking bar information, mouse position, and pane.
2157 cbStartBarDraggingEvent( cbBarInfo
* pBar
, const wxPoint
& pos
, cbDockPane
* pPane
)
2159 : cbPluginEvent( cbEVT_PL_START_BAR_DRAGGING
, pPane
),
2166 Class for hint-rectangle drawing events.
2169 class cbDrawHintRectEvent
: public cbPluginEvent
2172 wxRect mRect
; // is given in frame's coordinates
2175 bool mLastTime
; // indicates that this event finishes "session" of on-screen drawing,
2176 // thus associated resources can be freed now
2177 bool mEraseRect
; // does not have any impact, if recangle is drawn using XOR-mask
2179 bool mIsInClient
;// in cleint area hint could be drawn differently,
2180 // e.g. with fat/hatched border
2183 // Constructor, taking hint rectangle and three flags.
2185 cbDrawHintRectEvent( const wxRect
& rect
, bool isInClient
, bool eraseRect
, bool lastTime
)
2187 : cbPluginEvent( cbEVT_PL_DRAW_HINT_RECT
, 0 ),
2189 mLastTime ( lastTime
),
2190 mEraseRect ( eraseRect
),
2191 mIsInClient( isInClient
)
2196 Class for start drawing in area events.
2199 class cbStartDrawInAreaEvent
: public cbPluginEvent
2203 wxDC
** mppDc
; // points to pointer, where the reference
2204 // to the obtained buffer-context should be placed
2206 // Constructor, taking rectangular area, device context pointer to a pointer, and pane.
2208 cbStartDrawInAreaEvent( const wxRect
& area
, wxDC
** ppDCForArea
, cbDockPane
* pPane
)
2210 : cbPluginEvent( cbEVT_PL_START_DRAW_IN_AREA
, pPane
),
2212 mppDc( ppDCForArea
)
2217 Class for finish drawing in area events.
2220 class cbFinishDrawInAreaEvent
: public cbPluginEvent
2225 // Constructor, taking rectangular area and pane.
2227 cbFinishDrawInAreaEvent( const wxRect
& area
, cbDockPane
* pPane
)
2229 : cbPluginEvent( cbEVT_PL_FINISH_DRAW_IN_AREA
, pPane
),
2235 Class for bar customization events.
2238 class cbCustomizeBarEvent
: public cbPluginEvent
2241 wxPoint mClickPos
; // in parent frame's coordinates
2244 // Constructor, taking bar information, mouse position, and pane.
2246 cbCustomizeBarEvent( cbBarInfo
* pBar
, const wxPoint
& clickPos
, cbDockPane
* pPane
)
2248 : cbPluginEvent( cbEVT_PL_CUSTOMIZE_BAR
, pPane
),
2249 mClickPos( clickPos
),
2255 Class for layout customization events.
2258 class cbCustomizeLayoutEvent
: public cbPluginEvent
2261 wxPoint mClickPos
; // in parent frame's coordinates
2263 // Constructor, taking mouse position.
2265 cbCustomizeLayoutEvent( const wxPoint
& clickPos
)
2267 : cbPluginEvent( cbEVT_PL_CUSTOMIZE_LAYOUT
, 0 ),
2268 mClickPos( clickPos
)
2272 #endif /* __CONTROLBAR_G__ */