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"
25 #define WXCONTROLBAR_VERSION 1.3
27 // forward declarations
32 class cbUpdatesManagerBase
;
33 class cbBarDimHandlerBase
;
36 class cbPaneDrawPlugin
;
41 class cbCommonPaneProperties
;
43 typedef cbBarInfo
* BarInfoPtrT
;
44 typedef cbRowInfo
* RowInfoPtrT
;
46 WX_DEFINE_ARRAY( BarInfoPtrT
, BarArrayT
);
47 WX_DEFINE_ARRAY( RowInfoPtrT
, RowArrayT
);
51 #define wxCBAR_DOCKED_HORIZONTALLY 0
52 #define wxCBAR_DOCKED_VERTICALLY 1
53 #define wxCBAR_FLOATING 2
54 #define wxCBAR_HIDDEN 3
56 // the states are enumerated above
57 #define MAX_BAR_STATES 4
59 // control bar alignments
61 #if !defined(FL_ALIGN_TOP)
63 #define FL_ALIGN_TOP 0
64 #define FL_ALIGN_BOTTOM 1
65 #define FL_ALIGN_LEFT 2
66 #define FL_ALIGN_RIGHT 3
70 // one pane for each alignment
73 // masks for each pane
75 #define FL_ALIGN_TOP_PANE 0x0001
76 #define FL_ALIGN_BOTTOM_PANE 0x0002
77 #define FL_ALIGN_LEFT_PANE 0x0004
78 #define FL_ALIGN_RIGHT_PANE 0x0008
80 #define wxALL_PANES 0x000F
82 // enumeration of hittest results, see cbDockPane::HitTestPaneItems(..)
84 enum CB_HITTEST_RESULT
88 CB_UPPER_ROW_HANDLE_HITTED
,
89 CB_LOWER_ROW_HANDLE_HITTED
,
90 CB_LEFT_BAR_HANDLE_HITTED
,
91 CB_RIGHT_BAR_HANDLE_HITTED
,
96 Helper class, used for spying for unhandled mouse events on control bars
97 and forwarding them to the frame layout.
100 class cbBarSpy
: public wxEvtHandler
103 DECLARE_DYNAMIC_CLASS( cbBarSpy
)
105 wxFrameLayout
* mpLayout
;
109 // Default constructor.
113 // Constructor, taking a parent pane.
115 cbBarSpy( wxFrameLayout
* pPanel
);
117 // Sets the bar window.
119 void SetBarWindow( wxWindow
* pWnd
);
121 // Performs special event processing.
123 virtual bool ProcessEvent(wxEvent
& event
);
127 wxFrameLayout manages containment and docking of control bars,
128 which can be docked along the top, bottom, right, or left side of the
132 class wxFrameLayout
: public wxEvtHandler
135 // Default constructor, used only for serialization.
139 // Constructor, taking parent window, the (MDI) client of the parent if there
140 // is one, and flag specifying whether to activate the layout.
142 wxFrameLayout( wxWindow
* pParentFrame
,
143 wxWindow
* pFrameClient
= NULL
,
144 bool activateNow
= TRUE
);
146 // Destructor. It does not destroy the bar windows.
148 virtual ~wxFrameLayout();
150 // Enables floating behaviour. By default floating of control bars is on.
152 virtual void EnableFloating( bool enable
= TRUE
);
154 // Activate can be called after some other layout has been deactivated,
155 // and this one must take over the current contents of the frame window.
157 // Effectively hooks itself to the frame window, re-displays all non-hidden
158 // bar windows and repaints the decorations.
160 virtual void Activate();
162 // Deactivate unhooks itself from frame window, and hides all non-hidden windows.
164 // Note: two frame layouts should not be active at the same time in the
165 // same frame window, since it would cause messy overlapping of bar windows
166 // from both layouts.
168 virtual void Deactivate();
170 // Hides the bar windows, and also the client window if present.
172 void HideBarWindows();
174 // Destroys the bar windows.
176 virtual void DestroyBarWindows();
178 // Passes the client window (e.g. MDI client window) to be controlled by
179 // frame layout, the size and position of which should be adjusted to be
180 // surrounded by controlbar panes, whenever the frame is resized or the dimensions
181 // of control panes change.
183 void SetFrameClient( wxWindow
* pFrameClient
);
185 // Returns the frame client, or NULL if not present.
187 wxWindow
* GetFrameClient();
189 // Returns the parent frame.
191 wxWindow
& GetParentFrame() { return *mpFrame
; }
193 // Returns an array of panes. Used by update managers.
195 cbDockPane
** GetPanesArray() { return mPanes
; }
197 // Returns a pane for the given alignment. See pane alignment types.
199 cbDockPane
* GetPane( int alignment
)
201 { return mPanes
[alignment
]; }
203 // Adds bar information to the frame layout. The appearance of the layout is not refreshed
204 // immediately; RefreshNow() can be called if necessary.
206 // Notes: the argument pBarWnd can by NULL, resulting in bar decorations to be drawn
207 // around the empty rectangle (filled with default background colour).
208 // Argument dimInfo can be reused for adding any number of bars, since
209 // it is not used directly - instead its members are copied. If the dimensions
210 // handler is present, its instance is shared (reference counted). The dimension
211 // handler should always be allocated on the heap.
213 // pBarWnd is the window to be managed.
215 // dimInfo contains dimension information.
217 // alignment is a value such as FL_ALIGN_TOP.
219 // rowNo is the vertical position or row in the pane (if in docked state).
221 // columnPos is the horizontal position within the row in pixels (if in docked state).
223 // name is a name by which the bar can be referred in layout customization dialogs.
225 // If spyEvents is TRUE, input events for the bar should be "spyed" in order
226 // to forward unhandled mouse clicks to the frame layout, for example to enable
227 // easy draggablity of toolbars just by clicking on their interior regions.
228 // For widgets like text/tree control this value should be FALSE,
229 // since there's no certain way to detect whether the event was actually handled.
231 // state is the initial state, such as wxCBAR_DOCKED_HORIZONTALLY,
232 // wxCBAR_FLOATING, wxCBAR_HIDDEN.
234 virtual void AddBar( wxWindow
* pBarWnd
,
235 const cbDimInfo
& dimInfo
,
238 int alignment
= FL_ALIGN_TOP
,
241 const wxString
& name
="bar",
242 bool spyEvents
= FALSE
,
243 int state
= wxCBAR_DOCKED_HORIZONTALLY
246 // ReddockBar can be used for repositioning existing bars. The given bar is first removed
247 // from the pane it currently belongs to, and inserted into the pane, which "matches"
248 // the given rectangular area. If pToPane is not NULL, the bar is docked to this given pane.
249 // To dock a bar which is floating, use the wxFrameLayout::DockBar method.
251 virtual bool RedockBar( cbBarInfo
* pBar
, const wxRect
& shapeInParent
,
252 cbDockPane
* pToPane
= NULL
, bool updateNow
= TRUE
);
254 // Finds the bar in the framelayout, by name.
256 cbBarInfo
* FindBarByName( const wxString
& name
);
258 // Finds the bar in the framelayout, by window.
260 cbBarInfo
* FindBarByWindow( const wxWindow
* pWnd
);
262 // Gets an array of bars.
264 BarArrayT
& GetBars();
266 // Changes the bar's docking state (see possible control bar states).
268 void SetBarState( cbBarInfo
* pBar
, int newStatem
, bool updateNow
);
270 // Toggles the bar between visible and hidden.
272 void InverseVisibility( cbBarInfo
* pBar
);
274 // Reflects changes in bar information structure visually.
275 // For example, moves the bar, changes its dimension information,
276 // or changes the pane to which it is docked.
278 void ApplyBarProperties( cbBarInfo
* pBar
);
280 // Removes the bar from the layout permanently, and hides its corresponding window if present.
282 void RemoveBar( cbBarInfo
* pBar
);
284 // Recalculates the layout of panes, and all bars/rows in each pane.
286 virtual void RecalcLayout( bool repositionBarsNow
= FALSE
);
288 // Returns the client height.
290 int GetClientHeight();
292 // Returns the client width.
294 int GetClientWidth();
296 // Returns the client's rectangle.
298 wxRect
& GetClientRect() { return mClntWndBounds
; }
300 // Returns a reference to the updates manager.
301 // Note: in future, the updates manager will become a normal plugin.
303 cbUpdatesManagerBase
& GetUpdatesManager();
305 // Destroys the previous manager if any, and sets the new one.
307 void SetUpdatesManager( cbUpdatesManagerBase
* pUMgr
);
309 // Gets the pane properties for the given alignment.
311 virtual void GetPaneProperties( cbCommonPaneProperties
& props
, int alignment
= FL_ALIGN_TOP
);
313 // Sets the pane properties for the given alignment.
314 // Note: changing properties of panes does not result immediate on-screen update.
316 virtual void SetPaneProperties( const cbCommonPaneProperties
& props
,
317 int paneMask
= wxALL_PANES
);
319 // Sets the margins for the given panes.
320 // The margins should go into cbCommonPaneProperties in the future.
322 // Note: this method should be called before any custom plugins are attached.
324 virtual void SetMargins( int top
, int bottom
, int left
, int right
,
325 int paneMask
= wxALL_PANES
);
327 // Sets the pane background colour.
329 virtual void SetPaneBackground( const wxColour
& colour
);
331 // Recalculates layout and performs on-screen update of all panes.
333 void RefreshNow( bool recalcLayout
= TRUE
);
335 // Event handler for a size event.
337 void OnSize ( wxSizeEvent
& event
);
339 // Event handler for a left down button event.
341 void OnLButtonDown( wxMouseEvent
& event
);
343 // Event handler for a left doubleclick button event.
345 void OnLDblClick ( wxMouseEvent
& event
);
347 // Event handler for a left button up event.
349 void OnLButtonUp ( wxMouseEvent
& event
);
351 // Event handler for a right button down event.
353 void OnRButtonDown( wxMouseEvent
& event
);
355 // Event handler for a right button up event.
357 void OnRButtonUp ( wxMouseEvent
& event
);
359 // Event handler for a mouse move event.
361 void OnMouseMove ( wxMouseEvent
& event
);
363 // This function should be used instead of passing the event to the ProcessEvent method
364 // of the top-level plugin directly. This method checks if events are currently
365 // captured and ensures that plugin-event is routed correctly.
367 virtual void FirePluginEvent( cbPluginEvent
& event
);
369 // Captures user input events for the given plugin.
370 // Input events are: mouse movement, mouse clicks, keyboard input.
372 virtual void CaptureEventsForPlugin ( cbPluginBase
* pPlugin
);
374 // Releases user input events for the given plugin.
375 // Input events are: mouse movement, mouse clicks, keyboard input
377 virtual void ReleaseEventsFromPlugin( cbPluginBase
* pPlugin
);
379 // Called by plugins; also captures the mouse in the parent frame.
381 void CaptureEventsForPane( cbDockPane
* toPane
);
383 // Called by plugins; also releases mouse in the parent frame.
385 void ReleaseEventsFromPane( cbDockPane
* fromPane
);
387 // Returns the current top-level plugin (the one that receives events first,
388 // except if input events are currently captured by some other plugin).
390 virtual cbPluginBase
& GetTopPlugin();
392 // Hooking custom plugins to frame layout.
394 // Note: when hooking one plugin on top of the other,
395 // use SetNextHandler or similar methods
396 // of wxEvtHandler class to compose the chain of plugins,
397 // than pass the left-most handler in this chain to
398 // the above methods (assuming that events are delegated
399 // from left-most towards right-most handler).
401 // This secenario is very inconvenient and "low-level",
402 // so use the Add/Push/PopPlugin methods instead.
404 virtual void SetTopPlugin( cbPluginBase
* pPlugin
);
406 // Similar to wxWindow's "push/pop-event-handler" methods, execept
407 // that the plugin is deleted upon "popping".
409 virtual void PushPlugin( cbPluginBase
* pPugin
);
411 // Similar to wxWindow's "push/pop-event-handler" methods, execept
412 // that the plugin is deleted upon "popping".
414 virtual void PopPlugin();
417 virtual void PopAllPlugins();
419 // Adds the default plugins. These are cbPaneDrawPlugin, cbRowLayoutPlugin, cbBarDragPlugin,
420 // cbAntiflickerPlugin, cbSimpleCustomizePlugin.
422 // This method is automatically invoked if no plugins were found upon
423 // firing of the first plugin-event, i.e. when wxFrameLayout configures itself.
425 virtual void PushDefaultPlugins();
427 // An advanced methods for plugin configuration using their
428 // dynamic class information, for example CLASSINFO(pluginClass).
430 // First checks if the plugin of the given class is already "hooked up".
431 // If not, adds it to the top of the plugins chain.
433 virtual void AddPlugin( wxClassInfo
* pPlInfo
, int paneMask
= wxALL_PANES
);
435 // First checks if the plugin of the given class is already hooked.
436 // If so, removes it, and then inserts it into the chain
437 // before the plugin of the class given by pNextPlInfo.
439 // Note: this method is handy in some cases where the order
440 // of the plugin-chain could be important, for example when one plugin overrides
441 // some functionality of another already-hooked plugin,
442 // so that the former plugin should be hooked before the one
443 // whose functionality is being overridden.
445 virtual void AddPluginBefore( wxClassInfo
* pNextPlInfo
, wxClassInfo
* pPlInfo
,
446 int paneMask
= wxALL_PANES
);
448 // Checks if the plugin of the given class is hooked, and removes
451 virtual void RemovePlugin( wxClassInfo
* pPlInfo
);
453 // Finds a plugin with the given class, or returns NULL if a plugin of the given
454 // class is not hooked.
456 virtual cbPluginBase
* FindPlugin( wxClassInfo
* pPlInfo
);
458 // Returns true if there is a top plugin.
462 DECLARE_EVENT_TABLE()
463 DECLARE_DYNAMIC_CLASS( wxFrameLayout
)
465 public: /* protected really, acessed only by plugins and serializers */
467 friend class cbDockPane
;
468 friend class wxBarHandler
;
470 wxWindow
* mpFrame
; // parent frame
471 wxWindow
* mpFrameClient
; // client window
472 cbDockPane
* mPanes
[MAX_PANES
]; // panes in the panel
475 wxCursor
* mpHorizCursor
;
476 wxCursor
* mpVertCursor
;
477 wxCursor
* mpNormalCursor
;
478 wxCursor
* mpDragCursor
;
479 wxCursor
* mpNECursor
; // no-entry cursor
481 // pens for decoration and shades
483 wxPen mDarkPen
; // default wxSYS_COLOUR_3DSHADOW
484 wxPen mLightPen
; // default wxSYS_COLOUR_3DHILIGHT
485 wxPen mGrayPen
; // default wxSYS_COLOUR_3DFACE
486 wxPen mBlackPen
; // default wxColour( 0, 0, 0)
487 wxPen mBorderPen
; // default wxSYS_COLOUR_3DFACE
489 wxPen mNullPen
; // transparent pen
491 // pane to which the all mouse input is currently directed (caputred)
493 cbDockPane
* mpPaneInFocus
;
495 // pane, from which mouse pointer had just left
497 cbDockPane
* mpLRUPane
;
499 // bounds of client window in parent frame's coordinates
501 wxRect mClntWndBounds
;
502 wxRect mPrevClntWndBounds
;
505 wxPoint mNextFloatedWndPos
;
506 wxSize mFloatingPosStep
;
508 // current plugin (right-most) plugin which receives events first
510 cbPluginBase
* mpTopPlugin
;
512 // plugin, which currently has captured all input events, otherwise NULL
514 cbPluginBase
* mpCaputesInput
;
516 // list of event handlers which are "pushed" onto each bar, to catch
517 // mouse events which are not handled by bars, and froward them to the ,
518 // frome-layout and further to plugins
522 // list of top-most frames which contain floated bars
524 wxList mFloatedFrames
;
526 // linked list of references to all bars (docked/floated/hidden)
530 // FOR NOW:: dirty stuff...
531 bool mClientWndRefreshPending
;
533 bool mCheckFocusWhenIdle
;
535 public: /* protected really (accessed only by plugins) */
537 // refrence to custom updates manager
538 cbUpdatesManagerBase
* mpUpdatesMgr
;
540 // Called to apply the calculated layout to window objects.
542 void PositionClientWindow();
544 // Called to apply the calculated layout to window objects.
546 void PositionPanes();
548 // Creates the cursors.
550 void CreateCursors();
552 // Applies the calculated layout to a floating bar.
554 void RepositionFloatedBar( cbBarInfo
* pBar
);
556 // Applies the state to the window objects.
558 void DoSetBarState( cbBarInfo
* pBar
);
560 // The purpose of this function is unknown.
562 bool LocateBar( cbBarInfo
* pBarInfo
,
564 cbDockPane
** ppPane
);
567 // Returns TRUE if the position is within the given pane.
569 bool HitTestPane( cbDockPane
* pPane
, int x
, int y
);
571 // Returns the pane for which the rectangle hit test succeeds, giving
572 // preference to the given pane if supplied.
574 cbDockPane
* HitTestPanes( const wxRect
& rect
, cbDockPane
* pCurPane
);
576 // Returns the pane to which the given bar belongs.
578 cbDockPane
* GetBarPane( cbBarInfo
* pBar
);
580 // Delegated from "bar-spy".
581 void ForwardMouseEvent( wxMouseEvent
& event
,
585 // Routes the mouse event to the appropriate pane.
587 void RouteMouseEvent( wxMouseEvent
& event
, int pluginEvtType
);
589 // Shows all floated windows.
591 void ShowFloatedWindows( bool show
);
593 // Unhooks the layout from the frame.
595 void UnhookFromFrame();
597 // Hooks the layout up to the frame (pushes the layout onto the
598 // frame's event handler stack).
600 void HookUpToFrame();
602 // Returns TRUE if the platform allows reparenting. This may not return TRUE
603 // for all platforms. Reparenting allows control bars to be floated.
607 // Reparents pChild to have parent pNewParent.
609 void ReparentWindow( wxWindow
* pChild
, wxWindow
* pNewParent
);
611 // Returns the previous client window rectangle.
613 wxRect
& GetPrevClientRect() { return mPrevClntWndBounds
; }
615 // Handles paint events, calling PaintPane for each pane.
617 void OnPaint( wxPaintEvent
& event
);
619 // Handles background erase events. Currently does nothing.
621 void OnEraseBackground( wxEraseEvent
& event
);
623 // Handles focus kill events. Currently does nothing.
625 void OnKillFocus( wxFocusEvent
& event
);
627 // Handles focus set events. Currently does nothing.
629 void OnSetFocus( wxFocusEvent
& event
);
631 // Handles activation events. Currently does nothing.
633 void OnActivate( wxActivateEvent
& event
);
635 // Handles idle events.
637 void OnIdle( wxIdleEvent
& event
);
639 // Returns a new cbGCUpdatesMgr object.
641 virtual cbUpdatesManagerBase
* CreateUpdatesManager();
645 A structure that is present in each item of layout,
646 used by any particular updates-manager to store
647 auxiliary information to be used by its updating algorithm.
650 class cbUpdateMgrData
: public wxObject
652 DECLARE_DYNAMIC_CLASS( cbUpdateMgrData
)
654 wxRect mPrevBounds
; // previous state of layout item (in parent frame's coordinates)
656 bool mIsDirty
; // overrides result of current-against-previous bounds comparison,
657 // i.e. requires item to be updated, regardless of it's current area
659 wxObject
* mpCustomData
; // any custom data stored by specific updates mgr.
661 // Default constructor. Is-dirty flag is set TRUE initially.
665 // Store the item state.
667 void StoreItemState( const wxRect
& boundsInParent
);
669 // Set the dirty flag.
671 void SetDirty( bool isDirty
= TRUE
);
675 void SetCustomData( wxObject
* pCustomData
);
677 // Returns the is-dirty flag.
679 inline bool IsDirty() { return mIsDirty
; }
683 Abstract interface for bar-size handler classes.
684 These objects receive notifications whenever the docking
685 state of the bar is changed, thus they provide the possibility
686 to adjust the values in cbDimInfo::mSizes accordingly.
687 Specific handlers can be hooked up to specific types of bar.
690 class cbBarDimHandlerBase
: public wxObject
692 DECLARE_ABSTRACT_CLASS( cbBarDimHandlerBase
)
695 int mRefCount
; // since one dim-handler can be assigned
696 // to multiple bars, it's instance is
700 // Default constructor. The initial reference count is 0, since
701 // the handler is not used until the first invocation of AddRef().
703 cbBarDimHandlerBase();
705 // Increments the reference count.
709 // Decrements the reference count, and if the count is at zero,
714 // Responds to "bar-state-changes" notifications.
716 virtual void OnChangeBarState(cbBarInfo
* pBar
, int newState
) = 0;
718 // Responds to bar resize notifications.
720 virtual void OnResizeBar( cbBarInfo
* pBar
, const wxSize
& given
, wxSize
& preferred
) = 0;
724 Helper class used internally by the wxFrameLayout class.
725 Holds and manages information about bar dimensions.
728 class cbDimInfo
: public wxObject
730 DECLARE_DYNAMIC_CLASS( cbDimInfo
)
732 wxSize mSizes
[MAX_BAR_STATES
]; // preferred sizes for each possible bar state
734 wxRect mBounds
[MAX_BAR_STATES
]; // saved positions and sizes for each
735 // possible state, values contain (-1)s if
736 // not initialized yet
738 int mLRUPane
; // pane to which this bar was docked before it was floated
739 // (FL_ALIGN_TOP,FL_ALIGN_BOTTOM,..)
741 // top/bottom gap, separates decorations
742 // from the bar's actual window, filled
743 // with frame's beckground color, default: 0
747 // left/right gap, separates decorations
748 // from the bar's actual wndow, filled
749 // with frame's beckground colour, default: 0
751 int mHorizGap
; // NOTE:: gaps are given in frame's coord. orientation
753 // TRUE, if vertical/horizontal dimensions cannot be mannualy adjusted
754 // by user using resizing handles. If FALSE, the frame-layout
755 // *automatically* places resizing handles among not-fixed bars
759 cbBarDimHandlerBase
* mpHandler
; // NULL, if no handler present
763 // Default constructor.
768 // isFixed is TRUE if vertical/horizontal dimensions cannot be manually adjusted
769 // by the user using resizing handles. If FALSE, the frame-layout
770 // automatically places resizing handles among bars that do are not fixed.
772 cbDimInfo( cbBarDimHandlerBase
* pDimHandler
,
773 bool isFixed
// (see comments on mIsFixed member)
776 // Constructor taking dimenstion information.
778 // dh_x, dh_y are the dimensions when docked horizontally.
780 // dv_x, dv_y are the dimensions when docked vertically.
782 // f_x, f_y are the dimensions when floating.
784 // For information on isFixed, see comments above.
786 // horizGap is the left/right gap, separating decorations
787 // from the bar's actual wndow, filled with the frame's background colour.
788 // The dimension is given in the frame's coordinates.
790 // vertGap is the top/bottom gap, separating decorations
791 // from the bar's actual wndow, filled with the frame's background colour.
792 // The dimension is given in the frame's coordinates.
794 cbDimInfo( int dh_x
, int dh_y
,
802 cbBarDimHandlerBase
* pDimHandler
= NULL
807 cbDimInfo( int x
, int y
,
810 cbBarDimHandlerBase
* pDimHandler
= NULL
813 // Destructor. Destroys handler automatically, if present.
817 // Assignment operator.
819 const cbDimInfo
& operator=( const cbDimInfo
& other
);
821 // Returns the handler, if any.
823 inline cbBarDimHandlerBase
* GetDimHandler() { return mpHandler
; }
826 // FIXME: this array definition compiles but probably doesn't do what was intended (GD)
827 WX_DEFINE_ARRAY_LONG(float, cbArrayFloat
);
830 Helper class used internally by the wxFrameLayout class.
831 Holds and manages information about bar rows.
834 class cbRowInfo
: public wxObject
836 DECLARE_DYNAMIC_CLASS( cbRowInfo
)
839 BarArrayT mBars
; // row content
841 // row flags (set up according to row-relations)
843 bool mHasUpperHandle
;
844 bool mHasLowerHandle
;
845 bool mHasOnlyFixedBars
;
846 int mNotFixedBarsCnt
;
852 // stores precalculated row's bounds in parent frame's coordinates
853 wxRect mBoundsInParent
;
855 // info stored for updates-manager
856 cbUpdateMgrData mUMgrData
;
861 cbBarInfo
* mpExpandedBar
; // NULL, if non of the bars is currently expanded
863 cbArrayFloat mSavedRatios
; // length-ratios bofore some of the bars was expanded
874 // Returns the first bar.
876 inline cbBarInfo
* GetFirstBar()
878 { return mBars
.GetCount() ? mBars
[0] : NULL
; }
882 Helper class used internally by the wxFrameLayout class.
883 Holds and manages bar information.
886 class cbBarInfo
: public wxObject
888 DECLARE_DYNAMIC_CLASS( cbBarInfo
)
890 // textual name, by which this bar is refered in layout-customization dialogs
893 // stores bar's bounds in pane's coordinates
896 // stores precalculated bar's bounds in parent frame's coordinates
897 wxRect mBoundsInParent
;
899 // back-ref to the row, which contains this bar
902 // are set up according to the types of the surrounding bars in the row
904 bool mHasRightHandle
;
906 cbDimInfo mDimInfo
; // preferred sizes for each, control bar state
908 int mState
; // (see definition of controlbar states)
910 int mAlignment
; // alignment of the pane to which this
911 // bar is currently placed
913 int mRowNo
; // row, into which this bar would be placed,
914 // when in the docking state
916 wxWindow
* mpBarWnd
; // the actual window object, NULL if no window
917 // is attached to the control bar (possible!)
919 double mLenRatio
; // length ratio among not-fixed-size bars
921 wxPoint mPosIfFloated
; // stored last position when bar was in "floated" state
922 // poistion is stored in parent-window's coordinates
924 cbUpdateMgrData mUMgrData
; // info stored for updates-manager
926 cbBarInfo
* mpNext
; // next. bar in the row
927 cbBarInfo
* mpPrev
; // prev. bar in the row
938 // Returns TRUE if this bar is fixed.
940 inline bool IsFixed() const { return mDimInfo
.mIsFixed
; }
942 // Returns TRUE if this bar is expanded.
944 inline bool IsExpanded() const { return this == mpRow
->mpExpandedBar
; }
948 Used for storing the original bar's positions in the row, when the 'non-destructive-friction'
952 class cbBarShapeData
: public wxObject
960 Used for traversing through all bars of all rows in the pane.
970 // Constructor, taking row array.
972 wxBarIterator( RowArrayT
& rows
);
974 // Resets the iterator to the start of the first row.
978 // Advances the iterator and returns TRUE if a bar is available.
982 // Gets the current bar information.
984 cbBarInfo
& BarInfo();
986 // Returns a reference to the currently traversed row.
988 cbRowInfo
& RowInfo();
992 A structure holding configuration options,
993 which are usually the same for all panes in
997 class cbCommonPaneProperties
: public wxObject
999 DECLARE_DYNAMIC_CLASS( cbCommonPaneProperties
)
1001 // look-and-feel configuration
1003 bool mRealTimeUpdatesOn
; // default: ON
1004 bool mOutOfPaneDragOn
; // default: ON
1005 bool mExactDockPredictionOn
; // default: OFF
1006 bool mNonDestructFrictionOn
; // default: OFF
1008 bool mShow3DPaneBorderOn
; // default: ON
1010 // FOR NOW:: the below properties are reserved for the "future"
1012 bool mBarFloatingOn
; // default: OFF
1013 bool mRowProportionsOn
; // default: OFF
1014 bool mColProportionsOn
; // default: ON
1015 bool mBarCollapseIconsOn
; // default: OFF
1016 bool mBarDragHintsOn
; // default: OFF
1018 // minimal dimensions for not-fixed bars in this pane (16x16 default)
1022 // width/height of resizing sash
1024 int mResizeHandleSize
;
1026 // Default constructor.
1028 cbCommonPaneProperties(void);
1032 cbCommonPaneProperties(const cbCommonPaneProperties
&);
1034 // Assignment operator
1036 cbCommonPaneProperties
& operator=(const cbCommonPaneProperties
&);
1040 This class manages containment and control of control bars
1041 along one of the four edges of the parent frame.
1044 class cbDockPane
: public wxObject
1047 DECLARE_DYNAMIC_CLASS( cbDockPane
)
1049 // look-and-feel configuration for this pane
1050 cbCommonPaneProperties mProps
;
1052 // pane margins (in frame's coordinate-syst. orientation)
1054 int mLeftMargin
; // default: 2 pixels
1055 int mRightMargin
; // default: 2 pixels
1056 int mTopMargin
; // default: 2 pixels
1057 int mBottomMargin
; // default: 2 pixels
1060 // position of the pane in frame's coordinates
1061 wxRect mBoundsInParent
;
1063 // pane width and height in pane's coordinates
1069 // info stored for updates-manager
1070 cbUpdateMgrData mUMgrData
;
1072 public: /* protected really */
1075 wxFrameLayout
* mpLayout
; // back-ref
1077 // transient properties
1079 wxList mRowShapeData
; // shapes of bars of recently modified row,
1080 // stored when in "non-destructive-friction" mode
1081 cbRowInfo
* mpStoredRow
; // row-info for which the shapes are stored
1083 friend class wxFrameLayout
;
1085 public: /* protected really (accessed only by plugins) */
1087 // Returns the row info for a row index. Internal function called by plugins.
1089 cbRowInfo
* GetRow( int row
);
1091 // Returns the row index for the given row info. Internal function called by plugins.
1093 int GetRowIndex( cbRowInfo
* pRow
);
1095 // Returns the row at the given vertical position.
1096 // Returns -1 if the row is not present at given vertical position.
1097 // Internal function called by plugins.
1099 int GetRowAt( int paneY
);
1101 // Returns the row between the given vertical positions.
1102 // Returns -1 if the row is not present.
1103 // Internal function called by plugins.
1105 int GetRowAt( int upperY
, int lowerY
);
1107 // Sets up flags in the row information structure, so that
1108 // they match the changed state of row items correctly.
1109 // Internal function called by plugins.
1111 void SyncRowFlags( cbRowInfo
* pRow
);
1113 // Returns TRUE if the bar's dimension information indicates a fixed size.
1114 // Internal function called by plugins.
1116 bool IsFixedSize( cbBarInfo
* pInfo
);
1118 // Returns the number of bars whose size is not fixed.
1119 // Internal function called by plugins.
1121 int GetNotFixedBarsCount( cbRowInfo
* pRow
);
1123 // Gets the vertical position at the given row.
1124 // Internal function called by plugins.
1126 int GetRowY( cbRowInfo
* pRow
);
1128 // Returns TRUE if there are any variable-sized rows above this one.
1129 // Internal function called by plugins.
1131 bool HasNotFixedRowsAbove( cbRowInfo
* pRow
);
1133 // Returns TRUE if there are any variable-sized rows below this one.
1134 // Internal function called by plugins.
1136 bool HasNotFixedRowsBelow( cbRowInfo
* pRow
);
1138 // Returns TRUE if there are any variable-sized rows to the left of this one.
1139 // Internal function called by plugins.
1141 bool HasNotFixedBarsLeft ( cbBarInfo
* pBar
);
1143 // Returns TRUE if there are any variable-sized rows to the right of this one.
1144 // Internal function called by plugins.
1146 bool HasNotFixedBarsRight( cbBarInfo
* pBar
);
1148 // Calculate lengths.
1149 // Internal function called by plugins.
1151 virtual void CalcLengthRatios( cbRowInfo
* pInRow
);
1153 // Generates a cbLayoutRowEvent event to recalculate row layouts.
1154 // Internal function called by plugins.
1156 virtual void RecalcRowLayout( cbRowInfo
* pRow
);
1159 // Internal function called by plugins.
1161 virtual void ExpandBar( cbBarInfo
* pBar
);
1163 // Contracts the bar.
1164 // Internal function called by plugins.
1166 virtual void ContractBar( cbBarInfo
* pBar
);
1168 // Sets up links between bars.
1169 // Internal function called by plugins.
1171 void InitLinksForRow( cbRowInfo
* pRow
);
1173 // Sets up links between bars.
1174 // Internal function called by plugins.
1176 void InitLinksForRows();
1178 // Coordinate translation between parent's frame and this pane.
1179 // Internal function called by plugins.
1181 void FrameToPane( int* x
, int* y
);
1183 // Coordinate translation between parent's frame and this pane.
1184 // Internal function called by plugins.
1186 void PaneToFrame( int* x
, int* y
);
1188 // Coordinate translation between parent's frame and this pane.
1189 // Internal function called by plugins.
1191 void FrameToPane( wxRect
* pRect
);
1193 // Coordinate translation between parent's frame and this pane.
1194 // Internal function called by plugins.
1196 void PaneToFrame( wxRect
* pRect
);
1198 // Returns TRUE if pos is within the given rectangle.
1199 // Internal function called by plugins.
1201 inline bool HasPoint( const wxPoint
& pos
, int x
, int y
, int width
, int height
);
1203 // Returns the minimal row height for the given row.
1204 // Internal function called by plugins.
1206 int GetMinimalRowHeight( cbRowInfo
* pRow
);
1208 // Sets the row height for the given height. newHeight includes the height of row handles, if present.
1209 // Internal function called by plugins.
1211 void SetRowHeight( cbRowInfo
* pRow
, int newHeight
);
1213 // Inserts the bar at the given row number.
1214 // Internal function called by plugins.
1216 void DoInsertBar( cbBarInfo
* pBar
, int rowNo
);
1218 public: /* protected really (accessed only by plugins) */
1220 // Generates a cbDrawBarDecorEvent and sends it to the layout to paint the bar decorations.
1221 // Internal function called by plugins.
1223 virtual void PaintBarDecorations( cbBarInfo
* pBar
, wxDC
& dc
);
1225 // Generates a cbDrawBarHandlesEvent and sends it to the layout to paint the bar handles.
1226 // Internal function called by plugins.
1228 virtual void PaintBarHandles( cbBarInfo
* pBar
, wxDC
& dc
);
1230 // Calls PaintBarDecorations and PaintBarHandles.
1231 // Internal function called by plugins.
1233 virtual void PaintBar( cbBarInfo
* pBar
, wxDC
& dc
);
1235 // Generates cbDrawRowHandlesEvent and cbDrawRowDecorEvent and sends them to the layout.
1236 // Internal function called by plugins.
1238 virtual void PaintRowHandles( cbRowInfo
* pRow
, wxDC
& dc
);
1240 // Generates cbDrawRowBkGroundEvent and sends it to the layout.
1241 // Internal function called by plugins.
1243 virtual void PaintRowBackground ( cbRowInfo
* pRow
, wxDC
& dc
);
1245 // Calls PaintBarDecorations for each row.
1246 // Internal function called by plugins.
1248 virtual void PaintRowDecorations( cbRowInfo
* pRow
, wxDC
& dc
);
1250 // Calls PaintRowBackground, PaintRowDecorations, PaintRowHandles.
1251 // Internal function called by plugins.
1253 virtual void PaintRow( cbRowInfo
* pRow
, wxDC
& dc
);
1255 // Generates cbDrawPaneBkGroundEvent and sends it to the layout.
1256 // Internal function called by plugins.
1258 virtual void PaintPaneBackground( wxDC
& dc
);
1260 // Generates cbDrawPaneDecorEvent and sends it to the layout.
1261 // Internal function called by plugins.
1263 virtual void PaintPaneDecorations( wxDC
& dc
);
1265 // Paints the pane background, the row background and decorations,
1266 // and finally the pane decorations.
1267 // Internal function called by plugins.
1269 virtual void PaintPane( wxDC
& dc
);
1271 // Generates a cbSizeBarWndEvent and sends it to the layout.
1272 // Internal function called by plugins.
1274 virtual void SizeBar( cbBarInfo
* pBar
);
1276 // Calls SizeBar for each bar in the row.
1277 // Internal function called by plugins.
1279 virtual void SizeRowObjects( cbRowInfo
* pRow
);
1281 // Calls SizeRowObjects for each row.
1282 // Internal function called by plugins.
1284 virtual void SizePaneObjects();
1286 // Generates cbStartDrawInAreaEvent and sends it to the layout.
1287 // Internal function called by plugins.
1289 virtual wxDC
* StartDrawInArea ( const wxRect
& area
);
1291 // Generates cbFinishDrawInAreaEvent and sends it to the layout.
1292 // Internal function called by plugins.
1294 virtual void FinishDrawInArea( const wxRect
& area
);
1296 public: /* public members */
1298 // Default constructor.
1302 // Constructor, taking alignment and layout panel.
1304 cbDockPane( int alignment
, wxFrameLayout
* pPanel
);
1306 // Sets pane's margins in frame's coordinate orientations.
1308 void SetMargins( int top
, int bottom
, int left
, int right
);
1312 virtual ~cbDockPane();
1314 // Removes the bar from this pane. Does not destroy the bar.
1316 virtual void RemoveBar( cbBarInfo
* pBar
);
1318 // Inserts the bar into this pane. rect is given in the parent frame's coordinates.
1320 virtual void InsertBar( cbBarInfo
* pBar
, const wxRect
& rect
);
1322 // Inserts the bar into the given row, with dimensions and position
1323 // stored in pBarInfo->mBounds. Returns the node of inserted bar.
1325 virtual void InsertBar( cbBarInfo
* pBar
, cbRowInfo
* pIntoRow
);
1327 // Inserts bar and sets its position according to the preferred settings
1328 // given in pBarInfo.
1330 virtual void InsertBar( cbBarInfo
* pBarInfo
);
1332 // Removes the row from this pane. Does not destroy the row object.
1334 virtual void RemoveRow( cbRowInfo
* pRow
);
1336 // Inserts a row. Does not refresh the inserted row immediately.
1337 // If pBeforeRowNode is NULL, the row is appended to the end of pane's row list.
1339 virtual void InsertRow( cbRowInfo
* pRow
, cbRowInfo
* pBeforeRow
);
1341 // Sets pane's width in the pane's coordinates (including margins).
1343 void SetPaneWidth(int width
);
1345 // Set the position and dimensions of the pane in the parent frame's coordinates.
1347 void SetBoundsInParent( const wxRect
& rect
);
1349 // Returns the bounds of the pane, in parent coordinates.
1351 inline wxRect
& GetRealRect() { return mBoundsInParent
; }
1353 // Returns an array of rows. Used by updates-managers.
1355 inline RowArrayT
& GetRowList() { return mRows
; }
1357 // Returns the first row.
1359 inline cbRowInfo
* GetFirstRow()
1361 { return mRows
.GetCount() ? mRows
[0] : NULL
; }
1363 // Returns TRUE if the given bar is present in this pane.
1365 bool BarPresent( cbBarInfo
* pBar
);
1367 // Returns the height in the pane's coordinates.
1369 int GetPaneHeight();
1371 // Returns the alignment for this pane. The value is one of
1372 // FL_ALIGN_TOP, FL_ALIGN_BOTTOM, FL_ALIGN_LEFT, FL_ALIGN_RIGHT.
1376 // Returns TRUE if the given mask matches the pane's mask.
1378 bool MatchesMask( int paneMask
);
1380 // Returns TRUE if the pane is aligned to the top or bottom.
1382 inline bool IsHorizontal()
1384 return (mAlignment
== FL_ALIGN_TOP
||
1385 mAlignment
== FL_ALIGN_BOTTOM
);
1388 // Generates events to perform layout calculations.
1390 virtual void RecalcLayout();
1392 // Returns wxCBAR_DOCKED_HORIZONTALLY if the alignment is top or bottom,
1393 // or wxCBAR_DOCKED_VERTICALLY otherwise.
1395 virtual int GetDockingState();
1397 // Returns the result of hit-testing items in the pane.
1398 // See CB_HITTEST_RESULT enumerated type.
1399 // pos is the position in this pane's coordinates.
1401 virtual int HitTestPaneItems( const wxPoint
& pos
,
1406 // Returns the bar's resize range.
1408 void GetBarResizeRange( cbBarInfo
* pBar
, int* from
, int *till
, bool forLeftHandle
);
1410 // Returns the row's resize range.
1412 void GetRowResizeRange( cbRowInfo
* pRow
, int* from
, int* till
, bool forUpperHandle
);
1414 // Finds the bar information by corresponding window.
1416 cbBarInfo
* GetBarInfoByWindow( wxWindow
* pBarWnd
);
1418 public: /* protected really (accessed only by plugins) */
1420 // Row/bar resizing related helper-method.
1422 void DrawVertHandle ( wxDC
& dc
, int x
, int y
, int height
);
1424 // Row/bar resizing related helper-method.
1426 void DrawHorizHandle( wxDC
& dc
, int x
, int y
, int width
);
1428 // Row/bar resizing related helper-method.
1430 void ResizeRow( cbRowInfo
* pRow
, int ofs
, bool forUpperHandle
);
1432 // Row/bar resizing related helper-method.
1434 void ResizeBar( cbBarInfo
* pBar
, int ofs
, bool forLeftHandle
);
1436 // Returns row shape data.
1437 // cbBarShapeData objects will be added to the given pLst.
1438 // cbBarShapeData is used for storing the original bar's positions in the row,
1439 // when the 'non-destructive-friction' option is turned on.
1441 void GetRowShapeData( cbRowInfo
* pRow
, wxList
* pLst
);
1443 // Sets the shape data for the given row, using the data provided in pLst.
1444 // cbBarShapeData is used for storing the original bar's positions in the row,
1445 // when the 'non-destructive-friction' option is turned on.
1447 void SetRowShapeData( cbRowInfo
* pRowNode
, wxList
* pLst
);
1451 This class declares an abstract interface for optimized logic that should refresh
1452 areas of frame layout that actually need to be updated. This should be extended in future
1453 to implement a custom updating strategy.
1456 class cbUpdatesManagerBase
: public wxObject
1458 DECLARE_ABSTRACT_CLASS( cbUpdatesManagerBase
)
1460 public: /* protected really, accessed by serializer (if any) */
1462 wxFrameLayout
* mpLayout
;
1465 // Default constructor
1467 cbUpdatesManagerBase(void)
1470 // Constructor taking layout panel.
1472 cbUpdatesManagerBase( wxFrameLayout
* pPanel
)
1473 : mpLayout( pPanel
) {}
1477 virtual ~cbUpdatesManagerBase() {}
1479 // Sets the associated layout.
1481 void SetLayout( wxFrameLayout
* pLayout
) { mpLayout
= pLayout
; }
1483 // This function receives a notification from the frame layout (in the order in which
1484 // they would usually be invoked). Custom updates-managers may utilize
1485 // these notifications to implement a more fine-grained updating strategy.
1487 virtual void OnStartChanges() = 0;
1489 // This function receives a notification from the frame layout (in the order in which
1490 // they would usually be invoked). Custom updates-managers may utilize
1491 // these notifications to implement a more fine-grained updating strategy.
1493 virtual void OnRowWillChange( cbRowInfo
* pRow
, cbDockPane
* pInPane
) {}
1495 // This function receives a notification from the frame layout (in the order in which
1496 // they would usually be invoked). Custom updates-managers may utilize
1497 // these notifications to implement a more fine-grained updating strategy.
1499 virtual void OnBarWillChange( cbBarInfo
* pBar
, cbRowInfo
* pInRow
, cbDockPane
* pInPane
) {}
1501 // This function receives a notification from the frame layout (in the order in which
1502 // they would usually be invoked). Custom updates-managers may utilize
1503 // these notifications to implement a more fine-grained updating strategy.
1505 virtual void OnPaneMarginsWillChange( cbDockPane
* pPane
) {}
1507 // This function receives a notification from the frame layout (in the order in which
1508 // they would usually be invoked). Custom updates-managers may utilize
1509 // these notifications to implement a more fine-grained updating strategy.
1511 virtual void OnPaneWillChange( cbDockPane
* pPane
) {}
1513 // This function receives a notification from the frame layout (in the order in which
1514 // they would usually be invoked). Custom updates-managers may utilize
1515 // these notifications to implement a more fine-grained updating strategy.
1517 virtual void OnFinishChanges() {}
1519 // Refreshes parts of the frame layout that need an update.
1521 virtual void UpdateNow() = 0;
1525 Base class for all control-bar plugin events.
1526 This is not a dynamically-creatable class.
1529 class cbPluginEvent
: public wxEvent
1532 // NULL if event is not addressed to any specific pane.
1536 // Not used, but required.
1538 virtual wxEvent
* Clone() const { return NULL
; }
1540 // Constructor, taking event type and pane.
1542 cbPluginEvent( wxEventType eventType
, cbDockPane
* pPane
)
1545 { m_eventType
= eventType
; }
1548 // event types handled by plugins
1550 extern wxEventType cbEVT_PL_LEFT_DOWN
;
1551 extern wxEventType cbEVT_PL_LEFT_UP
;
1552 extern wxEventType cbEVT_PL_RIGHT_DOWN
;
1553 extern wxEventType cbEVT_PL_RIGHT_UP
;
1554 extern wxEventType cbEVT_PL_MOTION
;
1556 extern wxEventType cbEVT_PL_LEFT_DCLICK
;
1558 extern wxEventType cbEVT_PL_LAYOUT_ROW
;
1559 extern wxEventType cbEVT_PL_RESIZE_ROW
;
1560 extern wxEventType cbEVT_PL_LAYOUT_ROWS
;
1561 extern wxEventType cbEVT_PL_INSERT_BAR
;
1562 extern wxEventType cbEVT_PL_RESIZE_BAR
;
1563 extern wxEventType cbEVT_PL_REMOVE_BAR
;
1564 extern wxEventType cbEVT_PL_SIZE_BAR_WND
;
1566 extern wxEventType cbEVT_PL_DRAW_BAR_DECOR
;
1567 extern wxEventType cbEVT_PL_DRAW_ROW_DECOR
;
1568 extern wxEventType cbEVT_PL_DRAW_PANE_DECOR
;
1569 extern wxEventType cbEVT_PL_DRAW_BAR_HANDLES
;
1570 extern wxEventType cbEVT_PL_DRAW_ROW_HANDLES
;
1571 extern wxEventType cbEVT_PL_DRAW_ROW_BKGROUND
;
1572 extern wxEventType cbEVT_PL_DRAW_PANE_BKGROUND
;
1574 extern wxEventType cbEVT_PL_START_BAR_DRAGGING
;
1575 extern wxEventType cbEVT_PL_DRAW_HINT_RECT
;
1577 extern wxEventType cbEVT_PL_START_DRAW_IN_AREA
;
1578 extern wxEventType cbEVT_PL_FINISH_DRAW_IN_AREA
;
1580 extern wxEventType cbEVT_PL_CUSTOMIZE_BAR
;
1581 extern wxEventType cbEVT_PL_CUSTOMIZE_LAYOUT
;
1583 extern wxEventType wxCUSTOM_CB_PLUGIN_EVENTS_START_AT
;
1585 // Forward declarations, separated by categories.
1587 class cbLeftDownEvent
;
1588 class cbLeftUpEvent
;
1589 class cbRightDownEvent
;
1590 class cbRightUpEvent
;
1591 class cbMotionEvent
;
1592 class cbLeftDClickEvent
;
1594 class cbLayoutRowEvent
;
1595 class cbResizeRowEvent
;
1596 class cbLayoutRowsEvent
;
1597 class cbInsertBarEvent
;
1598 class cbResizeBarEvent
;
1599 class cbRemoveBarEvent
;
1600 class cbSizeBarWndEvent
;
1602 class cbDrawBarDecorEvent
;
1603 class cbDrawRowDecorEvent
;
1604 class cbDrawPaneDecorEvent
;
1605 class cbDrawBarHandlesEvent
;
1606 class cbDrawRowHandlesEvent
;
1607 class cbDrawRowBkGroundEvent
;
1608 class cbDrawPaneBkGroundEvent
;
1610 class cbStartBarDraggingEvent
;
1611 class cbDrawHintRectEvent
;
1613 class cbStartDrawInAreaEvent
;
1614 class cbFinishDrawInAreaEvent
;
1616 class cbCustomizeBarEvent
;
1617 class cbCustomizeLayoutEvent
;
1619 // Definitions for for handler-methods.
1621 typedef void (wxEvtHandler::*cbLeftDownHandler
)(cbLeftDownEvent
&);
1622 typedef void (wxEvtHandler::*cbLeftUpHandler
)(cbLeftUpEvent
&);
1623 typedef void (wxEvtHandler::*cbRightDownHandler
)(cbRightDownEvent
&);
1624 typedef void (wxEvtHandler::*cbRightUpHandler
)(cbRightUpEvent
&);
1625 typedef void (wxEvtHandler::*cbMotionHandler
)(cbMotionEvent
&);
1626 typedef void (wxEvtHandler::*cbLeftDClickHandler
)(cbLeftDClickEvent
&);
1628 typedef void (wxEvtHandler::*cbLayoutRowHandler
)(cbLayoutRowEvent
&);
1629 typedef void (wxEvtHandler::*cbResizeRowHandler
)(cbResizeRowEvent
&);
1630 typedef void (wxEvtHandler::*cbLayoutRowsHandler
)(cbLayoutRowsEvent
&);
1631 typedef void (wxEvtHandler::*cbInsertBarHandler
)(cbInsertBarEvent
&);
1632 typedef void (wxEvtHandler::*cbResizeBarHandler
)(cbResizeBarEvent
&);
1633 typedef void (wxEvtHandler::*cbRemoveBarHandler
)(cbRemoveBarEvent
&);
1634 typedef void (wxEvtHandler::*cbSizeBarWndHandler
)(cbSizeBarWndEvent
&);
1636 typedef void (wxEvtHandler::*cbDrawBarDecorHandler
)(cbDrawBarDecorEvent
&);
1637 typedef void (wxEvtHandler::*cbDrawRowDecorHandler
)(cbDrawRowDecorEvent
&);
1638 typedef void (wxEvtHandler::*cbDrawPaneDecorHandler
)(cbDrawPaneDecorEvent
&);
1639 typedef void (wxEvtHandler::*cbDrawBarHandlesHandler
)(cbDrawBarHandlesEvent
&);
1640 typedef void (wxEvtHandler::*cbDrawRowHandlesHandler
)(cbDrawRowHandlesEvent
&);
1641 typedef void (wxEvtHandler::*cbDrawRowBkGroundHandler
)(cbDrawRowBkGroundEvent
&);
1642 typedef void (wxEvtHandler::*cbDrawPaneBkGroundHandler
)(cbDrawPaneBkGroundEvent
&);
1644 typedef void (wxEvtHandler::*cbStartBarDraggingHandler
)(cbStartBarDraggingEvent
&);
1645 typedef void (wxEvtHandler::*cbDrawHintRectHandler
)(cbDrawHintRectEvent
&);
1647 typedef void (wxEvtHandler::*cbStartDrawInAreaHandler
)(cbStartDrawInAreaEvent
&);
1648 typedef void (wxEvtHandler::*cbFinishDrawInAreaHandler
)(cbFinishDrawInAreaEvent
&);
1650 typedef void (wxEvtHandler::*cbCustomizeBarHandler
)(cbCustomizeBarEvent
&);
1651 typedef void (wxEvtHandler::*cbCustomizeLayoutHandler
)(cbCustomizeLayoutEvent
&);
1653 // Macros for creating event table entries for plugin-events.
1655 #define EVT_PL_LEFT_DOWN(func) wxEventTableEntry( cbEVT_PL_LEFT_DOWN, -1, -1, (wxObjectEventFunction) (wxEventFunction) (cbLeftDownHandler ) & func, (wxObject *) NULL ),
1656 #define EVT_PL_LEFT_UP(func) wxEventTableEntry( cbEVT_PL_LEFT_UP, -1, -1, (wxObjectEventFunction) (wxEventFunction) (cbLeftUpHandler ) & func, (wxObject *) NULL ),
1657 #define EVT_PL_RIGHT_DOWN(func) wxEventTableEntry( cbEVT_PL_RIGHT_DOWN, -1, -1, (wxObjectEventFunction) (wxEventFunction) (cbRightDownHandler ) & func, (wxObject *) NULL ),
1658 #define EVT_PL_RIGHT_UP(func) wxEventTableEntry( cbEVT_PL_RIGHT_UP, -1, -1, (wxObjectEventFunction) (wxEventFunction) (cbRightUpHandler ) & func, (wxObject *) NULL ),
1659 #define EVT_PL_MOTION(func) wxEventTableEntry( cbEVT_PL_MOTION, -1, -1, (wxObjectEventFunction) (wxEventFunction) (cbMotionHandler ) & func, (wxObject *) NULL ),
1660 #define EVT_PL_LEFT_DCLICK(func) wxEventTableEntry( cbEVT_PL_LEFT_DCLICK, -1, -1, (wxObjectEventFunction) (wxEventFunction) (cbLeftDClickHandler ) & func, (wxObject *) NULL ),
1662 #define EVT_PL_LAYOUT_ROW(func) wxEventTableEntry( cbEVT_PL_LAYOUT_ROW, -1, -1, (wxObjectEventFunction) (wxEventFunction) (cbLayoutRowHandler ) & func, (wxObject *) NULL ),
1663 #define EVT_PL_RESIZE_ROW(func) wxEventTableEntry( cbEVT_PL_RESIZE_ROW, -1, -1, (wxObjectEventFunction) (wxEventFunction) (cbResizeRowHandler ) & func, (wxObject *) NULL ),
1664 #define EVT_PL_LAYOUT_ROWS(func) wxEventTableEntry( cbEVT_PL_LAYOUT_ROWS, -1, -1, (wxObjectEventFunction) (wxEventFunction) (cbLayoutRowsHandler ) & func, (wxObject *) NULL ),
1665 #define EVT_PL_INSERT_BAR(func) wxEventTableEntry( cbEVT_PL_INSERT_BAR, -1, -1, (wxObjectEventFunction) (wxEventFunction) (cbInsertBarHandler ) & func, (wxObject *) NULL ),
1666 #define EVT_PL_RESIZE_BAR(func) wxEventTableEntry( cbEVT_PL_RESIZE_BAR, -1, -1, (wxObjectEventFunction) (wxEventFunction) (cbResizeBarHandler ) & func, (wxObject *) NULL ),
1667 #define EVT_PL_REMOVE_BAR(func) wxEventTableEntry( cbEVT_PL_REMOVE_BAR, -1, -1, (wxObjectEventFunction) (wxEventFunction) (cbRemoveBarHandler ) & func, (wxObject *) NULL ),
1668 #define EVT_PL_SIZE_BAR_WND(func) wxEventTableEntry( cbEVT_PL_SIZE_BAR_WND, -1, -1, (wxObjectEventFunction) (wxEventFunction) (cbSizeBarWndHandler ) & func, (wxObject *) NULL ),
1670 #define EVT_PL_DRAW_BAR_DECOR(func) wxEventTableEntry( cbEVT_PL_DRAW_BAR_DECOR, -1, -1, (wxObjectEventFunction) (wxEventFunction) (cbDrawBarDecorHandler ) & func, (wxObject *) NULL ),
1671 #define EVT_PL_DRAW_ROW_DECOR(func) wxEventTableEntry( cbEVT_PL_DRAW_ROW_DECOR, -1, -1, (wxObjectEventFunction) (wxEventFunction) (cbDrawRowDecorHandler ) & func, (wxObject *) NULL ),
1672 #define EVT_PL_DRAW_PANE_DECOR(func) wxEventTableEntry( cbEVT_PL_DRAW_PANE_DECOR, -1, -1, (wxObjectEventFunction) (wxEventFunction) (cbDrawPaneDecorHandler ) & func, (wxObject *) NULL ),
1673 #define EVT_PL_DRAW_BAR_HANDLES(func) wxEventTableEntry( cbEVT_PL_DRAW_BAR_HANDLES, -1, -1, (wxObjectEventFunction) (wxEventFunction) (cbDrawBarHandlesHandler ) & func, (wxObject *) NULL ),
1674 #define EVT_PL_DRAW_ROW_HANDLES(func) wxEventTableEntry( cbEVT_PL_DRAW_ROW_HANDLES, -1, -1, (wxObjectEventFunction) (wxEventFunction) (cbDrawRowHandlesHandler ) & func, (wxObject *) NULL ),
1675 #define EVT_PL_DRAW_ROW_BKGROUND(func) wxEventTableEntry( cbEVT_PL_DRAW_ROW_BKGROUND, -1, -1, (wxObjectEventFunction) (wxEventFunction) (cbDrawRowBkGroundHandler ) & func, (wxObject *) NULL ),
1676 #define EVT_PL_DRAW_PANE_BKGROUND(func) wxEventTableEntry( cbEVT_PL_DRAW_PANE_BKGROUND, -1, -1, (wxObjectEventFunction) (wxEventFunction) (cbDrawPaneBkGroundHandler) & func, (wxObject *) NULL ),
1678 #define EVT_PL_START_BAR_DRAGGING(func) wxEventTableEntry( cbEVT_PL_START_BAR_DRAGGING, -1, -1, (wxObjectEventFunction) (wxEventFunction) (cbStartBarDraggingHandler) & func, (wxObject *) NULL ),
1679 #define EVT_PL_DRAW_HINT_RECT(func) wxEventTableEntry( cbEVT_PL_DRAW_HINT_RECT, -1, -1, (wxObjectEventFunction) (wxEventFunction) (cbDrawHintRectHandler ) & func, (wxObject *) NULL ),
1682 #define EVT_PL_START_DRAW_IN_AREA(func) wxEventTableEntry( cbEVT_PL_START_DRAW_IN_AREA, -1, -1, (wxObjectEventFunction) (wxEventFunction) (cbStartDrawInAreaHandler) & func, (wxObject *) NULL ),
1683 #define EVT_PL_FINISH_DRAW_IN_AREA(func) wxEventTableEntry( cbEVT_PL_FINISH_DRAW_IN_AREA, -1, -1, (wxObjectEventFunction) (wxEventFunction) (cbFinishDrawInAreaHandler) & func, (wxObject *) NULL ),
1685 #define EVT_PL_CUSTOMIZE_BAR(func) wxEventTableEntry( cbEVT_PL_CUSTOMIZE_BAR, -1, -1, (wxObjectEventFunction) (wxEventFunction) (cbCustomizeBarHandler) & func, (wxObject *) NULL ),
1686 #define EVT_PL_CUSTOMIZE_LAYOUT(func) wxEventTableEntry( cbEVT_PL_CUSTOMIZE_LAYOUT, -1, -1, (wxObjectEventFunction) (wxEventFunction) (cbCustomizeLayoutHandler) & func, (wxObject *) NULL ),
1689 Abstract base class for all control-bar related plugins.
1690 Note: pointer positions of mouse events sent to plugins
1691 are always in the pane's coordinates (the pane to which
1692 this plugin is hooked).
1695 class cbPluginBase
: public wxEvtHandler
1697 DECLARE_ABSTRACT_CLASS( cbPluginBase
)
1699 // Back-reference to the frame layout.
1701 wxFrameLayout
* mpLayout
;
1703 // Specifies panes for which this plugin receives events
1704 // (see pane masks definitions).
1708 // Is TRUE when plugin is ready to handle events.
1713 // Default constructor.
1718 mPaneMask( wxALL_PANES
),
1722 // Constructor taking layout panel and a mask.
1724 cbPluginBase( wxFrameLayout
* pPanel
, int paneMask
= wxALL_PANES
)
1726 : mpLayout ( pPanel
),
1727 mPaneMask( paneMask
),
1731 // Returns the pane mask.
1733 inline int GetPaneMask() { return mPaneMask
; }
1735 // Destructor. Destroys the whole plugin chain of connected plugins.
1737 virtual ~cbPluginBase();
1739 // Override this method to do plugin-specific initialization.
1740 // At this point plugin is already attached to the frame layout,
1741 // and pane masks are set.
1743 virtual void OnInitPlugin() { mIsReady
= TRUE
; }
1745 // Returns TRUE if the plugin is ready to receive events.
1747 bool IsReady() { return mIsReady
; }
1749 // Overridden to determine whether the target pane specified in the
1750 // event matches the pane mask of this plugin (specific plugins
1751 // do not override this method).
1753 virtual bool ProcessEvent(wxEvent
& event
);
1757 Class for mouse left down events.
1760 class cbLeftDownEvent
: public cbPluginEvent
1765 // Constructor, taking mouse position and pane.
1767 cbLeftDownEvent( const wxPoint
& pos
, cbDockPane
* pPane
)
1769 : cbPluginEvent( cbEVT_PL_LEFT_DOWN
, pPane
),
1775 Class for mouse left up events.
1778 class cbLeftUpEvent
: public cbPluginEvent
1783 // Constructor, taking mouse position and pane.
1785 cbLeftUpEvent( const wxPoint
& pos
, cbDockPane
* pPane
)
1787 : cbPluginEvent( cbEVT_PL_LEFT_UP
, pPane
),
1793 Class for mouse right down events.
1796 class cbRightDownEvent
: public cbPluginEvent
1801 // Constructor, taking mouse position and pane.
1803 cbRightDownEvent( const wxPoint
& pos
, cbDockPane
* pPane
)
1805 : cbPluginEvent( cbEVT_PL_RIGHT_DOWN
, pPane
),
1811 Class for mouse right up events.
1814 class cbRightUpEvent
: public cbPluginEvent
1819 // Constructor, taking mouse position and pane.
1821 cbRightUpEvent( const wxPoint
& pos
, cbDockPane
* pPane
)
1823 : cbPluginEvent( cbEVT_PL_RIGHT_UP
, pPane
),
1829 Class for mouse motion events.
1832 class cbMotionEvent
: public cbPluginEvent
1837 // Constructor, taking mouse position and pane.
1839 cbMotionEvent( const wxPoint
& pos
, cbDockPane
* pPane
)
1841 : cbPluginEvent( cbEVT_PL_MOTION
, pPane
),
1847 Class for mouse left double click events.
1850 class cbLeftDClickEvent
: public cbPluginEvent
1855 // Constructor, taking mouse position and pane.
1857 cbLeftDClickEvent( const wxPoint
& pos
, cbDockPane
* pPane
)
1859 : cbPluginEvent( cbEVT_PL_LEFT_DCLICK
, pPane
),
1865 Class for single row layout events.
1868 class cbLayoutRowEvent
: public cbPluginEvent
1873 // Constructor, taking row information and pane.
1875 cbLayoutRowEvent( cbRowInfo
* pRow
, cbDockPane
* pPane
)
1877 : cbPluginEvent( cbEVT_PL_LAYOUT_ROW
, pPane
),
1883 Class for row resize events.
1886 class cbResizeRowEvent
: public cbPluginEvent
1891 bool mForUpperHandle
;
1893 // Constructor, taking row information, two parameters of currently unknown use, and pane.
1895 cbResizeRowEvent( cbRowInfo
* pRow
, int handleOfs
, bool forUpperHandle
, cbDockPane
* pPane
)
1897 : cbPluginEvent( cbEVT_PL_RESIZE_ROW
, pPane
),
1899 mHandleOfs( handleOfs
),
1900 mForUpperHandle( forUpperHandle
)
1905 Class for multiple rows layout events.
1908 class cbLayoutRowsEvent
: public cbPluginEvent
1912 // Constructor, taking pane.
1914 cbLayoutRowsEvent( cbDockPane
* pPane
)
1916 : cbPluginEvent( cbEVT_PL_LAYOUT_ROWS
, pPane
)
1921 Class for bar insertion events.
1924 class cbInsertBarEvent
: public cbPluginEvent
1930 // Constructor, taking bar information, row information, and pane.
1932 cbInsertBarEvent( cbBarInfo
* pBar
, cbRowInfo
* pIntoRow
, cbDockPane
* pPane
)
1934 : cbPluginEvent( cbEVT_PL_INSERT_BAR
, pPane
),
1942 Class for bar resize events.
1945 class cbResizeBarEvent
: public cbPluginEvent
1951 // Constructor, taking bar information, row information, and pane.
1953 cbResizeBarEvent( cbBarInfo
* pBar
, cbRowInfo
* pRow
, cbDockPane
* pPane
)
1955 : cbPluginEvent( cbEVT_PL_RESIZE_BAR
, pPane
),
1962 Class for bar removal events.
1965 class cbRemoveBarEvent
: public cbPluginEvent
1970 // Constructor, taking bar information and pane.
1972 cbRemoveBarEvent( cbBarInfo
* pBar
, cbDockPane
* pPane
)
1974 : cbPluginEvent( cbEVT_PL_REMOVE_BAR
, pPane
),
1980 Class for bar window resize events.
1983 class cbSizeBarWndEvent
: public cbPluginEvent
1987 wxRect mBoundsInParent
;
1989 // Constructor, taking bar information and pane.
1991 cbSizeBarWndEvent( cbBarInfo
* pBar
, cbDockPane
* pPane
)
1993 : cbPluginEvent( cbEVT_PL_SIZE_BAR_WND
, pPane
),
1995 mBoundsInParent( pBar
->mBoundsInParent
)
2000 Class for bar decoration drawing events.
2003 class cbDrawBarDecorEvent
: public cbPluginEvent
2008 wxRect mBoundsInParent
;
2010 // Constructor, taking bar information, device context, and pane.
2012 cbDrawBarDecorEvent( cbBarInfo
* pBar
, wxDC
& dc
, cbDockPane
* pPane
)
2014 : cbPluginEvent( cbEVT_PL_DRAW_BAR_DECOR
, pPane
),
2017 mBoundsInParent( pBar
->mBoundsInParent
)
2022 Class for row decoration drawing events.
2025 class cbDrawRowDecorEvent
: public cbPluginEvent
2031 // Constructor, taking row information, device context, and pane.
2033 cbDrawRowDecorEvent( cbRowInfo
* pRow
, wxDC
& dc
, cbDockPane
* pPane
)
2035 : cbPluginEvent( cbEVT_PL_DRAW_ROW_DECOR
, pPane
),
2042 Class for pane decoration drawing events.
2045 class cbDrawPaneDecorEvent
: public cbPluginEvent
2050 // Constructor, taking device context and pane.
2052 cbDrawPaneDecorEvent( wxDC
& dc
, cbDockPane
* pPane
)
2054 : cbPluginEvent( cbEVT_PL_DRAW_PANE_DECOR
, pPane
),
2060 Class for bar handles drawing events.
2063 class cbDrawBarHandlesEvent
: public cbPluginEvent
2069 // Constructor, taking bar information, device context, and pane.
2071 cbDrawBarHandlesEvent( cbBarInfo
* pBar
, wxDC
& dc
, cbDockPane
* pPane
)
2073 : cbPluginEvent( cbEVT_PL_DRAW_BAR_HANDLES
, pPane
),
2080 Class for row handles drawing events.
2083 class cbDrawRowHandlesEvent
: public cbPluginEvent
2089 // Constructor, taking row information, device context, and pane.
2091 cbDrawRowHandlesEvent( cbRowInfo
* pRow
, wxDC
& dc
, cbDockPane
* pPane
)
2093 : cbPluginEvent( cbEVT_PL_DRAW_ROW_HANDLES
, pPane
),
2100 Class for row background drawing events.
2103 class cbDrawRowBkGroundEvent
: public cbPluginEvent
2109 // Constructor, taking row information, device context, and pane.
2111 cbDrawRowBkGroundEvent( cbRowInfo
* pRow
, wxDC
& dc
, cbDockPane
* pPane
)
2113 : cbPluginEvent( cbEVT_PL_DRAW_ROW_BKGROUND
, pPane
),
2120 Class for pane background drawing events.
2123 class cbDrawPaneBkGroundEvent
: public cbPluginEvent
2128 // Constructor, taking device context and pane.
2130 cbDrawPaneBkGroundEvent( wxDC
& dc
, cbDockPane
* pPane
)
2132 : cbPluginEvent( cbEVT_PL_DRAW_PANE_BKGROUND
, pPane
),
2138 Class for start-bar-dragging events.
2141 class cbStartBarDraggingEvent
: public cbPluginEvent
2145 wxPoint mPos
; // is given in frame's coordinates
2147 // Constructor, taking bar information, mouse position, and pane.
2149 cbStartBarDraggingEvent( cbBarInfo
* pBar
, const wxPoint
& pos
, cbDockPane
* pPane
)
2151 : cbPluginEvent( cbEVT_PL_START_BAR_DRAGGING
, pPane
),
2158 Class for hint-rectangle drawing events.
2161 class cbDrawHintRectEvent
: public cbPluginEvent
2164 wxRect mRect
; // is given in frame's coordinates
2167 bool mLastTime
; // indicates that this event finishes "session" of on-screen drawing,
2168 // thus associated resources can be freed now
2169 bool mEraseRect
; // does not have any impact, if recangle is drawn using XOR-mask
2171 bool mIsInClient
;// in cleint area hint could be drawn differently,
2172 // e.g. with fat/hatched border
2175 // Constructor, taking hint rectangle and three flags.
2177 cbDrawHintRectEvent( const wxRect
& rect
, bool isInClient
, bool eraseRect
, bool lastTime
)
2179 : cbPluginEvent( cbEVT_PL_DRAW_HINT_RECT
, 0 ),
2181 mLastTime ( lastTime
),
2182 mEraseRect ( eraseRect
),
2183 mIsInClient( isInClient
)
2188 Class for start drawing in area events.
2191 class cbStartDrawInAreaEvent
: public cbPluginEvent
2195 wxDC
** mppDc
; // points to pointer, where the reference
2196 // to the obtained buffer-context should be placed
2198 // Constructor, taking rectangular area, device context pointer to a pointer, and pane.
2200 cbStartDrawInAreaEvent( const wxRect
& area
, wxDC
** ppDCForArea
, cbDockPane
* pPane
)
2202 : cbPluginEvent( cbEVT_PL_START_DRAW_IN_AREA
, pPane
),
2204 mppDc( ppDCForArea
)
2209 Class for finish drawing in area events.
2212 class cbFinishDrawInAreaEvent
: public cbPluginEvent
2217 // Constructor, taking rectangular area and pane.
2219 cbFinishDrawInAreaEvent( const wxRect
& area
, cbDockPane
* pPane
)
2221 : cbPluginEvent( cbEVT_PL_FINISH_DRAW_IN_AREA
, pPane
),
2227 Class for bar customization events.
2230 class cbCustomizeBarEvent
: public cbPluginEvent
2233 wxPoint mClickPos
; // in parent frame's coordinates
2236 // Constructor, taking bar information, mouse position, and pane.
2238 cbCustomizeBarEvent( cbBarInfo
* pBar
, const wxPoint
& clickPos
, cbDockPane
* pPane
)
2240 : cbPluginEvent( cbEVT_PL_CUSTOMIZE_BAR
, pPane
),
2241 mClickPos( clickPos
),
2247 Class for layout customization events.
2250 class cbCustomizeLayoutEvent
: public cbPluginEvent
2253 wxPoint mClickPos
; // in parent frame's coordinates
2255 // Constructor, taking mouse position.
2257 cbCustomizeLayoutEvent( const wxPoint
& clickPos
)
2259 : cbPluginEvent( cbEVT_PL_CUSTOMIZE_LAYOUT
, 0 ),
2260 mClickPos( clickPos
)
2264 #endif /* __CONTROLBAR_G__ */