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 WXFL_DECLSPEC wxFrameLayout
;
32 class WXFL_DECLSPEC cbDockPane
;
33 class WXFL_DECLSPEC cbUpdatesManagerBase
;
34 class WXFL_DECLSPEC cbBarDimHandlerBase
;
35 class WXFL_DECLSPEC cbPluginBase
;
36 class WXFL_DECLSPEC cbPluginEvent
;
37 class WXFL_DECLSPEC cbPaneDrawPlugin
;
39 class WXFL_DECLSPEC cbBarInfo
;
40 class WXFL_DECLSPEC cbRowInfo
;
41 class WXFL_DECLSPEC cbDimInfo
;
42 class WXFL_DECLSPEC cbCommonPaneProperties
;
44 typedef cbBarInfo
* BarInfoPtrT
;
45 typedef cbRowInfo
* RowInfoPtrT
;
47 WXFL_DEFINE_ARRAY( BarInfoPtrT
, BarArrayT
);
48 WXFL_DEFINE_ARRAY( 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 WXFL_DECLSPEC 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 WXFL_DECLSPEC 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
="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 WXFL_DECLSPEC 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 WXFL_DECLSPEC 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 WXFL_DECLSPEC 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 cbDimInfo mDimInfo
; // preferred sizes for each, control bar state
909 int mState
; // (see definition of controlbar states)
911 int mAlignment
; // alignment of the pane to which this
912 // bar is currently placed
914 int mRowNo
; // row, into which this bar would be placed,
915 // when in the docking state
917 wxWindow
* mpBarWnd
; // the actual window object, NULL if no window
918 // is attached to the control bar (possible!)
920 double mLenRatio
; // length ratio among not-fixed-size bars
922 wxPoint mPosIfFloated
; // stored last position when bar was in "floated" state
923 // poistion is stored in parent-window's coordinates
925 cbUpdateMgrData mUMgrData
; // info stored for updates-manager
927 cbBarInfo
* mpNext
; // next. bar in the row
928 cbBarInfo
* mpPrev
; // prev. bar in the row
939 // Returns TRUE if this bar is fixed.
941 inline bool IsFixed() const { return mDimInfo
.mIsFixed
; }
943 // Returns TRUE if this bar is expanded.
945 inline bool IsExpanded() const { return this == mpRow
->mpExpandedBar
; }
949 Used for storing the original bar's positions in the row, when the 'non-destructive-friction'
953 class cbBarShapeData
: public wxObject
961 Used for traversing through all bars of all rows in the pane.
971 // Constructor, taking row array.
973 wxBarIterator( RowArrayT
& rows
);
975 // Resets the iterator to the start of the first row.
979 // Advances the iterator and returns TRUE if a bar is available.
983 // Gets the current bar information.
985 cbBarInfo
& BarInfo();
987 // Returns a reference to the currently traversed row.
989 cbRowInfo
& RowInfo();
993 A structure holding configuration options,
994 which are usually the same for all panes in
998 class cbCommonPaneProperties
: public wxObject
1000 DECLARE_DYNAMIC_CLASS( cbCommonPaneProperties
)
1002 // look-and-feel configuration
1004 bool mRealTimeUpdatesOn
; // default: ON
1005 bool mOutOfPaneDragOn
; // default: ON
1006 bool mExactDockPredictionOn
; // default: OFF
1007 bool mNonDestructFrictionOn
; // default: OFF
1009 bool mShow3DPaneBorderOn
; // default: ON
1011 // FOR NOW:: the below properties are reserved for the "future"
1013 bool mBarFloatingOn
; // default: OFF
1014 bool mRowProportionsOn
; // default: OFF
1015 bool mColProportionsOn
; // default: ON
1016 bool mBarCollapseIconsOn
; // default: OFF
1017 bool mBarDragHintsOn
; // default: OFF
1019 // minimal dimensions for not-fixed bars in this pane (16x16 default)
1023 // width/height of resizing sash
1025 int mResizeHandleSize
;
1027 // Default constructor.
1029 cbCommonPaneProperties(void);
1033 cbCommonPaneProperties(const cbCommonPaneProperties
&);
1035 // Assignment operator
1037 cbCommonPaneProperties
& operator=(const cbCommonPaneProperties
&);
1041 This class manages containment and control of control bars
1042 along one of the four edges of the parent frame.
1045 class cbDockPane
: public wxObject
1048 DECLARE_DYNAMIC_CLASS( cbDockPane
)
1050 // look-and-feel configuration for this pane
1051 cbCommonPaneProperties mProps
;
1053 // pane margins (in frame's coordinate-syst. orientation)
1055 int mLeftMargin
; // default: 2 pixels
1056 int mRightMargin
; // default: 2 pixels
1057 int mTopMargin
; // default: 2 pixels
1058 int mBottomMargin
; // default: 2 pixels
1061 // position of the pane in frame's coordinates
1062 wxRect mBoundsInParent
;
1064 // pane width and height in pane's coordinates
1070 // info stored for updates-manager
1071 cbUpdateMgrData mUMgrData
;
1073 public: /* protected really */
1076 wxFrameLayout
* mpLayout
; // back-ref
1078 // transient properties
1080 wxList mRowShapeData
; // shapes of bars of recently modified row,
1081 // stored when in "non-destructive-friction" mode
1082 cbRowInfo
* mpStoredRow
; // row-info for which the shapes are stored
1084 friend class wxFrameLayout
;
1086 public: /* protected really (accessed only by plugins) */
1088 // Returns the row info for a row index. Internal function called by plugins.
1090 cbRowInfo
* GetRow( int row
);
1092 // Returns the row index for the given row info. Internal function called by plugins.
1094 int GetRowIndex( cbRowInfo
* pRow
);
1096 // Returns the row at the given vertical position.
1097 // Returns -1 if the row is not present at given vertical position.
1098 // Internal function called by plugins.
1100 int GetRowAt( int paneY
);
1102 // Returns the row between the given vertical positions.
1103 // Returns -1 if the row is not present.
1104 // Internal function called by plugins.
1106 int GetRowAt( int upperY
, int lowerY
);
1108 // Sets up flags in the row information structure, so that
1109 // they match the changed state of row items correctly.
1110 // Internal function called by plugins.
1112 void SyncRowFlags( cbRowInfo
* pRow
);
1114 // Returns TRUE if the bar's dimension information indicates a fixed size.
1115 // Internal function called by plugins.
1117 bool IsFixedSize( cbBarInfo
* pInfo
);
1119 // Returns the number of bars whose size is not fixed.
1120 // Internal function called by plugins.
1122 int GetNotFixedBarsCount( cbRowInfo
* pRow
);
1124 // Gets the vertical position at the given row.
1125 // Internal function called by plugins.
1127 int GetRowY( cbRowInfo
* pRow
);
1129 // Returns TRUE if there are any variable-sized rows above this one.
1130 // Internal function called by plugins.
1132 bool HasNotFixedRowsAbove( cbRowInfo
* pRow
);
1134 // Returns TRUE if there are any variable-sized rows below this one.
1135 // Internal function called by plugins.
1137 bool HasNotFixedRowsBelow( cbRowInfo
* pRow
);
1139 // Returns TRUE if there are any variable-sized rows to the left of this one.
1140 // Internal function called by plugins.
1142 bool HasNotFixedBarsLeft ( cbBarInfo
* pBar
);
1144 // Returns TRUE if there are any variable-sized rows to the right of this one.
1145 // Internal function called by plugins.
1147 bool HasNotFixedBarsRight( cbBarInfo
* pBar
);
1149 // Calculate lengths.
1150 // Internal function called by plugins.
1152 virtual void CalcLengthRatios( cbRowInfo
* pInRow
);
1154 // Generates a cbLayoutRowEvent event to recalculate row layouts.
1155 // Internal function called by plugins.
1157 virtual void RecalcRowLayout( cbRowInfo
* pRow
);
1160 // Internal function called by plugins.
1162 virtual void ExpandBar( cbBarInfo
* pBar
);
1164 // Contracts the bar.
1165 // Internal function called by plugins.
1167 virtual void ContractBar( cbBarInfo
* pBar
);
1169 // Sets up links between bars.
1170 // Internal function called by plugins.
1172 void InitLinksForRow( cbRowInfo
* pRow
);
1174 // Sets up links between bars.
1175 // Internal function called by plugins.
1177 void InitLinksForRows();
1179 // Coordinate translation between parent's frame and this pane.
1180 // Internal function called by plugins.
1182 void FrameToPane( int* x
, int* y
);
1184 // Coordinate translation between parent's frame and this pane.
1185 // Internal function called by plugins.
1187 void PaneToFrame( int* x
, int* y
);
1189 // Coordinate translation between parent's frame and this pane.
1190 // Internal function called by plugins.
1192 void FrameToPane( wxRect
* pRect
);
1194 // Coordinate translation between parent's frame and this pane.
1195 // Internal function called by plugins.
1197 void PaneToFrame( wxRect
* pRect
);
1199 // Returns TRUE if pos is within the given rectangle.
1200 // Internal function called by plugins.
1202 inline bool HasPoint( const wxPoint
& pos
, int x
, int y
, int width
, int height
);
1204 // Returns the minimal row height for the given row.
1205 // Internal function called by plugins.
1207 int GetMinimalRowHeight( cbRowInfo
* pRow
);
1209 // Sets the row height for the given height. newHeight includes the height of row handles, if present.
1210 // Internal function called by plugins.
1212 void SetRowHeight( cbRowInfo
* pRow
, int newHeight
);
1214 // Inserts the bar at the given row number.
1215 // Internal function called by plugins.
1217 void DoInsertBar( cbBarInfo
* pBar
, int rowNo
);
1219 public: /* protected really (accessed only by plugins) */
1221 // Generates a cbDrawBarDecorEvent and sends it to the layout to paint the bar decorations.
1222 // Internal function called by plugins.
1224 virtual void PaintBarDecorations( cbBarInfo
* pBar
, wxDC
& dc
);
1226 // Generates a cbDrawBarHandlesEvent and sends it to the layout to paint the bar handles.
1227 // Internal function called by plugins.
1229 virtual void PaintBarHandles( cbBarInfo
* pBar
, wxDC
& dc
);
1231 // Calls PaintBarDecorations and PaintBarHandles.
1232 // Internal function called by plugins.
1234 virtual void PaintBar( cbBarInfo
* pBar
, wxDC
& dc
);
1236 // Generates cbDrawRowHandlesEvent and cbDrawRowDecorEvent and sends them to the layout.
1237 // Internal function called by plugins.
1239 virtual void PaintRowHandles( cbRowInfo
* pRow
, wxDC
& dc
);
1241 // Generates cbDrawRowBkGroundEvent and sends it to the layout.
1242 // Internal function called by plugins.
1244 virtual void PaintRowBackground ( cbRowInfo
* pRow
, wxDC
& dc
);
1246 // Calls PaintBarDecorations for each row.
1247 // Internal function called by plugins.
1249 virtual void PaintRowDecorations( cbRowInfo
* pRow
, wxDC
& dc
);
1251 // Calls PaintRowBackground, PaintRowDecorations, PaintRowHandles.
1252 // Internal function called by plugins.
1254 virtual void PaintRow( cbRowInfo
* pRow
, wxDC
& dc
);
1256 // Generates cbDrawPaneBkGroundEvent and sends it to the layout.
1257 // Internal function called by plugins.
1259 virtual void PaintPaneBackground( wxDC
& dc
);
1261 // Generates cbDrawPaneDecorEvent and sends it to the layout.
1262 // Internal function called by plugins.
1264 virtual void PaintPaneDecorations( wxDC
& dc
);
1266 // Paints the pane background, the row background and decorations,
1267 // and finally the pane decorations.
1268 // Internal function called by plugins.
1270 virtual void PaintPane( wxDC
& dc
);
1272 // Generates a cbSizeBarWndEvent and sends it to the layout.
1273 // Internal function called by plugins.
1275 virtual void SizeBar( cbBarInfo
* pBar
);
1277 // Calls SizeBar for each bar in the row.
1278 // Internal function called by plugins.
1280 virtual void SizeRowObjects( cbRowInfo
* pRow
);
1282 // Calls SizeRowObjects for each row.
1283 // Internal function called by plugins.
1285 virtual void SizePaneObjects();
1287 // Generates cbStartDrawInAreaEvent and sends it to the layout.
1288 // Internal function called by plugins.
1290 virtual wxDC
* StartDrawInArea ( const wxRect
& area
);
1292 // Generates cbFinishDrawInAreaEvent and sends it to the layout.
1293 // Internal function called by plugins.
1295 virtual void FinishDrawInArea( const wxRect
& area
);
1297 public: /* public members */
1299 // Default constructor.
1303 // Constructor, taking alignment and layout panel.
1305 cbDockPane( int alignment
, wxFrameLayout
* pPanel
);
1307 // Sets pane's margins in frame's coordinate orientations.
1309 void SetMargins( int top
, int bottom
, int left
, int right
);
1313 virtual ~cbDockPane();
1315 // Removes the bar from this pane. Does not destroy the bar.
1317 virtual void RemoveBar( cbBarInfo
* pBar
);
1319 // Inserts the bar into this pane. rect is given in the parent frame's coordinates.
1321 virtual void InsertBar( cbBarInfo
* pBar
, const wxRect
& rect
);
1323 // Inserts the bar into the given row, with dimensions and position
1324 // stored in pBarInfo->mBounds. Returns the node of inserted bar.
1326 virtual void InsertBar( cbBarInfo
* pBar
, cbRowInfo
* pIntoRow
);
1328 // Inserts bar and sets its position according to the preferred settings
1329 // given in pBarInfo.
1331 virtual void InsertBar( cbBarInfo
* pBarInfo
);
1333 // Removes the row from this pane. Does not destroy the row object.
1335 virtual void RemoveRow( cbRowInfo
* pRow
);
1337 // Inserts a row. Does not refresh the inserted row immediately.
1338 // If pBeforeRowNode is NULL, the row is appended to the end of pane's row list.
1340 virtual void InsertRow( cbRowInfo
* pRow
, cbRowInfo
* pBeforeRow
);
1342 // Sets pane's width in the pane's coordinates (including margins).
1344 void SetPaneWidth(int width
);
1346 // Set the position and dimensions of the pane in the parent frame's coordinates.
1348 void SetBoundsInParent( const wxRect
& rect
);
1350 // Returns the bounds of the pane, in parent coordinates.
1352 inline wxRect
& GetRealRect() { return mBoundsInParent
; }
1354 // Returns an array of rows. Used by updates-managers.
1356 inline RowArrayT
& GetRowList() { return mRows
; }
1358 // Returns the first row.
1360 inline cbRowInfo
* GetFirstRow()
1362 { return mRows
.GetCount() ? mRows
[0] : NULL
; }
1364 // Returns TRUE if the given bar is present in this pane.
1366 bool BarPresent( cbBarInfo
* pBar
);
1368 // Returns the height in the pane's coordinates.
1370 int GetPaneHeight();
1372 // Returns the alignment for this pane. The value is one of
1373 // FL_ALIGN_TOP, FL_ALIGN_BOTTOM, FL_ALIGN_LEFT, FL_ALIGN_RIGHT.
1377 // Returns TRUE if the given mask matches the pane's mask.
1379 bool MatchesMask( int paneMask
);
1381 // Returns TRUE if the pane is aligned to the top or bottom.
1383 inline bool IsHorizontal()
1385 return (mAlignment
== FL_ALIGN_TOP
||
1386 mAlignment
== FL_ALIGN_BOTTOM
);
1389 // Generates events to perform layout calculations.
1391 virtual void RecalcLayout();
1393 // Returns wxCBAR_DOCKED_HORIZONTALLY if the alignment is top or bottom,
1394 // or wxCBAR_DOCKED_VERTICALLY otherwise.
1396 virtual int GetDockingState();
1398 // Returns the result of hit-testing items in the pane.
1399 // See CB_HITTEST_RESULT enumerated type.
1400 // pos is the position in this pane's coordinates.
1402 virtual int HitTestPaneItems( const wxPoint
& pos
,
1407 // Returns the bar's resize range.
1409 void GetBarResizeRange( cbBarInfo
* pBar
, int* from
, int *till
, bool forLeftHandle
);
1411 // Returns the row's resize range.
1413 void GetRowResizeRange( cbRowInfo
* pRow
, int* from
, int* till
, bool forUpperHandle
);
1415 // Finds the bar information by corresponding window.
1417 cbBarInfo
* GetBarInfoByWindow( wxWindow
* pBarWnd
);
1419 public: /* protected really (accessed only by plugins) */
1421 // Row/bar resizing related helper-method.
1423 void DrawVertHandle ( wxDC
& dc
, int x
, int y
, int height
);
1425 // Row/bar resizing related helper-method.
1427 void DrawHorizHandle( wxDC
& dc
, int x
, int y
, int width
);
1429 // Row/bar resizing related helper-method.
1431 void ResizeRow( cbRowInfo
* pRow
, int ofs
, bool forUpperHandle
);
1433 // Row/bar resizing related helper-method.
1435 void ResizeBar( cbBarInfo
* pBar
, int ofs
, bool forLeftHandle
);
1437 // Returns row shape data.
1438 // cbBarShapeData objects will be added to the given pLst.
1439 // cbBarShapeData is used for storing the original bar's positions in the row,
1440 // when the 'non-destructive-friction' option is turned on.
1442 void GetRowShapeData( cbRowInfo
* pRow
, wxList
* pLst
);
1444 // Sets the shape data for the given row, using the data provided in pLst.
1445 // cbBarShapeData is used for storing the original bar's positions in the row,
1446 // when the 'non-destructive-friction' option is turned on.
1448 void SetRowShapeData( cbRowInfo
* pRowNode
, wxList
* pLst
);
1452 This class declares an abstract interface for optimized logic that should refresh
1453 areas of frame layout that actually need to be updated. This should be extended in future
1454 to implement a custom updating strategy.
1457 class cbUpdatesManagerBase
: public wxObject
1459 DECLARE_ABSTRACT_CLASS( cbUpdatesManagerBase
)
1461 public: /* protected really, accessed by serializer (if any) */
1463 wxFrameLayout
* mpLayout
;
1466 // Default constructor
1468 cbUpdatesManagerBase(void)
1471 // Constructor taking layout panel.
1473 cbUpdatesManagerBase( wxFrameLayout
* pPanel
)
1474 : mpLayout( pPanel
) {}
1478 virtual ~cbUpdatesManagerBase() {}
1480 // Sets the associated layout.
1482 void SetLayout( wxFrameLayout
* pLayout
) { mpLayout
= pLayout
; }
1484 // This function receives a notification from the frame layout (in the order in which
1485 // they would usually be invoked). Custom updates-managers may utilize
1486 // these notifications to implement a more fine-grained updating strategy.
1488 virtual void OnStartChanges() = 0;
1490 // This function receives a notification from the frame layout (in the order in which
1491 // they would usually be invoked). Custom updates-managers may utilize
1492 // these notifications to implement a more fine-grained updating strategy.
1494 virtual void OnRowWillChange( cbRowInfo
* pRow
, cbDockPane
* pInPane
) {}
1496 // This function receives a notification from the frame layout (in the order in which
1497 // they would usually be invoked). Custom updates-managers may utilize
1498 // these notifications to implement a more fine-grained updating strategy.
1500 virtual void OnBarWillChange( cbBarInfo
* pBar
, cbRowInfo
* pInRow
, cbDockPane
* pInPane
) {}
1502 // This function receives a notification from the frame layout (in the order in which
1503 // they would usually be invoked). Custom updates-managers may utilize
1504 // these notifications to implement a more fine-grained updating strategy.
1506 virtual void OnPaneMarginsWillChange( cbDockPane
* pPane
) {}
1508 // This function receives a notification from the frame layout (in the order in which
1509 // they would usually be invoked). Custom updates-managers may utilize
1510 // these notifications to implement a more fine-grained updating strategy.
1512 virtual void OnPaneWillChange( cbDockPane
* pPane
) {}
1514 // This function receives a notification from the frame layout (in the order in which
1515 // they would usually be invoked). Custom updates-managers may utilize
1516 // these notifications to implement a more fine-grained updating strategy.
1518 virtual void OnFinishChanges() {}
1520 // Refreshes parts of the frame layout that need an update.
1522 virtual void UpdateNow() = 0;
1526 Base class for all control-bar plugin events.
1527 This is not a dynamically-creatable class.
1530 class cbPluginEvent
: public wxEvent
1533 // NULL if event is not addressed to any specific pane.
1537 // Not used, but required.
1539 virtual wxEvent
* Clone() const { return NULL
; }
1541 // Constructor, taking event type and pane.
1543 cbPluginEvent( wxEventType eventType
, cbDockPane
* pPane
)
1546 { m_eventType
= eventType
; }
1549 // event types handled by plugins
1551 extern wxEventType cbEVT_PL_LEFT_DOWN
;
1552 extern wxEventType cbEVT_PL_LEFT_UP
;
1553 extern wxEventType cbEVT_PL_RIGHT_DOWN
;
1554 extern wxEventType cbEVT_PL_RIGHT_UP
;
1555 extern wxEventType cbEVT_PL_MOTION
;
1557 extern wxEventType cbEVT_PL_LEFT_DCLICK
;
1559 extern wxEventType cbEVT_PL_LAYOUT_ROW
;
1560 extern wxEventType cbEVT_PL_RESIZE_ROW
;
1561 extern wxEventType cbEVT_PL_LAYOUT_ROWS
;
1562 extern wxEventType cbEVT_PL_INSERT_BAR
;
1563 extern wxEventType cbEVT_PL_RESIZE_BAR
;
1564 extern wxEventType cbEVT_PL_REMOVE_BAR
;
1565 extern wxEventType cbEVT_PL_SIZE_BAR_WND
;
1567 extern wxEventType cbEVT_PL_DRAW_BAR_DECOR
;
1568 extern wxEventType cbEVT_PL_DRAW_ROW_DECOR
;
1569 extern wxEventType cbEVT_PL_DRAW_PANE_DECOR
;
1570 extern wxEventType cbEVT_PL_DRAW_BAR_HANDLES
;
1571 extern wxEventType cbEVT_PL_DRAW_ROW_HANDLES
;
1572 extern wxEventType cbEVT_PL_DRAW_ROW_BKGROUND
;
1573 extern wxEventType cbEVT_PL_DRAW_PANE_BKGROUND
;
1575 extern wxEventType cbEVT_PL_START_BAR_DRAGGING
;
1576 extern wxEventType cbEVT_PL_DRAW_HINT_RECT
;
1578 extern wxEventType cbEVT_PL_START_DRAW_IN_AREA
;
1579 extern wxEventType cbEVT_PL_FINISH_DRAW_IN_AREA
;
1581 extern wxEventType cbEVT_PL_CUSTOMIZE_BAR
;
1582 extern wxEventType cbEVT_PL_CUSTOMIZE_LAYOUT
;
1584 extern wxEventType wxCUSTOM_CB_PLUGIN_EVENTS_START_AT
;
1586 // Forward declarations, separated by categories.
1588 class cbLeftDownEvent
;
1589 class cbLeftUpEvent
;
1590 class cbRightDownEvent
;
1591 class cbRightUpEvent
;
1592 class cbMotionEvent
;
1593 class cbLeftDClickEvent
;
1595 class cbLayoutRowEvent
;
1596 class cbResizeRowEvent
;
1597 class cbLayoutRowsEvent
;
1598 class cbInsertBarEvent
;
1599 class cbResizeBarEvent
;
1600 class cbRemoveBarEvent
;
1601 class cbSizeBarWndEvent
;
1603 class cbDrawBarDecorEvent
;
1604 class cbDrawRowDecorEvent
;
1605 class cbDrawPaneDecorEvent
;
1606 class cbDrawBarHandlesEvent
;
1607 class cbDrawRowHandlesEvent
;
1608 class cbDrawRowBkGroundEvent
;
1609 class cbDrawPaneBkGroundEvent
;
1611 class cbStartBarDraggingEvent
;
1612 class cbDrawHintRectEvent
;
1614 class cbStartDrawInAreaEvent
;
1615 class cbFinishDrawInAreaEvent
;
1617 class cbCustomizeBarEvent
;
1618 class cbCustomizeLayoutEvent
;
1620 // Definitions for for handler-methods.
1622 typedef void (wxEvtHandler::*cbLeftDownHandler
)(cbLeftDownEvent
&);
1623 typedef void (wxEvtHandler::*cbLeftUpHandler
)(cbLeftUpEvent
&);
1624 typedef void (wxEvtHandler::*cbRightDownHandler
)(cbRightDownEvent
&);
1625 typedef void (wxEvtHandler::*cbRightUpHandler
)(cbRightUpEvent
&);
1626 typedef void (wxEvtHandler::*cbMotionHandler
)(cbMotionEvent
&);
1627 typedef void (wxEvtHandler::*cbLeftDClickHandler
)(cbLeftDClickEvent
&);
1629 typedef void (wxEvtHandler::*cbLayoutRowHandler
)(cbLayoutRowEvent
&);
1630 typedef void (wxEvtHandler::*cbResizeRowHandler
)(cbResizeRowEvent
&);
1631 typedef void (wxEvtHandler::*cbLayoutRowsHandler
)(cbLayoutRowsEvent
&);
1632 typedef void (wxEvtHandler::*cbInsertBarHandler
)(cbInsertBarEvent
&);
1633 typedef void (wxEvtHandler::*cbResizeBarHandler
)(cbResizeBarEvent
&);
1634 typedef void (wxEvtHandler::*cbRemoveBarHandler
)(cbRemoveBarEvent
&);
1635 typedef void (wxEvtHandler::*cbSizeBarWndHandler
)(cbSizeBarWndEvent
&);
1637 typedef void (wxEvtHandler::*cbDrawBarDecorHandler
)(cbDrawBarDecorEvent
&);
1638 typedef void (wxEvtHandler::*cbDrawRowDecorHandler
)(cbDrawRowDecorEvent
&);
1639 typedef void (wxEvtHandler::*cbDrawPaneDecorHandler
)(cbDrawPaneDecorEvent
&);
1640 typedef void (wxEvtHandler::*cbDrawBarHandlesHandler
)(cbDrawBarHandlesEvent
&);
1641 typedef void (wxEvtHandler::*cbDrawRowHandlesHandler
)(cbDrawRowHandlesEvent
&);
1642 typedef void (wxEvtHandler::*cbDrawRowBkGroundHandler
)(cbDrawRowBkGroundEvent
&);
1643 typedef void (wxEvtHandler::*cbDrawPaneBkGroundHandler
)(cbDrawPaneBkGroundEvent
&);
1645 typedef void (wxEvtHandler::*cbStartBarDraggingHandler
)(cbStartBarDraggingEvent
&);
1646 typedef void (wxEvtHandler::*cbDrawHintRectHandler
)(cbDrawHintRectEvent
&);
1648 typedef void (wxEvtHandler::*cbStartDrawInAreaHandler
)(cbStartDrawInAreaEvent
&);
1649 typedef void (wxEvtHandler::*cbFinishDrawInAreaHandler
)(cbFinishDrawInAreaEvent
&);
1651 typedef void (wxEvtHandler::*cbCustomizeBarHandler
)(cbCustomizeBarEvent
&);
1652 typedef void (wxEvtHandler::*cbCustomizeLayoutHandler
)(cbCustomizeLayoutEvent
&);
1654 // Macros for creating event table entries for plugin-events.
1656 #define EVT_PL_LEFT_DOWN(func) wxEventTableEntry( cbEVT_PL_LEFT_DOWN, -1, -1, (wxObjectEventFunction) (wxEventFunction) (cbLeftDownHandler ) & func, (wxObject *) NULL ),
1657 #define EVT_PL_LEFT_UP(func) wxEventTableEntry( cbEVT_PL_LEFT_UP, -1, -1, (wxObjectEventFunction) (wxEventFunction) (cbLeftUpHandler ) & func, (wxObject *) NULL ),
1658 #define EVT_PL_RIGHT_DOWN(func) wxEventTableEntry( cbEVT_PL_RIGHT_DOWN, -1, -1, (wxObjectEventFunction) (wxEventFunction) (cbRightDownHandler ) & func, (wxObject *) NULL ),
1659 #define EVT_PL_RIGHT_UP(func) wxEventTableEntry( cbEVT_PL_RIGHT_UP, -1, -1, (wxObjectEventFunction) (wxEventFunction) (cbRightUpHandler ) & func, (wxObject *) NULL ),
1660 #define EVT_PL_MOTION(func) wxEventTableEntry( cbEVT_PL_MOTION, -1, -1, (wxObjectEventFunction) (wxEventFunction) (cbMotionHandler ) & func, (wxObject *) NULL ),
1661 #define EVT_PL_LEFT_DCLICK(func) wxEventTableEntry( cbEVT_PL_LEFT_DCLICK, -1, -1, (wxObjectEventFunction) (wxEventFunction) (cbLeftDClickHandler ) & func, (wxObject *) NULL ),
1663 #define EVT_PL_LAYOUT_ROW(func) wxEventTableEntry( cbEVT_PL_LAYOUT_ROW, -1, -1, (wxObjectEventFunction) (wxEventFunction) (cbLayoutRowHandler ) & func, (wxObject *) NULL ),
1664 #define EVT_PL_RESIZE_ROW(func) wxEventTableEntry( cbEVT_PL_RESIZE_ROW, -1, -1, (wxObjectEventFunction) (wxEventFunction) (cbResizeRowHandler ) & func, (wxObject *) NULL ),
1665 #define EVT_PL_LAYOUT_ROWS(func) wxEventTableEntry( cbEVT_PL_LAYOUT_ROWS, -1, -1, (wxObjectEventFunction) (wxEventFunction) (cbLayoutRowsHandler ) & func, (wxObject *) NULL ),
1666 #define EVT_PL_INSERT_BAR(func) wxEventTableEntry( cbEVT_PL_INSERT_BAR, -1, -1, (wxObjectEventFunction) (wxEventFunction) (cbInsertBarHandler ) & func, (wxObject *) NULL ),
1667 #define EVT_PL_RESIZE_BAR(func) wxEventTableEntry( cbEVT_PL_RESIZE_BAR, -1, -1, (wxObjectEventFunction) (wxEventFunction) (cbResizeBarHandler ) & func, (wxObject *) NULL ),
1668 #define EVT_PL_REMOVE_BAR(func) wxEventTableEntry( cbEVT_PL_REMOVE_BAR, -1, -1, (wxObjectEventFunction) (wxEventFunction) (cbRemoveBarHandler ) & func, (wxObject *) NULL ),
1669 #define EVT_PL_SIZE_BAR_WND(func) wxEventTableEntry( cbEVT_PL_SIZE_BAR_WND, -1, -1, (wxObjectEventFunction) (wxEventFunction) (cbSizeBarWndHandler ) & func, (wxObject *) NULL ),
1671 #define EVT_PL_DRAW_BAR_DECOR(func) wxEventTableEntry( cbEVT_PL_DRAW_BAR_DECOR, -1, -1, (wxObjectEventFunction) (wxEventFunction) (cbDrawBarDecorHandler ) & func, (wxObject *) NULL ),
1672 #define EVT_PL_DRAW_ROW_DECOR(func) wxEventTableEntry( cbEVT_PL_DRAW_ROW_DECOR, -1, -1, (wxObjectEventFunction) (wxEventFunction) (cbDrawRowDecorHandler ) & func, (wxObject *) NULL ),
1673 #define EVT_PL_DRAW_PANE_DECOR(func) wxEventTableEntry( cbEVT_PL_DRAW_PANE_DECOR, -1, -1, (wxObjectEventFunction) (wxEventFunction) (cbDrawPaneDecorHandler ) & func, (wxObject *) NULL ),
1674 #define EVT_PL_DRAW_BAR_HANDLES(func) wxEventTableEntry( cbEVT_PL_DRAW_BAR_HANDLES, -1, -1, (wxObjectEventFunction) (wxEventFunction) (cbDrawBarHandlesHandler ) & func, (wxObject *) NULL ),
1675 #define EVT_PL_DRAW_ROW_HANDLES(func) wxEventTableEntry( cbEVT_PL_DRAW_ROW_HANDLES, -1, -1, (wxObjectEventFunction) (wxEventFunction) (cbDrawRowHandlesHandler ) & func, (wxObject *) NULL ),
1676 #define EVT_PL_DRAW_ROW_BKGROUND(func) wxEventTableEntry( cbEVT_PL_DRAW_ROW_BKGROUND, -1, -1, (wxObjectEventFunction) (wxEventFunction) (cbDrawRowBkGroundHandler ) & func, (wxObject *) NULL ),
1677 #define EVT_PL_DRAW_PANE_BKGROUND(func) wxEventTableEntry( cbEVT_PL_DRAW_PANE_BKGROUND, -1, -1, (wxObjectEventFunction) (wxEventFunction) (cbDrawPaneBkGroundHandler) & func, (wxObject *) NULL ),
1679 #define EVT_PL_START_BAR_DRAGGING(func) wxEventTableEntry( cbEVT_PL_START_BAR_DRAGGING, -1, -1, (wxObjectEventFunction) (wxEventFunction) (cbStartBarDraggingHandler) & func, (wxObject *) NULL ),
1680 #define EVT_PL_DRAW_HINT_RECT(func) wxEventTableEntry( cbEVT_PL_DRAW_HINT_RECT, -1, -1, (wxObjectEventFunction) (wxEventFunction) (cbDrawHintRectHandler ) & func, (wxObject *) NULL ),
1683 #define EVT_PL_START_DRAW_IN_AREA(func) wxEventTableEntry( cbEVT_PL_START_DRAW_IN_AREA, -1, -1, (wxObjectEventFunction) (wxEventFunction) (cbStartDrawInAreaHandler) & func, (wxObject *) NULL ),
1684 #define EVT_PL_FINISH_DRAW_IN_AREA(func) wxEventTableEntry( cbEVT_PL_FINISH_DRAW_IN_AREA, -1, -1, (wxObjectEventFunction) (wxEventFunction) (cbFinishDrawInAreaHandler) & func, (wxObject *) NULL ),
1686 #define EVT_PL_CUSTOMIZE_BAR(func) wxEventTableEntry( cbEVT_PL_CUSTOMIZE_BAR, -1, -1, (wxObjectEventFunction) (wxEventFunction) (cbCustomizeBarHandler) & func, (wxObject *) NULL ),
1687 #define EVT_PL_CUSTOMIZE_LAYOUT(func) wxEventTableEntry( cbEVT_PL_CUSTOMIZE_LAYOUT, -1, -1, (wxObjectEventFunction) (wxEventFunction) (cbCustomizeLayoutHandler) & func, (wxObject *) NULL ),
1690 Abstract base class for all control-bar related plugins.
1691 Note: pointer positions of mouse events sent to plugins
1692 are always in the pane's coordinates (the pane to which
1693 this plugin is hooked).
1696 class cbPluginBase
: public wxEvtHandler
1698 DECLARE_ABSTRACT_CLASS( cbPluginBase
)
1700 // Back-reference to the frame layout.
1702 wxFrameLayout
* mpLayout
;
1704 // Specifies panes for which this plugin receives events
1705 // (see pane masks definitions).
1709 // Is TRUE when plugin is ready to handle events.
1714 // Default constructor.
1719 mPaneMask( wxALL_PANES
),
1723 // Constructor taking layout panel and a mask.
1725 cbPluginBase( wxFrameLayout
* pPanel
, int paneMask
= wxALL_PANES
)
1727 : mpLayout ( pPanel
),
1728 mPaneMask( paneMask
),
1732 // Returns the pane mask.
1734 inline int GetPaneMask() { return mPaneMask
; }
1736 // Destructor. Destroys the whole plugin chain of connected plugins.
1738 virtual ~cbPluginBase();
1740 // Override this method to do plugin-specific initialization.
1741 // At this point plugin is already attached to the frame layout,
1742 // and pane masks are set.
1744 virtual void OnInitPlugin() { mIsReady
= TRUE
; }
1746 // Returns TRUE if the plugin is ready to receive events.
1748 bool IsReady() { return mIsReady
; }
1750 // Overridden to determine whether the target pane specified in the
1751 // event matches the pane mask of this plugin (specific plugins
1752 // do not override this method).
1754 virtual bool ProcessEvent(wxEvent
& event
);
1758 Class for mouse left down events.
1761 class cbLeftDownEvent
: public cbPluginEvent
1766 // Constructor, taking mouse position and pane.
1768 cbLeftDownEvent( const wxPoint
& pos
, cbDockPane
* pPane
)
1770 : cbPluginEvent( cbEVT_PL_LEFT_DOWN
, pPane
),
1776 Class for mouse left up events.
1779 class cbLeftUpEvent
: public cbPluginEvent
1784 // Constructor, taking mouse position and pane.
1786 cbLeftUpEvent( const wxPoint
& pos
, cbDockPane
* pPane
)
1788 : cbPluginEvent( cbEVT_PL_LEFT_UP
, pPane
),
1794 Class for mouse right down events.
1797 class cbRightDownEvent
: public cbPluginEvent
1802 // Constructor, taking mouse position and pane.
1804 cbRightDownEvent( const wxPoint
& pos
, cbDockPane
* pPane
)
1806 : cbPluginEvent( cbEVT_PL_RIGHT_DOWN
, pPane
),
1812 Class for mouse right up events.
1815 class cbRightUpEvent
: public cbPluginEvent
1820 // Constructor, taking mouse position and pane.
1822 cbRightUpEvent( const wxPoint
& pos
, cbDockPane
* pPane
)
1824 : cbPluginEvent( cbEVT_PL_RIGHT_UP
, pPane
),
1830 Class for mouse motion events.
1833 class cbMotionEvent
: public cbPluginEvent
1838 // Constructor, taking mouse position and pane.
1840 cbMotionEvent( const wxPoint
& pos
, cbDockPane
* pPane
)
1842 : cbPluginEvent( cbEVT_PL_MOTION
, pPane
),
1848 Class for mouse left double click events.
1851 class cbLeftDClickEvent
: public cbPluginEvent
1856 // Constructor, taking mouse position and pane.
1858 cbLeftDClickEvent( const wxPoint
& pos
, cbDockPane
* pPane
)
1860 : cbPluginEvent( cbEVT_PL_LEFT_DCLICK
, pPane
),
1866 Class for single row layout events.
1869 class cbLayoutRowEvent
: public cbPluginEvent
1874 // Constructor, taking row information and pane.
1876 cbLayoutRowEvent( cbRowInfo
* pRow
, cbDockPane
* pPane
)
1878 : cbPluginEvent( cbEVT_PL_LAYOUT_ROW
, pPane
),
1884 Class for row resize events.
1887 class cbResizeRowEvent
: public cbPluginEvent
1892 bool mForUpperHandle
;
1894 // Constructor, taking row information, two parameters of currently unknown use, and pane.
1896 cbResizeRowEvent( cbRowInfo
* pRow
, int handleOfs
, bool forUpperHandle
, cbDockPane
* pPane
)
1898 : cbPluginEvent( cbEVT_PL_RESIZE_ROW
, pPane
),
1900 mHandleOfs( handleOfs
),
1901 mForUpperHandle( forUpperHandle
)
1906 Class for multiple rows layout events.
1909 class cbLayoutRowsEvent
: public cbPluginEvent
1913 // Constructor, taking pane.
1915 cbLayoutRowsEvent( cbDockPane
* pPane
)
1917 : cbPluginEvent( cbEVT_PL_LAYOUT_ROWS
, pPane
)
1922 Class for bar insertion events.
1925 class cbInsertBarEvent
: public cbPluginEvent
1931 // Constructor, taking bar information, row information, and pane.
1933 cbInsertBarEvent( cbBarInfo
* pBar
, cbRowInfo
* pIntoRow
, cbDockPane
* pPane
)
1935 : cbPluginEvent( cbEVT_PL_INSERT_BAR
, pPane
),
1943 Class for bar resize events.
1946 class cbResizeBarEvent
: public cbPluginEvent
1952 // Constructor, taking bar information, row information, and pane.
1954 cbResizeBarEvent( cbBarInfo
* pBar
, cbRowInfo
* pRow
, cbDockPane
* pPane
)
1956 : cbPluginEvent( cbEVT_PL_RESIZE_BAR
, pPane
),
1963 Class for bar removal events.
1966 class cbRemoveBarEvent
: public cbPluginEvent
1971 // Constructor, taking bar information and pane.
1973 cbRemoveBarEvent( cbBarInfo
* pBar
, cbDockPane
* pPane
)
1975 : cbPluginEvent( cbEVT_PL_REMOVE_BAR
, pPane
),
1981 Class for bar window resize events.
1984 class cbSizeBarWndEvent
: public cbPluginEvent
1988 wxRect mBoundsInParent
;
1990 // Constructor, taking bar information and pane.
1992 cbSizeBarWndEvent( cbBarInfo
* pBar
, cbDockPane
* pPane
)
1994 : cbPluginEvent( cbEVT_PL_SIZE_BAR_WND
, pPane
),
1996 mBoundsInParent( pBar
->mBoundsInParent
)
2001 Class for bar decoration drawing events.
2004 class cbDrawBarDecorEvent
: public cbPluginEvent
2009 wxRect mBoundsInParent
;
2011 // Constructor, taking bar information, device context, and pane.
2013 cbDrawBarDecorEvent( cbBarInfo
* pBar
, wxDC
& dc
, cbDockPane
* pPane
)
2015 : cbPluginEvent( cbEVT_PL_DRAW_BAR_DECOR
, pPane
),
2018 mBoundsInParent( pBar
->mBoundsInParent
)
2023 Class for row decoration drawing events.
2026 class cbDrawRowDecorEvent
: public cbPluginEvent
2032 // Constructor, taking row information, device context, and pane.
2034 cbDrawRowDecorEvent( cbRowInfo
* pRow
, wxDC
& dc
, cbDockPane
* pPane
)
2036 : cbPluginEvent( cbEVT_PL_DRAW_ROW_DECOR
, pPane
),
2043 Class for pane decoration drawing events.
2046 class cbDrawPaneDecorEvent
: public cbPluginEvent
2051 // Constructor, taking device context and pane.
2053 cbDrawPaneDecorEvent( wxDC
& dc
, cbDockPane
* pPane
)
2055 : cbPluginEvent( cbEVT_PL_DRAW_PANE_DECOR
, pPane
),
2061 Class for bar handles drawing events.
2064 class cbDrawBarHandlesEvent
: public cbPluginEvent
2070 // Constructor, taking bar information, device context, and pane.
2072 cbDrawBarHandlesEvent( cbBarInfo
* pBar
, wxDC
& dc
, cbDockPane
* pPane
)
2074 : cbPluginEvent( cbEVT_PL_DRAW_BAR_HANDLES
, pPane
),
2081 Class for row handles drawing events.
2084 class cbDrawRowHandlesEvent
: public cbPluginEvent
2090 // Constructor, taking row information, device context, and pane.
2092 cbDrawRowHandlesEvent( cbRowInfo
* pRow
, wxDC
& dc
, cbDockPane
* pPane
)
2094 : cbPluginEvent( cbEVT_PL_DRAW_ROW_HANDLES
, pPane
),
2101 Class for row background drawing events.
2104 class cbDrawRowBkGroundEvent
: public cbPluginEvent
2110 // Constructor, taking row information, device context, and pane.
2112 cbDrawRowBkGroundEvent( cbRowInfo
* pRow
, wxDC
& dc
, cbDockPane
* pPane
)
2114 : cbPluginEvent( cbEVT_PL_DRAW_ROW_BKGROUND
, pPane
),
2121 Class for pane background drawing events.
2124 class cbDrawPaneBkGroundEvent
: public cbPluginEvent
2129 // Constructor, taking device context and pane.
2131 cbDrawPaneBkGroundEvent( wxDC
& dc
, cbDockPane
* pPane
)
2133 : cbPluginEvent( cbEVT_PL_DRAW_PANE_BKGROUND
, pPane
),
2139 Class for start-bar-dragging events.
2142 class cbStartBarDraggingEvent
: public cbPluginEvent
2146 wxPoint mPos
; // is given in frame's coordinates
2148 // Constructor, taking bar information, mouse position, and pane.
2150 cbStartBarDraggingEvent( cbBarInfo
* pBar
, const wxPoint
& pos
, cbDockPane
* pPane
)
2152 : cbPluginEvent( cbEVT_PL_START_BAR_DRAGGING
, pPane
),
2159 Class for hint-rectangle drawing events.
2162 class cbDrawHintRectEvent
: public cbPluginEvent
2165 wxRect mRect
; // is given in frame's coordinates
2168 bool mLastTime
; // indicates that this event finishes "session" of on-screen drawing,
2169 // thus associated resources can be freed now
2170 bool mEraseRect
; // does not have any impact, if recangle is drawn using XOR-mask
2172 bool mIsInClient
;// in cleint area hint could be drawn differently,
2173 // e.g. with fat/hatched border
2176 // Constructor, taking hint rectangle and three flags.
2178 cbDrawHintRectEvent( const wxRect
& rect
, bool isInClient
, bool eraseRect
, bool lastTime
)
2180 : cbPluginEvent( cbEVT_PL_DRAW_HINT_RECT
, 0 ),
2182 mLastTime ( lastTime
),
2183 mEraseRect ( eraseRect
),
2184 mIsInClient( isInClient
)
2189 Class for start drawing in area events.
2192 class cbStartDrawInAreaEvent
: public cbPluginEvent
2196 wxDC
** mppDc
; // points to pointer, where the reference
2197 // to the obtained buffer-context should be placed
2199 // Constructor, taking rectangular area, device context pointer to a pointer, and pane.
2201 cbStartDrawInAreaEvent( const wxRect
& area
, wxDC
** ppDCForArea
, cbDockPane
* pPane
)
2203 : cbPluginEvent( cbEVT_PL_START_DRAW_IN_AREA
, pPane
),
2205 mppDc( ppDCForArea
)
2210 Class for finish drawing in area events.
2213 class cbFinishDrawInAreaEvent
: public cbPluginEvent
2218 // Constructor, taking rectangular area and pane.
2220 cbFinishDrawInAreaEvent( const wxRect
& area
, cbDockPane
* pPane
)
2222 : cbPluginEvent( cbEVT_PL_FINISH_DRAW_IN_AREA
, pPane
),
2228 Class for bar customization events.
2231 class cbCustomizeBarEvent
: public cbPluginEvent
2234 wxPoint mClickPos
; // in parent frame's coordinates
2237 // Constructor, taking bar information, mouse position, and pane.
2239 cbCustomizeBarEvent( cbBarInfo
* pBar
, const wxPoint
& clickPos
, cbDockPane
* pPane
)
2241 : cbPluginEvent( cbEVT_PL_CUSTOMIZE_BAR
, pPane
),
2242 mClickPos( clickPos
),
2248 Class for layout customization events.
2251 class cbCustomizeLayoutEvent
: public cbPluginEvent
2254 wxPoint mClickPos
; // in parent frame's coordinates
2256 // Constructor, taking mouse position.
2258 cbCustomizeLayoutEvent( const wxPoint
& clickPos
)
2260 : cbPluginEvent( cbEVT_PL_CUSTOMIZE_LAYOUT
, 0 ),
2261 mClickPos( clickPos
)
2265 #endif /* __CONTROLBAR_G__ */