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