]> git.saurik.com Git - wxWidgets.git/blob - contrib/include/wx/fl/rowdragpl.h
glibc's vswprintf doesn't nul terminate on truncation.
[wxWidgets.git] / contrib / include / wx / fl / rowdragpl.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: rowdragpl.h
3 // Purpose: cbRowDragPlugin class header.
4 // Author: Aleksandras Gluchovas
5 // Modified by:
6 // Created: 06/10/98
7 // RCS-ID: $Id$
8 // Copyright: (c) Aleksandras Gluchovas
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
11
12 #ifndef __ROWDRAGPL_G__
13 #define __ROWDRAGPL_G__
14
15 #include "wx/fl/controlbar.h"
16
17 /*
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 */
23
24 class WXDLLIMPEXP_FL cbRowDragPlugin : public cbPluginBase
25 {
26 DECLARE_DYNAMIC_CLASS( cbRowDragPlugin )
27 public:
28 // background colours for the highlighted/unhighlighted icons
29
30 wxColour mHightColor; // light-blue for NC-look
31 wxColour mLowColor; // light-gray -/-
32 wxColour mTrianInnerColor; // blue -/-
33 wxPen mTrianInnerPen; // black -/-
34
35 protected:
36 friend class cbRowDragPluginSerializer;
37
38 // drag & drop state variables
39 bool mDragStarted;
40 bool mDecisionMode;
41 wxPoint mDragOrigin;
42 int mCurDragOfs;
43 bool mCaptureIsOn;
44
45 // saved margins of the pane
46 int mSvTopMargin;
47 int mSvBottomMargin;
48 int mSvLeftMargin;
49 int mSvRightMargin;
50
51 // on-screen drawing state variables
52 wxBitmap* mpPaneImage;
53 wxBitmap* mpRowImage;
54 wxBitmap* mpCombinedImage;
55
56 wxScreenDC* mpScrDc;
57 wxRect mCombRect;
58 wxSize mRowImgDim;
59 int mInitialRowOfs;
60
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)
63
64 cbRowInfo* mpRowInFocus;
65 int mCollapsedIconInFocus;
66
67 cbDockPane* mpPane; // is set up temorarely, while handling event
68
69 wxList mHiddenBars;
70
71 // Helper for drag and drop.
72 wxBitmap* CaptureDCArea( wxDC& dc, wxRect& area );
73
74 // Helper for drag and drop.
75 int GetHRowsCountForPane( cbDockPane* pPane );
76
77 // Helper for drag and drop.
78 void SetMouseCapture( bool captureOn );
79
80 // Helper for drag and drop.
81 void PrepareForRowDrag();
82
83 // Helper for drag and drop.
84 void ShowDraggedRow( int offset );
85
86 // Helper for drag and drop.
87 void ShowPaneImage();
88
89 // Helper for drag and drop.
90 void FinishOnScreenDraw();
91
92 // Helper for drag and drop.
93 void CollapseRow( cbRowInfo* pRow );
94
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, const wxBrush& bkBrush );
130
131 // Implements 'hard-coded metafile' for Netscape Navigator look.
132 virtual void DrawRomb( wxRect& inRect, wxDC& dc, const wxBrush& bkBrush );
133
134 // Implements 'hard-coded metafile' for Netscape Navigator look.
135 virtual void Draw3DRect( wxRect& inRect, wxDC& dc, const wxBrush& bkBrush );
136
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 );
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();
149
150 public:
151
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();
160
161 // Clone function, returning a new instance of this class.
162 virtual cbPluginBase* Clone() { return new cbRowDragPlugin(NULL,0); }
163
164 // Called to initialize this plugin.
165 virtual void OnInitPlugin();
166
167 // Handles mouse move plugin events (appearance-independent logic).
168 void OnMouseMove ( cbMotionEvent& event );
169
170 // Handles left button down plugin events (appearance-independent logic).
171 void OnLButtonDown( cbLeftDownEvent& event );
172
173 // Handles left button up plugin events (appearance-independent logic).
174 void OnLButtonUp ( cbLeftUpEvent& event );
175
176 // Handles pane drawing plugin events (appearance-independent logic).
177 void OnDrawPaneBackground( cbDrawPaneDecorEvent& event );
178
179 // Draws collapsed row icon (appearance-dependent).
180 virtual void DrawCollapsedRowIcon( int index, wxDC& dc, bool isHighlighted );
181
182 // Draws collapsed rows border (appearance-dependent).
183 virtual void DrawCollapsedRowsBorder( wxDC& dc );
184
185 // Draws rows drag hints border (appearance-dependent).
186 virtual void DrawRowsDragHintsBorder( wxDC& dc );
187
188 // Draws row drag hint (appearance-dependent).
189 virtual void DrawRowDragHint( cbRowInfo* pRow, wxDC& dc, bool isHighlighted );
190
191 // Draws empty row (appearance-dependent).
192 virtual void DrawEmptyRow( wxDC& dc, wxRect& rowBounds );
193
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()
210 };
211
212 /*
213 Internal helper class.
214 */
215
216 class WXDLLIMPEXP_FL cbHiddenBarInfo : public wxObject
217 {
218 DECLARE_DYNAMIC_CLASS( cbHiddenBarInfo )
219 public:
220 cbBarInfo* mpBar;
221 int mRowNo;
222 int mIconNo;
223 int mAlignment;
224 };
225
226 #endif /* __ROWDRAGPL_G__ */
227