]> git.saurik.com Git - wxWidgets.git/blame - utils/framelayout/src/toolwnd.h
don't crash when invalid colour is set as fg/bg colour
[wxWidgets.git] / utils / framelayout / src / toolwnd.h
CommitLineData
bd9396d5
HH
1/////////////////////////////////////////////////////////////////////////////
2// Name: No names yet.
3// Purpose: Contrib. demo
4// Author: Aleksandras Gluchovas
5// Modified by:
6// Created: 06/09/98
7// RCS-ID: $Id$
8// Copyright: (c) Aleksandras Gluchovas
9// Licence: wxWindows license
10/////////////////////////////////////////////////////////////////////////////
11
12#ifndef __TOOLWND_G__
13#define __TOOLWND_G__
14
15#include "wx/frame.h"
16#include "wx/dynarray.h"
17
18// fixed settings
19
20#define BTN_BOX_HEIGHT 12
21#define BTN_BOX_WIDTH 12
22#define BTN_X_WIEGHT 2
23
24class cbMiniButton;
25
26typedef cbMiniButton* cbMinitButtonPtrT;
27
28WX_DEFINE_ARRAY( cbMinitButtonPtrT, cbMiniButtonArrayT );
29
30class wxToolWindow : public wxFrame
31{
32 DECLARE_DYNAMIC_CLASS( wxToolWindow )
33
34public: /** protected really, accesssed only by serializers **/
35
36 cbMiniButtonArrayT mButtons;
37 wxWindow* mpClientWnd;
38
39 wxFont mTitleFont;
40
41 int mTitleHeight;
42 int mClntHorizGap;
43 int mClntVertGap;
44 int mWndVertGap;
45 int mWndHorizGap;
46 int mButtonGap;
47 int mInTitleMargin;
48 int mHintBorder;
49
50 bool mResizeStarted;
51 bool mRealTimeUpdatesOn;
52
53 int mMTolerance;
54
55 int mCursorType;
56 bool mMouseCaptured;
57
58 // drag&drop state variables
59
60 wxPoint mDragOrigin;
61 wxRect mInitialRect;
62 wxRect mPrevHintRect;
63 wxScreenDC* mpScrDc;
64
65protected:
66 void GetScrWindowRect( wxRect& r );
67 void GetScrMousePos ( wxMouseEvent& event, wxPoint& pos );
68 void SetHintCursor ( int type );
69
70 void CalcResizedRect( wxRect& rect, wxPoint& delta, const wxSize& minDim );
71 void AdjustRectPos( const wxRect& original, const wxSize& newDim, wxRect& newRect );
72 wxSize GetMinimalWndDim();
73
74 void DrawHintRect( const wxRect& r );
75
76 int HitTestWindow( wxMouseEvent& event );
77
78 void LayoutMiniButtons();
79
80public:
81
82 wxToolWindow();
83 ~wxToolWindow();
84
85 void SetClient( wxWindow* pWnd );
86 wxWindow* GetClient();
87
88 void SetTitleFont( wxFont& font );
89
90 // buttons are added in right-to-left order
91 void AddMiniButton( cbMiniButton* pBtn );
92
93 void OnPaint( wxPaintEvent& event );
94
95 void OnMotion( wxMouseEvent& event );
96 void OnLeftDown( wxMouseEvent& event );
97 void OnLeftUp( wxMouseEvent& event );
98 void OnSize( wxSizeEvent& event );
99
100 void OnEraseBackground( wxEraseEvent& event );
101
102 // overridables:
103
104 virtual wxSize GetPreferredSize( const wxSize& given );
105 virtual void OnMiniButtonClicked( int btnIdx ) {}
106 virtual bool HandleTitleClick( wxMouseEvent& event ) { return FALSE; }
107
108 DECLARE_EVENT_TABLE()
109};
110
111// FIXME:: the code below should be moved to a separate file
112
113#include "controlbar.h"
114
115class cbMiniButton : public wxObject
116{
117public:
118 wxPoint mPos;
119 wxSize mDim;
120 bool mVisible;
121 bool mEnabled;
122
123 wxFrameLayout* mpLayout;
124 cbDockPane* mpPane;
125 cbPluginBase* mpPlugin;
126
127 wxWindow* mpWnd;
128
129 bool mWasClicked;
130 bool mDragStarted;
131
132 bool mPressed;
133public:
134 cbMiniButton();
135
136 void SetPos( const wxPoint& pos );
137 bool HitTest( const wxPoint& pos );
138
139 void OnLeftDown( const wxPoint& pos );
140 void OnLeftUp( const wxPoint& pos );
141 void OnMotion( const wxPoint& pos );
142
143 void Refresh();
144 virtual void Draw( wxDC& dc );
145
146 bool WasClicked();
147 void Reset();
148
149 void Enable( bool enable ) { mEnabled = enable; }
150
151 bool IsPressed() { return mPressed; }
152};
153
154// classes specific to wxFrameLayout engine (FOR NOW in here...)
155
156class cbCloseBox : public cbMiniButton
157{
158public:
159 virtual void Draw( wxDC& dc );
160};
161
162class cbCollapseBox : public cbMiniButton
163{
164public:
165 bool mIsAtLeft;
166
167 virtual void Draw( wxDC& dc );
168};
169
170class cbDockBox : public cbMiniButton
171{
172public:
173 virtual void Draw( wxDC& dc );
174};
175
176class cbFloatedBarWindow : public wxToolWindow
177{
178 DECLARE_DYNAMIC_CLASS( cbFloatedBarWindow )
179protected:
180 cbBarInfo* mpBar;
181 wxFrameLayout* mpLayout;
182
183 friend class cbFloatedBarWindowSerializer;
184
185public:
186 cbFloatedBarWindow();
187
188 void SetBar( cbBarInfo* pBar );
189 void SetLayout( wxFrameLayout* pLayout );
190 cbBarInfo* GetBar();
191
192 // given coordinates are those of the bar itself
193 // floated container window's position and size
194 // are ajusted accordingly
195
196 void PositionFloatedWnd( int scrX, int scrY,
197 int width, int height );
198
199 // overriden methods of wxToolWindow
200
201 virtual wxSize GetPreferredSize( const wxSize& given );
202 virtual void OnMiniButtonClicked( int btnIdx );
203 virtual bool HandleTitleClick( wxMouseEvent& event );
204
205 void OnDblClick( wxMouseEvent& event );
206
207 DECLARE_EVENT_TABLE()
208};
209
210#endif