]> git.saurik.com Git - wxWidgets.git/blob - contrib/include/wx/fl/toolwnd.h
wxPalette unified. Source cleaning.
[wxWidgets.git] / contrib / include / wx / fl / toolwnd.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: toolwnd.h
3 // Purpose: wxToolWindow, cbMiniButton, cbCloseBox, cbCollapseBox,
4 // cbDockBox, cbFloatedBarWindow class declarations.
5 // Author: Aleksandras Gluchovas
6 // Modified by:
7 // Created: 06/09/98
8 // RCS-ID: $Id$
9 // Copyright: (c) Aleksandras Gluchovas
10 // Licence: wxWindows licence
11 /////////////////////////////////////////////////////////////////////////////
12
13 #ifndef __TOOLWND_G__
14 #define __TOOLWND_G__
15
16 #include "wx/frame.h"
17 #include "wx/dynarray.h"
18 #include "wx/fl/fldefs.h"
19
20 // fixed settings
21
22 #define BTN_BOX_HEIGHT 12
23 #define BTN_BOX_WIDTH 12
24 #define BTN_X_WEIGHT 2
25
26 class WXDLLIMPEXP_FL cbMiniButton;
27
28 typedef cbMiniButton* cbMinitButtonPtrT;
29
30 WXFL_DEFINE_ARRAY_PTR( cbMinitButtonPtrT, cbMiniButtonArrayT );
31
32 /*
33 A tool window is a special kind of frame that paints its own title, and
34 can be used to implement small floating windows.
35 */
36
37 class WXDLLIMPEXP_FL wxToolWindow : public wxFrame
38 {
39 DECLARE_DYNAMIC_CLASS( wxToolWindow )
40
41 public: /** protected really, accessed only by serializers **/
42
43 cbMiniButtonArrayT mButtons;
44 wxWindow* mpClientWnd;
45
46 wxFont mTitleFont;
47
48 int mTitleHeight;
49 int mClntHorizGap;
50 int mClntVertGap;
51 int mWndVertGap;
52 int mWndHorizGap;
53 int mButtonGap;
54 int mInTitleMargin;
55 int mHintBorder;
56
57 bool mResizeStarted;
58 bool mRealTimeUpdatesOn;
59
60 int mMTolerance;
61
62 int mCursorType;
63 bool mMouseCaptured;
64
65 // drag&drop state variables
66
67 wxPoint mDragOrigin;
68 wxRect mInitialRect;
69 wxRect mPrevHintRect;
70 wxScreenDC* mpScrDc;
71
72 protected:
73 // Maps client coordinates to screen coordinates.
74 void GetScrWindowRect( wxRect& r );
75
76 // Gets the mouse position in screen coordinates.
77 void GetScrMousePos ( wxMouseEvent& event, wxPoint& pos );
78
79 // Sets the hint cursor.
80 void SetHintCursor ( int type );
81
82 // Calculate resized rectangle.
83 void CalcResizedRect( wxRect& rect, wxPoint& delta, const wxSize& minDim );
84
85 // Helper function.
86 void AdjustRectPos( const wxRect& original, const wxSize& newDim, wxRect& newRect );
87
88 // Helper function.
89 wxSize GetMinimalWndDim();
90
91 // Draws the hint rectangle.
92 void DrawHintRect( const wxRect& r );
93
94 // Tests if the mouse position is in this window.
95 int HitTestWindow( wxMouseEvent& event );
96
97 // Lays out the buttons.
98 void LayoutMiniButtons();
99
100 public:
101
102 // Default constructor.
103 wxToolWindow();
104
105 // Destructor.
106 ~wxToolWindow();
107
108 // Sets the client for this tool window.
109 void SetClient( wxWindow* pWnd );
110
111 // Returns the client window.
112 wxWindow* GetClient();
113
114 // Sets the title font.
115 void SetTitleFont( wxFont& font );
116
117 // Adds a button. Buttons are added in right-to-left order.
118 void AddMiniButton( cbMiniButton* pBtn );
119
120 // Responds to a paint event.
121 void OnPaint( wxPaintEvent& event );
122
123 // Responds to a mouse move event.
124 void OnMotion( wxMouseEvent& event );
125
126 // Responds to a mouse left down event.
127 void OnLeftDown( wxMouseEvent& event );
128
129 // Responds to a mouse left up event.
130 void OnLeftUp( wxMouseEvent& event );
131
132 // Responds to a size event.
133 void OnSize( wxSizeEvent& event );
134
135 // Responds to an erase background event.
136 void OnEraseBackground( wxEraseEvent& event );
137
138 // Returns the preferred size for the window.
139 virtual wxSize GetPreferredSize( const wxSize& given );
140
141 // Called when a mini button is clicked.
142 // By default, does nothing.
143 virtual void OnMiniButtonClicked( int WXUNUSED(btnIdx) ) {}
144
145 // Handles clicking on the title. By default, does nothing.
146 virtual bool HandleTitleClick( wxMouseEvent& WXUNUSED(event) ) { return false; }
147
148 DECLARE_EVENT_TABLE()
149 };
150
151 // FIXME:: the code below should be moved to a separate file
152
153 #include "wx/fl/controlbar.h"
154
155 /*
156 cbMiniButton is the base class for a small button that can be placed in a wxToolWindow
157 titlebar.
158 */
159
160 class cbMiniButton : public wxObject
161 {
162 public:
163 wxPoint mPos;
164 wxSize mDim;
165 bool mVisible;
166 bool mEnabled;
167
168 wxFrameLayout* mpLayout;
169 cbDockPane* mpPane;
170 cbPluginBase* mpPlugin;
171
172 wxWindow* mpWnd;
173
174 bool mWasClicked;
175 bool mDragStarted;
176
177 bool mPressed;
178 public:
179 // Default constructor.
180 cbMiniButton();
181
182 // Set the position of the button.
183 void SetPos( const wxPoint& pos );
184
185 // Returns true if the given position was over the button.
186 bool HitTest( const wxPoint& pos );
187
188 // Responds to a left down event.
189 void OnLeftDown( const wxPoint& pos );
190
191 // Responds to a left up event.
192 void OnLeftUp( const wxPoint& pos );
193
194 // Responds to a mouse move event.
195 void OnMotion( const wxPoint& pos );
196
197 // Refreshes the button.
198 void Refresh();
199
200 // Draws the button. Override this to implement
201 // the desired appearance.
202 virtual void Draw( wxDC& dc );
203
204 // Returns true if the button was clicked.
205 bool WasClicked();
206
207 // Reset the button.
208 void Reset();
209
210 // Enable or disable the button.
211 void Enable( bool enable ) { mEnabled = enable; }
212
213 // Returns true if this button is pressed.
214 bool IsPressed() { return mPressed; }
215 };
216
217 /*
218 cbCloseBox is a window close button, used in a wxToolWindow titlebar.
219 */
220
221 class WXDLLIMPEXP_FL cbCloseBox : public cbMiniButton
222 {
223 public:
224 // Draws the close button appearance.
225 virtual void Draw( wxDC& dc );
226 };
227
228 /*
229 cbCollapseBox is a window collapse button, used in a wxToolWindow titlebar.
230 */
231
232 class WXDLLIMPEXP_FL cbCollapseBox : public cbMiniButton
233 {
234 public:
235 bool mIsAtLeft;
236
237 // Draws the collapse button appearance.
238 virtual void Draw( wxDC& dc );
239 };
240
241 /*
242 cbDockBox is a window dock button, used in a wxToolWindow titlebar.
243 */
244
245 class WXDLLIMPEXP_FL cbDockBox : public cbMiniButton
246 {
247 public:
248 // Draws the dock button appearance.
249 virtual void Draw( wxDC& dc );
250 };
251
252 /*
253 cbFloatedBarWindow is a kind of wxToolWindow,
254 implementing floating toolbars.
255 */
256
257 class WXDLLIMPEXP_FL cbFloatedBarWindow : public wxToolWindow
258 {
259 DECLARE_DYNAMIC_CLASS( cbFloatedBarWindow )
260 protected:
261 cbBarInfo* mpBar;
262 wxFrameLayout* mpLayout;
263
264 friend class cbFloatedBarWindowSerializer;
265
266 public:
267 // Default constructor.
268 cbFloatedBarWindow();
269
270 // Sets the bar information for this window.
271 void SetBar( cbBarInfo* pBar );
272
273 // Sets the layout for this window.
274 void SetLayout( wxFrameLayout* pLayout );
275
276 // Returns the bar information for this window.
277 cbBarInfo* GetBar();
278
279 // Position the floating window. The given coordinates
280 // are those of the bar itself; the floated container window's
281 // position and size are ajusted accordingly.
282 void PositionFloatedWnd( int scrX, int scrY,
283 int width, int height );
284
285 // Overridden function returning the preferred size.
286 virtual wxSize GetPreferredSize( const wxSize& given );
287
288 // Overridden function responding to mouse clicks on mini-buttons.
289 virtual void OnMiniButtonClicked( int btnIdx );
290
291 // Overridden function responding to mouse button clicks on the titlebar.
292 virtual bool HandleTitleClick( wxMouseEvent& event );
293
294 // Responds to double-click mouse events.
295 void OnDblClick( wxMouseEvent& event );
296
297 DECLARE_EVENT_TABLE()
298 };
299
300 #endif /* __TOOLWND_G__ */
301
302