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__
16 #pragma interface "rowdragpl.h"
19 #include "wx/fl/controlbar.h"
22 This plugin adds row-dragging functionality to the pane.
23 It handles mouse movement and pane background-erasing plugin events.
24 The behaviour and appearance resembles drag and drop positioning
25 of the toolbar rows in Netscape Communicator 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 // Helper for drag and drop.
76 wxBitmap
* CaptureDCArea( wxDC
& dc
, wxRect
& area
);
78 // Helper for drag and drop.
79 int GetHRowsCountForPane( cbDockPane
* pPane
);
81 // Helper for drag and drop.
82 void SetMouseCapture( bool captureOn
);
84 // Helper for drag and drop.
85 void PrepareForRowDrag();
87 // Helper for drag and drop.
88 void ShowDraggedRow( int offset
);
90 // Helper for drag and drop.
93 // Helper for drag and drop.
94 void FinishOnScreenDraw();
96 // Helper for drag and drop.
97 void CollapseRow( cbRowInfo
* pRow
);
99 // Helper for drag and drop.
100 void ExpandRow( int collapsedIconIdx
);
102 // Helper for drag and drop.
103 void InsertDraggedRowBefore( cbRowInfo
* pBeforeRow
);
105 // Helper for drag and drop.
106 bool ItemIsInFocus();
108 // Helper for drag and drop.
109 void CheckPrevItemInFocus( cbRowInfo
* pRow
, int iconIdx
);
111 // Helper for drag and drop.
112 void UnhighlightItemInFocus();
114 // Helper for drag and drop.
115 cbRowInfo
* GetFirstRow();
117 // Implements 'hard-coded metafile' for Netscape Navigator look.
118 virtual void DrawTrianUp( wxRect
& inRect
, wxDC
& dc
);
120 // Implements 'hard-coded metafile' for Netscape Navigator look.
121 virtual void DrawTrianDown( wxRect
& inRect
, wxDC
& dc
);
123 // Implements 'hard-coded metafile' for Netscape Navigator look.
124 virtual void DrawTrianRight( wxRect
& inRect
, wxDC
& dc
);
126 // Implements 'hard-coded metafile' for Netscape Navigator look.
127 virtual void Draw3DPattern( wxRect
& inRect
, wxDC
& dc
);
129 // Implements 'hard-coded metafile' for Netscape Navigator look.
130 virtual void DrawRombShades( wxPoint
& p1
, wxPoint
& p2
, wxPoint
& p3
, wxPoint
& p4
, wxDC
& dc
);
132 // Implements 'hard-coded metafile' for Netscape Navigator look.
133 virtual void DrawOrtoRomb( wxRect
& inRect
, wxDC
& dc
, wxBrush
& bkBrush
);
135 // Implements 'hard-coded metafile' for Netscape Navigator look.
136 virtual void DrawRomb( wxRect
& inRect
, wxDC
& dc
, wxBrush
& bkBrush
);
138 // Implements 'hard-coded metafile' for Netscape Navigator look.
139 virtual void Draw3DRect( wxRect
& inRect
, wxDC
& dc
, wxBrush
& bkBrush
);
141 // Implements 'hard-coded metafile' for Netscape Navigator look.
142 virtual void DrawRectShade( wxRect
& inRect
, wxDC
& dc
,
143 int level
, wxPen
& upperPen
, wxPen
& lowerPen
);
145 // Helper for drag and drop.
146 virtual void GetRowHintRect( cbRowInfo
* pRow
, wxRect
& rect
);
148 // Helper for drag and drop.
149 virtual void GetCollapsedInconRect( int iconIdx
, wxRect
& rect
);
151 // Helper for drag and drop.
152 virtual int GetCollapsedIconsPos();
156 // Default constructor.
159 // Constructor, taking paren layout frame and pane mask.
160 cbRowDragPlugin( wxFrameLayout
* pLayout
, int paneMask
= wxALL_PANES
);
163 virtual ~cbRowDragPlugin();
165 // Clone function, returning a new instance of this class.
166 virtual cbPluginBase
* Clone() { return new cbRowDragPlugin(NULL
,0); }
168 // Called to initialize this plugin.
169 virtual void OnInitPlugin();
171 // Handles mouse move plugin events (appearance-independent logic).
172 void OnMouseMove ( cbMotionEvent
& event
);
174 // Handles left button down plugin events (appearance-independent logic).
175 void OnLButtonDown( cbLeftDownEvent
& event
);
177 // Handles left button up plugin events (appearance-independent logic).
178 void OnLButtonUp ( cbLeftUpEvent
& event
);
180 // Handles pane drawing plugin events (appearance-independent logic).
181 void OnDrawPaneBackground( cbDrawPaneDecorEvent
& event
);
183 // Draws collapsed row icon (appearance-dependent).
184 virtual void DrawCollapsedRowIcon( int index
, wxDC
& dc
, bool isHighlighted
);
186 // Draws collapsed rows border (appearance-dependent).
187 virtual void DrawCollapsedRowsBorder( wxDC
& dc
);
189 // Draws rows drag hints border (appearance-dependent).
190 virtual void DrawRowsDragHintsBorder( wxDC
& dc
);
192 // Draws row drag hint (appearance-dependent).
193 virtual void DrawRowDragHint( cbRowInfo
* pRow
, wxDC
& dc
, bool isHighlighted
);
195 // Draws empty row (appearance-dependent).
196 virtual void DrawEmptyRow( wxDC
& dc
, wxRect
& rowBounds
);
198 // Gets the collapsed row icon height.
199 virtual int GetCollapsedRowIconHeight();
201 // Gets the row drag hint width.
202 virtual int GetRowDragHintWidth();
204 // Sets the pane margins.
205 virtual void SetPaneMargins();
207 // Test for the collapsed row icon position.
208 virtual bool HitTestCollapsedRowIcon( int iconIdx
, const wxPoint
& pos
);
210 // Test for the row drag hint position.
211 virtual bool HitTestRowDragHint( cbRowInfo
* pRow
, const wxPoint
& pos
);
213 DECLARE_EVENT_TABLE()
217 Internal helper class.
220 class cbHiddenBarInfo
: public wxObject
222 DECLARE_DYNAMIC_CLASS( cbHiddenBarInfo
)
230 #endif /* __ROWDRAGPL_G__ */