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__
16 #pragma interface "rowdragpl.h"
19 #include "wx/fl/controlbar.h"
22 * Plugin adds row-dragging fuctionality to the pane.
23 * Handles mouse/movement and pane-background erasing plugin-events.
24 * Behaviour and appearence resembles drag & drop posotioning
25 * of the toolbar-rows int Netscape Comunicator 4.xx.
28 class cbRowDragPlugin
: public cbPluginBase
30 DECLARE_DYNAMIC_CLASS( cbRowDragPlugin
)
32 // background colours for the highlighted/unhighlighted icons
34 wxColour mHightColor
; // light-blue for NC-look
35 wxColour mLowColor
; // light-gray -/-
36 wxColour mTrianInnerColor
; // blue -/-
37 wxPen mTrianInnerPen
; // black -/-
40 friend class cbRowDragPluginSerializer
;
42 // drag & drop state variables
49 // saved margins of the pane
55 //on-screen drawing state variables
56 wxBitmap
* mpPaneImage
;
58 wxBitmap
* mpCombinedImage
;
65 // NOTE:: if mpRowInFocus is not NULL, then mCollapsedIconInFocus is -1,
66 // and v.v. (two different items cannot be in focus at the same time)
68 cbRowInfo
* mpRowInFocus
;
69 int mCollapsedIconInFocus
;
71 cbDockPane
* mpPane
; // is set up temorarely, while handling event
75 wxBitmap
* CaptureDCArea( wxDC
& dc
, wxRect
& area
);
77 // helpers for drag&drop
79 int GetHRowsCountForPane( cbDockPane
* pPane
);
81 void SetMouseCapture( bool captureOn
);
82 void PrepareForRowDrag();
83 void ShowDraggedRow( int offset
);
85 void FinishOnScreenDraw();
86 void CollapseRow( cbRowInfo
* pRow
);
87 void ExpandRow( int collapsedIconIdx
);
88 void InsertDraggedRowBefore( cbRowInfo
* pBeforeRow
);
90 void CheckPrevItemInFocus( cbRowInfo
* pRow
, int iconIdx
);
91 void UnhiglightItemInFocus();
93 cbRowInfo
* GetFirstRow();
95 // "hard-coded metafile" for NN-look
97 virtual void DrawTrianUp( wxRect
& inRect
, wxDC
& dc
);
98 virtual void DrawTrianDown( wxRect
& inRect
, wxDC
& dc
);
99 virtual void DrawTrianRight( wxRect
& inRect
, wxDC
& dc
);
100 virtual void Draw3DPattern( wxRect
& inRect
, wxDC
& dc
);
101 virtual void DrawRombShades( wxPoint
& p1
, wxPoint
& p2
, wxPoint
& p3
, wxPoint
& p4
, wxDC
& dc
);
102 virtual void DrawOrtoRomb( wxRect
& inRect
, wxDC
& dc
, wxBrush
& bkBrush
);
103 virtual void DrawRomb( wxRect
& inRect
, wxDC
& dc
, wxBrush
& bkBrush
);
104 virtual void Draw3DRect( wxRect
& inRect
, wxDC
& dc
, wxBrush
& bkBrush
);
105 virtual void DrawRectShade( wxRect
& inRect
, wxDC
& dc
,
106 int level
, wxPen
& upperPen
, wxPen
& lowerPen
);
108 virtual void GetRowHintRect( cbRowInfo
* pRow
, wxRect
& rect
);
109 virtual void GetCollapsedInconRect( int iconIdx
, wxRect
& rect
);
111 virtual int GetCollapsedIconsPos();
115 cbRowDragPlugin(void);
117 cbRowDragPlugin( wxFrameLayout
* pLayout
, int paneMask
= wxALL_PANES
);
118 virtual ~cbRowDragPlugin();
120 virtual cbPluginBase
* Clone() { return new cbRowDragPlugin(NULL
,0); }
122 virtual void OnInitPlugin();
124 // handlers for plugin events (appearence-independent logic)
126 void OnMouseMove ( cbMotionEvent
& event
);
127 void OnLButtonDown( cbLeftDownEvent
& event
);
128 void OnLButtonUp ( cbLeftUpEvent
& event
);
129 void OnDrawPaneBackground( cbDrawPaneDecorEvent
& event
);
131 // overridables (appearence-depedent)
133 virtual void DrawCollapsedRowIcon( int index
, wxDC
& dc
, bool isHighlighted
);
134 virtual void DrawCollapsedRowsBorder( wxDC
& dc
);
135 virtual void DrawRowsDragHintsBorder( wxDC
& dc
);
136 virtual void DrawRowDragHint( cbRowInfo
* pRow
, wxDC
& dc
, bool isHighlighted
);
137 virtual void DrawEmptyRow( wxDC
& dc
, wxRect
& rowBounds
);
139 virtual int GetCollapsedRowIconHeight();
140 virtual int GetRowDragHintWidth();
142 virtual void SetPaneMargins();
145 virtual bool HitTestCollapsedRowIcon( int iconIdx
, const wxPoint
& pos
);
146 virtual bool HitTestRowDragHint( cbRowInfo
* pRow
, const wxPoint
& pos
);
148 DECLARE_EVENT_TABLE()
151 // internal helper-class
153 class cbHiddenBarInfo
: public wxObject
155 DECLARE_DYNAMIC_CLASS( cbHiddenBarInfo
)
163 #endif /* __ROWDRAGPL_G__ */