]> git.saurik.com Git - wxWidgets.git/blame - contrib/include/wx/fl/toolwnd.h
remove odbc lib to prevent rpm errors about unpackaged files (patch 1151783)
[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
ab7ce33c 16#if defined(__GNUG__) && !defined(__APPLE__)
8e08b761
JS
17 #pragma interface "toolwnd.h"
18#endif
19
20#include "wx/frame.h"
21#include "wx/dynarray.h"
2b5f62a0 22#include "wx/fl/fldefs.h"
8e08b761
JS
23
24// fixed settings
25
26#define BTN_BOX_HEIGHT 12
27#define BTN_BOX_WIDTH 12
8f351668 28#define BTN_X_WEIGHT 2
8e08b761 29
510b9edb 30class WXDLLIMPEXP_FL cbMiniButton;
8e08b761
JS
31
32typedef cbMiniButton* cbMinitButtonPtrT;
33
659f8ec3 34WXFL_DEFINE_ARRAY_PTR( cbMinitButtonPtrT, cbMiniButtonArrayT );
8e08b761 35
4cbc57f0
JS
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
510b9edb 41class WXDLLIMPEXP_FL wxToolWindow : public wxFrame
8e08b761 42{
4cbc57f0 43 DECLARE_DYNAMIC_CLASS( wxToolWindow )
8e08b761 44
4cbc57f0 45public: /** protected really, accessed only by serializers **/
8e08b761 46
4cbc57f0
JS
47 cbMiniButtonArrayT mButtons;
48 wxWindow* mpClientWnd;
8e08b761 49
4cbc57f0 50 wxFont mTitleFont;
8e08b761 51
4cbc57f0
JS
52 int mTitleHeight;
53 int mClntHorizGap;
54 int mClntVertGap;
55 int mWndVertGap;
56 int mWndHorizGap;
57 int mButtonGap;
58 int mInTitleMargin;
59 int mHintBorder;
8e08b761 60
4cbc57f0
JS
61 bool mResizeStarted;
62 bool mRealTimeUpdatesOn;
8e08b761 63
4cbc57f0 64 int mMTolerance;
8e08b761 65
4cbc57f0
JS
66 int mCursorType;
67 bool mMouseCaptured;
8e08b761 68
4cbc57f0 69 // drag&drop state variables
8e08b761 70
4cbc57f0
JS
71 wxPoint mDragOrigin;
72 wxRect mInitialRect;
73 wxRect mPrevHintRect;
74 wxScreenDC* mpScrDc;
8e08b761
JS
75
76protected:
4cbc57f0
JS
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 );
8e08b761 85
4cbc57f0
JS
86 // Calculate resized rectangle.
87 void CalcResizedRect( wxRect& rect, wxPoint& delta, const wxSize& minDim );
8e08b761 88
4cbc57f0
JS
89 // Helper function.
90 void AdjustRectPos( const wxRect& original, const wxSize& newDim, wxRect& newRect );
8e08b761 91
4cbc57f0
JS
92 // Helper function.
93 wxSize GetMinimalWndDim();
8e08b761 94
4cbc57f0
JS
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();
8e08b761
JS
103
104public:
8e08b761 105
4cbc57f0
JS
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 );
8e08b761 129
4cbc57f0
JS
130 // Responds to a mouse left down event.
131 void OnLeftDown( wxMouseEvent& event );
8e08b761 132
4cbc57f0
JS
133 // Responds to a mouse left up event.
134 void OnLeftUp( wxMouseEvent& event );
8e08b761 135
4cbc57f0
JS
136 // Responds to a size event.
137 void OnSize( wxSizeEvent& event );
8e08b761 138
4cbc57f0
JS
139 // Responds to an erase background event.
140 void OnEraseBackground( wxEraseEvent& event );
8e08b761 141
4cbc57f0
JS
142 // Returns the preferred size for the window.
143 virtual wxSize GetPreferredSize( const wxSize& given );
8e08b761 144
4cbc57f0
JS
145 // Called when a mini button is clicked.
146 // By default, does nothing.
cd6754a1 147 virtual void OnMiniButtonClicked( int WXUNUSED(btnIdx) ) {}
8e08b761 148
4cbc57f0 149 // Handles clicking on the title. By default, does nothing.
cd6754a1 150 virtual bool HandleTitleClick( wxMouseEvent& WXUNUSED(event) ) { return false; }
8e08b761 151
4cbc57f0 152 DECLARE_EVENT_TABLE()
8e08b761
JS
153};
154
155// FIXME:: the code below should be moved to a separate file
156
157#include "wx/fl/controlbar.h"
158
4cbc57f0
JS
159/*
160cbMiniButton is the base class for a small button that can be placed in a wxToolWindow
161titlebar.
162*/
163
8e08b761
JS
164class cbMiniButton : public wxObject
165{
166public:
4cbc57f0
JS
167 wxPoint mPos;
168 wxSize mDim;
169 bool mVisible;
170 bool mEnabled;
8e08b761 171
4cbc57f0
JS
172 wxFrameLayout* mpLayout;
173 cbDockPane* mpPane;
174 cbPluginBase* mpPlugin;
8e08b761 175
4cbc57f0 176 wxWindow* mpWnd;
8e08b761 177
4cbc57f0
JS
178 bool mWasClicked;
179 bool mDragStarted;
8e08b761 180
4cbc57f0 181 bool mPressed;
8e08b761 182public:
4cbc57f0
JS
183 // Default constructor.
184 cbMiniButton();
185
186 // Set the position of the button.
187 void SetPos( const wxPoint& pos );
188
c82c42d4 189 // Returns true if the given position was over the button.
4cbc57f0
JS
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 );
8e08b761 200
4cbc57f0
JS
201 // Refreshes the button.
202 void Refresh();
8e08b761 203
4cbc57f0
JS
204 // Draws the button. Override this to implement
205 // the desired appearance.
206 virtual void Draw( wxDC& dc );
8e08b761 207
c82c42d4 208 // Returns true if the button was clicked.
4cbc57f0 209 bool WasClicked();
8e08b761 210
4cbc57f0
JS
211 // Reset the button.
212 void Reset();
8e08b761 213
4cbc57f0
JS
214 // Enable or disable the button.
215 void Enable( bool enable ) { mEnabled = enable; }
8e08b761 216
c82c42d4 217 // Returns true if this button is pressed.
4cbc57f0 218 bool IsPressed() { return mPressed; }
8e08b761
JS
219};
220
4cbc57f0
JS
221/*
222cbCloseBox is a window close button, used in a wxToolWindow titlebar.
223*/
8e08b761 224
510b9edb 225class WXDLLIMPEXP_FL cbCloseBox : public cbMiniButton
8e08b761
JS
226{
227public:
4cbc57f0
JS
228 // Draws the close button appearance.
229 virtual void Draw( wxDC& dc );
8e08b761
JS
230};
231
4cbc57f0
JS
232/*
233cbCollapseBox is a window collapse button, used in a wxToolWindow titlebar.
234*/
235
510b9edb 236class WXDLLIMPEXP_FL cbCollapseBox : public cbMiniButton
8e08b761
JS
237{
238public:
4cbc57f0 239 bool mIsAtLeft;
8e08b761 240
4cbc57f0
JS
241 // Draws the collapse button appearance.
242 virtual void Draw( wxDC& dc );
8e08b761
JS
243};
244
4cbc57f0
JS
245/*
246cbDockBox is a window dock button, used in a wxToolWindow titlebar.
247*/
248
510b9edb 249class WXDLLIMPEXP_FL cbDockBox : public cbMiniButton
8e08b761
JS
250{
251public:
4cbc57f0
JS
252 // Draws the dock button appearance.
253 virtual void Draw( wxDC& dc );
8e08b761
JS
254};
255
4cbc57f0
JS
256/*
257cbFloatedBarWindow is a kind of wxToolWindow,
258implementing floating toolbars.
259*/
260
510b9edb 261class WXDLLIMPEXP_FL cbFloatedBarWindow : public wxToolWindow
8e08b761 262{
4cbc57f0 263 DECLARE_DYNAMIC_CLASS( cbFloatedBarWindow )
8e08b761 264protected:
4cbc57f0
JS
265 cbBarInfo* mpBar;
266 wxFrameLayout* mpLayout;
8e08b761 267
4cbc57f0 268 friend class cbFloatedBarWindowSerializer;
8e08b761
JS
269
270public:
4cbc57f0
JS
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 );
8e08b761 279
4cbc57f0
JS
280 // Returns the bar information for this window.
281 cbBarInfo* GetBar();
8e08b761 282
4cbc57f0
JS
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 );
8e08b761 288
4cbc57f0
JS
289 // Overridden function returning the preferred size.
290 virtual wxSize GetPreferredSize( const wxSize& given );
8e08b761 291
4cbc57f0
JS
292 // Overridden function responding to mouse clicks on mini-buttons.
293 virtual void OnMiniButtonClicked( int btnIdx );
8e08b761 294
4cbc57f0
JS
295 // Overridden function responding to mouse button clicks on the titlebar.
296 virtual bool HandleTitleClick( wxMouseEvent& event );
8e08b761 297
4cbc57f0
JS
298 // Responds to double-click mouse events.
299 void OnDblClick( wxMouseEvent& event );
8e08b761 300
4cbc57f0 301 DECLARE_EVENT_TABLE()
8e08b761
JS
302};
303
304#endif /* __TOOLWND_G__ */
305
306