1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: Contrib. demo
4 // Author: Aleksandras Gluchovas
8 // Copyright: (c) Aleksandras Gluchovas
9 // Licence: wxWindows license
10 /////////////////////////////////////////////////////////////////////////////
16 #pragma interface "toolwnd.h"
20 #include "wx/dynarray.h"
24 #define BTN_BOX_HEIGHT 12
25 #define BTN_BOX_WIDTH 12
26 #define BTN_X_WIEGHT 2
30 typedef cbMiniButton
* cbMinitButtonPtrT
;
32 WX_DEFINE_ARRAY( cbMinitButtonPtrT
, cbMiniButtonArrayT
);
34 class wxToolWindow
: public wxFrame
36 DECLARE_DYNAMIC_CLASS( wxToolWindow
)
38 public: /** protected really, accessed only by serializers **/
40 cbMiniButtonArrayT mButtons
;
41 wxWindow
* mpClientWnd
;
55 bool mRealTimeUpdatesOn
;
62 // drag&drop state variables
70 void GetScrWindowRect( wxRect
& r
);
71 void GetScrMousePos ( wxMouseEvent
& event
, wxPoint
& pos
);
72 void SetHintCursor ( int type
);
74 void CalcResizedRect( wxRect
& rect
, wxPoint
& delta
, const wxSize
& minDim
);
75 void AdjustRectPos( const wxRect
& original
, const wxSize
& newDim
, wxRect
& newRect
);
76 wxSize
GetMinimalWndDim();
78 void DrawHintRect( const wxRect
& r
);
80 int HitTestWindow( wxMouseEvent
& event
);
82 void LayoutMiniButtons();
89 void SetClient( wxWindow
* pWnd
);
90 wxWindow
* GetClient();
92 void SetTitleFont( wxFont
& font
);
94 // buttons are added in right-to-left order
95 void AddMiniButton( cbMiniButton
* pBtn
);
97 void OnPaint( wxPaintEvent
& event
);
99 void OnMotion( wxMouseEvent
& event
);
100 void OnLeftDown( wxMouseEvent
& event
);
101 void OnLeftUp( wxMouseEvent
& event
);
102 void OnSize( wxSizeEvent
& event
);
104 void OnEraseBackground( wxEraseEvent
& event
);
108 virtual wxSize
GetPreferredSize( const wxSize
& given
);
109 virtual void OnMiniButtonClicked( int btnIdx
) {}
110 virtual bool HandleTitleClick( wxMouseEvent
& event
) { return FALSE
; }
112 DECLARE_EVENT_TABLE()
115 // FIXME:: the code below should be moved to a separate file
117 #include "wx/fl/controlbar.h"
119 class cbMiniButton
: public wxObject
127 wxFrameLayout
* mpLayout
;
129 cbPluginBase
* mpPlugin
;
140 void SetPos( const wxPoint
& pos
);
141 bool HitTest( const wxPoint
& pos
);
143 void OnLeftDown( const wxPoint
& pos
);
144 void OnLeftUp( const wxPoint
& pos
);
145 void OnMotion( const wxPoint
& pos
);
148 virtual void Draw( wxDC
& dc
);
153 void Enable( bool enable
) { mEnabled
= enable
; }
155 bool IsPressed() { return mPressed
; }
158 // classes specific to wxFrameLayout engine (FOR NOW in here...)
160 class cbCloseBox
: public cbMiniButton
163 virtual void Draw( wxDC
& dc
);
166 class cbCollapseBox
: public cbMiniButton
171 virtual void Draw( wxDC
& dc
);
174 class cbDockBox
: public cbMiniButton
177 virtual void Draw( wxDC
& dc
);
180 class cbFloatedBarWindow
: public wxToolWindow
182 DECLARE_DYNAMIC_CLASS( cbFloatedBarWindow
)
185 wxFrameLayout
* mpLayout
;
187 friend class cbFloatedBarWindowSerializer
;
190 cbFloatedBarWindow();
192 void SetBar( cbBarInfo
* pBar
);
193 void SetLayout( wxFrameLayout
* pLayout
);
196 // given coordinates are those of the bar itself
197 // floated container window's position and size
198 // are ajusted accordingly
200 void PositionFloatedWnd( int scrX
, int scrY
,
201 int width
, int height
);
203 // overriden methods of wxToolWindow
205 virtual wxSize
GetPreferredSize( const wxSize
& given
);
206 virtual void OnMiniButtonClicked( int btnIdx
);
207 virtual bool HandleTitleClick( wxMouseEvent
& event
);
209 void OnDblClick( wxMouseEvent
& event
);
211 DECLARE_EVENT_TABLE()
214 #endif /* __TOOLWND_G__ */