]>
Commit | Line | Data |
---|---|---|
8e08b761 | 1 | ///////////////////////////////////////////////////////////////////////////// |
4cbc57f0 JS |
2 | // Name: rowdragpl.h |
3 | // Purpose: cbRowDragPlugin class header. | |
8e08b761 JS |
4 | // Author: Aleksandras Gluchovas |
5 | // Modified by: | |
6 | // Created: 06/10/98 | |
7 | // RCS-ID: $Id$ | |
8 | // Copyright: (c) Aleksandras Gluchovas | |
4cbc57f0 | 9 | // Licence: wxWindows licence |
8e08b761 JS |
10 | ///////////////////////////////////////////////////////////////////////////// |
11 | ||
12 | #ifndef __ROWDRAGPL_G__ | |
13 | #define __ROWDRAGPL_G__ | |
14 | ||
8e08b761 JS |
15 | #include "wx/fl/controlbar.h" |
16 | ||
17 | /* | |
4cbc57f0 JS |
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. | |
22 | */ | |
8e08b761 | 23 | |
510b9edb | 24 | class WXDLLIMPEXP_FL cbRowDragPlugin : public cbPluginBase |
8e08b761 | 25 | { |
4cbc57f0 | 26 | DECLARE_DYNAMIC_CLASS( cbRowDragPlugin ) |
8e08b761 | 27 | public: |
4cbc57f0 | 28 | // background colours for the highlighted/unhighlighted icons |
8e08b761 | 29 | |
4cbc57f0 JS |
30 | wxColour mHightColor; // light-blue for NC-look |
31 | wxColour mLowColor; // light-gray -/- | |
32 | wxColour mTrianInnerColor; // blue -/- | |
33 | wxPen mTrianInnerPen; // black -/- | |
8e08b761 JS |
34 | |
35 | protected: | |
4cbc57f0 | 36 | friend class cbRowDragPluginSerializer; |
8e08b761 | 37 | |
4cbc57f0 JS |
38 | // drag & drop state variables |
39 | bool mDragStarted; | |
40 | bool mDecisionMode; | |
41 | wxPoint mDragOrigin; | |
42 | int mCurDragOfs; | |
43 | bool mCaptureIsOn; | |
8e08b761 | 44 | |
4cbc57f0 JS |
45 | // saved margins of the pane |
46 | int mSvTopMargin; | |
47 | int mSvBottomMargin; | |
48 | int mSvLeftMargin; | |
49 | int mSvRightMargin; | |
8e08b761 | 50 | |
4cbc57f0 JS |
51 | // on-screen drawing state variables |
52 | wxBitmap* mpPaneImage; | |
53 | wxBitmap* mpRowImage; | |
54 | wxBitmap* mpCombinedImage; | |
8e08b761 | 55 | |
4cbc57f0 JS |
56 | wxScreenDC* mpScrDc; |
57 | wxRect mCombRect; | |
58 | wxSize mRowImgDim; | |
59 | int mInitialRowOfs; | |
8e08b761 | 60 | |
4cbc57f0 JS |
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) | |
8e08b761 | 63 | |
4cbc57f0 JS |
64 | cbRowInfo* mpRowInFocus; |
65 | int mCollapsedIconInFocus; | |
8e08b761 | 66 | |
4cbc57f0 | 67 | cbDockPane* mpPane; // is set up temorarely, while handling event |
8e08b761 | 68 | |
4cbc57f0 | 69 | wxList mHiddenBars; |
8e08b761 | 70 | |
4cbc57f0 JS |
71 | // Helper for drag and drop. |
72 | wxBitmap* CaptureDCArea( wxDC& dc, wxRect& area ); | |
8e08b761 | 73 | |
4cbc57f0 JS |
74 | // Helper for drag and drop. |
75 | int GetHRowsCountForPane( cbDockPane* pPane ); | |
8e08b761 | 76 | |
4cbc57f0 JS |
77 | // Helper for drag and drop. |
78 | void SetMouseCapture( bool captureOn ); | |
8e08b761 | 79 | |
4cbc57f0 JS |
80 | // Helper for drag and drop. |
81 | void PrepareForRowDrag(); | |
8e08b761 | 82 | |
4cbc57f0 JS |
83 | // Helper for drag and drop. |
84 | void ShowDraggedRow( int offset ); | |
8e08b761 | 85 | |
4cbc57f0 JS |
86 | // Helper for drag and drop. |
87 | void ShowPaneImage(); | |
8e08b761 | 88 | |
4cbc57f0 JS |
89 | // Helper for drag and drop. |
90 | void FinishOnScreenDraw(); | |
8e08b761 | 91 | |
4cbc57f0 JS |
92 | // Helper for drag and drop. |
93 | void CollapseRow( cbRowInfo* pRow ); | |
8e08b761 | 94 | |
4cbc57f0 JS |
95 | // Helper for drag and drop. |
96 | void ExpandRow( int collapsedIconIdx ); | |
97 | ||
98 | // Helper for drag and drop. | |
99 | void InsertDraggedRowBefore( cbRowInfo* pBeforeRow ); | |
100 | ||
101 | // Helper for drag and drop. | |
102 | bool ItemIsInFocus(); | |
103 | ||
104 | // Helper for drag and drop. | |
105 | void CheckPrevItemInFocus( cbRowInfo* pRow, int iconIdx ); | |
106 | ||
107 | // Helper for drag and drop. | |
108 | void UnhighlightItemInFocus(); | |
109 | ||
110 | // Helper for drag and drop. | |
111 | cbRowInfo* GetFirstRow(); | |
112 | ||
113 | // Implements 'hard-coded metafile' for Netscape Navigator look. | |
114 | virtual void DrawTrianUp( wxRect& inRect, wxDC& dc ); | |
115 | ||
116 | // Implements 'hard-coded metafile' for Netscape Navigator look. | |
117 | virtual void DrawTrianDown( wxRect& inRect, wxDC& dc ); | |
118 | ||
119 | // Implements 'hard-coded metafile' for Netscape Navigator look. | |
120 | virtual void DrawTrianRight( wxRect& inRect, wxDC& dc ); | |
121 | ||
122 | // Implements 'hard-coded metafile' for Netscape Navigator look. | |
123 | virtual void Draw3DPattern( wxRect& inRect, wxDC& dc ); | |
124 | ||
125 | // Implements 'hard-coded metafile' for Netscape Navigator look. | |
126 | virtual void DrawRombShades( wxPoint& p1, wxPoint& p2, wxPoint& p3, wxPoint& p4, wxDC& dc ); | |
127 | ||
128 | // Implements 'hard-coded metafile' for Netscape Navigator look. | |
129 | virtual void DrawOrtoRomb( wxRect& inRect, wxDC& dc, wxBrush& bkBrush ); | |
130 | ||
131 | // Implements 'hard-coded metafile' for Netscape Navigator look. | |
132 | virtual void DrawRomb( wxRect& inRect, wxDC& dc, wxBrush& bkBrush ); | |
133 | ||
134 | // Implements 'hard-coded metafile' for Netscape Navigator look. | |
135 | virtual void Draw3DRect( wxRect& inRect, wxDC& dc, wxBrush& bkBrush ); | |
136 | ||
137 | // Implements 'hard-coded metafile' for Netscape Navigator look. | |
138 | virtual void DrawRectShade( wxRect& inRect, wxDC& dc, | |
139 | int level, wxPen& upperPen, wxPen& lowerPen ); | |
140 | ||
141 | // Helper for drag and drop. | |
142 | virtual void GetRowHintRect( cbRowInfo* pRow, wxRect& rect ); | |
143 | ||
144 | // Helper for drag and drop. | |
145 | virtual void GetCollapsedInconRect( int iconIdx, wxRect& rect ); | |
146 | ||
147 | // Helper for drag and drop. | |
148 | virtual int GetCollapsedIconsPos(); | |
8e08b761 JS |
149 | |
150 | public: | |
151 | ||
4cbc57f0 JS |
152 | // Default constructor. |
153 | cbRowDragPlugin(); | |
154 | ||
155 | // Constructor, taking paren layout frame and pane mask. | |
156 | cbRowDragPlugin( wxFrameLayout* pLayout, int paneMask = wxALL_PANES ); | |
157 | ||
158 | // Destructor. | |
159 | virtual ~cbRowDragPlugin(); | |
8e08b761 | 160 | |
4cbc57f0 JS |
161 | // Clone function, returning a new instance of this class. |
162 | virtual cbPluginBase* Clone() { return new cbRowDragPlugin(NULL,0); } | |
8e08b761 | 163 | |
4cbc57f0 JS |
164 | // Called to initialize this plugin. |
165 | virtual void OnInitPlugin(); | |
8e08b761 | 166 | |
4cbc57f0 JS |
167 | // Handles mouse move plugin events (appearance-independent logic). |
168 | void OnMouseMove ( cbMotionEvent& event ); | |
8e08b761 | 169 | |
4cbc57f0 JS |
170 | // Handles left button down plugin events (appearance-independent logic). |
171 | void OnLButtonDown( cbLeftDownEvent& event ); | |
8e08b761 | 172 | |
4cbc57f0 JS |
173 | // Handles left button up plugin events (appearance-independent logic). |
174 | void OnLButtonUp ( cbLeftUpEvent& event ); | |
8e08b761 | 175 | |
4cbc57f0 JS |
176 | // Handles pane drawing plugin events (appearance-independent logic). |
177 | void OnDrawPaneBackground( cbDrawPaneDecorEvent& event ); | |
8e08b761 | 178 | |
4cbc57f0 JS |
179 | // Draws collapsed row icon (appearance-dependent). |
180 | virtual void DrawCollapsedRowIcon( int index, wxDC& dc, bool isHighlighted ); | |
8e08b761 | 181 | |
4cbc57f0 JS |
182 | // Draws collapsed rows border (appearance-dependent). |
183 | virtual void DrawCollapsedRowsBorder( wxDC& dc ); | |
8e08b761 | 184 | |
4cbc57f0 JS |
185 | // Draws rows drag hints border (appearance-dependent). |
186 | virtual void DrawRowsDragHintsBorder( wxDC& dc ); | |
8e08b761 | 187 | |
4cbc57f0 JS |
188 | // Draws row drag hint (appearance-dependent). |
189 | virtual void DrawRowDragHint( cbRowInfo* pRow, wxDC& dc, bool isHighlighted ); | |
8e08b761 | 190 | |
4cbc57f0 JS |
191 | // Draws empty row (appearance-dependent). |
192 | virtual void DrawEmptyRow( wxDC& dc, wxRect& rowBounds ); | |
8e08b761 | 193 | |
4cbc57f0 JS |
194 | // Gets the collapsed row icon height. |
195 | virtual int GetCollapsedRowIconHeight(); | |
196 | ||
197 | // Gets the row drag hint width. | |
198 | virtual int GetRowDragHintWidth(); | |
199 | ||
200 | // Sets the pane margins. | |
201 | virtual void SetPaneMargins(); | |
202 | ||
203 | // Test for the collapsed row icon position. | |
204 | virtual bool HitTestCollapsedRowIcon( int iconIdx, const wxPoint& pos ); | |
205 | ||
206 | // Test for the row drag hint position. | |
207 | virtual bool HitTestRowDragHint( cbRowInfo* pRow, const wxPoint& pos ); | |
208 | ||
209 | DECLARE_EVENT_TABLE() | |
8e08b761 JS |
210 | }; |
211 | ||
4cbc57f0 JS |
212 | /* |
213 | Internal helper class. | |
214 | */ | |
8e08b761 | 215 | |
510b9edb | 216 | class WXDLLIMPEXP_FL cbHiddenBarInfo : public wxObject |
8e08b761 | 217 | { |
4cbc57f0 | 218 | DECLARE_DYNAMIC_CLASS( cbHiddenBarInfo ) |
8e08b761 | 219 | public: |
4cbc57f0 JS |
220 | cbBarInfo* mpBar; |
221 | int mRowNo; | |
222 | int mIconNo; | |
223 | int mAlignment; | |
8e08b761 JS |
224 | }; |
225 | ||
226 | #endif /* __ROWDRAGPL_G__ */ | |
227 |