1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: Contrib. demo
4 // Author: Aleksandras Gluchovas
8 // Copyright: (c) Aleksandras Gluchovas
9 // Licence: wxWindows license
10 /////////////////////////////////////////////////////////////////////////////
16 #include "wx/dynarray.h"
20 #define BTN_BOX_HEIGHT 12
21 #define BTN_BOX_WIDTH 12
22 #define BTN_X_WIEGHT 2
26 typedef cbMiniButton
* cbMinitButtonPtrT
;
28 WX_DEFINE_ARRAY( cbMinitButtonPtrT
, cbMiniButtonArrayT
);
30 class wxToolWindow
: public wxFrame
32 DECLARE_DYNAMIC_CLASS( wxToolWindow
)
34 public: /** protected really, accesssed only by serializers **/
36 cbMiniButtonArrayT mButtons
;
37 wxWindow
* mpClientWnd
;
51 bool mRealTimeUpdatesOn
;
58 // drag&drop state variables
66 void GetScrWindowRect( wxRect
& r
);
67 void GetScrMousePos ( wxMouseEvent
& event
, wxPoint
& pos
);
68 void SetHintCursor ( int type
);
70 void CalcResizedRect( wxRect
& rect
, wxPoint
& delta
, const wxSize
& minDim
);
71 void AdjustRectPos( const wxRect
& original
, const wxSize
& newDim
, wxRect
& newRect
);
72 wxSize
GetMinimalWndDim();
74 void DrawHintRect( const wxRect
& r
);
76 int HitTestWindow( wxMouseEvent
& event
);
78 void LayoutMiniButtons();
85 void SetClient( wxWindow
* pWnd
);
86 wxWindow
* GetClient();
88 void SetTitleFont( wxFont
& font
);
90 // buttons are added in right-to-left order
91 void AddMiniButton( cbMiniButton
* pBtn
);
93 void OnPaint( wxPaintEvent
& event
);
95 void OnMotion( wxMouseEvent
& event
);
96 void OnLeftDown( wxMouseEvent
& event
);
97 void OnLeftUp( wxMouseEvent
& event
);
98 void OnSize( wxSizeEvent
& event
);
100 void OnEraseBackground( wxEraseEvent
& event
);
104 virtual wxSize
GetPreferredSize( const wxSize
& given
);
105 virtual void OnMiniButtonClicked( int btnIdx
) {}
106 virtual bool HandleTitleClick( wxMouseEvent
& event
) { return FALSE
; }
108 DECLARE_EVENT_TABLE()
111 // FIXME:: the code below should be moved to a separate file
113 #include "controlbar.h"
115 class cbMiniButton
: public wxObject
123 wxFrameLayout
* mpLayout
;
125 cbPluginBase
* mpPlugin
;
136 void SetPos( const wxPoint
& pos
);
137 bool HitTest( const wxPoint
& pos
);
139 void OnLeftDown( const wxPoint
& pos
);
140 void OnLeftUp( const wxPoint
& pos
);
141 void OnMotion( const wxPoint
& pos
);
144 virtual void Draw( wxDC
& dc
);
149 void Enable( bool enable
) { mEnabled
= enable
; }
151 bool IsPressed() { return mPressed
; }
154 // classes specific to wxFrameLayout engine (FOR NOW in here...)
156 class cbCloseBox
: public cbMiniButton
159 virtual void Draw( wxDC
& dc
);
162 class cbCollapseBox
: public cbMiniButton
167 virtual void Draw( wxDC
& dc
);
170 class cbDockBox
: public cbMiniButton
173 virtual void Draw( wxDC
& dc
);
176 class cbFloatedBarWindow
: public wxToolWindow
178 DECLARE_DYNAMIC_CLASS( cbFloatedBarWindow
)
181 wxFrameLayout
* mpLayout
;
183 friend class cbFloatedBarWindowSerializer
;
186 cbFloatedBarWindow();
188 void SetBar( cbBarInfo
* pBar
);
189 void SetLayout( wxFrameLayout
* pLayout
);
192 // given coordinates are those of the bar itself
193 // floated container window's position and size
194 // are ajusted accordingly
196 void PositionFloatedWnd( int scrX
, int scrY
,
197 int width
, int height
);
199 // overriden methods of wxToolWindow
201 virtual wxSize
GetPreferredSize( const wxSize
& given
);
202 virtual void OnMiniButtonClicked( int btnIdx
);
203 virtual bool HandleTitleClick( wxMouseEvent
& event
);
205 void OnDblClick( wxMouseEvent
& event
);
207 DECLARE_EVENT_TABLE()