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