1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxToolWindow, cbMiniButton, cbCloseBox, cbCollapseBox,
4 // cbDockBox, cbFloatedBarWindow class declarations.
5 // Author: Aleksandras Gluchovas
9 // Copyright: (c) Aleksandras Gluchovas
10 // Licence: wxWindows licence
11 /////////////////////////////////////////////////////////////////////////////
16 #if defined(__GNUG__) && !defined(__APPLE__)
17 #pragma interface "toolwnd.h"
21 #include "wx/dynarray.h"
22 #include "wx/fl/fldefs.h"
26 #define BTN_BOX_HEIGHT 12
27 #define BTN_BOX_WIDTH 12
28 #define BTN_X_WEIGHT 2
30 class WXDLLIMPEXP_FL cbMiniButton
;
32 typedef cbMiniButton
* cbMinitButtonPtrT
;
34 WXFL_DEFINE_ARRAY_PTR( cbMinitButtonPtrT
, cbMiniButtonArrayT
);
37 A tool window is a special kind of frame that paints its own title, and
38 can be used to implement small floating windows.
41 class WXDLLIMPEXP_FL wxToolWindow
: public wxFrame
43 DECLARE_DYNAMIC_CLASS( wxToolWindow
)
45 public: /** protected really, accessed only by serializers **/
47 cbMiniButtonArrayT mButtons
;
48 wxWindow
* mpClientWnd
;
62 bool mRealTimeUpdatesOn
;
69 // drag&drop state variables
77 // Maps client coordinates to screen coordinates.
78 void GetScrWindowRect( wxRect
& r
);
80 // Gets the mouse position in screen coordinates.
81 void GetScrMousePos ( wxMouseEvent
& event
, wxPoint
& pos
);
83 // Sets the hint cursor.
84 void SetHintCursor ( int type
);
86 // Calculate resized rectangle.
87 void CalcResizedRect( wxRect
& rect
, wxPoint
& delta
, const wxSize
& minDim
);
90 void AdjustRectPos( const wxRect
& original
, const wxSize
& newDim
, wxRect
& newRect
);
93 wxSize
GetMinimalWndDim();
95 // Draws the hint rectangle.
96 void DrawHintRect( const wxRect
& r
);
98 // Tests if the mouse position is in this window.
99 int HitTestWindow( wxMouseEvent
& event
);
101 // Lays out the buttons.
102 void LayoutMiniButtons();
106 // Default constructor.
112 // Sets the client for this tool window.
113 void SetClient( wxWindow
* pWnd
);
115 // Returns the client window.
116 wxWindow
* GetClient();
118 // Sets the title font.
119 void SetTitleFont( wxFont
& font
);
121 // Adds a button. Buttons are added in right-to-left order.
122 void AddMiniButton( cbMiniButton
* pBtn
);
124 // Responds to a paint event.
125 void OnPaint( wxPaintEvent
& event
);
127 // Responds to a mouse move event.
128 void OnMotion( wxMouseEvent
& event
);
130 // Responds to a mouse left down event.
131 void OnLeftDown( wxMouseEvent
& event
);
133 // Responds to a mouse left up event.
134 void OnLeftUp( wxMouseEvent
& event
);
136 // Responds to a size event.
137 void OnSize( wxSizeEvent
& event
);
139 // Responds to an erase background event.
140 void OnEraseBackground( wxEraseEvent
& event
);
142 // Returns the preferred size for the window.
143 virtual wxSize
GetPreferredSize( const wxSize
& given
);
145 // Called when a mini button is clicked.
146 // By default, does nothing.
147 virtual void OnMiniButtonClicked( int WXUNUSED(btnIdx
) ) {}
149 // Handles clicking on the title. By default, does nothing.
150 virtual bool HandleTitleClick( wxMouseEvent
& WXUNUSED(event
) ) { return false; }
152 DECLARE_EVENT_TABLE()
155 // FIXME:: the code below should be moved to a separate file
157 #include "wx/fl/controlbar.h"
160 cbMiniButton is the base class for a small button that can be placed in a wxToolWindow
164 class cbMiniButton
: public wxObject
172 wxFrameLayout
* mpLayout
;
174 cbPluginBase
* mpPlugin
;
183 // Default constructor.
186 // Set the position of the button.
187 void SetPos( const wxPoint
& pos
);
189 // Returns true if the given position was over the button.
190 bool HitTest( const wxPoint
& pos
);
192 // Responds to a left down event.
193 void OnLeftDown( const wxPoint
& pos
);
195 // Responds to a left up event.
196 void OnLeftUp( const wxPoint
& pos
);
198 // Responds to a mouse move event.
199 void OnMotion( const wxPoint
& pos
);
201 // Refreshes the button.
204 // Draws the button. Override this to implement
205 // the desired appearance.
206 virtual void Draw( wxDC
& dc
);
208 // Returns true if the button was clicked.
214 // Enable or disable the button.
215 void Enable( bool enable
) { mEnabled
= enable
; }
217 // Returns true if this button is pressed.
218 bool IsPressed() { return mPressed
; }
222 cbCloseBox is a window close button, used in a wxToolWindow titlebar.
225 class WXDLLIMPEXP_FL cbCloseBox
: public cbMiniButton
228 // Draws the close button appearance.
229 virtual void Draw( wxDC
& dc
);
233 cbCollapseBox is a window collapse button, used in a wxToolWindow titlebar.
236 class WXDLLIMPEXP_FL cbCollapseBox
: public cbMiniButton
241 // Draws the collapse button appearance.
242 virtual void Draw( wxDC
& dc
);
246 cbDockBox is a window dock button, used in a wxToolWindow titlebar.
249 class WXDLLIMPEXP_FL cbDockBox
: public cbMiniButton
252 // Draws the dock button appearance.
253 virtual void Draw( wxDC
& dc
);
257 cbFloatedBarWindow is a kind of wxToolWindow,
258 implementing floating toolbars.
261 class WXDLLIMPEXP_FL cbFloatedBarWindow
: public wxToolWindow
263 DECLARE_DYNAMIC_CLASS( cbFloatedBarWindow
)
266 wxFrameLayout
* mpLayout
;
268 friend class cbFloatedBarWindowSerializer
;
271 // Default constructor.
272 cbFloatedBarWindow();
274 // Sets the bar information for this window.
275 void SetBar( cbBarInfo
* pBar
);
277 // Sets the layout for this window.
278 void SetLayout( wxFrameLayout
* pLayout
);
280 // Returns the bar information for this window.
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
);
289 // Overridden function returning the preferred size.
290 virtual wxSize
GetPreferredSize( const wxSize
& given
);
292 // Overridden function responding to mouse clicks on mini-buttons.
293 virtual void OnMiniButtonClicked( int btnIdx
);
295 // Overridden function responding to mouse button clicks on the titlebar.
296 virtual bool HandleTitleClick( wxMouseEvent
& event
);
298 // Responds to double-click mouse events.
299 void OnDblClick( wxMouseEvent
& event
);
301 DECLARE_EVENT_TABLE()
304 #endif /* __TOOLWND_G__ */