1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: Contrib. demo
4 // Author: Aleksandras Gluchovas
8 // Copyright: (c) Aleksandras Gluchovas
9 // Licence: wxWindows license
10 /////////////////////////////////////////////////////////////////////////////
12 #ifndef __ROWDRAGPL_G__
13 #define __ROWDRAGPL_G__
15 #include "controlbar.h"
18 * Plugin adds row-dragging fuctionality to the pane.
19 * Handles mouse/movement and pane-background erasing plugin-events.
20 * Behaviour and appearence resembles drag & drop posotioning
21 * of the toolbar-rows int Netscape Comunicator 4.xx.
24 class cbRowDragPlugin
: public cbPluginBase
26 DECLARE_DYNAMIC_CLASS( cbRowDragPlugin
)
28 // background colours for the highlighted/unhighlighted icons
30 wxColour mHightColor
; // light-blue for NC-look
31 wxColour mLowColor
; // light-gray -/-
32 wxColour mTrianInnerColor
; // blue -/-
33 wxPen mTrianInnerPen
; // black -/-
36 friend class cbRowDragPluginSerializer
;
38 // drag & drop state variables
45 // saved margins of the pane
51 //on-screen drawing state variables
52 wxBitmap
* mpPaneImage
;
54 wxBitmap
* mpCombinedImage
;
61 // NOTE:: if mpRowInFocus is not NULL, then mCollapsedIconInFocus is -1,
62 // and v.v. (two different items cannot be in focus at the same time)
64 cbRowInfo
* mpRowInFocus
;
65 int mCollapsedIconInFocus
;
67 cbDockPane
* mpPane
; // is set up temorarely, while handling event
71 wxBitmap
* CaptureDCArea( wxDC
& dc
, wxRect
& area
);
73 // helpers for drag&drop
75 int GetHRowsCountForPane( cbDockPane
* pPane
);
77 void SetMouseCapture( bool captureOn
);
78 void PrepareForRowDrag();
79 void ShowDraggedRow( int offset
);
81 void FinishOnScreenDraw();
82 void CollapseRow( cbRowInfo
* pRow
);
83 void ExpandRow( int collapsedIconIdx
);
84 void InsertDraggedRowBefore( cbRowInfo
* pBeforeRow
);
86 void CheckPrevItemInFocus( cbRowInfo
* pRow
, int iconIdx
);
87 void UnhiglightItemInFocus();
89 cbRowInfo
* GetFirstRow();
91 // "hard-coded metafile" for NN-look
93 virtual void DrawTrianUp( wxRect
& inRect
, wxDC
& dc
);
94 virtual void DrawTrianDown( wxRect
& inRect
, wxDC
& dc
);
95 virtual void DrawTrianRight( wxRect
& inRect
, wxDC
& dc
);
96 virtual void Draw3DPattern( wxRect
& inRect
, wxDC
& dc
);
97 virtual void DrawRombShades( wxPoint
& p1
, wxPoint
& p2
, wxPoint
& p3
, wxPoint
& p4
, wxDC
& dc
);
98 virtual void DrawOrtoRomb( wxRect
& inRect
, wxDC
& dc
, wxBrush
& bkBrush
);
99 virtual void DrawRomb( wxRect
& inRect
, wxDC
& dc
, wxBrush
& bkBrush
);
100 virtual void Draw3DRect( wxRect
& inRect
, wxDC
& dc
, wxBrush
& bkBrush
);
101 virtual void DrawRectShade( wxRect
& inRect
, wxDC
& dc
,
102 int level
, wxPen
& upperPen
, wxPen
& lowerPen
);
104 virtual void GetRowHintRect( cbRowInfo
* pRow
, wxRect
& rect
);
105 virtual void GetCollapsedInconRect( int iconIdx
, wxRect
& rect
);
107 virtual int GetCollapsedIconsPos();
111 cbRowDragPlugin(void);
113 cbRowDragPlugin( wxFrameLayout
* pLayout
, int paneMask
= wxALL_PANES
);
114 virtual ~cbRowDragPlugin();
116 virtual cbPluginBase
* Clone() { return new cbRowDragPlugin(NULL
,0); }
118 virtual void OnInitPlugin();
120 // handlers for plugin events (appearence-independent logic)
122 void OnMouseMove ( cbMotionEvent
& event
);
123 void OnLButtonDown( cbLeftDownEvent
& event
);
124 void OnLButtonUp ( cbLeftUpEvent
& event
);
125 void OnDrawPaneBackground( cbDrawPaneDecorEvent
& event
);
127 // overridables (appearence-depedent)
129 virtual void DrawCollapsedRowIcon( int index
, wxDC
& dc
, bool isHighlighted
);
130 virtual void DrawCollapsedRowsBorder( wxDC
& dc
);
131 virtual void DrawRowsDragHintsBorder( wxDC
& dc
);
132 virtual void DrawRowDragHint( cbRowInfo
* pRow
, wxDC
& dc
, bool isHighlighted
);
133 virtual void DrawEmptyRow( wxDC
& dc
, wxRect
& rowBounds
);
135 virtual int GetCollapsedRowIconHeight();
136 virtual int GetRowDragHintWidth();
138 virtual void SetPaneMargins();
141 virtual bool HitTestCollapsedRowIcon( int iconIdx
, const wxPoint
& pos
);
142 virtual bool HitTestRowDragHint( cbRowInfo
* pRow
, const wxPoint
& pos
);
144 DECLARE_EVENT_TABLE()
147 // internal helper-class
149 class cbHiddenBarInfo
: public wxObject
151 DECLARE_DYNAMIC_CLASS( cbHiddenBarInfo
)