1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: Central header file for control-bar related classes
5 // Author: Aleksandras Gluchovas <mailto:alex@soften.ktu.lt>
9 // Copyright: (c) Aleksandras Gluchovas
10 // Licence: wxWindows license
11 /////////////////////////////////////////////////////////////////////////////
13 #ifndef __CONTROLBAR_G__
14 #define __CONTROLBAR_G__
17 #pragma interface "controlbar.h"
21 #include "wx/string.h"
22 #include "wx/window.h"
23 #include "wx/dynarray.h"
25 #define WXCONTROLBAR_VERSION 1.3
27 // forward declarations
32 class cbUpdatesManagerBase
;
33 class cbBarDimHandlerBase
;
36 class cbPaneDrawPlugin
;
41 class cbCommonPaneProperties
;
43 typedef cbBarInfo
* BarInfoPtrT
;
44 typedef cbRowInfo
* RowInfoPtrT
;
46 WX_DEFINE_ARRAY( BarInfoPtrT
, BarArrayT
);
47 WX_DEFINE_ARRAY( RowInfoPtrT
, RowArrayT
);
51 #define wxCBAR_DOCKED_HORIZONTALLY 0
52 #define wxCBAR_DOCKED_VERTICALLY 1
53 #define wxCBAR_FLOATING 2
54 #define wxCBAR_HIDDEN 3
56 // the states are enumerated above
57 #define MAX_BAR_STATES 4
59 // control bar alignments
61 #if !defined(FL_ALIGN_TOP)
63 #define FL_ALIGN_TOP 0
64 #define FL_ALIGN_BOTTOM 1
65 #define FL_ALIGN_LEFT 2
66 #define FL_ALIGN_RIGHT 3
70 // one pane for each alignment
73 // masks for each pane
75 #define FL_ALIGN_TOP_PANE 0x0001
76 #define FL_ALIGN_BOTTOM_PANE 0x0002
77 #define FL_ALIGN_LEFT_PANE 0x0004
78 #define FL_ALIGN_RIGHT_PANE 0x0008
80 #define wxALL_PANES 0x000F
82 // enumeration of hittest results, see cbDockPane::HitTestPaneItems(..)
84 enum CB_HITTEST_RESULT
88 CB_UPPER_ROW_HANDLE_HITTED
,
89 CB_LOWER_ROW_HANDLE_HITTED
,
90 CB_LEFT_BAR_HANDLE_HITTED
,
91 CB_RIGHT_BAR_HANDLE_HITTED
,
95 // FIXME:: somehow in debug v. originall wxASSERT's are not compiled in...
98 //#define wxASSERT(x) if ( !(x) ) throw;
100 // helper class, used for spying for not-handled mouse events on control-bars
101 // and forwarding them to the frame layout
103 class cbBarSpy
: public wxEvtHandler
106 DECLARE_DYNAMIC_CLASS( cbBarSpy
)
108 wxFrameLayout
* mpLayout
;
114 cbBarSpy( wxFrameLayout
* pPanel
);
116 void SetBarWindow( wxWindow
* pWnd
);
120 virtual bool ProcessEvent(wxEvent
& event
);
123 /* wxFrameLayout manages containment and docking of control bars.
124 * which can be docked along top, bottom, righ, or left side of the
128 class wxFrameLayout
: public wxEvtHandler
131 wxFrameLayout(void); // used only while serializing
133 wxFrameLayout( wxWindow
* pParentFrame
,
134 wxWindow
* pFrameClient
= NULL
,
135 bool activateNow
= TRUE
);
137 // (doesn't destroy bar windows)
138 virtual ~wxFrameLayout();
140 // (by default floating of control-bars is ON)
141 virtual void EnableFloating( bool enable
= TRUE
);
143 // Can be called after some other layout has been deactivated,
144 // and this one must "take over" the current contents of frame window.
146 // Effectively hooks itself to the frame window, re-displays all not-hidden
147 // bar-windows and repaints decorations
149 virtual void Activate();
151 // unhooks itself from frame window, and hides all not-hidden windows
153 // NOTE:: two frame-layouts should not be active at the same time in the
154 // same frame window, it would cause messy overlapping of bar windows
157 virtual void Deactivate();
159 // also hides the client window if presents
161 void HideBarWindows();
163 virtual void DestroyBarWindows();
165 // passes the client window (e.g. MDI-client frame) to be controled by
166 // frame layout, the size and position of which should be adjusted to be
167 // surrounded by controlbar panes, whenever frame is resized, or dimensions
168 // of control panes change
170 void SetFrameClient( wxWindow
* pFrameClient
);
172 wxWindow
* GetFrameClient();
174 wxWindow
& GetParentFrame() { return *mpFrame
; }
176 // used by updates-managers
177 cbDockPane
** GetPanesArray() { return mPanes
; }
179 // see pane alignment types
180 cbDockPane
* GetPane( int alignment
)
182 { return mPanes
[alignment
]; }
184 // Adds bar information to frame-layout, appearence of layout is not refreshed
185 // immediately, RefreshNow() can be called if necessary.
187 // NOTES:: argument pBarWnd can by NULL, resulting bar decorations to be drawn
188 // around the empty rectangle (filled with default background colour).
189 // Argument dimInfo, can be re-used for adding any number of bars, since
190 // it is not used directly, instead it's members are copied. If dimensions-
191 // handler is present, it's instance shared (reference counted). Dimension
192 // handler should always be allocated on the heap!)
194 virtual void AddBar( wxWindow
* pBarWnd
,
195 const cbDimInfo
& dimInfo
,
198 int alignment
= FL_ALIGN_TOP
,
199 int rowNo
= 0, // vert. position - row in the pane (if docked state)
200 int columnPos
= 0, // horiz. position in the row in pixels (if docked state)
201 const wxString
& name
="bar",// name, by which the bar could be referred
202 // in layout customization dialogs
204 bool spyEvents
= FALSE
, // if TRUE - input events for the bar should
205 // be "spyed" in order to forward not-handled
206 // mouse clicks to frame layout (e.g. to enable
207 // easy-draggablity of toolbars just by clicking
208 // on their interior regions). For widgets like
209 // text/tree control this value should be FALSE
210 // (since there's _no_ certain way to detect
211 // whether the event was actually handled...)
213 int state
= wxCBAR_DOCKED_HORIZONTALLY
// e.g. wxCBAR_FLOATING
217 // can be used for repositioning already existing bars. The given bar is first removed
218 // from the pane it currently belongs to, and inserted into the pane, which "matches"
219 // the given recantular area. If pToPane is not NULL, bar is docked to this given pane
221 // to dock the bar which is floated, use wxFrameLayout::DockBar(..) method
223 virtual bool RedockBar( cbBarInfo
* pBar
, const wxRect
& shapeInParent
,
224 cbDockPane
* pToPane
= NULL
, bool updateNow
= TRUE
);
226 // methods for access and modification of bars in frame layout
228 cbBarInfo
* FindBarByName( const wxString
& name
);
230 cbBarInfo
* FindBarByWindow( const wxWindow
* pWnd
);
232 BarArrayT
& GetBars();
234 // changes bar's docking state (see possible control bar states)
236 void SetBarState( cbBarInfo
* pBar
, int newStatem
, bool updateNow
);
238 void InverseVisibility( cbBarInfo
* pBar
);
240 // reflects changes in bar information structure visually
241 // (e.g. moves bar, changes it's dimension info, pane to which it is docked)
243 void ApplyBarProperties( cbBarInfo
* pBar
);
245 // removes bar from layout permanently, hides it's corresponding window if present
247 void RemoveBar( cbBarInfo
* pBar
);
249 // recalcualtes layout of panes, and all bars/rows in each pane
251 virtual void RecalcLayout( bool repositionBarsNow
= FALSE
);
253 int GetClientHeight();
254 int GetClientWidth();
255 wxRect
& GetClientRect() { return mClntWndBounds
; }
257 // NOTE:: in future ubdates-manager will become a normal plugin
259 cbUpdatesManagerBase
& GetUpdatesManager();
261 // destroys the previous manager if any, set the new one
263 void SetUpdatesManager( cbUpdatesManagerBase
* pUMgr
);
265 // NOTE:: changing properties of panes, does not result immediate on-screen update
267 virtual void GetPaneProperties( cbCommonPaneProperties
& props
, int alignment
= FL_ALIGN_TOP
);
269 virtual void SetPaneProperties( const cbCommonPaneProperties
& props
,
270 int paneMask
= wxALL_PANES
);
272 // TODO:: margins should go into cbCommonPaneProperties in the future
274 // NOTE:: this method should be called before any custom plugins are attached
276 virtual void SetMargins( int top
, int bottom
, int left
, int right
,
277 int paneMask
= wxALL_PANES
);
279 virtual void SetPaneBackground( const wxColour
& colour
);
281 // recalculates layoute and performs on-screen update of all panes
283 void RefreshNow( bool recalcLayout
= TRUE
);
287 void OnSize ( wxSizeEvent
& event
);
288 void OnLButtonDown( wxMouseEvent
& event
);
289 void OnLDblClick ( wxMouseEvent
& event
);
290 void OnLButtonUp ( wxMouseEvent
& event
);
291 void OnRButtonDown( wxMouseEvent
& event
);
292 void OnRButtonUp ( wxMouseEvent
& event
);
293 void OnMouseMove ( wxMouseEvent
& event
);
295 /*** plugin-related methods ***/
297 // should be used, instead of passing the event to ProcessEvent(..) method
298 // of the top-plugin directly. This method checks if events are currently
299 // captured and ensures that plugin-event is routed correctly.
301 virtual void FirePluginEvent( cbPluginEvent
& event
);
303 // captures/releases user-input event's for the given plugin
304 // Input events are: mouse movement, mouse clicks, keyboard input
306 virtual void CaptureEventsForPlugin ( cbPluginBase
* pPlugin
);
307 virtual void ReleaseEventsFromPlugin( cbPluginBase
* pPlugin
);
309 // called by plugins ( also captures/releases mouse in parent frame)
310 void CaptureEventsForPane( cbDockPane
* toPane
);
311 void ReleaseEventsFromPane( cbDockPane
* fromPane
);
313 // returns current top-level plugin (the one which receives events first,
314 // with an exception if input-events are currently captured by some other plugin)
316 virtual cbPluginBase
& GetTopPlugin();
318 // hooking custom plugins to frame layout
320 // NOTE:: when hooking one plugin on top of the other -
321 // use SetNextHandler(..) or similar methods
322 // of wxEvtHandler class to compose the chain of plugins,
323 // than pass the left-most handler in this chain to
324 // the above methods (assuming that events are delegated
325 // from left-most towards right-most handler)
327 // NOTE2:: this secenario is very inconvenient and "low-level",
328 // use Add/Push/PopPlugin methods instead
330 virtual void SetTopPlugin( cbPluginBase
* pPlugin
);
332 // similar to wxWindow's "push/pop-event-handler" methods, execept
333 // that plugin is *deleted* upon "popping"
335 virtual void PushPlugin( cbPluginBase
* pPugin
);
336 virtual void PopPlugin();
338 virtual void PopAllPlugins();
340 // default plugins are : cbPaneDrawPlugin, cbRowLayoutPlugin, cbBarDragPlugin,
341 // cbAntiflickerPlugin, cbSimpleCustomizePlugin
343 // this method is automatically invoked, if no plugins were found upon
344 // fireing of the first plugin-event, i.e. wxFrameLayout *CONFIGURES* itself
346 virtual void PushDefaultPlugins();
348 /* "Advanced" methods for plugin-configuration using their */
349 /* dynamic class information (e.g. CLASSINFO(pluginClass) ) */
351 // first checks if plugin of the given class is already "hooked up",
352 // if not, adds it to the top of plugins chain
354 virtual void AddPlugin( wxClassInfo
* pPlInfo
, int paneMask
= wxALL_PANES
);
356 // first checks if plugin of the givne class already hooked,
357 // if so, removes it, and then inserts it to the chain
358 // before plugin of the class given by "pNextPlInfo"
360 // NOTE:: this method is "handy" in some cases, where the order
361 // of plugin-chain could be important, e.g. one plugin overrides
362 // some functionallity of the other already hooked plugin,
363 // thefore the former should be hooked before the one
364 // who's functionality is being overriden
366 virtual void AddPluginBefore( wxClassInfo
* pNextPlInfo
, wxClassInfo
* pPlInfo
,
367 int paneMask
= wxALL_PANES
);
369 // checks if plugin of the given class is hooked, removes
372 // @param pPlInfo class information structure for the plugin
374 // @see wxFrameLayout::Method
377 virtual void RemovePlugin( wxClassInfo
* pPlInfo
);
379 // returns NULL, if plugin of the given class is not hooked
381 virtual cbPluginBase
* FindPlugin( wxClassInfo
* pPlInfo
);
385 DECLARE_EVENT_TABLE()
386 DECLARE_DYNAMIC_CLASS( wxFrameLayout
)
388 public: /* protected really, acessed only by plugins and serializers */
390 friend class cbDockPane
;
391 friend class wxBarHandler
;
393 wxWindow
* mpFrame
; // parent frame
394 wxWindow
* mpFrameClient
; // client window
395 cbDockPane
* mPanes
[MAX_PANES
]; // panes in the panel
398 wxCursor
* mpHorizCursor
;
399 wxCursor
* mpVertCursor
;
400 wxCursor
* mpNormalCursor
;
401 wxCursor
* mpDragCursor
;
402 wxCursor
* mpNECursor
; // no-entry cursor
404 // pens for decoration and shades
406 wxPen mDarkPen
; // default wxSYS_COLOUR_3DSHADOW
407 wxPen mLightPen
; // default wxSYS_COLOUR_3DHILIGHT
408 wxPen mGrayPen
; // default wxSYS_COLOUR_3DFACE
409 wxPen mBlackPen
; // default wxColour( 0, 0, 0)
410 wxPen mBorderPen
; // default wxSYS_COLOUR_3DFACE
412 wxPen mNullPen
; // transparent pen
414 // pane to which the all mouse input is currently directed (caputred)
416 cbDockPane
* mpPaneInFocus
;
418 // pane, from which mouse pointer had just left
420 cbDockPane
* mpLRUPane
;
422 // bounds of client window in parent frame's coordinates
424 wxRect mClntWndBounds
;
425 wxRect mPrevClntWndBounds
;
428 wxPoint mNextFloatedWndPos
;
429 wxSize mFloatingPosStep
;
431 // current plugin (right-most) plugin which receives events first
433 cbPluginBase
* mpTopPlugin
;
435 // plugin, which currently has captured all input events, otherwise NULL
437 cbPluginBase
* mpCaputesInput
;
439 // list of event handlers which are "pushed" onto each bar, to catch
440 // mouse events which are not handled by bars, and froward them to the ,
441 // frome-layout and further to plugins
445 // list of top-most frames which contain floated bars
447 wxList mFloatedFrames
;
449 // linked list of references to all bars (docked/floated/hidden)
453 // FOR NOW:: dirty stuff...
454 bool mClientWndRefreshPending
;
456 bool mCheckFocusWhenIdle
;
458 public: /* protected really (accessed only by plugins) */
460 // refrence to custom updates manager
461 cbUpdatesManagerBase
* mpUpdatesMgr
;
463 // called to set calculated layout to window objects
464 void PositionClientWindow();
465 void PositionPanes();
466 void CreateCursors();
468 void RepositionFloatedBar( cbBarInfo
* pBar
);
469 void DoSetBarState( cbBarInfo
* pBar
);
471 bool LocateBar( cbBarInfo
* pBarInfo
,
473 cbDockPane
** ppPane
);
476 bool HitTestPane( cbDockPane
* pPane
, int x
, int y
);
477 cbDockPane
* HitTestPanes( const wxRect
& rect
, cbDockPane
* pCurPane
);
479 // returns panes, to which the given bar belongs
481 cbDockPane
* GetBarPane( cbBarInfo
* pBar
);
483 // delegated from "bar-spy"
484 void ForwardMouseEvent( wxMouseEvent
& event
,
488 void RouteMouseEvent( wxMouseEvent
& event
, int pluginEvtType
);
490 void ShowFloatedWindows( bool show
);
492 void UnhookFromFrame();
493 void HookUpToFrame();
495 // NOTE:: reparenting of windows may NOT work on all platforms
496 // (reparenting allows control-bars to be floated)
499 void ReparentWindow( wxWindow
* pChild
, wxWindow
* pNewParent
);
501 wxRect
& GetPrevClientRect() { return mPrevClntWndBounds
; }
503 void OnPaint( wxPaintEvent
& event
);
504 void OnEraseBackground( wxEraseEvent
& event
);
505 void OnKillFocus( wxFocusEvent
& event
);
506 void OnSetFocus( wxFocusEvent
& event
);
507 void OnActivate( wxActivateEvent
& event
);
508 void OnIdle( wxIdleEvent
& event
);
511 virtual cbUpdatesManagerBase
* CreateUpdatesManager();
514 /* structure, which is present in each item of layout,
515 * it used by any specific updates-manager to store
516 * auxilary information to be used by it's specific
520 class cbUpdateMgrData
: public wxObject
522 DECLARE_DYNAMIC_CLASS( cbUpdateMgrData
)
524 wxRect mPrevBounds
; // previous state of layout item (in parent frame's coordinates)
526 bool mIsDirty
; // overrides result of current-against-previous bounds comparison,
527 // i.e. requires item to be updated, regardless of it's current area
529 wxObject
* mpCustomData
; // any custom data stored by specific updates mgr.
531 cbUpdateMgrData(); // is-dirty flag is set TRUE initially
533 void StoreItemState( const wxRect
& boundsInParent
);
535 void SetDirty( bool isDirty
= TRUE
);
537 void SetCustomData( wxObject
* pCustomData
);
539 inline bool IsDirty() { return mIsDirty
; }
542 /* Abstract interface for bar-size handler classes.
543 * These objects receive notifications, whenever the docking
544 * state of the bar is changed, thus they have a possibility
545 * to adjust the values in cbDimInfo::mSizes accordingly.
546 * Specific handlers can be hooked to specific types of bars.
549 class cbBarDimHandlerBase
: public wxObject
551 DECLARE_ABSTRACT_CLASS( cbBarDimHandlerBase
)
554 int mRefCount
; // since one dim-handler can be assigned
555 // to multiple bars, it's instance is
559 // initial reference count is 0, since handler is not used, until the
560 // first invocation of AddRef()
562 cbBarDimHandlerBase();
567 // "bar-state-changes" notification
568 virtual void OnChangeBarState(cbBarInfo
* pBar
, int newState
) = 0;
569 virtual void OnResizeBar( cbBarInfo
* pBar
, const wxSize
& given
, wxSize
& preferred
) = 0;
572 /* helper classes (used internally by wxFrameLayout class) */
574 // holds and manages information about bar dimensions
576 class cbDimInfo
: public wxObject
578 DECLARE_DYNAMIC_CLASS( cbDimInfo
)
580 wxSize mSizes
[MAX_BAR_STATES
]; // preferred sizes for each possible bar state
582 wxRect mBounds
[MAX_BAR_STATES
]; // saved positions and sizes for each
583 // possible state, values contain (-1)s if
584 // not initialized yet
586 int mLRUPane
; // pane to which this bar was docked before it was floated
587 // (FL_ALIGN_TOP,FL_ALIGN_BOTTOM,..)
589 // top/bottom gap, separates decorations
590 // from the bar's actual window, filled
591 // with frame's beckground color, default: 0
595 // left/right gap, separates decorations
596 // from the bar's actual window, filled
597 // with frame's beckground colour, default: 0
599 int mHorizGap
; // NOTE:: gaps are given in frame's coord. orientation
601 // TRUE, if vertical/horizotal dimensions cannot be mannualy adjusted
602 // by user using resizing handles. If FALSE, the frame-layout
603 // *automatically* places resizing handles among not-fixed bars
607 cbBarDimHandlerBase
* mpHandler
; // NULL, if no handler present
613 cbDimInfo( cbBarDimHandlerBase
* pDimHandler
,
614 bool isFixed
// (see comments on mIsFixed member)
617 cbDimInfo( int dh_x
, int dh_y
, // dims when docked horizontally
618 int dv_x
, int dv_y
, // dims when docked vertically
619 int f_x
, int f_y
, // dims when floating
621 bool isFixed
= TRUE
,// (see comments on mIsFixed member)
622 int horizGap
= 6, // (see comments on mHorizGap member)
623 int vertGap
= 6, // -/-
625 cbBarDimHandlerBase
* pDimHandler
= NULL
628 cbDimInfo( int x
, int y
,
631 cbBarDimHandlerBase
* pDimHandler
= NULL
634 const cbDimInfo
& operator=( const cbDimInfo
& other
);
636 // destroys handler automatically, if present
639 inline cbBarDimHandlerBase
* GetDimHandler() { return mpHandler
; }
642 WX_DEFINE_ARRAY(float, cbArrayFloat
);
644 class cbRowInfo
: public wxObject
646 DECLARE_DYNAMIC_CLASS( cbRowInfo
)
649 BarArrayT mBars
; // row content
651 // row flags (set up according to row-relations)
653 bool mHasUpperHandle
;
654 bool mHasLowerHandle
;
655 bool mHasOnlyFixedBars
;
656 int mNotFixedBarsCnt
;
662 // stores precalculated row's bounds in parent frame's coordinates
663 wxRect mBoundsInParent
;
665 // info stored for updates-manager
666 cbUpdateMgrData mUMgrData
;
671 cbBarInfo
* mpExpandedBar
; // NULL, if non of the bars is currently expanded
673 cbArrayFloat mSavedRatios
; // length-ratios bofore some of the bars was expanded
680 // convenience method
682 inline cbBarInfo
* GetFirstBar()
684 { return mBars
.GetCount() ? mBars
[0] : NULL
; }
687 class cbBarInfo
: public wxObject
689 DECLARE_DYNAMIC_CLASS( cbBarInfo
)
691 // textual name, by which this bar is refered in layout-customization dialogs
694 // stores bar's bounds in pane's coordinates
697 // stores precalculated bar's bounds in parent frame's coordinates
698 wxRect mBoundsInParent
;
700 // back-ref to the row, which contains this bar
703 // are set up according to the types of the surrounding bars in the row
705 bool mHasRightHandle
;
707 cbDimInfo mDimInfo
; // preferred sizes for each, control bar state
709 int mState
; // (see definition of controlbar states)
711 int mAlignment
; // alignment of the pane to which this
712 // bar is currently placed
714 int mRowNo
; // row, into which this bar would be placed,
715 // when in the docking state
717 wxWindow
* mpBarWnd
; // the actual window object, NULL if no window
718 // is attached to the control bar (possible!)
720 double mLenRatio
; // length ratio among not-fixed-size bars
722 wxPoint mPosIfFloated
; // stored last position when bar was in "floated" state
723 // poistion is stored in parent-window's coordinates
725 cbUpdateMgrData mUMgrData
; // info stored for updates-manager
727 cbBarInfo
* mpNext
; // next. bar in the row
728 cbBarInfo
* mpPrev
; // prev. bar in the row
735 inline bool IsFixed() const { return mDimInfo
.mIsFixed
; }
737 inline bool IsExpanded() const { return this == mpRow
->mpExpandedBar
; }
740 // used for storing original bar's postions in the row, when the "non-destructive-friction"
741 // option is turned ON
743 class cbBarShapeData
: public wxObject
750 // used for traversing through all bars of all rows in the pane
759 wxBarIterator( RowArrayT
& rows
);
762 bool Next(); // TRUE, if next bar is available
764 cbBarInfo
& BarInfo();
766 // returns reference to currently traversed row
767 cbRowInfo
& RowInfo();
770 /* structure holds configuration options,
771 * which are usually the same for all panes in
775 class cbCommonPaneProperties
: public wxObject
777 DECLARE_DYNAMIC_CLASS( cbCommonPaneProperties
)
779 // look-and-feel configuration
781 bool mRealTimeUpdatesOn
; // default: ON
782 bool mOutOfPaneDragOn
; // default: ON
783 bool mExactDockPredictionOn
; // default: OFF
784 bool mNonDestructFirctionOn
; // default: OFF
786 bool mShow3DPaneBorderOn
; // default: ON
788 // FOR NOW:: the below properties are reserved for the "future"
790 bool mBarFloatingOn
; // default: OFF
791 bool mRowProportionsOn
; // default: OFF
792 bool mColProportionsOn
; // default: ON
793 bool mBarCollapseIconsOn
; // default: OFF
794 bool mBarDragHintsOn
; // default: OFF
796 // minimal dimensions for not-fixed bars in this pane (16x16 default)
800 // width/height of resizing sash
802 int mResizeHandleSize
;
804 cbCommonPaneProperties(void);
807 /* class manages containment and control of control-bars
808 * along one of the four edges of the parent frame
811 class cbDockPane
: public wxObject
814 DECLARE_DYNAMIC_CLASS( cbDockPane
)
816 // look-and-feel configuration for this pane
817 cbCommonPaneProperties mProps
;
819 // pane margins (in frame's coordinate-syst. orientation)
821 int mLeftMargin
; // default: 2 pixels
822 int mRightMargin
; // default: 2 pixels
823 int mTopMargin
; // default: 2 pixels
824 int mBottomMargin
; // default: 2 pixels
827 // position of the pane in frame's coordinates
828 wxRect mBoundsInParent
;
830 // pane width and height in pane's coordinates
836 // info stored for updates-manager
837 cbUpdateMgrData mUMgrData
;
839 public: /* protected really */
842 wxFrameLayout
* mpLayout
; // back-ref
844 // transient properties
846 wxList mRowShapeData
; // shapes of bars of recently modified row,
847 // stored when in "non-destructive-firction" mode
848 cbRowInfo
* mpStoredRow
; // row-info for which the shapes are stored
850 friend class wxFrameLayout
;
852 public: /* protected really (accessed only by plugins) */
854 cbRowInfo
* GetRow( int row
);
856 int GetRowIndex( cbRowInfo
* pRow
);
858 // return -1, if row is not present at given vertical position
859 int GetRowAt( int paneY
);
860 int GetRowAt( int upperY
, int lowerY
);
862 // re-setups flags in the row-information structure, so that
863 // the would match the changed state of row-items correctly
864 void SyncRowFlags( cbRowInfo
* pRow
);
866 // layout "AI" helpers:
868 bool IsFixedSize( cbBarInfo
* pInfo
);
869 int GetNotFixedBarsCount( cbRowInfo
* pRow
);
871 int GetRowWidth( wxList
* pRow
);
873 int GetRowY( cbRowInfo
* pRow
);
875 bool HasNotFixedRowsAbove( cbRowInfo
* pRow
);
876 bool HasNotFixedRowsBelow( cbRowInfo
* pRow
);
877 bool HasNotFixedBarsLeft ( cbBarInfo
* pBar
);
878 bool HasNotFixedBarsRight( cbBarInfo
* pBar
);
880 virtual void CalcLengthRatios( cbRowInfo
* pInRow
);
881 virtual void RecalcRowLayout( cbRowInfo
* pRow
);
883 virtual void ExpandBar( cbBarInfo
* pBar
);
884 virtual void ContractBar( cbBarInfo
* pBar
);
886 void InitLinksForRow( cbRowInfo
* pRow
);
887 void InitLinksForRows();
889 // coordinate translation between parent's frame and this pane
891 void FrameToPane( int* x
, int* y
);
892 void PaneToFrame( int* x
, int* y
);
893 void FrameToPane( wxRect
* pRect
);
894 void PaneToFrame( wxRect
* pRect
);
896 inline bool HasPoint( const wxPoint
& pos
, int x
, int y
, int width
, int height
);
898 int GetMinimalRowHeight( cbRowInfo
* pRow
);
900 // given row height includes height of row handles, if present
901 void SetRowHeight( cbRowInfo
* pRow
, int newHeight
);
903 void DoInsertBar( cbBarInfo
* pBar
, int rowNo
);
905 public: /* protected really (accessed only by plugins) */
907 // methods for incramental on-screen refreshing of the pane
908 // (simply, they are wrappers around corresponding plugin-events)
910 virtual void PaintBarDecorations( cbBarInfo
* pBar
, wxDC
& dc
);
911 virtual void PaintBarHandles( cbBarInfo
* pBar
, wxDC
& dc
);
912 virtual void PaintBar( cbBarInfo
* pBar
, wxDC
& dc
);
913 virtual void PaintRowHandles( cbRowInfo
* pRow
, wxDC
& dc
);
914 virtual void PaintRowBackground ( cbRowInfo
* pRow
, wxDC
& dc
);
915 virtual void PaintRowDecorations( cbRowInfo
* pRow
, wxDC
& dc
);
916 virtual void PaintRow( cbRowInfo
* pRow
, wxDC
& dc
);
917 virtual void PaintPaneBackground( wxDC
& dc
);
918 virtual void PaintPaneDecorations( wxDC
& dc
);
919 virtual void PaintPane( wxDC
& dc
);
920 virtual void SizeBar( cbBarInfo
* pBar
);
921 virtual void SizeRowObjects( cbRowInfo
* pRow
);
922 virtual void SizePaneObjects();
924 virtual wxDC
* StartDrawInArea ( const wxRect
& area
);
925 virtual void FinishDrawInArea( const wxRect
& area
);
927 public: /* public members */
931 cbDockPane( int alignment
, wxFrameLayout
* pPanel
);
933 // sets pane's margins in frame's coordinate orientations
934 void SetMargins( int top
, int bottom
, int left
, int right
);
936 virtual ~cbDockPane();
938 // does not destroys the info bar , only removes it's reference
941 virtual void RemoveBar( cbBarInfo
* pBar
);
943 // rect given in the parent frame's coordinates
945 virtual void InsertBar( cbBarInfo
* pBar
, const wxRect
& atRect
);
947 // inserts bar into the given row, with dimensions and position
948 // stored in pBarInfo->mBounds. Returns the node of inserted bar
950 virtual void InsertBar( cbBarInfo
* pBar
, cbRowInfo
* pIntoRow
);
952 // inserts bar, sets its position according to the preferred settings
953 // given in (*pBarInfo) structure
955 virtual void InsertBar( cbBarInfo
* pBarInfo
);
957 // does not destroy the row object, only removes the corresponding
958 // node from this pane
959 virtual void RemoveRow( cbRowInfo
* pRow
);
961 // does not refresh the inserted row immediately,
962 // if pBeforeRowNode arg. is NULL, row is appended to the end of pane's row list
963 virtual void InsertRow( cbRowInfo
* pRow
, cbRowInfo
* pBeforeRow
);
965 // sets pane's width in pane's coordinates (including margins)
966 void SetPaneWidth(int width
);
968 // set the position and dims. of the pane in parent frame's coordinates
969 void SetBoundsInParent( const wxRect
& rect
);
971 inline wxRect
& GetRealRect() { return mBoundsInParent
; }
973 // used by updates-managers
974 inline RowArrayT
& GetRowList() { return mRows
; }
976 // convenience method
978 inline cbRowInfo
* GetFirstRow()
980 { return mRows
.GetCount() ? mRows
[0] : NULL
; }
982 // TRUE, if the given bar node presents in this pane
984 bool BarPresent( cbBarInfo
* pBar
);
986 // retuns height, in pane's coordinates
991 bool MatchesMask( int paneMask
);
993 inline bool IsHorizontal()
995 return (mAlignment
== FL_ALIGN_TOP
||
996 mAlignment
== FL_ALIGN_BOTTOM
);
999 virtual void RecalcLayout();
1001 virtual int GetDockingState();
1003 // returns result of hit-testing items in the pane,
1004 // see CB_HITTEST_RESULTS enumeration
1006 virtual int HitTestPaneItems( const wxPoint
& pos
, // position in pane's coordinates
1011 void GetBarResizeRange( cbBarInfo
* pBar
, int* from
, int *till
, bool forLeftHandle
);
1012 void GetRowResizeRange( cbRowInfo
* pRow
, int* from
, int* till
, bool forUpperHandle
);
1014 cbBarInfo
* GetBarInfoByWindow( wxWindow
* pBarWnd
);
1016 public: /* protected really (accessed only by plugins) */
1018 // row/bar resizing related helper-methods
1020 void DrawVertHandle ( wxDC
& dc
, int x
, int y
, int height
);
1021 void DrawHorizHandle( wxDC
& dc
, int x
, int y
, int width
);
1023 void ResizeRow( cbRowInfo
* pRow
, int ofs
, bool forUpperHandle
);
1024 void ResizeBar( cbBarInfo
* pBar
, int ofs
, bool forLeftHandle
);
1026 // cbBarShapeData objects will be placed to given pLst (see comments on cbBarShapeData)
1028 void GetRowShapeData( cbRowInfo
* pRow
, wxList
* pLst
);
1030 // sets the shape to the given row, using the data provided in pLst
1031 void SetRowShapeData( cbRowInfo
* pRowNode
, wxList
* pLst
);
1035 * class declares abstract interface for optimized logic, which should refresh
1036 * areas of frame layout - that actually need to be updated. Should be extended,
1037 * to implement custom updating strategy
1040 class cbUpdatesManagerBase
: public wxObject
1042 DECLARE_ABSTRACT_CLASS( cbUpdatesManagerBase
)
1044 public: /* protected really, accessed by serializer (if any) */
1046 wxFrameLayout
* mpLayout
;
1049 cbUpdatesManagerBase(void)
1052 cbUpdatesManagerBase( wxFrameLayout
* pPanel
)
1053 : mpLayout( pPanel
) {}
1055 virtual ~cbUpdatesManagerBase() {}
1057 void SetLayout( wxFrameLayout
* pLayout
) { mpLayout
= pLayout
; }
1059 // notificiactions received from frame-layout (in the order, in which
1060 // they usually would be invoked). Custom updates-managers may utilize
1061 // these notifications to implement more "fine-grained" updating strategy
1063 virtual void OnStartChanges() = 0;
1065 virtual void OnRowWillChange( cbRowInfo
* pRow
, cbDockPane
* pInPane
) {}
1066 virtual void OnBarWillChange( cbBarInfo
* pBar
, cbRowInfo
* pInRow
, cbDockPane
* pInPane
) {}
1067 virtual void OnPaneMarginsWillChange( cbDockPane
* pPane
) {}
1068 virtual void OnPaneWillChange( cbDockPane
* pPane
) {}
1070 virtual void OnFinishChanges() {}
1072 // refreshes parts of the frame layout, which need an update
1073 virtual void UpdateNow() = 0;
1076 /*------------------------------------------------------------
1077 * "API" for developing custom plugins of Frame Layout Engine
1078 * TODO:: documentation
1079 *------------------------------------------------------------
1082 // base class for all control-bar plugin events
1084 class cbPluginEvent
: public wxEvent
1086 // NOTE:: plugin-event does not need to be a dynamic class
1089 cbDockPane
* mpPane
; // NULL, if event is not addressed to any specific pane
1092 // FOR NOW FOR NOW:: all-in-one plugin event structure
1094 wxNode* mpObjNodeAux;
1101 #if wxCHECK_VERSION(2,3,0)
1102 cbPluginEvent( wxEventType eventType
, cbDockPane
* pPane
)
1105 { m_eventType
= eventType
; }
1107 cbPluginEvent( int eventType
, cbDockPane
* pPane
)
1110 { m_eventType
= eventType
; }
1114 // event types handled by plugins
1116 #if wxCHECK_VERSION(2,3,0)
1118 extern wxEventType cbEVT_PL_LEFT_DOWN
;
1119 extern wxEventType cbEVT_PL_LEFT_UP
;
1120 extern wxEventType cbEVT_PL_RIGHT_DOWN
;
1121 extern wxEventType cbEVT_PL_RIGHT_UP
;
1122 extern wxEventType cbEVT_PL_MOTION
;
1124 extern wxEventType cbEVT_PL_LEFT_DCLICK
;
1126 extern wxEventType cbEVT_PL_LAYOUT_ROW
;
1127 extern wxEventType cbEVT_PL_RESIZE_ROW
;
1128 extern wxEventType cbEVT_PL_LAYOUT_ROWS
;
1129 extern wxEventType cbEVT_PL_INSERT_BAR
;
1130 extern wxEventType cbEVT_PL_RESIZE_BAR
;
1131 extern wxEventType cbEVT_PL_REMOVE_BAR
;
1132 extern wxEventType cbEVT_PL_SIZE_BAR_WND
;
1134 extern wxEventType cbEVT_PL_DRAW_BAR_DECOR
;
1135 extern wxEventType cbEVT_PL_DRAW_ROW_DECOR
;
1136 extern wxEventType cbEVT_PL_DRAW_PANE_DECOR
;
1137 extern wxEventType cbEVT_PL_DRAW_BAR_HANDLES
;
1138 extern wxEventType cbEVT_PL_DRAW_ROW_HANDLES
;
1139 extern wxEventType cbEVT_PL_DRAW_ROW_BKGROUND
;
1140 extern wxEventType cbEVT_PL_DRAW_PANE_BKGROUND
;
1142 extern wxEventType cbEVT_PL_START_BAR_DRAGGING
;
1143 extern wxEventType cbEVT_PL_DRAW_HINT_RECT
;
1145 extern wxEventType cbEVT_PL_START_DRAW_IN_AREA
;
1146 extern wxEventType cbEVT_PL_FINISH_DRAW_IN_AREA
;
1148 extern wxEventType cbEVT_PL_CUSTOMIZE_BAR
;
1149 extern wxEventType cbEVT_PL_CUSTOMIZE_LAYOUT
;
1151 extern wxEventType wxCUSTOM_CB_PLUGIN_EVENTS_START_AT
;
1155 #define cbEVT_PL_LEFT_DOWN 0
1156 #define cbEVT_PL_LEFT_UP 1
1157 #define cbEVT_PL_RIGHT_DOWN 2
1158 #define cbEVT_PL_RIGHT_UP 3
1159 #define cbEVT_PL_MOTION 4
1161 #define cbEVT_PL_LEFT_DCLICK 5
1163 #define cbEVT_PL_LAYOUT_ROW 6
1164 #define cbEVT_PL_RESIZE_ROW 7
1165 #define cbEVT_PL_LAYOUT_ROWS 8
1166 #define cbEVT_PL_INSERT_BAR 9
1167 #define cbEVT_PL_RESIZE_BAR 10
1168 #define cbEVT_PL_REMOVE_BAR 11
1169 #define cbEVT_PL_SIZE_BAR_WND 12
1171 #define cbEVT_PL_DRAW_BAR_DECOR 13
1172 #define cbEVT_PL_DRAW_ROW_DECOR 14
1173 #define cbEVT_PL_DRAW_PANE_DECOR 15
1174 #define cbEVT_PL_DRAW_BAR_HANDLES 16
1175 #define cbEVT_PL_DRAW_ROW_HANDLES 17
1176 #define cbEVT_PL_DRAW_ROW_BKGROUND 18
1177 #define cbEVT_PL_DRAW_PANE_BKGROUND 19
1179 #define cbEVT_PL_START_BAR_DRAGGING 20
1180 #define cbEVT_PL_DRAW_HINT_RECT 21
1182 #define cbEVT_PL_START_DRAW_IN_AREA 22
1183 #define cbEVT_PL_FINISH_DRAW_IN_AREA 23
1185 #define cbEVT_PL_CUSTOMIZE_BAR 24
1186 #define cbEVT_PL_CUSTOMIZE_LAYOUT 25
1188 #define wxCUSTOM_CB_PLUGIN_EVENTS_START_AT 100
1190 #endif // wxCHECK_VERSION(2,3,0) else
1192 // forward decls, separated by categories
1194 class cbLeftDownEvent
;
1195 class cbLeftUpEvent
;
1196 class cbRightDownEvent
;
1197 class cbRightUpEvent
;
1198 class cbMotionEvent
;
1199 class cbLeftDClickEvent
;
1201 class cbLayoutRowEvent
;
1202 class cbResizeRowEvent
;
1203 class cbLayoutRowsEvent
;
1204 class cbInsertBarEvent
;
1205 class cbResizeBarEvent
;
1206 class cbRemoveBarEvent
;
1207 class cbSizeBarWndEvent
;
1209 class cbDrawBarDecorEvent
;
1210 class cbDrawRowDecorEvent
;
1211 class cbDrawPaneDecorEvent
;
1212 class cbDrawBarHandlesEvent
;
1213 class cbDrawRowHandlesEvent
;
1214 class cbDrawRowBkGroundEvent
;
1215 class cbDrawPaneBkGroundEvent
;
1217 class cbStartBarDraggingEvent
;
1218 class cbDrawHintRectEvent
;
1220 class cbStartDrawInAreaEvent
;
1221 class cbFinishDrawInAreaEvent
;
1223 class cbCustomizeBarEvent
;
1224 class cbCustomizeLayoutEvent
;
1226 // defs. for handler-methods
1228 typedef void (wxEvtHandler::*cbLeftDownHandler
)(cbLeftDownEvent
&);
1229 typedef void (wxEvtHandler::*cbLeftUpHandler
)(cbLeftUpEvent
&);
1230 typedef void (wxEvtHandler::*cbRightDownHandler
)(cbRightDownEvent
&);
1231 typedef void (wxEvtHandler::*cbRightUpHandler
)(cbRightUpEvent
&);
1232 typedef void (wxEvtHandler::*cbMotionHandler
)(cbMotionEvent
&);
1233 typedef void (wxEvtHandler::*cbLeftDClickHandler
)(cbLeftDClickEvent
&);
1235 typedef void (wxEvtHandler::*cbLayoutRowHandler
)(cbLayoutRowEvent
&);
1236 typedef void (wxEvtHandler::*cbResizeRowHandler
)(cbResizeRowEvent
&);
1237 typedef void (wxEvtHandler::*cbLayoutRowsHandler
)(cbLayoutRowsEvent
&);
1238 typedef void (wxEvtHandler::*cbInsertBarHandler
)(cbInsertBarEvent
&);
1239 typedef void (wxEvtHandler::*cbResizeBarHandler
)(cbResizeBarEvent
&);
1240 typedef void (wxEvtHandler::*cbRemoveBarHandler
)(cbRemoveBarEvent
&);
1241 typedef void (wxEvtHandler::*cbSizeBarWndHandler
)(cbSizeBarWndEvent
&);
1243 typedef void (wxEvtHandler::*cbDrawBarDecorHandler
)(cbDrawBarDecorEvent
&);
1244 typedef void (wxEvtHandler::*cbDrawRowDecorHandler
)(cbDrawRowDecorEvent
&);
1245 typedef void (wxEvtHandler::*cbDrawPaneDecorHandler
)(cbDrawPaneDecorEvent
&);
1246 typedef void (wxEvtHandler::*cbDrawBarHandlesHandler
)(cbDrawBarHandlesEvent
&);
1247 typedef void (wxEvtHandler::*cbDrawRowHandlesHandler
)(cbDrawRowHandlesEvent
&);
1248 typedef void (wxEvtHandler::*cbDrawRowBkGroundHandler
)(cbDrawRowBkGroundEvent
&);
1249 typedef void (wxEvtHandler::*cbDrawPaneBkGroundHandler
)(cbDrawPaneBkGroundEvent
&);
1251 typedef void (wxEvtHandler::*cbStartBarDraggingHandler
)(cbStartBarDraggingEvent
&);
1252 typedef void (wxEvtHandler::*cbDrawHintRectHandler
)(cbDrawHintRectEvent
&);
1254 typedef void (wxEvtHandler::*cbStartDrawInAreaHandler
)(cbStartDrawInAreaEvent
&);
1255 typedef void (wxEvtHandler::*cbFinishDrawInAreaHandler
)(cbFinishDrawInAreaEvent
&);
1257 typedef void (wxEvtHandler::*cbCustomizeBarHandler
)(cbCustomizeBarEvent
&);
1258 typedef void (wxEvtHandler::*cbCustomizeLayoutHandler
)(cbCustomizeLayoutEvent
&);
1260 // macros for creating event table entries for plugin-events
1262 #if wxCHECK_VERSION(2,3,0)
1263 #define EVT_PL_LEFT_DOWN(func) wxEventTableEntry( cbEVT_PL_LEFT_DOWN, -1, -1, (wxObjectEventFunction) (wxEventFunction) (cbLeftDownHandler ) & func, (wxObject *) NULL ),
1264 #define EVT_PL_LEFT_UP(func) wxEventTableEntry( cbEVT_PL_LEFT_UP, -1, -1, (wxObjectEventFunction) (wxEventFunction) (cbLeftUpHandler ) & func, (wxObject *) NULL ),
1265 #define EVT_PL_RIGHT_DOWN(func) wxEventTableEntry( cbEVT_PL_RIGHT_DOWN, -1, -1, (wxObjectEventFunction) (wxEventFunction) (cbRightDownHandler ) & func, (wxObject *) NULL ),
1266 #define EVT_PL_RIGHT_UP(func) wxEventTableEntry( cbEVT_PL_RIGHT_UP, -1, -1, (wxObjectEventFunction) (wxEventFunction) (cbRightUpHandler ) & func, (wxObject *) NULL ),
1267 #define EVT_PL_MOTION(func) wxEventTableEntry( cbEVT_PL_MOTION, -1, -1, (wxObjectEventFunction) (wxEventFunction) (cbMotionHandler ) & func, (wxObject *) NULL ),
1268 #define EVT_PL_LEFT_DCLICK(func) wxEventTableEntry( cbEVT_PL_LEFT_DCLICK, -1, -1, (wxObjectEventFunction) (wxEventFunction) (cbLeftDClickHandler ) & func, (wxObject *) NULL ),
1270 #define EVT_PL_LAYOUT_ROW(func) wxEventTableEntry( cbEVT_PL_LAYOUT_ROW, -1, -1, (wxObjectEventFunction) (wxEventFunction) (cbLayoutRowHandler ) & func, (wxObject *) NULL ),
1271 #define EVT_PL_RESIZE_ROW(func) wxEventTableEntry( cbEVT_PL_RESIZE_ROW, -1, -1, (wxObjectEventFunction) (wxEventFunction) (cbResizeRowHandler ) & func, (wxObject *) NULL ),
1272 #define EVT_PL_LAYOUT_ROWS(func) wxEventTableEntry( cbEVT_PL_LAYOUT_ROWS, -1, -1, (wxObjectEventFunction) (wxEventFunction) (cbLayoutRowsHandler ) & func, (wxObject *) NULL ),
1273 #define EVT_PL_INSERT_BAR(func) wxEventTableEntry( cbEVT_PL_INSERT_BAR, -1, -1, (wxObjectEventFunction) (wxEventFunction) (cbInsertBarHandler ) & func, (wxObject *) NULL ),
1274 #define EVT_PL_RESIZE_BAR(func) wxEventTableEntry( cbEVT_PL_RESIZE_BAR, -1, -1, (wxObjectEventFunction) (wxEventFunction) (cbResizeBarHandler ) & func, (wxObject *) NULL ),
1275 #define EVT_PL_REMOVE_BAR(func) wxEventTableEntry( cbEVT_PL_REMOVE_BAR, -1, -1, (wxObjectEventFunction) (wxEventFunction) (cbRemoveBarHandler ) & func, (wxObject *) NULL ),
1276 #define EVT_PL_SIZE_BAR_WND(func) wxEventTableEntry( cbEVT_PL_SIZE_BAR_WND, -1, -1, (wxObjectEventFunction) (wxEventFunction) (cbSizeBarWndHandler ) & func, (wxObject *) NULL ),
1278 #define EVT_PL_DRAW_BAR_DECOR(func) wxEventTableEntry( cbEVT_PL_DRAW_BAR_DECOR, -1, -1, (wxObjectEventFunction) (wxEventFunction) (cbDrawBarDecorHandler ) & func, (wxObject *) NULL ),
1279 #define EVT_PL_DRAW_ROW_DECOR(func) wxEventTableEntry( cbEVT_PL_DRAW_ROW_DECOR, -1, -1, (wxObjectEventFunction) (wxEventFunction) (cbDrawRowDecorHandler ) & func, (wxObject *) NULL ),
1280 #define EVT_PL_DRAW_PANE_DECOR(func) wxEventTableEntry( cbEVT_PL_DRAW_PANE_DECOR, -1, -1, (wxObjectEventFunction) (wxEventFunction) (cbDrawPaneDecorHandler ) & func, (wxObject *) NULL ),
1281 #define EVT_PL_DRAW_BAR_HANDLES(func) wxEventTableEntry( cbEVT_PL_DRAW_BAR_HANDLES, -1, -1, (wxObjectEventFunction) (wxEventFunction) (cbDrawBarHandlesHandler ) & func, (wxObject *) NULL ),
1282 #define EVT_PL_DRAW_ROW_HANDLES(func) wxEventTableEntry( cbEVT_PL_DRAW_ROW_HANDLES, -1, -1, (wxObjectEventFunction) (wxEventFunction) (cbDrawRowHandlesHandler ) & func, (wxObject *) NULL ),
1283 #define EVT_PL_DRAW_ROW_BKGROUND(func) wxEventTableEntry( cbEVT_PL_DRAW_ROW_BKGROUND, -1, -1, (wxObjectEventFunction) (wxEventFunction) (cbDrawRowBkGroundHandler ) & func, (wxObject *) NULL ),
1284 #define EVT_PL_DRAW_PANE_BKGROUND(func) wxEventTableEntry( cbEVT_PL_DRAW_PANE_BKGROUND, -1, -1, (wxObjectEventFunction) (wxEventFunction) (cbDrawPaneBkGroundHandler) & func, (wxObject *) NULL ),
1286 #define EVT_PL_START_BAR_DRAGGING(func) wxEventTableEntry( cbEVT_PL_START_BAR_DRAGGING, -1, -1, (wxObjectEventFunction) (wxEventFunction) (cbStartBarDraggingHandler) & func, (wxObject *) NULL ),
1287 #define EVT_PL_DRAW_HINT_RECT(func) wxEventTableEntry( cbEVT_PL_DRAW_HINT_RECT, -1, -1, (wxObjectEventFunction) (wxEventFunction) (cbDrawHintRectHandler ) & func, (wxObject *) NULL ),
1290 #define EVT_PL_START_DRAW_IN_AREA(func) wxEventTableEntry( cbEVT_PL_START_DRAW_IN_AREA, -1, -1, (wxObjectEventFunction) (wxEventFunction) (cbStartDrawInAreaHandler) & func, (wxObject *) NULL ),
1291 #define EVT_PL_FINISH_DRAW_IN_AREA(func) wxEventTableEntry( cbEVT_PL_FINISH_DRAW_IN_AREA, -1, -1, (wxObjectEventFunction) (wxEventFunction) (cbFinishDrawInAreaHandler) & func, (wxObject *) NULL ),
1293 #define EVT_PL_CUSTOMIZE_BAR(func) wxEventTableEntry( cbEVT_PL_CUSTOMIZE_BAR, -1, -1, (wxObjectEventFunction) (wxEventFunction) (cbCustomizeBarHandler) & func, (wxObject *) NULL ),
1294 #define EVT_PL_CUSTOMIZE_LAYOUT(func) wxEventTableEntry( cbEVT_PL_CUSTOMIZE_LAYOUT, -1, -1, (wxObjectEventFunction) (wxEventFunction) (cbCustomizeLayoutHandler) & func, (wxObject *) NULL ),
1296 #define EVT_PL_LEFT_DOWN(func) { cbEVT_PL_LEFT_DOWN, -1, -1, (wxObjectEventFunction) (wxEventFunction) (cbLeftDownHandler ) & func },
1297 #define EVT_PL_LEFT_UP(func) { cbEVT_PL_LEFT_UP, -1, -1, (wxObjectEventFunction) (wxEventFunction) (cbLeftUpHandler ) & func },
1298 #define EVT_PL_RIGHT_DOWN(func) { cbEVT_PL_RIGHT_DOWN, -1, -1, (wxObjectEventFunction) (wxEventFunction) (cbRightDownHandler ) & func },
1299 #define EVT_PL_RIGHT_UP(func) { cbEVT_PL_RIGHT_UP, -1, -1, (wxObjectEventFunction) (wxEventFunction) (cbRightUpHandler ) & func },
1300 #define EVT_PL_MOTION(func) { cbEVT_PL_MOTION, -1, -1, (wxObjectEventFunction) (wxEventFunction) (cbMotionHandler ) & func },
1301 #define EVT_PL_LEFT_DCLICK(func) { cbEVT_PL_LEFT_DCLICK, -1, -1, (wxObjectEventFunction) (wxEventFunction) (cbLeftDClickHandler ) & func },
1303 #define EVT_PL_LAYOUT_ROW(func) { cbEVT_PL_LAYOUT_ROW, -1, -1, (wxObjectEventFunction) (wxEventFunction) (cbLayoutRowHandler ) & func },
1304 #define EVT_PL_RESIZE_ROW(func) { cbEVT_PL_RESIZE_ROW, -1, -1, (wxObjectEventFunction) (wxEventFunction) (cbResizeRowHandler ) & func },
1305 #define EVT_PL_LAYOUT_ROWS(func) { cbEVT_PL_LAYOUT_ROWS, -1, -1, (wxObjectEventFunction) (wxEventFunction) (cbLayoutRowsHandler ) & func },
1306 #define EVT_PL_INSERT_BAR(func) { cbEVT_PL_INSERT_BAR, -1, -1, (wxObjectEventFunction) (wxEventFunction) (cbInsertBarHandler ) & func },
1307 #define EVT_PL_RESIZE_BAR(func) { cbEVT_PL_RESIZE_BAR, -1, -1, (wxObjectEventFunction) (wxEventFunction) (cbResizeBarHandler ) & func },
1308 #define EVT_PL_REMOVE_BAR(func) { cbEVT_PL_REMOVE_BAR, -1, -1, (wxObjectEventFunction) (wxEventFunction) (cbRemoveBarHandler ) & func },
1309 #define EVT_PL_SIZE_BAR_WND(func) { cbEVT_PL_SIZE_BAR_WND, -1, -1, (wxObjectEventFunction) (wxEventFunction) (cbSizeBarWndHandler ) & func },
1311 #define EVT_PL_DRAW_BAR_DECOR(func) { cbEVT_PL_DRAW_BAR_DECOR, -1, -1, (wxObjectEventFunction) (wxEventFunction) (cbDrawBarDecorHandler ) & func },
1312 #define EVT_PL_DRAW_ROW_DECOR(func) { cbEVT_PL_DRAW_ROW_DECOR, -1, -1, (wxObjectEventFunction) (wxEventFunction) (cbDrawRowDecorHandler ) & func },
1313 #define EVT_PL_DRAW_PANE_DECOR(func) { cbEVT_PL_DRAW_PANE_DECOR, -1, -1, (wxObjectEventFunction) (wxEventFunction) (cbDrawPaneDecorHandler ) & func },
1314 #define EVT_PL_DRAW_BAR_HANDLES(func) { cbEVT_PL_DRAW_BAR_HANDLES, -1, -1, (wxObjectEventFunction) (wxEventFunction) (cbDrawBarHandlesHandler ) & func },
1315 #define EVT_PL_DRAW_ROW_HANDLES(func) { cbEVT_PL_DRAW_ROW_HANDLES, -1, -1, (wxObjectEventFunction) (wxEventFunction) (cbDrawRowHandlesHandler ) & func },
1316 #define EVT_PL_DRAW_ROW_BKGROUND(func) { cbEVT_PL_DRAW_ROW_BKGROUND, -1, -1, (wxObjectEventFunction) (wxEventFunction) (cbDrawRowBkGroundHandler ) & func },
1317 #define EVT_PL_DRAW_PANE_BKGROUND(func) { cbEVT_PL_DRAW_PANE_BKGROUND, -1, -1, (wxObjectEventFunction) (wxEventFunction) (cbDrawPaneBkGroundHandler) & func },
1319 #define EVT_PL_START_BAR_DRAGGING(func) { cbEVT_PL_START_BAR_DRAGGING, -1, -1, (wxObjectEventFunction) (wxEventFunction) (cbStartBarDraggingHandler) & func },
1320 #define EVT_PL_DRAW_HINT_RECT(func) { cbEVT_PL_DRAW_HINT_RECT, -1, -1, (wxObjectEventFunction) (wxEventFunction) (cbDrawHintRectHandler ) & func },
1322 #define EVT_PL_START_DRAW_IN_AREA(func) { cbEVT_PL_START_DRAW_IN_AREA, -1, -1, (wxObjectEventFunction) (wxEventFunction) (cbStartDrawInAreaHandler) & func },
1323 #define EVT_PL_FINISH_DRAW_IN_AREA(func) { cbEVT_PL_FINISH_DRAW_IN_AREA, -1, -1, (wxObjectEventFunction) (wxEventFunction) (cbFinishDrawInAreaHandler) & func },
1325 #define EVT_PL_CUSTOMIZE_BAR(func) { cbEVT_PL_CUSTOMIZE_BAR, -1, -1, (wxObjectEventFunction) (wxEventFunction) (cbCustomizeBarHandler) & func },
1326 #define EVT_PL_CUSTOMIZE_LAYOUT(func) { cbEVT_PL_CUSTOMIZE_LAYOUT, -1, -1, (wxObjectEventFunction) (wxEventFunction) (cbCustomizeLayoutHandler) & func },
1329 * abstract base class for all control-bar related plugins
1332 class cbPluginBase
: public wxEvtHandler
1334 DECLARE_ABSTRACT_CLASS( cbPluginBase
)
1337 wxFrameLayout
* mpLayout
; // back-reference to the frame layout
1339 // specifies panes, for which this plugin receives events
1340 // (see pane masks definitions)
1343 bool mIsReady
; // is TRUE, when plugin is ready to handle events
1349 mPaneMask( wxALL_PANES
),
1353 cbPluginBase( wxFrameLayout
* pPanel
, int paneMask
= wxALL_PANES
)
1355 : mpLayout ( pPanel
),
1356 mPaneMask( paneMask
),
1360 inline int GetPaneMask() { return mPaneMask
; }
1362 // NOTE:: pointer positions of mouse-events sent to plugins
1363 // are always in pane's coordinates (pane's to which
1364 // this plugin is hooked)
1366 // destroys the whole plugin chain of connected plagins
1367 virtual ~cbPluginBase();
1369 // override this method to do plugin-specific initialization
1370 // (at this point plugin is already attached to the frame layout,
1371 // and pane masks are set)
1372 virtual void OnInitPlugin() { mIsReady
= TRUE
; }
1374 bool IsReady() { return mIsReady
; }
1376 // overriden, to determine whether the target pane specified in the
1377 // event, matches the pane mask of this plugin (specific plugins
1378 // do not override this method)
1380 virtual bool ProcessEvent(wxEvent
& event
);
1383 /*** event classes, for each corresponding event type (24 currnetly...uhh) ***/
1385 // mouse-events category
1387 class cbLeftDownEvent
: public cbPluginEvent
1392 cbLeftDownEvent( const wxPoint
& pos
, cbDockPane
* pPane
)
1394 : cbPluginEvent( cbEVT_PL_LEFT_DOWN
, pPane
),
1399 class cbLeftUpEvent
: public cbPluginEvent
1404 cbLeftUpEvent( const wxPoint
& pos
, cbDockPane
* pPane
)
1406 : cbPluginEvent( cbEVT_PL_LEFT_UP
, pPane
),
1411 class cbRightDownEvent
: public cbPluginEvent
1416 cbRightDownEvent( const wxPoint
& pos
, cbDockPane
* pPane
)
1418 : cbPluginEvent( cbEVT_PL_RIGHT_DOWN
, pPane
),
1423 class cbRightUpEvent
: public cbPluginEvent
1428 cbRightUpEvent( const wxPoint
& pos
, cbDockPane
* pPane
)
1430 : cbPluginEvent( cbEVT_PL_RIGHT_UP
, pPane
),
1435 class cbMotionEvent
: public cbPluginEvent
1440 cbMotionEvent( const wxPoint
& pos
, cbDockPane
* pPane
)
1442 : cbPluginEvent( cbEVT_PL_MOTION
, pPane
),
1447 class cbLeftDClickEvent
: public cbPluginEvent
1452 cbLeftDClickEvent( const wxPoint
& pos
, cbDockPane
* pPane
)
1454 : cbPluginEvent( cbEVT_PL_LEFT_DCLICK
, pPane
),
1459 // bar/row events category
1461 class cbLayoutRowEvent
: public cbPluginEvent
1466 cbLayoutRowEvent( cbRowInfo
* pRow
, cbDockPane
* pPane
)
1468 : cbPluginEvent( cbEVT_PL_LAYOUT_ROW
, pPane
),
1473 class cbResizeRowEvent
: public cbPluginEvent
1478 bool mForUpperHandle
;
1480 cbResizeRowEvent( cbRowInfo
* pRow
, int handleOfs
, bool forUpperHandle
, cbDockPane
* pPane
)
1482 : cbPluginEvent( cbEVT_PL_RESIZE_ROW
, pPane
),
1484 mHandleOfs( handleOfs
),
1485 mForUpperHandle( forUpperHandle
)
1489 class cbLayoutRowsEvent
: public cbPluginEvent
1493 cbLayoutRowsEvent( cbDockPane
* pPane
)
1495 : cbPluginEvent( cbEVT_PL_LAYOUT_ROWS
, pPane
)
1499 class cbInsertBarEvent
: public cbPluginEvent
1505 cbInsertBarEvent( cbBarInfo
* pBar
, cbRowInfo
* pIntoRow
, cbDockPane
* pPane
)
1507 : cbPluginEvent( cbEVT_PL_INSERT_BAR
, pPane
),
1514 class cbResizeBarEvent
: public cbPluginEvent
1520 cbResizeBarEvent( cbBarInfo
* pBar
, cbRowInfo
* pRow
, cbDockPane
* pPane
)
1522 : cbPluginEvent( cbEVT_PL_RESIZE_BAR
, pPane
),
1528 class cbRemoveBarEvent
: public cbPluginEvent
1533 cbRemoveBarEvent( cbBarInfo
* pBar
, cbDockPane
* pPane
)
1535 : cbPluginEvent( cbEVT_PL_REMOVE_BAR
, pPane
),
1540 class cbSizeBarWndEvent
: public cbPluginEvent
1544 wxRect mBoundsInParent
;
1546 cbSizeBarWndEvent( cbBarInfo
* pBar
, cbDockPane
* pPane
)
1548 : cbPluginEvent( cbEVT_PL_SIZE_BAR_WND
, pPane
),
1550 mBoundsInParent( pBar
->mBoundsInParent
)
1554 class cbDrawBarDecorEvent
: public cbPluginEvent
1559 wxRect mBoundsInParent
;
1561 cbDrawBarDecorEvent( cbBarInfo
* pBar
, wxDC
& dc
, cbDockPane
* pPane
)
1563 : cbPluginEvent( cbEVT_PL_DRAW_BAR_DECOR
, pPane
),
1566 mBoundsInParent( pBar
->mBoundsInParent
)
1570 class cbDrawRowDecorEvent
: public cbPluginEvent
1576 cbDrawRowDecorEvent( cbRowInfo
* pRow
, wxDC
& dc
, cbDockPane
* pPane
)
1578 : cbPluginEvent( cbEVT_PL_DRAW_ROW_DECOR
, pPane
),
1584 class cbDrawPaneDecorEvent
: public cbPluginEvent
1589 cbDrawPaneDecorEvent( wxDC
& dc
, cbDockPane
* pPane
)
1591 : cbPluginEvent( cbEVT_PL_DRAW_PANE_DECOR
, pPane
),
1596 class cbDrawBarHandlesEvent
: public cbPluginEvent
1602 cbDrawBarHandlesEvent( cbBarInfo
* pBar
, wxDC
& dc
, cbDockPane
* pPane
)
1604 : cbPluginEvent( cbEVT_PL_DRAW_BAR_HANDLES
, pPane
),
1610 class cbDrawRowHandlesEvent
: public cbPluginEvent
1616 cbDrawRowHandlesEvent( cbRowInfo
* pRow
, wxDC
& dc
, cbDockPane
* pPane
)
1618 : cbPluginEvent( cbEVT_PL_DRAW_ROW_HANDLES
, pPane
),
1624 class cbDrawRowBkGroundEvent
: public cbPluginEvent
1630 cbDrawRowBkGroundEvent( cbRowInfo
* pRow
, wxDC
& dc
, cbDockPane
* pPane
)
1632 : cbPluginEvent( cbEVT_PL_DRAW_ROW_BKGROUND
, pPane
),
1638 class cbDrawPaneBkGroundEvent
: public cbPluginEvent
1643 cbDrawPaneBkGroundEvent( wxDC
& dc
, cbDockPane
* pPane
)
1645 : cbPluginEvent( cbEVT_PL_DRAW_PANE_BKGROUND
, pPane
),
1650 class cbStartBarDraggingEvent
: public cbPluginEvent
1654 wxPoint mPos
; // is given in frame's coordinates
1656 cbStartBarDraggingEvent( cbBarInfo
* pBar
, const wxPoint
& pos
, cbDockPane
* pPane
)
1658 : cbPluginEvent( cbEVT_PL_START_BAR_DRAGGING
, pPane
),
1664 class cbDrawHintRectEvent
: public cbPluginEvent
1667 wxRect mRect
; // is given in frame's coordinates
1670 bool mLastTime
; // indicates that this event finishes "session" of on-screen drawing,
1671 // thus associated resources can be freed now
1672 bool mEraseRect
; // does not have any impact, if recangle is drawn using XOR-mask
1674 bool mIsInClient
;// in cleint area hint could be drawn differently,
1675 // e.g. with fat/hatched border
1678 cbDrawHintRectEvent( const wxRect
& rect
, bool isInClient
, bool eraseRect
, bool lastTime
)
1680 : cbPluginEvent( cbEVT_PL_DRAW_HINT_RECT
, 0 ),
1682 mLastTime ( lastTime
),
1683 mEraseRect ( eraseRect
),
1684 mIsInClient( isInClient
)
1688 class cbStartDrawInAreaEvent
: public cbPluginEvent
1692 wxDC
** mppDc
; // points to pointer, where the reference
1693 // to the obtained buffer-context should be placed
1695 cbStartDrawInAreaEvent( const wxRect
& area
, wxDC
** ppDCForArea
, cbDockPane
* pPane
)
1697 : cbPluginEvent( cbEVT_PL_START_DRAW_IN_AREA
, pPane
),
1699 mppDc( ppDCForArea
)
1703 class cbFinishDrawInAreaEvent
: public cbPluginEvent
1708 cbFinishDrawInAreaEvent( const wxRect
& area
, cbDockPane
* pPane
)
1710 : cbPluginEvent( cbEVT_PL_FINISH_DRAW_IN_AREA
, pPane
),
1715 class cbCustomizeBarEvent
: public cbPluginEvent
1718 wxPoint mClickPos
; // in parent frame's coordinates
1721 cbCustomizeBarEvent( cbBarInfo
* pBar
, const wxPoint
& clickPos
, cbDockPane
* pPane
)
1723 : cbPluginEvent( cbEVT_PL_CUSTOMIZE_BAR
, pPane
),
1724 mClickPos( clickPos
),
1729 class cbCustomizeLayoutEvent
: public cbPluginEvent
1732 wxPoint mClickPos
; // in parent frame's coordinates
1734 cbCustomizeLayoutEvent( const wxPoint
& clickPos
)
1736 : cbPluginEvent( cbEVT_PL_CUSTOMIZE_LAYOUT
, 0 ),
1737 mClickPos( clickPos
)
1741 #endif /* __CONTROLBAR_G__ */