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"
25 #define BTN_BOX_HEIGHT 12
26 #define BTN_BOX_WIDTH 12
27 #define BTN_X_WIEGHT 2
31 typedef cbMiniButton
* cbMinitButtonPtrT
;
33 WX_DEFINE_ARRAY( cbMinitButtonPtrT
, cbMiniButtonArrayT
);
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.
40 class wxToolWindow
: public wxFrame
42 DECLARE_DYNAMIC_CLASS( wxToolWindow
)
44 public: /** protected really, accessed only by serializers **/
46 cbMiniButtonArrayT mButtons
;
47 wxWindow
* mpClientWnd
;
61 bool mRealTimeUpdatesOn
;
68 // drag&drop state variables
76 // Maps client coordinates to screen coordinates.
77 void GetScrWindowRect( wxRect
& r
);
79 // Gets the mouse position in screen coordinates.
80 void GetScrMousePos ( wxMouseEvent
& event
, wxPoint
& pos
);
82 // Sets the hint cursor.
83 void SetHintCursor ( int type
);
85 // Calculate resized rectangle.
86 void CalcResizedRect( wxRect
& rect
, wxPoint
& delta
, const wxSize
& minDim
);
89 void AdjustRectPos( const wxRect
& original
, const wxSize
& newDim
, wxRect
& newRect
);
92 wxSize
GetMinimalWndDim();
94 // Draws the hint rectangle.
95 void DrawHintRect( const wxRect
& r
);
97 // Tests if the mouse position is in this window.
98 int HitTestWindow( wxMouseEvent
& event
);
100 // Lays out the buttons.
101 void LayoutMiniButtons();
105 // Default constructor.
111 // Sets the client for this tool window.
112 void SetClient( wxWindow
* pWnd
);
114 // Returns the client window.
115 wxWindow
* GetClient();
117 // Sets the title font.
118 void SetTitleFont( wxFont
& font
);
120 // Adds a button. Buttons are added in right-to-left order.
121 void AddMiniButton( cbMiniButton
* pBtn
);
123 // Responds to a paint event.
124 void OnPaint( wxPaintEvent
& event
);
126 // Responds to a mouse move event.
127 void OnMotion( wxMouseEvent
& event
);
129 // Responds to a mouse left down event.
130 void OnLeftDown( wxMouseEvent
& event
);
132 // Responds to a mouse left up event.
133 void OnLeftUp( wxMouseEvent
& event
);
135 // Responds to a size event.
136 void OnSize( wxSizeEvent
& event
);
138 // Responds to an erase background event.
139 void OnEraseBackground( wxEraseEvent
& event
);
141 // Returns the preferred size for the window.
142 virtual wxSize
GetPreferredSize( const wxSize
& given
);
144 // Called when a mini button is clicked.
145 // By default, does nothing.
146 virtual void OnMiniButtonClicked( int btnIdx
) {}
148 // Handles clicking on the title. By default, does nothing.
149 virtual bool HandleTitleClick( wxMouseEvent
& event
) { return FALSE
; }
151 DECLARE_EVENT_TABLE()
154 // FIXME:: the code below should be moved to a separate file
156 #include "wx/fl/controlbar.h"
159 cbMiniButton is the base class for a small button that can be placed in a wxToolWindow
163 class cbMiniButton
: public wxObject
171 wxFrameLayout
* mpLayout
;
173 cbPluginBase
* mpPlugin
;
182 // Default constructor.
185 // Set the position of the button.
186 void SetPos( const wxPoint
& pos
);
188 // Returns TRUE if the given position was over the button.
189 bool HitTest( const wxPoint
& pos
);
191 // Responds to a left down event.
192 void OnLeftDown( const wxPoint
& pos
);
194 // Responds to a left up event.
195 void OnLeftUp( const wxPoint
& pos
);
197 // Responds to a mouse move event.
198 void OnMotion( const wxPoint
& pos
);
200 // Refreshes the button.
203 // Draws the button. Override this to implement
204 // the desired appearance.
205 virtual void Draw( wxDC
& dc
);
207 // Returns TRUE if the button was clicked.
213 // Enable or disable the button.
214 void Enable( bool enable
) { mEnabled
= enable
; }
216 // Returns TRUE if this button is pressed.
217 bool IsPressed() { return mPressed
; }
221 cbCloseBox is a window close button, used in a wxToolWindow titlebar.
224 class cbCloseBox
: public cbMiniButton
227 // Draws the close button appearance.
228 virtual void Draw( wxDC
& dc
);
232 cbCollapseBox is a window collapse button, used in a wxToolWindow titlebar.
235 class cbCollapseBox
: public cbMiniButton
240 // Draws the collapse button appearance.
241 virtual void Draw( wxDC
& dc
);
245 cbDockBox is a window dock button, used in a wxToolWindow titlebar.
248 class cbDockBox
: public cbMiniButton
251 // Draws the dock button appearance.
252 virtual void Draw( wxDC
& dc
);
256 cbFloatedBarWindow is a kind of wxToolWindow,
257 implementing floating toolbars.
260 class cbFloatedBarWindow
: public wxToolWindow
262 DECLARE_DYNAMIC_CLASS( cbFloatedBarWindow
)
265 wxFrameLayout
* mpLayout
;
267 friend class cbFloatedBarWindowSerializer
;
270 // Default constructor.
271 cbFloatedBarWindow();
273 // Sets the bar information for this window.
274 void SetBar( cbBarInfo
* pBar
);
276 // Sets the layout for this window.
277 void SetLayout( wxFrameLayout
* pLayout
);
279 // Returns the bar information for this window.
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
);
288 // Overridden function returning the preferred size.
289 virtual wxSize
GetPreferredSize( const wxSize
& given
);
291 // Overridden function responding to mouse clicks on mini-buttons.
292 virtual void OnMiniButtonClicked( int btnIdx
);
294 // Overridden function responding to mouse button clicks on the titlebar.
295 virtual bool HandleTitleClick( wxMouseEvent
& event
);
297 // Responds to double-click mouse events.
298 void OnDblClick( wxMouseEvent
& event
);
300 DECLARE_EVENT_TABLE()
303 #endif /* __TOOLWND_G__ */