1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: cbRowDragPlugin class header.
4 // Author: Aleksandras Gluchovas
8 // Copyright: (c) Aleksandras Gluchovas
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 #ifndef __ROWDRAGPL_G__
13 #define __ROWDRAGPL_G__
15 #include "wx/fl/controlbar.h"
18 This plugin adds row-dragging functionality to the pane.
19 It handles mouse movement and pane background-erasing plugin events.
20 The behaviour and appearance resembles drag and drop positioning
21 of the toolbar rows in Netscape Communicator 4.xx.
24 class WXDLLIMPEXP_FL 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 // Helper for drag and drop.
72 wxBitmap
* CaptureDCArea( wxDC
& dc
, wxRect
& area
);
74 // Helper for drag and drop.
75 int GetHRowsCountForPane( cbDockPane
* pPane
);
77 // Helper for drag and drop.
78 void SetMouseCapture( bool captureOn
);
80 // Helper for drag and drop.
81 void PrepareForRowDrag();
83 // Helper for drag and drop.
84 void ShowDraggedRow( int offset
);
86 // Helper for drag and drop.
89 // Helper for drag and drop.
90 void FinishOnScreenDraw();
92 // Helper for drag and drop.
93 void CollapseRow( cbRowInfo
* pRow
);
95 // Helper for drag and drop.
96 void ExpandRow( int collapsedIconIdx
);
98 // Helper for drag and drop.
99 void InsertDraggedRowBefore( cbRowInfo
* pBeforeRow
);
101 // Helper for drag and drop.
102 bool ItemIsInFocus();
104 // Helper for drag and drop.
105 void CheckPrevItemInFocus( cbRowInfo
* pRow
, int iconIdx
);
107 // Helper for drag and drop.
108 void UnhighlightItemInFocus();
110 // Helper for drag and drop.
111 cbRowInfo
* GetFirstRow();
113 // Implements 'hard-coded metafile' for Netscape Navigator look.
114 virtual void DrawTrianUp( wxRect
& inRect
, wxDC
& dc
);
116 // Implements 'hard-coded metafile' for Netscape Navigator look.
117 virtual void DrawTrianDown( wxRect
& inRect
, wxDC
& dc
);
119 // Implements 'hard-coded metafile' for Netscape Navigator look.
120 virtual void DrawTrianRight( wxRect
& inRect
, wxDC
& dc
);
122 // Implements 'hard-coded metafile' for Netscape Navigator look.
123 virtual void Draw3DPattern( wxRect
& inRect
, wxDC
& dc
);
125 // Implements 'hard-coded metafile' for Netscape Navigator look.
126 virtual void DrawRombShades( wxPoint
& p1
, wxPoint
& p2
, wxPoint
& p3
, wxPoint
& p4
, wxDC
& dc
);
128 // Implements 'hard-coded metafile' for Netscape Navigator look.
129 virtual void DrawOrtoRomb( wxRect
& inRect
, wxDC
& dc
, const wxBrush
& bkBrush
);
131 // Implements 'hard-coded metafile' for Netscape Navigator look.
132 virtual void DrawRomb( wxRect
& inRect
, wxDC
& dc
, const wxBrush
& bkBrush
);
134 // Implements 'hard-coded metafile' for Netscape Navigator look.
135 virtual void Draw3DRect( wxRect
& inRect
, wxDC
& dc
, const wxBrush
& bkBrush
);
137 // Implements 'hard-coded metafile' for Netscape Navigator look.
138 virtual void DrawRectShade( wxRect
& inRect
, wxDC
& dc
,
139 int level
, const wxPen
& upperPen
, const wxPen
& lowerPen
);
141 // Helper for drag and drop.
142 virtual void GetRowHintRect( cbRowInfo
* pRow
, wxRect
& rect
);
144 // Helper for drag and drop.
145 virtual void GetCollapsedInconRect( int iconIdx
, wxRect
& rect
);
147 // Helper for drag and drop.
148 virtual int GetCollapsedIconsPos();
152 // Default constructor.
155 // Constructor, taking paren layout frame and pane mask.
156 cbRowDragPlugin( wxFrameLayout
* pLayout
, int paneMask
= wxALL_PANES
);
159 virtual ~cbRowDragPlugin();
161 // Clone function, returning a new instance of this class.
162 virtual cbPluginBase
* Clone() { return new cbRowDragPlugin(NULL
,0); }
164 // Called to initialize this plugin.
165 virtual void OnInitPlugin();
167 // Handles mouse move plugin events (appearance-independent logic).
168 void OnMouseMove ( cbMotionEvent
& event
);
170 // Handles left button down plugin events (appearance-independent logic).
171 void OnLButtonDown( cbLeftDownEvent
& event
);
173 // Handles left button up plugin events (appearance-independent logic).
174 void OnLButtonUp ( cbLeftUpEvent
& event
);
176 // Handles pane drawing plugin events (appearance-independent logic).
177 void OnDrawPaneBackground( cbDrawPaneDecorEvent
& event
);
179 // Draws collapsed row icon (appearance-dependent).
180 virtual void DrawCollapsedRowIcon( int index
, wxDC
& dc
, bool isHighlighted
);
182 // Draws collapsed rows border (appearance-dependent).
183 virtual void DrawCollapsedRowsBorder( wxDC
& dc
);
185 // Draws rows drag hints border (appearance-dependent).
186 virtual void DrawRowsDragHintsBorder( wxDC
& dc
);
188 // Draws row drag hint (appearance-dependent).
189 virtual void DrawRowDragHint( cbRowInfo
* pRow
, wxDC
& dc
, bool isHighlighted
);
191 // Draws empty row (appearance-dependent).
192 virtual void DrawEmptyRow( wxDC
& dc
, wxRect
& rowBounds
);
194 // Gets the collapsed row icon height.
195 virtual int GetCollapsedRowIconHeight();
197 // Gets the row drag hint width.
198 virtual int GetRowDragHintWidth();
200 // Sets the pane margins.
201 virtual void SetPaneMargins();
203 // Test for the collapsed row icon position.
204 virtual bool HitTestCollapsedRowIcon( int iconIdx
, const wxPoint
& pos
);
206 // Test for the row drag hint position.
207 virtual bool HitTestRowDragHint( cbRowInfo
* pRow
, const wxPoint
& pos
);
209 DECLARE_EVENT_TABLE()
213 Internal helper class.
216 class WXDLLIMPEXP_FL cbHiddenBarInfo
: public wxObject
218 DECLARE_DYNAMIC_CLASS( cbHiddenBarInfo
)
226 #endif /* __ROWDRAGPL_G__ */