]> git.saurik.com Git - wxWidgets.git/blob - utils/framelayout/src/controlbar.h
fix for the crash when many listctrl items change state
[wxWidgets.git] / utils / framelayout / src / controlbar.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: No names yet.
3 // Purpose: Central header file for control-bar related classes
4 //
5 // Author: Aleksandras Gluchovas <mailto:alex@soften.ktu.lt>
6 // Modified by:
7 // Created: 06/09/98
8 // RCS-ID: $Id$
9 // Copyright: (c) Aleksandras Gluchovas
10 // Licence: wxWindows license
11 /////////////////////////////////////////////////////////////////////////////
12
13 #ifndef __CONTROLBAR_G__
14 #define __CONTROLBAR_G__
15
16 #ifdef __GNUG__
17 #pragma interface "controlbar.h"
18 #endif
19
20 #include "wx/defs.h"
21 #include "wx/string.h"
22 #include "wx/window.h"
23 #include "wx/dynarray.h"
24
25 #define WXCONTROLBAR_VERSION 1.3
26
27 // forward declarations
28
29 class wxFrameLayout;
30
31 class cbDockPane;
32 class cbUpdatesManagerBase;
33 class cbBarDimHandlerBase;
34 class cbPluginBase;
35 class cbPluginEvent;
36 class cbPaneDrawPlugin;
37
38 class cbBarInfo;
39 class cbRowInfo;
40 class cbDimInfo;
41 class cbCommonPaneProperties;
42
43 typedef cbBarInfo* BarInfoPtrT;
44 typedef cbRowInfo* RowInfoPtrT;
45
46 WX_DEFINE_ARRAY( BarInfoPtrT, BarArrayT );
47 WX_DEFINE_ARRAY( RowInfoPtrT, RowArrayT );
48
49 // control bar states
50
51 #define wxCBAR_DOCKED_HORIZONTALLY 0
52 #define wxCBAR_DOCKED_VERTICALLY 1
53 #define wxCBAR_FLOATING 2
54 #define wxCBAR_HIDDEN 3
55
56 // the states are enumerated above
57 #define MAX_BAR_STATES 4
58
59 // control bar alignments
60
61 #if !defined(wxTOP)
62
63 #define wxTOP 0
64 #define wxBOTTOM 1
65 #define wxLEFT 2
66 #define wxRIGHT 3
67
68 #endif
69
70 // one pane for each alignment
71 #define MAX_PANES 4
72
73 // masks for each pane
74
75 #define wxTOP_PANE 0x0001
76 #define wxBOTTOM_PANE 0x0002
77 #define wxLEFT_PANE 0x0004
78 #define wxRIGHT_PANE 0x0008
79
80 #define wxALL_PANES 0x000F
81
82 // enumeration of hittest results, see cbDockPane::HitTestPaneItems(..)
83
84 enum CB_HITTEST_RESULT
85 {
86 CB_NO_ITEMS_HITTED,
87
88 CB_UPPER_ROW_HANDLE_HITTED,
89 CB_LOWER_ROW_HANDLE_HITTED,
90 CB_LEFT_BAR_HANDLE_HITTED,
91 CB_RIGHT_BAR_HANDLE_HITTED,
92 CB_BAR_CONTENT_HITTED
93 };
94
95 // FIXME:: somehow in debug v. originall wxASSERT's are not compiled in...
96
97 //#undef wxASSERT
98 //#define wxASSERT(x) if ( !(x) ) throw;
99
100 // helper class, used for spying for not-handled mouse events on control-bars
101 // and forwarding them to the frame layout
102
103 class cbBarSpy : public wxEvtHandler
104 {
105 public:
106 DECLARE_DYNAMIC_CLASS( cbBarSpy )
107
108 wxFrameLayout* mpLayout;
109 wxWindow* mpBarWnd;
110
111 public:
112 cbBarSpy(void);
113
114 cbBarSpy( wxFrameLayout* pPanel );
115
116 void SetBarWindow( wxWindow* pWnd );
117
118 // overriden
119
120 virtual bool ProcessEvent(wxEvent& event);
121 };
122
123 /* wxFrameLayout manages containment and docking of control bars.
124 * which can be docked along top, bottom, righ, or left side of the
125 * parent frame
126 */
127
128 class wxFrameLayout : public wxEvtHandler
129 {
130 public:
131 DECLARE_DYNAMIC_CLASS( wxFrameLayout )
132
133 public: /* protected really, acessed only by plugins and serializers */
134
135 friend class cbDockPane;
136 friend class wxBarHandler;
137
138 wxWindow* mpFrame; // parent frame
139 wxWindow* mpFrameClient; // client window
140 cbDockPane* mPanes[MAX_PANES]; // panes in the panel
141
142 // misc. cursors
143 wxCursor* mpHorizCursor;
144 wxCursor* mpVertCursor;
145 wxCursor* mpNormalCursor;
146 wxCursor* mpDragCursor;
147 wxCursor* mpNECursor; // no-entry cursor
148
149 // pens for decoration and shades
150
151 wxPen mDarkPen; // default wxSYS_COLOUR_3DSHADOW
152 wxPen mLightPen; // default wxSYS_COLOUR_3DHILIGHT
153 wxPen mGrayPen; // default wxSYS_COLOUR_3DFACE
154 wxPen mBlackPen; // default wxColour( 0, 0, 0)
155 wxPen mBorderPen; // default wxSYS_COLOUR_3DFACE
156
157 wxPen mNullPen; // transparent pen
158
159 // pane to which the all mouse input is currently directed (caputred)
160
161 cbDockPane* mpPaneInFocus;
162
163 // pane, from which mouse pointer had just leaft
164
165 cbDockPane* mpLRUPane;
166
167 // bounds of client window in parent frame's coordinates
168
169 wxRect mClntWndBounds;
170 wxRect mPrevClntWndBounds;
171
172 bool mFloatingOn;
173 wxPoint mNextFloatedWndPos;
174 wxSize mFloatingPosStep;
175
176 // current plugin (right-most) plugin which receives events first
177
178 cbPluginBase* mpTopPlugin;
179
180 // plugin, which currently has caputred all input events, otherwise NULL
181
182 cbPluginBase* mpCaputesInput;
183
184 // list of event handlers which are "pushed" onto each bar, to catch
185 // mouse events which are not handled by bars, and froward them to the ,
186 // frome-layout and further to plugins
187
188 wxList mBarSpyList;
189
190 // list of top-most frames which contain floated bars
191
192 wxList mFloatedFrames;
193
194 // linked list of references to all bars (docked/floated/hidden)
195
196 BarArrayT mAllBars;
197
198 // FOR NOW:: dirty stuff...
199 bool mClientWndRefreshPending;
200 bool mRecalcPending;
201 bool mCheckFocusWhenIdle;
202
203 public: /* protected really (accessed only by plugins) */
204
205 // refrence to custom updates manager
206 cbUpdatesManagerBase* mpUpdatesMgr;
207
208 // called to set calculated layout to window objects
209 void PositionClientWindow();
210 void PositionPanes();
211 void CreateCursors();
212
213 void RepositionFloatedBar( cbBarInfo* pBar );
214 void DoSetBarState( cbBarInfo* pBar );
215
216 bool LocateBar( cbBarInfo* pBarInfo,
217 cbRowInfo** ppRow,
218 cbDockPane** ppPane );
219
220
221 bool HitTestPane( cbDockPane* pPane, int x, int y );
222 cbDockPane* HitTestPanes( const wxRect& rect, cbDockPane* pCurPane );
223
224 // returns panes, to which the given bar belongs
225
226 cbDockPane* GetBarPane( cbBarInfo* pBar );
227
228 // delegated from "bar-spy"
229 void ForwardMouseEvent( wxMouseEvent& event,
230 cbDockPane* pToPane,
231 int eventType );
232
233 void RouteMouseEvent( wxMouseEvent& event, int pluginEvtType );
234
235 void ShowFloatedWindows( bool show );
236
237 void UnhookFromFrame();
238 void HookUpToFrame();
239
240 // NOTE:: reparenting of windows may NOT work on all platforms
241 // (reparenting allows control-bars to be floated)
242
243 bool CanReparent();
244 void ReparentWindow( wxWindow* pChild, wxWindow* pNewParent );
245
246 wxRect& GetPrevClientRect() { return mPrevClntWndBounds; }
247
248 void OnPaint( wxPaintEvent& event );
249 void OnEraseBackground( wxEraseEvent& event );
250 void OnKillFocus( wxFocusEvent& event );
251 void OnSetFocus( wxFocusEvent& event );
252 void OnActivate( wxActivateEvent& event );
253 void OnIdle( wxIdleEvent& event );
254
255 // factory method
256 virtual cbUpdatesManagerBase* CreateUpdatesManager();
257
258 public: /* public members */
259
260 wxFrameLayout(void); // used only while serializing
261
262 wxFrameLayout( wxWindow* pParentFrame,
263 wxWindow* pFrameClient = NULL,
264 bool activateNow = TRUE );
265
266 // (doesn't destory bar windows)
267 virtual ~wxFrameLayout();
268
269 // (by default floating of control-bars is ON)
270 virtual void EnableFloating( bool enable = TRUE );
271
272 // Can be called after some other layout has been deactivated,
273 // and this one must "take over" the current contents of frame window.
274 //
275 // Effectivelly hooks itself to the frame window, re-displays all not-hidden
276 // bar-windows and repaints decorations
277
278 virtual void Activate();
279
280 // unhooks itself from frame window, and hides all not-hidden windows
281 //
282 // NOTE:: two frame-layouts should not be active at the same time in the
283 // same frame window, it would cause messy overlapping of bar windows
284 // from both layouts
285
286 virtual void Deactivate();
287
288 // also hides the client window if presents
289
290 void HideBarWindows();
291
292 virtual void DestroyBarWindows();
293
294 // passes the client window (e.g. MDI-client frame) to be controled by
295 // frame layout, the size and position of which should be adjusted to be
296 // surrounded by controlbar panes, whenever frame is resized, or dimesnions
297 // of control panes change
298
299 void SetFrameClient( wxWindow* pFrameClient );
300
301 wxWindow* GetFrameClient();
302
303 wxWindow& GetParentFrame() { return *mpFrame; }
304
305 // used by updates-managers
306 cbDockPane** GetPanesArray() { return mPanes; }
307
308 // see pane alignment types
309 cbDockPane* GetPane( int alignment )
310
311 { return mPanes[alignment]; }
312
313 // Adds bar information to frame-layout, appearence of layout is not refreshed
314 // immediatelly, RefreshNow() can be called if necessary.
315 //
316 // NOTES:: argument pBarWnd can by NULL, resulting bar decorations to be drawn
317 // around the empty rectangle (filled with default background colour).
318 // Argument dimInfo, can be re-used for adding any number of bars, since
319 // it is not used directly, instead it's members are copied. If dimensions-
320 // handler is present, it's instance shared (reference counted). Dimension
321 // handler should always be allocated on the heap!)
322
323 virtual void AddBar( wxWindow* pBarWnd,
324 cbDimInfo& dimInfo,
325
326 // defaults:
327
328 int alignment = wxTOP,
329 int rowNo = 0, // vert. position - row in the pane (if docked state)
330 int columnPos = 0, // horiz. position in the row in pixels (if docked state)
331 const wxString& name="bar",// name, by which the bar could be referred
332 // in layout costumization dialogs
333
334 bool spyEvents = FALSE, // if TRUE - input events for the bar should
335 // be "spyed" in order to forward not-handled
336 // mouse clicks to frame layout (e.g. to enable
337 // easy-draggablity of toolbars just by clicking
338 // on their interior regions). For widgets like
339 // text/tree control this value should be FALSE
340 // (since there's _no_ certain way to detect
341 // whether the event was actually handled...)
342
343 int state = wxCBAR_DOCKED_HORIZONTALLY // e.g. wxCBAR_FLOATING
344 // or wxCBAR_HIDDEN
345 );
346
347 // can be used for repositioning already existing bars. The given bar is first removed
348 // from the pane it currently belongs to, and inserted into the pane, which "matches"
349 // the given recantular area. If pToPane is not NULL, bar is docked to this given pane
350
351 // to dock the bar which is floated, use wxFrameLayout::DockBar(..) method
352
353 virtual bool RedockBar( cbBarInfo* pBar, const wxRect& shapeInParent,
354 cbDockPane* pToPane = NULL, bool updateNow = TRUE );
355
356 // methods for access and modification of bars in frame layout
357
358 cbBarInfo* FindBarByName( const wxString& name );
359
360 BarArrayT& GetBars();
361
362 // changes bar's docking state (see possible control bar states)
363
364 void SetBarState( cbBarInfo* pBar, int newStatem, bool updateNow );
365
366 // reflects changes in bar information structure visually
367 // (e.g. moves bar, changes it's dimension info, pane to which it is docked)
368
369 void ApplyBarProperties( cbBarInfo* pBar );
370
371 // removes bar from layout permanently, hides it's corresponding window if present
372
373 void RemoveBar( cbBarInfo* pBar );
374
375 // recalcualtes layout of panes, and all bars/rows in each pane
376
377 virtual void RecalcLayout( bool repositionBarsNow = FALSE );
378
379 int GetClientHeight();
380 int GetClientWidth();
381 wxRect& GetClientRect() { return mClntWndBounds; }
382
383 // NOTE:: in future ubdates-manager will become a normal plugin
384
385 cbUpdatesManagerBase& GetUpdatesManager();
386
387 // destroys the previous manager if any, set the new one
388
389 void SetUpdatesManager( cbUpdatesManagerBase* pUMgr );
390
391 // NOTE:: changing properties of panes, does not result immediate on-screen update
392
393 virtual void GetPaneProperties( cbCommonPaneProperties& props, int alignment = wxTOP );
394
395 virtual void SetPaneProperties( const cbCommonPaneProperties& props,
396 int paneMask = wxALL_PANES );
397
398 // TODO:: margins should go into cbCommonPaneProperties in the future
399 //
400 // NOTE:: this method should be called before any custom plugins are attached
401
402 virtual void SetMargins( int top, int bottom, int left, int right,
403 int paneMask = wxALL_PANES );
404
405 virtual void SetPaneBackground( const wxColour& colour );
406
407 // recalculates layoute and performs on-screen update of all panes
408
409 void RefreshNow( bool recalcLayout = TRUE );
410
411 // event handlers
412
413 void OnSize ( wxSizeEvent& event );
414 void OnLButtonDown( wxMouseEvent& event );
415 void OnLDblClick ( wxMouseEvent& event );
416 void OnLButtonUp ( wxMouseEvent& event );
417 void OnRButtonDown( wxMouseEvent& event );
418 void OnRButtonUp ( wxMouseEvent& event );
419 void OnMouseMove ( wxMouseEvent& event );
420
421 /*** plugin-related methods ***/
422
423 // should be used, instead of passing the event to ProcessEvent(..) method
424 // of the top-plugin directly. This method checks if events are currently
425 // captured and ensures that plugin-event is routed correctly.
426
427 virtual void FirePluginEvent( cbPluginEvent& event );
428
429 // captures/releases user-input event's for the given plugin
430 // Input events are: mouse movement, mouse clicks, keyboard input
431
432 virtual void CaptureEventsForPlugin ( cbPluginBase* pPlugin );
433 virtual void ReleaseEventsFromPlugin( cbPluginBase* pPlugin );
434
435 // called by plugins ( also captures/releases mouse in parent frame)
436 void CaptureEventsForPane( cbDockPane* toPane );
437 void ReleaseEventsFromPane( cbDockPane* fromPane );
438
439 // returns current top-level plugin (the one which receives events first,
440 // with an exception if input-events are currently captured by some other plugin)
441
442 virtual cbPluginBase& GetTopPlugin();
443
444 // hooking custom plugins to frame layout
445 //
446 // NOTE:: when hooking one plugin on top of the other -
447 // use SetNextHandler(..) or similar methods
448 // of wxEvtHandler class to compose the chain of plugins,
449 // than pass the left-most handler in this chain to
450 // the above methods (assuming that events are delegated
451 // from left-most towards right-most handler)
452 //
453 // NOTE2:: this secenario is very inconvenient and "low-level",
454 // use Add/Push/PopPlugin methods instead
455
456 virtual void SetTopPlugin( cbPluginBase* pPlugin );
457
458 // similar to wxWindow's "push/pop-event-handler" methods, execept
459 // that plugin is *deleted* upon "popping"
460
461 virtual void PushPlugin( cbPluginBase* pPugin );
462 virtual void PopPlugin();
463
464 virtual void PopAllPlugins();
465
466 // default plugins are : cbPaneDrawPlugin, cbRowLayoutPlugin, cbBarDragPlugin,
467 // cbAntiflickerPlugin, cbSimpleCustomizePlugin
468 //
469 // this method is automatically invoked, if no plugins were found upon
470 // fireing of the first plugin-event, i.e. wxFrameLayout *CONFIGURES* itself
471
472 virtual void PushDefaultPlugins();
473
474 /* "Advanced" methods for plugin-configuration using their */
475 /* dynamic class information (e.g. CLASSINFO(pluginClass) ) */
476
477 // first checks if plugin of the given class is already "hooked up",
478 // if not, adds it to the top of plugins chain
479
480 virtual void AddPlugin( wxClassInfo* pPlInfo, int paneMask = wxALL_PANES );
481
482 // first checks if plugin of the givne class already hooked,
483 // if so, removes it, and then inserts it to the chain
484 // before plugin of the class given by "pNextPlInfo"
485 //
486 // NOTE:: this method is "handy" in some cases, where the order
487 // of plugin-chain could be important, e.g. one plugin overrides
488 // some functionallity of the other already hooked plugin,
489 // thefore the former should be hooked before the one
490 // who's functionality is being overriden
491
492 virtual void AddPluginBefore( wxClassInfo* pNextPlInfo, wxClassInfo* pPlInfo,
493 int paneMask = wxALL_PANES );
494
495 // checks if plugin of the given class is hooked, removes
496 // it if found
497 //
498 // @param pPlInfo class information structure for the plugin
499 // @note
500 // @see wxFrameLayout::Method
501
502
503 virtual void RemovePlugin( wxClassInfo* pPlInfo );
504
505 // returns NULL, if plugin of the given class is not hooked
506
507 virtual cbPluginBase* FindPlugin( wxClassInfo* pPlInfo );
508
509 bool HasTopPlugin();
510
511 DECLARE_EVENT_TABLE();
512 };
513
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
517 * updating algorithm
518 */
519
520 class cbUpdateMgrData : public wxObject
521 {
522 DECLARE_DYNAMIC_CLASS( cbUpdateMgrData )
523 public:
524 wxRect mPrevBounds; // previous state of layout item (in parent frame's coordinates)
525
526 bool mIsDirty; // overrides result of current-against-previouse bounds comparison,
527 // i.e. requires item to be updated, regardless of it's current area
528
529 wxObject* mpCustomData; // any custom data stored by specific updates mgr.
530
531 cbUpdateMgrData(); // is-dirty flag is set TRUE initially
532
533 void StoreItemState( const wxRect& boundsInParent );
534
535 void SetDirty( bool isDirty = TRUE );
536
537 void SetCustomData( wxObject* pCustomData );
538
539 inline bool IsDirty() { return mIsDirty; }
540 };
541
542 /* Abstract inteface 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.
547 */
548
549 class cbBarDimHandlerBase : public wxObject
550 {
551 DECLARE_ABSTRACT_CLASS( cbBarDimHandlerBase )
552
553 public:
554 int mRefCount; // since one dim-handler can be asigned
555 // to multiple bars, it's instance is
556 // refernce-counted
557 public:
558
559 // inital refernce count is 0, since handler is not used, until the
560 // first invocation of AddRef()
561
562 cbBarDimHandlerBase();
563
564 void AddRef();
565 void RemoveRef();
566
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;
570 };
571
572 /* helper classes (used internally by wxFrameLayout class) */
573
574 // holds and manages information about bar demensions
575
576 class cbDimInfo : public wxObject
577 {
578 DECLARE_DYNAMIC_CLASS( cbDimInfo )
579 public:
580 wxSize mSizes[MAX_BAR_STATES]; // preferred sizes for each possible bar state
581
582 wxRect mBounds[MAX_BAR_STATES]; // saved positions and sizes for each
583 // possible state, values contain (-1)s if
584 // not initialized yet
585
586 int mLRUPane; // pane to which this bar was docked before it was floated
587 // (wxTOP,wxBOTTOM,..)
588
589 // top/bottom gap, separates decorations
590 // from the bar's actual window, filled
591 // with frame's beckground color, default: 0
592
593 int mVertGap;
594
595 // left/right gap, separates decorations
596 // from the bar's actual window, filled
597 // with frame's beckground colour, default: 0
598
599 int mHorizGap; // NOTE:: gaps are given in frame's coord. orientation
600
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
604
605 bool mIsFixed;
606
607 cbBarDimHandlerBase* mpHandler; // NULL, if no handler present
608
609 public:
610
611 cbDimInfo(void);
612
613 cbDimInfo( cbBarDimHandlerBase* pDimHandler,
614 bool isFixed // (see comments on mIsFixed member)
615 );
616
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
620
621 bool isFixed = TRUE,// (see comments on mIsFixed member)
622 int horizGap = 6, // (see comments on mHorizGap member)
623 int vertGap = 6, // -/-
624
625 cbBarDimHandlerBase* pDimHandler = NULL
626 );
627
628 const cbDimInfo& operator=( cbDimInfo& other );
629
630 // destroys handler automatically, if present
631 ~cbDimInfo();
632
633 inline cbBarDimHandlerBase* GetDimHandler() { return mpHandler; }
634 };
635
636 WX_DEFINE_ARRAY(float, cbArrayFloat);
637
638 class cbRowInfo : public wxObject
639 {
640 DECLARE_DYNAMIC_CLASS( cbRowInfo )
641 public:
642
643 BarArrayT mBars; // row content
644
645 // row flags (set up according to row-relations)
646
647 bool mHasUpperHandle;
648 bool mHasLowerHandle;
649 bool mHasOnlyFixedBars;
650 int mNotFixedBarsCnt;
651
652 int mRowWidth;
653 int mRowHeight;
654 int mRowY;
655
656 // stores precalculated row's bounds in parent frame's coordinates
657 wxRect mBoundsInParent;
658
659 // info stored for updates-manager
660 cbUpdateMgrData mUMgrData;
661
662 cbRowInfo* mpNext;
663 cbRowInfo* mpPrev;
664
665 cbBarInfo* mpExpandedBar; // NULL, if non of the bars is currently expanded
666
667 cbArrayFloat mSavedRatios; // length-ratios bofore some of the bars was expanded
668
669 public:
670 cbRowInfo(void);
671
672 ~cbRowInfo();
673
674 // convenience method
675
676 inline cbBarInfo* GetFirstBar()
677
678 { return mBars.GetCount() ? mBars[0] : NULL; }
679 };
680
681 class cbBarInfo : public wxObject
682 {
683 DECLARE_DYNAMIC_CLASS( cbBarInfo )
684 public:
685 // textual name, by which this bar is refered in layout-costumization dialogs
686 wxString mName;
687
688 // stores bar's bounds in pane's coordinates
689 wxRect mBounds;
690
691 // stores precalculated bar's bounds in parent frame's coordinates
692 wxRect mBoundsInParent;
693
694 // back-ref to the row, which contains this bar
695 cbRowInfo* mpRow;
696
697 // are set up according to the types of the surrounding bars in the row
698 bool mHasLeftHandle;
699 bool mHasRightHandle;
700
701 cbDimInfo mDimInfo; // preferred sizes for each, control bar state
702
703 int mState; // (see definition of controlbar states)
704
705 int mAlignment; // alignment of the pane to which this
706 // bar is currently placed
707
708 int mRowNo; // row, into which this bar would be placed,
709 // when in the docking state
710
711 wxWindow* mpBarWnd; // the actual window object, NULL if no window
712 // is attached to the control bar (possible!)
713
714 double mLenRatio; // length ratio among not-fixed-size bars
715
716 wxPoint mPosIfFloated; // stored last position when bar was in "floated" state
717 // poistion is stored in parent-window's coordinates
718
719 cbUpdateMgrData mUMgrData; // info stored for updates-manager
720
721 cbBarInfo* mpNext; // next. bar in the row
722 cbBarInfo* mpPrev; // prev. bar in the row
723
724 public:
725 cbBarInfo(void);
726
727 ~cbBarInfo();
728
729 inline bool IsFixed() const { return mDimInfo.mIsFixed; }
730
731 inline bool IsExpanded() const { return this == mpRow->mpExpandedBar; }
732 };
733
734 // used for storing original bar's postions in the row, when the "non-destructive-friction"
735 // option is turned ON
736
737 class cbBarShapeData : public wxObject
738 {
739 public:
740 wxRect mBounds;
741 double mLenRatio;
742 };
743
744 // used for traversing through all bars of all rows in the pane
745
746 class wxBarIterator
747 {
748 RowArrayT* mpRows;
749 cbRowInfo* mpRow;
750 cbBarInfo* mpBar;
751
752 public:
753 wxBarIterator( RowArrayT& rows );
754
755 void Reset();
756 bool Next(); // TRUE, if next bar is available
757
758 cbBarInfo& BarInfo();
759
760 // returns reference to currently traversed row
761 cbRowInfo& RowInfo();
762 };
763
764 /* structure holds configuration options,
765 * which are usually the same for all panes in
766 * frame layout
767 */
768
769 class cbCommonPaneProperties : public wxObject
770 {
771 DECLARE_DYNAMIC_CLASS( cbCommonPaneProperties )
772
773 // look-and-feel configuration
774
775 bool mRealTimeUpdatesOn; // default: ON
776 bool mOutOfPaneDragOn; // default: ON
777 bool mExactDockPredictionOn; // default: OFF
778 bool mNonDestructFirctionOn; // default: OFF
779
780 bool mShow3DPaneBorderOn; // default: ON
781
782 // FOR NOW:: the below properties are reserved for the "future"
783
784 bool mBarFloatingOn; // default: OFF
785 bool mRowProportionsOn; // default: OFF
786 bool mColProportionsOn; // default: ON
787 bool mBarCollapseIconsOn; // default: OFF
788 bool mBarDragHintsOn; // default: OFF
789
790 // minimal dimensions for not-fixed bars in this pane (16x16 default)
791
792 wxSize mMinCBarDim;
793
794 // width/height of resizing sash
795
796 int mResizeHandleSize;
797
798 cbCommonPaneProperties(void);
799 };
800
801 /* class manages containment and control of control-bars
802 * along one of the four edges of the parent frame
803 */
804
805 class cbDockPane : public wxObject
806 {
807 public:
808 DECLARE_DYNAMIC_CLASS( cbDockPane )
809
810 // look-and-feel configuration for this pane
811 cbCommonPaneProperties mProps;
812
813 // pane margins (in frame's coordinate-syst. orientation)
814
815 int mLeftMargin; // default: 2 pixels
816 int mRightMargin; // default: 2 pixels
817 int mTopMargin; // default: 2 pixels
818 int mBottomMargin; // default: 2 pixels
819
820 public:
821 // position of the pane in frame's coordinates
822 wxRect mBoundsInParent;
823
824 // pane width and height in pane's coordinates
825 int mPaneWidth;
826 int mPaneHeight;
827
828 int mAlignment;
829
830 // info stored for updates-manager
831 cbUpdateMgrData mUMgrData;
832
833 public: /* protected really */
834
835 RowArrayT mRows;
836 wxFrameLayout* mpLayout; // back-ref
837
838 // transient properties
839
840 wxList mRowShapeData; // shapes of bars of recently modified row,
841 // stored when in "non-destructive-firction" mode
842 cbRowInfo* mpStoredRow; // row-info for which the shapes are stored
843
844 friend class wxFrameLayout;
845
846 public: /* protected really (accessed only by plugins) */
847
848 cbRowInfo* GetRow( int row );
849
850 int GetRowIndex( cbRowInfo* pRow );
851
852 // return -1, if row is not present at given vertical position
853 int GetRowAt( int paneY );
854 int GetRowAt( int upperY, int lowerY );
855
856 // re-setups flags in the row-information structure, so that
857 // the would match the changed state of row-items correctly
858 void SyncRowFlags( cbRowInfo* pRow );
859
860 // layout "AI" helpers:
861
862 bool IsFixedSize( cbBarInfo* pInfo );
863 int GetNotFixedBarsCount( cbRowInfo* pRow );
864
865 int GetRowWidth( wxList* pRow );
866
867 int GetRowY( cbRowInfo* pRow );
868
869 bool HasNotFixedRowsAbove( cbRowInfo* pRow );
870 bool HasNotFixedRowsBelow( cbRowInfo* pRow );
871 bool HasNotFixedBarsLeft ( cbBarInfo* pBar );
872 bool HasNotFixedBarsRight( cbBarInfo* pBar );
873
874 virtual void CalcLenghtRatios( cbRowInfo* pInRow );
875 virtual void RecalcRowLayout( cbRowInfo* pRow );
876
877 virtual void ExpandBar( cbBarInfo* pBar );
878 virtual void ContractBar( cbBarInfo* pBar );
879
880 void InitLinksForRow( cbRowInfo* pRow );
881 void InitLinksForRows();
882
883 // coordinate translation between parent's frame and this pane
884
885 void FrameToPane( long* x, long* y );
886 void PaneToFrame( long* x, long* y );
887 void FrameToPane( wxRect* pRect );
888 void PaneToFrame( wxRect* pRect );
889
890 inline bool HasPoint( const wxPoint& pos, int x, int y, int width, int height );
891
892 int GetMinimalRowHeight( cbRowInfo* pRow );
893
894 // given row height includes height of row handles, if present
895 void SetRowHeight( cbRowInfo* pRow, int newHeight );
896
897 void DoInsertBar( cbBarInfo* pBar, int rowNo );
898
899 public: /* protected really (accessed only by plugins) */
900
901 // methods for incramental on-screen refreshing of the pane
902 // (simply, they are wrappers around corresponding plugin-events)
903
904 virtual void PaintBarDecorations( cbBarInfo* pBar, wxDC& dc );
905 virtual void PaintBarHandles( cbBarInfo* pBar, wxDC& dc );
906 virtual void PaintBar( cbBarInfo* pBar, wxDC& dc );
907 virtual void PaintRowHandles( cbRowInfo* pRow, wxDC& dc );
908 virtual void PaintRowBackground ( cbRowInfo* pRow, wxDC& dc );
909 virtual void PaintRowDecorations( cbRowInfo* pRow, wxDC& dc );
910 virtual void PaintRow( cbRowInfo* pRow, wxDC& dc );
911 virtual void PaintPaneBackground( wxDC& dc );
912 virtual void PaintPaneDecorations( wxDC& dc );
913 virtual void PaintPane( wxDC& dc );
914 virtual void SizeBar( cbBarInfo* pBar );
915 virtual void SizeRowObjects( cbRowInfo* pRow );
916 virtual void SizePaneObjects();
917
918 virtual wxDC* StartDrawInArea ( const wxRect& area );
919 virtual void FinishDrawInArea( const wxRect& area );
920
921 public: /* public members */
922
923 cbDockPane(void);
924
925 cbDockPane( int alignment, wxFrameLayout* pPanel );
926
927 // sets pane's margins in frame's coordinate orientations
928 void SetMargins( int top, int bottom, int left, int right );
929
930 virtual ~cbDockPane();
931
932 // does not destroys the info bar , only removes it's reference
933 // from this pane
934
935 virtual void RemoveBar( cbBarInfo* pBar );
936
937 // rect given in the parent frame's coordinates
938
939 virtual void InsertBar( cbBarInfo* pBar, const wxRect& atRect );
940
941 // inserts bar into the given row, with dimensions and position
942 // stored in pBarInfo->mBounds. Returns the node of inserted bar
943
944 virtual void InsertBar( cbBarInfo* pBar, cbRowInfo* pIntoRow );
945
946 // inserts bar, sets its position according to the preferred settings
947 // given in (*pBarInfo) structure
948
949 virtual void InsertBar( cbBarInfo* pBarInfo );
950
951 // does not destroy the row object, only removes the corresponding
952 // node from this pane
953 virtual void RemoveRow( cbRowInfo* pRow );
954
955 // does not refresh the inserted row immediatelly,
956 // if pBeforeRowNode arg. is NULL, row is appended to the end of pane's row list
957 virtual void InsertRow( cbRowInfo* pRow, cbRowInfo* pBeforeRow );
958
959 // sets pane's width in pane's coordinates (including margins)
960 void SetPaneWidth(int width);
961
962 // set the position and dims. of the pane in parent frame's coordinates
963 void SetBoundsInParent( const wxRect& rect );
964
965 inline wxRect& GetRealRect() { return mBoundsInParent; }
966
967 // used by upadates-managers
968 inline RowArrayT& GetRowList() { return mRows; }
969
970 // convenience method
971
972 inline cbRowInfo* GetFirstRow()
973
974 { return mRows.GetCount() ? mRows[0] : NULL; }
975
976 // TRUE, if the given bar node presents in this pane
977
978 bool BarPresent( cbBarInfo* pBar );
979
980 // retuns height, in pane's coordinates
981 int GetPaneHeight();
982
983 int GetAlignment();
984
985 bool MatchesMask( int paneMask );
986
987 inline bool IsHorizontal()
988 {
989 return (mAlignment == wxTOP ||
990 mAlignment == wxBOTTOM );
991 }
992
993 virtual void RecalcLayout();
994
995 virtual int GetDockingState();
996
997 // returns result of hit-testing items in the pane,
998 // see CB_HITTEST_RESULTS enumeration
999
1000 virtual int HitTestPaneItems( const wxPoint& pos, // position in pane's coorinates
1001 cbRowInfo** ppRow,
1002 cbBarInfo** ppBar
1003 );
1004
1005 void GetBarResizeRange( cbBarInfo* pBar, int* from, int *till, bool forLeftHandle );
1006 void GetRowResizeRange( cbRowInfo* pRow, int* from, int* till, bool forUpperHandle );
1007
1008 cbBarInfo* GetBarInfoByWindow( wxWindow* pBarWnd );
1009
1010 public: /* protected really (accessed only by plugins) */
1011
1012 // row/bar resizing related helper-methods
1013
1014 void DrawVertHandle ( wxDC& dc, int x, int y, int height );
1015 void DrawHorizHandle( wxDC& dc, int x, int y, int width );
1016
1017 void ResizeRow( cbRowInfo* pRow, int ofs, bool forUpperHandle );
1018 void ResizeBar( cbBarInfo* pBar, int ofs, bool forLeftHandle );
1019
1020 // cbBarShapeData objects will be placed to given pLst (see comments on cbBarShapeData)
1021
1022 void GetRowShapeData( cbRowInfo* pRow, wxList* pLst );
1023
1024 // sets the shape to the given row, using the data provided in pLst
1025 void SetRowShapeData( cbRowInfo* pRowNode, wxList* pLst );
1026 };
1027
1028 /*
1029 * class declares abstract interface for optimized logic, which should refresh
1030 * areas of frame layout - that actually need to be updated. Should be extanded,
1031 * to implemnet custom updating strategy
1032 */
1033
1034 class cbUpdatesManagerBase : public wxObject
1035 {
1036 DECLARE_ABSTRACT_CLASS( cbUpdatesManagerBase )
1037
1038 public: /* protected really, accessed by serializer (if any) */
1039
1040 wxFrameLayout* mpLayout;
1041
1042 public:
1043 cbUpdatesManagerBase(void)
1044 : mpLayout( 0 ) {}
1045
1046 cbUpdatesManagerBase( wxFrameLayout* pPanel )
1047 : mpLayout( pPanel ) {}
1048
1049 void SetLayout( wxFrameLayout* pLayout ) { mpLayout = pLayout; }
1050
1051 // notificiactions received from frame-layout (in the order, in which
1052 // they usually would be invoked). Custom updates-managers may utilize
1053 // these notifications to implement more "fine-grained" updating strategy
1054
1055 virtual void OnStartChanges() = 0;
1056
1057 virtual void OnRowWillChange( cbRowInfo* pRow, cbDockPane* pInPane ) {}
1058 virtual void OnBarWillChange( cbBarInfo* pBar, cbRowInfo* pInRow, cbDockPane* pInPane ) {}
1059 virtual void OnPaneMarginsWillChange( cbDockPane* pPane ) {}
1060 virtual void OnPaneWillChange( cbDockPane* pPane ) {}
1061
1062 virtual void OnFinishChanges() {}
1063
1064 // refreshes parts of the frame layout, which need an update
1065 virtual void UpdateNow() = 0;
1066 };
1067
1068 /*------------------------------------------------------------
1069 * "API" for developing custom plugins of Frame Layout Engine
1070 * TODO:: documentation
1071 *------------------------------------------------------------
1072 */
1073
1074 // base class for all control-bar plugin events
1075
1076 class cbPluginEvent : public wxEvent
1077 {
1078 // NOTE:: plugin-event does not need to be a dynamic class
1079
1080 public:
1081 cbDockPane* mpPane; // NULL, if event is not addressed to any specific pane
1082
1083 /* OLD STUFF::
1084 // FOR NOW FOR NOW:: all-in-on plugin event structure
1085 wxNode* mpObjNode;
1086 wxNode* mpObjNodeAux;
1087 wxPoint mPos;
1088 wxSize mSize;
1089 wxDC* mpDC;
1090 bool mAuxBoolVal;
1091 */
1092
1093 cbPluginEvent( int eventType, cbDockPane* pPane )
1094 : mpPane( pPane )
1095
1096 { m_eventType = eventType; }
1097 };
1098
1099 // event types handled by plugins
1100
1101 #define cbEVT_PL_LEFT_DOWN 0
1102 #define cbEVT_PL_LEFT_UP 1
1103 #define cbEVT_PL_RIGHT_DOWN 2
1104 #define cbEVT_PL_RIGHT_UP 3
1105 #define cbEVT_PL_MOTION 4
1106
1107 #define cbEVT_PL_LEFT_DCLICK 5
1108
1109 #define cbEVT_PL_LAYOUT_ROW 6
1110 #define cbEVT_PL_RESIZE_ROW 7
1111 #define cbEVT_PL_LAYOUT_ROWS 8
1112 #define cbEVT_PL_INSERT_BAR 9
1113 #define cbEVT_PL_RESIZE_BAR 10
1114 #define cbEVT_PL_REMOVE_BAR 11
1115 #define cbEVT_PL_SIZE_BAR_WND 12
1116
1117 #define cbEVT_PL_DRAW_BAR_DECOR 13
1118 #define cbEVT_PL_DRAW_ROW_DECOR 14
1119 #define cbEVT_PL_DRAW_PANE_DECOR 15
1120 #define cbEVT_PL_DRAW_BAR_HANDLES 16
1121 #define cbEVT_PL_DRAW_ROW_HANDLES 17
1122 #define cbEVT_PL_DRAW_ROW_BKGROUND 18
1123 #define cbEVT_PL_DRAW_PANE_BKGROUND 19
1124
1125 #define cbEVT_PL_START_BAR_DRAGGING 20
1126 #define cbEVT_PL_DRAW_HINT_RECT 21
1127
1128 #define cbEVT_PL_START_DRAW_IN_AREA 22
1129 #define cbEVT_PL_FINISH_DRAW_IN_AREA 23
1130
1131 #define cbEVT_PL_CUSTOMIZE_BAR 24
1132 #define cbEVT_PL_CUSTOMIZE_LAYOUT 25
1133
1134 #define wxCUSTOM_CB_PLUGIN_EVENTS_START_AT 100
1135
1136 // forward decls, separated by categories
1137
1138 class cbLeftDownEvent;
1139 class cbLeftUpEvent;
1140 class cbRightDownEvent;
1141 class cbRightUpEvent;
1142 class cbMotionEvent;
1143 class cbLeftDClickEvent;
1144
1145 class cbLayoutRowEvent;
1146 class cbResizeRowEvent;
1147 class cbLayoutRowsEvent;
1148 class cbInsertBarEvent;
1149 class cbResizeBarEvent;
1150 class cbRemoveBarEvent;
1151 class cbSizeBarWndEvent;
1152
1153 class cbDrawBarDecorEvent;
1154 class cbDrawRowDecorEvent;
1155 class cbDrawPaneDecorEvent;
1156 class cbDrawBarHandlesEvent;
1157 class cbDrawRowHandlesEvent;
1158 class cbDrawRowBkGroundEvent;
1159 class cbDrawPaneBkGroundEvent;
1160
1161 class cbStartBarDraggingEvent;
1162 class cbDrawHintRectEvent;
1163
1164 class cbStartDrawInAreaEvent;
1165 class cbFinishDrawInAreaEvent;
1166
1167 class cbCustomizeBarEvent;
1168 class cbCustomizeLayoutEvent;
1169
1170 // defs. for handler-methods
1171
1172 typedef void (wxEvtHandler::*cbLeftDownHandler )(cbLeftDownEvent&);
1173 typedef void (wxEvtHandler::*cbLeftUpHandler )(cbLeftUpEvent&);
1174 typedef void (wxEvtHandler::*cbRightDownHandler )(cbRightDownEvent&);
1175 typedef void (wxEvtHandler::*cbRightUpHandler )(cbRightUpEvent&);
1176 typedef void (wxEvtHandler::*cbMotionHandler )(cbMotionEvent&);
1177 typedef void (wxEvtHandler::*cbLeftDClickHandler )(cbLeftDClickEvent&);
1178
1179 typedef void (wxEvtHandler::*cbLayoutRowHandler )(cbLayoutRowEvent&);
1180 typedef void (wxEvtHandler::*cbResizeRowHandler )(cbResizeRowEvent&);
1181 typedef void (wxEvtHandler::*cbLayoutRowsHandler )(cbLayoutRowsEvent&);
1182 typedef void (wxEvtHandler::*cbInsertBarHandler )(cbInsertBarEvent&);
1183 typedef void (wxEvtHandler::*cbResizeBarHandler )(cbResizeBarEvent&);
1184 typedef void (wxEvtHandler::*cbRemoveBarHandler )(cbRemoveBarEvent&);
1185 typedef void (wxEvtHandler::*cbSizeBarWndHandler )(cbSizeBarWndEvent&);
1186
1187 typedef void (wxEvtHandler::*cbDrawBarDecorHandler )(cbDrawBarDecorEvent&);
1188 typedef void (wxEvtHandler::*cbDrawRowDecorHandler )(cbDrawRowDecorEvent&);
1189 typedef void (wxEvtHandler::*cbDrawPaneDecorHandler )(cbDrawPaneDecorEvent&);
1190 typedef void (wxEvtHandler::*cbDrawBarHandlesHandler )(cbDrawBarHandlesEvent&);
1191 typedef void (wxEvtHandler::*cbDrawRowHandlesHandler )(cbDrawRowHandlesEvent&);
1192 typedef void (wxEvtHandler::*cbDrawRowBkGroundHandler )(cbDrawRowBkGroundEvent&);
1193 typedef void (wxEvtHandler::*cbDrawPaneBkGroundHandler)(cbDrawPaneBkGroundEvent&);
1194
1195 typedef void (wxEvtHandler::*cbStartBarDraggingHandler )(cbStartBarDraggingEvent&);
1196 typedef void (wxEvtHandler::*cbDrawHintRectHandler )(cbDrawHintRectEvent&);
1197
1198 typedef void (wxEvtHandler::*cbStartDrawInAreaHandler )(cbStartDrawInAreaEvent&);
1199 typedef void (wxEvtHandler::*cbFinishDrawInAreaHandler)(cbFinishDrawInAreaEvent&);
1200
1201 typedef void (wxEvtHandler::*cbCustomizeBarHandler )(cbCustomizeBarEvent&);
1202 typedef void (wxEvtHandler::*cbCustomizeLayoutHandler )(cbCustomizeLayoutEvent&);
1203
1204 // macros for creating event table entries for plugin-events
1205
1206 #define EVT_PL_LEFT_DOWN(func) { cbEVT_PL_LEFT_DOWN, -1, -1, (wxObjectEventFunction) (wxEventFunction) (cbLeftDownHandler ) & func },
1207 #define EVT_PL_LEFT_UP(func) { cbEVT_PL_LEFT_UP, -1, -1, (wxObjectEventFunction) (wxEventFunction) (cbLeftUpHandler ) & func },
1208 #define EVT_PL_RIGHT_DOWN(func) { cbEVT_PL_RIGHT_DOWN, -1, -1, (wxObjectEventFunction) (wxEventFunction) (cbRightDownHandler ) & func },
1209 #define EVT_PL_RIGHT_UP(func) { cbEVT_PL_RIGHT_UP, -1, -1, (wxObjectEventFunction) (wxEventFunction) (cbRightUpHandler ) & func },
1210 #define EVT_PL_MOTION(func) { cbEVT_PL_MOTION, -1, -1, (wxObjectEventFunction) (wxEventFunction) (cbMotionHandler ) & func },
1211 #define EVT_PL_LEFT_DCLICK(func) { cbEVT_PL_LEFT_DCLICK, -1, -1, (wxObjectEventFunction) (wxEventFunction) (cbLeftDClickHandler ) & func },
1212
1213 #define EVT_PL_LAYOUT_ROW(func) { cbEVT_PL_LAYOUT_ROW, -1, -1, (wxObjectEventFunction) (wxEventFunction) (cbLayoutRowHandler ) & func },
1214 #define EVT_PL_RESIZE_ROW(func) { cbEVT_PL_RESIZE_ROW, -1, -1, (wxObjectEventFunction) (wxEventFunction) (cbResizeRowHandler ) & func },
1215 #define EVT_PL_LAYOUT_ROWS(func) { cbEVT_PL_LAYOUT_ROWS, -1, -1, (wxObjectEventFunction) (wxEventFunction) (cbLayoutRowsHandler ) & func },
1216 #define EVT_PL_INSERT_BAR(func) { cbEVT_PL_INSERT_BAR, -1, -1, (wxObjectEventFunction) (wxEventFunction) (cbInsertBarHandler ) & func },
1217 #define EVT_PL_RESIZE_BAR(func) { cbEVT_PL_RESIZE_BAR, -1, -1, (wxObjectEventFunction) (wxEventFunction) (cbResizeBarHandler ) & func },
1218 #define EVT_PL_REMOVE_BAR(func) { cbEVT_PL_REMOVE_BAR, -1, -1, (wxObjectEventFunction) (wxEventFunction) (cbRemoveBarHandler ) & func },
1219 #define EVT_PL_SIZE_BAR_WND(func) { cbEVT_PL_SIZE_BAR_WND, -1, -1, (wxObjectEventFunction) (wxEventFunction) (cbSizeBarWndHandler ) & func },
1220
1221 #define EVT_PL_DRAW_BAR_DECOR(func) { cbEVT_PL_DRAW_BAR_DECOR, -1, -1, (wxObjectEventFunction) (wxEventFunction) (cbDrawBarDecorHandler ) & func },
1222 #define EVT_PL_DRAW_ROW_DECOR(func) { cbEVT_PL_DRAW_ROW_DECOR, -1, -1, (wxObjectEventFunction) (wxEventFunction) (cbDrawRowDecorHandler ) & func },
1223 #define EVT_PL_DRAW_PANE_DECOR(func) { cbEVT_PL_DRAW_PANE_DECOR, -1, -1, (wxObjectEventFunction) (wxEventFunction) (cbDrawPaneDecorHandler ) & func },
1224 #define EVT_PL_DRAW_BAR_HANDLES(func) { cbEVT_PL_DRAW_BAR_HANDLES, -1, -1, (wxObjectEventFunction) (wxEventFunction) (cbDrawBarHandlesHandler ) & func },
1225 #define EVT_PL_DRAW_ROW_HANDLES(func) { cbEVT_PL_DRAW_ROW_HANDLES, -1, -1, (wxObjectEventFunction) (wxEventFunction) (cbDrawRowHandlesHandler ) & func },
1226 #define EVT_PL_DRAW_ROW_BKGROUND(func) { cbEVT_PL_DRAW_ROW_BKGROUND, -1, -1, (wxObjectEventFunction) (wxEventFunction) (cbDrawRowBkGroundHandler ) & func },
1227 #define EVT_PL_DRAW_PANE_BKGROUND(func) { cbEVT_PL_DRAW_PANE_BKGROUND, -1, -1, (wxObjectEventFunction) (wxEventFunction) (cbDrawPaneBkGroundHandler) & func },
1228
1229 #define EVT_PL_START_BAR_DRAGGING(func) { cbEVT_PL_START_BAR_DRAGGING, -1, -1, (wxObjectEventFunction) (wxEventFunction) (cbStartBarDraggingHandler) & func },
1230 #define EVT_PL_DRAW_HINT_RECT(func) { cbEVT_PL_DRAW_HINT_RECT, -1, -1, (wxObjectEventFunction) (wxEventFunction) (cbDrawHintRectHandler ) & func },
1231
1232 #define EVT_PL_START_DRAW_IN_AREA(func) { cbEVT_PL_START_DRAW_IN_AREA, -1, -1, (wxObjectEventFunction) (wxEventFunction) (cbStartDrawInAreaHandler) & func },
1233 #define EVT_PL_FINISH_DRAW_IN_AREA(func) { cbEVT_PL_FINISH_DRAW_IN_AREA, -1, -1, (wxObjectEventFunction) (wxEventFunction) (cbFinishDrawInAreaHandler) & func },
1234
1235 #define EVT_PL_CUSTOMIZE_BAR(func) { cbEVT_PL_CUSTOMIZE_BAR, -1, -1, (wxObjectEventFunction) (wxEventFunction) (cbCustomizeBarHandler) & func },
1236 #define EVT_PL_CUSTOMIZE_LAYOUT(func) { cbEVT_PL_CUSTOMIZE_LAYOUT, -1, -1, (wxObjectEventFunction) (wxEventFunction) (cbCustomizeLayoutHandler) & func },
1237
1238 /*
1239 * abstract base class for all control-bar related plugins
1240 */
1241
1242 class cbPluginBase : public wxEvtHandler
1243 {
1244 DECLARE_ABSTRACT_CLASS( cbPluginBase )
1245 public:
1246
1247 wxFrameLayout* mpLayout; // back-reference to the frame layout
1248
1249 // specifies panes, for which this plugin receives events
1250 // (see pane masks definitions)
1251 int mPaneMask;
1252
1253 bool mIsReady; // is TRUE, when plugin is ready to handle events
1254
1255 public:
1256 cbPluginBase(void)
1257
1258 : mpLayout ( 0 ),
1259 mPaneMask( wxALL_PANES ),
1260 mIsReady ( FALSE )
1261 {}
1262
1263 cbPluginBase( wxFrameLayout* pPanel, int paneMask = wxALL_PANES )
1264
1265 : mpLayout ( pPanel ),
1266 mPaneMask( paneMask ),
1267 mIsReady ( FALSE )
1268 {}
1269
1270 inline int GetPaneMask() { return mPaneMask; }
1271
1272 // NOTE:: pointer positions of mouse-events sent to plugins
1273 // are always in pane's coordinates (pane's to which
1274 // this plugin is hooked)
1275
1276 // destroys the whole plugin chain of connected plagins
1277 virtual ~cbPluginBase();
1278
1279 // override this method to do plugin-specific initialization
1280 // (at this point plugin is already attached to the frame layout,
1281 // and pane masks are set)
1282 virtual void OnInitPlugin() { mIsReady = TRUE; }
1283
1284 bool IsReady() { return mIsReady; }
1285
1286 // overriden, to determine whether the target pane specified in the
1287 // event, matches the pane mask of this plugin (specific plugins
1288 // do not override this method)
1289
1290 virtual bool ProcessEvent(wxEvent& event);
1291 };
1292
1293 /*** event classes, for each corresponding event type (24 currnetly...uhh) ***/
1294
1295 // mouse-events category
1296
1297 class cbLeftDownEvent : public cbPluginEvent
1298 {
1299 public:
1300 wxPoint mPos;
1301
1302 cbLeftDownEvent( const wxPoint& pos, cbDockPane* pPane )
1303
1304 : cbPluginEvent( cbEVT_PL_LEFT_DOWN, pPane ),
1305 mPos( pos )
1306 {}
1307 };
1308
1309 class cbLeftUpEvent : public cbPluginEvent
1310 {
1311 public:
1312 wxPoint mPos;
1313
1314 cbLeftUpEvent( const wxPoint& pos, cbDockPane* pPane )
1315
1316 : cbPluginEvent( cbEVT_PL_LEFT_UP, pPane ),
1317 mPos( pos )
1318 {}
1319 };
1320
1321 class cbRightDownEvent : public cbPluginEvent
1322 {
1323 public:
1324 wxPoint mPos;
1325
1326 cbRightDownEvent( const wxPoint& pos, cbDockPane* pPane )
1327
1328 : cbPluginEvent( cbEVT_PL_RIGHT_DOWN, pPane ),
1329 mPos( pos )
1330 {}
1331 };
1332
1333 class cbRightUpEvent : public cbPluginEvent
1334 {
1335 public:
1336 wxPoint mPos;
1337
1338 cbRightUpEvent( const wxPoint& pos, cbDockPane* pPane )
1339
1340 : cbPluginEvent( cbEVT_PL_RIGHT_UP, pPane ),
1341 mPos( pos )
1342 {}
1343 };
1344
1345 class cbMotionEvent : public cbPluginEvent
1346 {
1347 public:
1348 wxPoint mPos;
1349
1350 cbMotionEvent( const wxPoint& pos, cbDockPane* pPane )
1351
1352 : cbPluginEvent( cbEVT_PL_MOTION, pPane ),
1353 mPos( pos )
1354 {}
1355 };
1356
1357 class cbLeftDClickEvent : public cbPluginEvent
1358 {
1359 public:
1360 wxPoint mPos;
1361
1362 cbLeftDClickEvent( const wxPoint& pos, cbDockPane* pPane )
1363
1364 : cbPluginEvent( cbEVT_PL_LEFT_DCLICK, pPane ),
1365 mPos( pos )
1366 {}
1367 };
1368
1369 // bar/row events category
1370
1371 class cbLayoutRowEvent : public cbPluginEvent
1372 {
1373 public:
1374 cbRowInfo* mpRow;
1375
1376 cbLayoutRowEvent( cbRowInfo* pRow, cbDockPane* pPane )
1377
1378 : cbPluginEvent( cbEVT_PL_LAYOUT_ROW, pPane ),
1379 mpRow( pRow )
1380 {}
1381 };
1382
1383 class cbResizeRowEvent : public cbPluginEvent
1384 {
1385 public:
1386 cbRowInfo* mpRow;
1387 int mHandleOfs;
1388 bool mForUpperHandle;
1389
1390 cbResizeRowEvent( cbRowInfo* pRow, int handleOfs, bool forUpperHandle, cbDockPane* pPane )
1391
1392 : cbPluginEvent( cbEVT_PL_RESIZE_ROW, pPane ),
1393 mpRow( pRow ),
1394 mHandleOfs( handleOfs ),
1395 mForUpperHandle( forUpperHandle )
1396 {}
1397 };
1398
1399 class cbLayoutRowsEvent : public cbPluginEvent
1400 {
1401 public:
1402
1403 cbLayoutRowsEvent( cbDockPane* pPane )
1404
1405 : cbPluginEvent( cbEVT_PL_LAYOUT_ROWS, pPane )
1406 {}
1407 };
1408
1409 class cbInsertBarEvent : public cbPluginEvent
1410 {
1411 public:
1412 cbBarInfo* mpBar;
1413 cbRowInfo* mpRow;
1414
1415 cbInsertBarEvent( cbBarInfo* pBar, cbRowInfo* pIntoRow, cbDockPane* pPane )
1416
1417 : cbPluginEvent( cbEVT_PL_INSERT_BAR, pPane ),
1418
1419 mpBar( pBar ),
1420 mpRow( pIntoRow )
1421 {}
1422 };
1423
1424 class cbResizeBarEvent : public cbPluginEvent
1425 {
1426 public:
1427 cbBarInfo* mpBar;
1428 cbRowInfo* mpRow;
1429
1430 cbResizeBarEvent( cbBarInfo* pBar, cbRowInfo* pRow, cbDockPane* pPane )
1431
1432 : cbPluginEvent( cbEVT_PL_RESIZE_BAR, pPane ),
1433 mpBar( pBar ),
1434 mpRow( pRow )
1435 {}
1436 };
1437
1438 class cbRemoveBarEvent : public cbPluginEvent
1439 {
1440 public:
1441 cbBarInfo* mpBar;
1442
1443 cbRemoveBarEvent( cbBarInfo* pBar, cbDockPane* pPane )
1444
1445 : cbPluginEvent( cbEVT_PL_REMOVE_BAR, pPane ),
1446 mpBar( pBar )
1447 {}
1448 };
1449
1450 class cbSizeBarWndEvent : public cbPluginEvent
1451 {
1452 public:
1453 cbBarInfo* mpBar;
1454 wxRect mBoundsInParent;
1455
1456 cbSizeBarWndEvent( cbBarInfo* pBar, cbDockPane* pPane )
1457
1458 : cbPluginEvent( cbEVT_PL_SIZE_BAR_WND, pPane ),
1459 mpBar( pBar ),
1460 mBoundsInParent( pBar->mBoundsInParent )
1461 {}
1462 };
1463
1464 class cbDrawBarDecorEvent : public cbPluginEvent
1465 {
1466 public:
1467 cbBarInfo* mpBar;
1468 wxDC* mpDc;
1469 wxRect mBoundsInParent;
1470
1471 cbDrawBarDecorEvent( cbBarInfo* pBar, wxDC& dc, cbDockPane* pPane )
1472
1473 : cbPluginEvent( cbEVT_PL_DRAW_BAR_DECOR, pPane ),
1474 mpBar( pBar ),
1475 mpDc( &dc ),
1476 mBoundsInParent( pBar->mBoundsInParent )
1477 {}
1478 };
1479
1480 class cbDrawRowDecorEvent : public cbPluginEvent
1481 {
1482 public:
1483 cbRowInfo* mpRow;
1484 wxDC* mpDc;
1485
1486 cbDrawRowDecorEvent( cbRowInfo* pRow, wxDC& dc, cbDockPane* pPane )
1487
1488 : cbPluginEvent( cbEVT_PL_DRAW_ROW_DECOR, pPane ),
1489 mpRow( pRow ),
1490 mpDc( &dc )
1491 {}
1492 };
1493
1494 class cbDrawPaneDecorEvent : public cbPluginEvent
1495 {
1496 public:
1497 wxDC* mpDc;
1498
1499 cbDrawPaneDecorEvent( wxDC& dc, cbDockPane* pPane )
1500
1501 : cbPluginEvent( cbEVT_PL_DRAW_PANE_DECOR, pPane ),
1502 mpDc( &dc )
1503 {}
1504 };
1505
1506 class cbDrawBarHandlesEvent : public cbPluginEvent
1507 {
1508 public:
1509 cbBarInfo* mpBar;
1510 wxDC* mpDc;
1511
1512 cbDrawBarHandlesEvent( cbBarInfo* pBar, wxDC& dc, cbDockPane* pPane )
1513
1514 : cbPluginEvent( cbEVT_PL_DRAW_BAR_HANDLES, pPane ),
1515 mpBar( pBar ),
1516 mpDc( &dc )
1517 {}
1518 };
1519
1520 class cbDrawRowHandlesEvent : public cbPluginEvent
1521 {
1522 public:
1523 cbRowInfo* mpRow;
1524 wxDC* mpDc;
1525
1526 cbDrawRowHandlesEvent( cbRowInfo* pRow, wxDC& dc, cbDockPane* pPane )
1527
1528 : cbPluginEvent( cbEVT_PL_DRAW_ROW_HANDLES, pPane ),
1529 mpRow( pRow ),
1530 mpDc( &dc )
1531 {}
1532 };
1533
1534 class cbDrawRowBkGroundEvent : public cbPluginEvent
1535 {
1536 public:
1537 cbRowInfo* mpRow;
1538 wxDC* mpDc;
1539
1540 cbDrawRowBkGroundEvent( cbRowInfo* pRow, wxDC& dc, cbDockPane* pPane )
1541
1542 : cbPluginEvent( cbEVT_PL_DRAW_ROW_BKGROUND, pPane ),
1543 mpRow( pRow ),
1544 mpDc( &dc )
1545 {}
1546 };
1547
1548 class cbDrawPaneBkGroundEvent : public cbPluginEvent
1549 {
1550 public:
1551 wxDC* mpDc;
1552
1553 cbDrawPaneBkGroundEvent( wxDC& dc, cbDockPane* pPane )
1554
1555 : cbPluginEvent( cbEVT_PL_DRAW_PANE_BKGROUND, pPane ),
1556 mpDc( &dc )
1557 {}
1558 };
1559
1560 class cbStartBarDraggingEvent : public cbPluginEvent
1561 {
1562 public:
1563 cbBarInfo* mpBar;
1564 wxPoint mPos; // is given in frame's coordinates
1565
1566 cbStartBarDraggingEvent( cbBarInfo* pBar, const wxPoint& pos, cbDockPane* pPane )
1567
1568 : cbPluginEvent( cbEVT_PL_START_BAR_DRAGGING, pPane ),
1569 mpBar( pBar ),
1570 mPos( pos )
1571 {}
1572 };
1573
1574 class cbDrawHintRectEvent : public cbPluginEvent
1575 {
1576 public:
1577 wxRect mRect; // is given in frame's coordinates
1578
1579
1580 bool mLastTime; // indicates that this event finishes "session" of on-screen drawing,
1581 // thus associated resources can be freed now
1582 bool mEraseRect; // does not have any impact, if recangle is drawn using XOR-mask
1583
1584 bool mIsInClient;// in cleint area hint could be drawn differently,
1585 // e.g. with fat/hatched border
1586
1587
1588 cbDrawHintRectEvent( const wxRect& rect, bool isInClient, bool eraseRect, bool lastTime )
1589
1590 : cbPluginEvent( cbEVT_PL_DRAW_HINT_RECT, 0 ),
1591 mRect ( rect ),
1592 mLastTime ( lastTime ),
1593 mEraseRect ( eraseRect ),
1594 mIsInClient( isInClient )
1595 {}
1596 };
1597
1598 class cbStartDrawInAreaEvent : public cbPluginEvent
1599 {
1600 public:
1601 wxRect mArea;
1602 wxDC** mppDc; // points to pointer, where the reference
1603 // to the obtained buffer-context should be placed
1604
1605 cbStartDrawInAreaEvent( const wxRect& area, wxDC** ppDCForArea, cbDockPane* pPane )
1606
1607 : cbPluginEvent( cbEVT_PL_START_DRAW_IN_AREA, pPane ),
1608 mArea( area ),
1609 mppDc( ppDCForArea )
1610 {}
1611 };
1612
1613 class cbFinishDrawInAreaEvent : public cbPluginEvent
1614 {
1615 public:
1616 wxRect mArea;
1617
1618 cbFinishDrawInAreaEvent( const wxRect& area, cbDockPane* pPane )
1619
1620 : cbPluginEvent( cbEVT_PL_FINISH_DRAW_IN_AREA, pPane ),
1621 mArea( area )
1622 {}
1623 };
1624
1625 class cbCustomizeBarEvent : public cbPluginEvent
1626 {
1627 public:
1628 wxPoint mClickPos; // in parent frame's coordinates
1629 cbBarInfo* mpBar;
1630
1631 cbCustomizeBarEvent( cbBarInfo* pBar, const wxPoint& clickPos, cbDockPane* pPane )
1632
1633 : cbPluginEvent( cbEVT_PL_CUSTOMIZE_BAR, pPane ),
1634 mClickPos( clickPos ),
1635 mpBar( pBar )
1636 {}
1637 };
1638
1639 class cbCustomizeLayoutEvent : public cbPluginEvent
1640 {
1641 public:
1642 wxPoint mClickPos; // in parent frame's coordinates
1643
1644 cbCustomizeLayoutEvent( const wxPoint& clickPos )
1645
1646 : cbPluginEvent( cbEVT_PL_CUSTOMIZE_LAYOUT, 0 ),
1647 mClickPos( clickPos )
1648 {}
1649 };
1650
1651
1652 #endif