]> git.saurik.com Git - wxWidgets.git/blame - contrib/include/wx/fl/toolwnd.h
wx/wxprec.h already includes wx/defs.h (with other minor cleaning).
[wxWidgets.git] / contrib / include / wx / fl / toolwnd.h
CommitLineData
8e08b761 1/////////////////////////////////////////////////////////////////////////////
4cbc57f0
JS
2// Name: toolwnd.h
3// Purpose: wxToolWindow, cbMiniButton, cbCloseBox, cbCollapseBox,
4// cbDockBox, cbFloatedBarWindow class declarations.
8e08b761
JS
5// Author: Aleksandras Gluchovas
6// Modified by:
7// Created: 06/09/98
8// RCS-ID: $Id$
9// Copyright: (c) Aleksandras Gluchovas
4cbc57f0 10// Licence: wxWindows licence
8e08b761
JS
11/////////////////////////////////////////////////////////////////////////////
12
13#ifndef __TOOLWND_G__
14#define __TOOLWND_G__
15
8e08b761
JS
16#include "wx/frame.h"
17#include "wx/dynarray.h"
2b5f62a0 18#include "wx/fl/fldefs.h"
8e08b761
JS
19
20// fixed settings
21
22#define BTN_BOX_HEIGHT 12
23#define BTN_BOX_WIDTH 12
8f351668 24#define BTN_X_WEIGHT 2
8e08b761 25
510b9edb 26class WXDLLIMPEXP_FL cbMiniButton;
8e08b761
JS
27
28typedef cbMiniButton* cbMinitButtonPtrT;
29
659f8ec3 30WXFL_DEFINE_ARRAY_PTR( cbMinitButtonPtrT, cbMiniButtonArrayT );
8e08b761 31
4cbc57f0
JS
32/*
33A tool window is a special kind of frame that paints its own title, and
34can be used to implement small floating windows.
35*/
36
510b9edb 37class WXDLLIMPEXP_FL wxToolWindow : public wxFrame
8e08b761 38{
4cbc57f0 39 DECLARE_DYNAMIC_CLASS( wxToolWindow )
8e08b761 40
4cbc57f0 41public: /** protected really, accessed only by serializers **/
8e08b761 42
4cbc57f0
JS
43 cbMiniButtonArrayT mButtons;
44 wxWindow* mpClientWnd;
8e08b761 45
4cbc57f0 46 wxFont mTitleFont;
8e08b761 47
4cbc57f0
JS
48 int mTitleHeight;
49 int mClntHorizGap;
50 int mClntVertGap;
51 int mWndVertGap;
52 int mWndHorizGap;
53 int mButtonGap;
54 int mInTitleMargin;
55 int mHintBorder;
8e08b761 56
4cbc57f0
JS
57 bool mResizeStarted;
58 bool mRealTimeUpdatesOn;
8e08b761 59
4cbc57f0 60 int mMTolerance;
8e08b761 61
4cbc57f0
JS
62 int mCursorType;
63 bool mMouseCaptured;
8e08b761 64
4cbc57f0 65 // drag&drop state variables
8e08b761 66
4cbc57f0
JS
67 wxPoint mDragOrigin;
68 wxRect mInitialRect;
69 wxRect mPrevHintRect;
70 wxScreenDC* mpScrDc;
8e08b761
JS
71
72protected:
4cbc57f0
JS
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 );
8e08b761 81
4cbc57f0
JS
82 // Calculate resized rectangle.
83 void CalcResizedRect( wxRect& rect, wxPoint& delta, const wxSize& minDim );
8e08b761 84
4cbc57f0
JS
85 // Helper function.
86 void AdjustRectPos( const wxRect& original, const wxSize& newDim, wxRect& newRect );
8e08b761 87
4cbc57f0
JS
88 // Helper function.
89 wxSize GetMinimalWndDim();
8e08b761 90
4cbc57f0
JS
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();
8e08b761
JS
99
100public:
8e08b761 101
4cbc57f0
JS
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 );
8e08b761 125
4cbc57f0
JS
126 // Responds to a mouse left down event.
127 void OnLeftDown( wxMouseEvent& event );
8e08b761 128
4cbc57f0
JS
129 // Responds to a mouse left up event.
130 void OnLeftUp( wxMouseEvent& event );
8e08b761 131
4cbc57f0
JS
132 // Responds to a size event.
133 void OnSize( wxSizeEvent& event );
8e08b761 134
4cbc57f0
JS
135 // Responds to an erase background event.
136 void OnEraseBackground( wxEraseEvent& event );
8e08b761 137
4cbc57f0
JS
138 // Returns the preferred size for the window.
139 virtual wxSize GetPreferredSize( const wxSize& given );
8e08b761 140
4cbc57f0
JS
141 // Called when a mini button is clicked.
142 // By default, does nothing.
cd6754a1 143 virtual void OnMiniButtonClicked( int WXUNUSED(btnIdx) ) {}
8e08b761 144
4cbc57f0 145 // Handles clicking on the title. By default, does nothing.
cd6754a1 146 virtual bool HandleTitleClick( wxMouseEvent& WXUNUSED(event) ) { return false; }
8e08b761 147
4cbc57f0 148 DECLARE_EVENT_TABLE()
8e08b761
JS
149};
150
151// FIXME:: the code below should be moved to a separate file
152
153#include "wx/fl/controlbar.h"
154
4cbc57f0
JS
155/*
156cbMiniButton is the base class for a small button that can be placed in a wxToolWindow
157titlebar.
158*/
159
8e08b761
JS
160class cbMiniButton : public wxObject
161{
162public:
4cbc57f0
JS
163 wxPoint mPos;
164 wxSize mDim;
165 bool mVisible;
166 bool mEnabled;
8e08b761 167
4cbc57f0
JS
168 wxFrameLayout* mpLayout;
169 cbDockPane* mpPane;
170 cbPluginBase* mpPlugin;
8e08b761 171
4cbc57f0 172 wxWindow* mpWnd;
8e08b761 173
4cbc57f0
JS
174 bool mWasClicked;
175 bool mDragStarted;
8e08b761 176
4cbc57f0 177 bool mPressed;
8e08b761 178public:
4cbc57f0
JS
179 // Default constructor.
180 cbMiniButton();
181
182 // Set the position of the button.
183 void SetPos( const wxPoint& pos );
184
c82c42d4 185 // Returns true if the given position was over the button.
4cbc57f0
JS
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 );
8e08b761 196
4cbc57f0
JS
197 // Refreshes the button.
198 void Refresh();
8e08b761 199
4cbc57f0
JS
200 // Draws the button. Override this to implement
201 // the desired appearance.
202 virtual void Draw( wxDC& dc );
8e08b761 203
c82c42d4 204 // Returns true if the button was clicked.
4cbc57f0 205 bool WasClicked();
8e08b761 206
4cbc57f0
JS
207 // Reset the button.
208 void Reset();
8e08b761 209
4cbc57f0
JS
210 // Enable or disable the button.
211 void Enable( bool enable ) { mEnabled = enable; }
8e08b761 212
c82c42d4 213 // Returns true if this button is pressed.
4cbc57f0 214 bool IsPressed() { return mPressed; }
8e08b761
JS
215};
216
4cbc57f0
JS
217/*
218cbCloseBox is a window close button, used in a wxToolWindow titlebar.
219*/
8e08b761 220
510b9edb 221class WXDLLIMPEXP_FL cbCloseBox : public cbMiniButton
8e08b761
JS
222{
223public:
4cbc57f0
JS
224 // Draws the close button appearance.
225 virtual void Draw( wxDC& dc );
8e08b761
JS
226};
227
4cbc57f0
JS
228/*
229cbCollapseBox is a window collapse button, used in a wxToolWindow titlebar.
230*/
231
510b9edb 232class WXDLLIMPEXP_FL cbCollapseBox : public cbMiniButton
8e08b761
JS
233{
234public:
4cbc57f0 235 bool mIsAtLeft;
8e08b761 236
4cbc57f0
JS
237 // Draws the collapse button appearance.
238 virtual void Draw( wxDC& dc );
8e08b761
JS
239};
240
4cbc57f0
JS
241/*
242cbDockBox is a window dock button, used in a wxToolWindow titlebar.
243*/
244
510b9edb 245class WXDLLIMPEXP_FL cbDockBox : public cbMiniButton
8e08b761
JS
246{
247public:
4cbc57f0
JS
248 // Draws the dock button appearance.
249 virtual void Draw( wxDC& dc );
8e08b761
JS
250};
251
4cbc57f0
JS
252/*
253cbFloatedBarWindow is a kind of wxToolWindow,
254implementing floating toolbars.
255*/
256
510b9edb 257class WXDLLIMPEXP_FL cbFloatedBarWindow : public wxToolWindow
8e08b761 258{
4cbc57f0 259 DECLARE_DYNAMIC_CLASS( cbFloatedBarWindow )
8e08b761 260protected:
4cbc57f0
JS
261 cbBarInfo* mpBar;
262 wxFrameLayout* mpLayout;
8e08b761 263
4cbc57f0 264 friend class cbFloatedBarWindowSerializer;
8e08b761
JS
265
266public:
4cbc57f0
JS
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 );
8e08b761 275
4cbc57f0
JS
276 // Returns the bar information for this window.
277 cbBarInfo* GetBar();
8e08b761 278
4cbc57f0
JS
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 );
8e08b761 284
4cbc57f0
JS
285 // Overridden function returning the preferred size.
286 virtual wxSize GetPreferredSize( const wxSize& given );
8e08b761 287
4cbc57f0
JS
288 // Overridden function responding to mouse clicks on mini-buttons.
289 virtual void OnMiniButtonClicked( int btnIdx );
8e08b761 290
4cbc57f0
JS
291 // Overridden function responding to mouse button clicks on the titlebar.
292 virtual bool HandleTitleClick( wxMouseEvent& event );
8e08b761 293
4cbc57f0
JS
294 // Responds to double-click mouse events.
295 void OnDblClick( wxMouseEvent& event );
8e08b761 296
4cbc57f0 297 DECLARE_EVENT_TABLE()
8e08b761
JS
298};
299
300#endif /* __TOOLWND_G__ */
301
302