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 /////////////////////////////////////////////////////////////////////////////
17 #include "wx/dynarray.h"
18 #include "wx/fl/fldefs.h"
22 #define BTN_BOX_HEIGHT 12
23 #define BTN_BOX_WIDTH 12
24 #define BTN_X_WEIGHT 2
26 class WXDLLIMPEXP_FL cbMiniButton
;
28 typedef cbMiniButton
* cbMinitButtonPtrT
;
30 WXFL_DEFINE_ARRAY_PTR( cbMinitButtonPtrT
, cbMiniButtonArrayT
);
33 A tool window is a special kind of frame that paints its own title, and
34 can be used to implement small floating windows.
37 class WXDLLIMPEXP_FL wxToolWindow
: public wxFrame
39 DECLARE_DYNAMIC_CLASS( wxToolWindow
)
41 public: /** protected really, accessed only by serializers **/
43 cbMiniButtonArrayT mButtons
;
44 wxWindow
* mpClientWnd
;
58 bool mRealTimeUpdatesOn
;
65 // drag&drop state variables
73 // Maps client coordinates to screen coordinates.
74 void GetScrWindowRect( wxRect
& r
);
76 // Gets the mouse position in screen coordinates.
77 void GetScrMousePos ( wxMouseEvent
& event
, wxPoint
& pos
);
79 // Sets the hint cursor.
80 void SetHintCursor ( int type
);
82 // Calculate resized rectangle.
83 void CalcResizedRect( wxRect
& rect
, wxPoint
& delta
, const wxSize
& minDim
);
86 void AdjustRectPos( const wxRect
& original
, const wxSize
& newDim
, wxRect
& newRect
);
89 wxSize
GetMinimalWndDim();
91 // Draws the hint rectangle.
92 void DrawHintRect( const wxRect
& r
);
94 // Tests if the mouse position is in this window.
95 int HitTestWindow( wxMouseEvent
& event
);
97 // Lays out the buttons.
98 void LayoutMiniButtons();
102 // Default constructor.
108 // Sets the client for this tool window.
109 void SetClient( wxWindow
* pWnd
);
111 // Returns the client window.
112 wxWindow
* GetClient();
114 // Sets the title font.
115 void SetTitleFont( wxFont
& font
);
117 // Adds a button. Buttons are added in right-to-left order.
118 void AddMiniButton( cbMiniButton
* pBtn
);
120 // Responds to a paint event.
121 void OnPaint( wxPaintEvent
& event
);
123 // Responds to a mouse move event.
124 void OnMotion( wxMouseEvent
& event
);
126 // Responds to a mouse left down event.
127 void OnLeftDown( wxMouseEvent
& event
);
129 // Responds to a mouse left up event.
130 void OnLeftUp( wxMouseEvent
& event
);
132 // Responds to a size event.
133 void OnSize( wxSizeEvent
& event
);
135 // Responds to an erase background event.
136 void OnEraseBackground( wxEraseEvent
& event
);
138 // Returns the preferred size for the window.
139 virtual wxSize
GetPreferredSize( const wxSize
& given
);
141 // Called when a mini button is clicked.
142 // By default, does nothing.
143 virtual void OnMiniButtonClicked( int WXUNUSED(btnIdx
) ) {}
145 // Handles clicking on the title. By default, does nothing.
146 virtual bool HandleTitleClick( wxMouseEvent
& WXUNUSED(event
) ) { return false; }
148 DECLARE_EVENT_TABLE()
151 // FIXME:: the code below should be moved to a separate file
153 #include "wx/fl/controlbar.h"
156 cbMiniButton is the base class for a small button that can be placed in a wxToolWindow
160 class cbMiniButton
: public wxObject
168 wxFrameLayout
* mpLayout
;
170 cbPluginBase
* mpPlugin
;
179 // Default constructor.
182 // Set the position of the button.
183 void SetPos( const wxPoint
& pos
);
185 // Returns true if the given position was over the button.
186 bool HitTest( const wxPoint
& pos
);
188 // Responds to a left down event.
189 void OnLeftDown( const wxPoint
& pos
);
191 // Responds to a left up event.
192 void OnLeftUp( const wxPoint
& pos
);
194 // Responds to a mouse move event.
195 void OnMotion( const wxPoint
& pos
);
197 // Refreshes the button.
200 // Draws the button. Override this to implement
201 // the desired appearance.
202 virtual void Draw( wxDC
& dc
);
204 // Returns true if the button was clicked.
210 // Enable or disable the button.
211 void Enable( bool enable
) { mEnabled
= enable
; }
213 // Returns true if this button is pressed.
214 bool IsPressed() { return mPressed
; }
218 cbCloseBox is a window close button, used in a wxToolWindow titlebar.
221 class WXDLLIMPEXP_FL cbCloseBox
: public cbMiniButton
224 // Draws the close button appearance.
225 virtual void Draw( wxDC
& dc
);
229 cbCollapseBox is a window collapse button, used in a wxToolWindow titlebar.
232 class WXDLLIMPEXP_FL cbCollapseBox
: public cbMiniButton
237 // Draws the collapse button appearance.
238 virtual void Draw( wxDC
& dc
);
242 cbDockBox is a window dock button, used in a wxToolWindow titlebar.
245 class WXDLLIMPEXP_FL cbDockBox
: public cbMiniButton
248 // Draws the dock button appearance.
249 virtual void Draw( wxDC
& dc
);
253 cbFloatedBarWindow is a kind of wxToolWindow,
254 implementing floating toolbars.
257 class WXDLLIMPEXP_FL cbFloatedBarWindow
: public wxToolWindow
259 DECLARE_DYNAMIC_CLASS( cbFloatedBarWindow
)
262 wxFrameLayout
* mpLayout
;
264 friend class cbFloatedBarWindowSerializer
;
267 // Default constructor.
268 cbFloatedBarWindow();
270 // Sets the bar information for this window.
271 void SetBar( cbBarInfo
* pBar
);
273 // Sets the layout for this window.
274 void SetLayout( wxFrameLayout
* pLayout
);
276 // Returns the bar information for this window.
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
);
285 // Overridden function returning the preferred size.
286 virtual wxSize
GetPreferredSize( const wxSize
& given
);
288 // Overridden function responding to mouse clicks on mini-buttons.
289 virtual void OnMiniButtonClicked( int btnIdx
);
291 // Overridden function responding to mouse button clicks on the titlebar.
292 virtual bool HandleTitleClick( wxMouseEvent
& event
);
294 // Responds to double-click mouse events.
295 void OnDblClick( wxMouseEvent
& event
);
297 DECLARE_EVENT_TABLE()
300 #endif /* __TOOLWND_G__ */