]> git.saurik.com Git - wxWidgets.git/blame - utils/framelayout/src/controlarea.h
don't crash when invalid colour is set as fg/bg colour
[wxWidgets.git] / utils / framelayout / src / controlarea.h
CommitLineData
bd9396d5
HH
1/////////////////////////////////////////////////////////////////////////////
2// Name: No names yet.
3// Purpose: Contrib. demo
4// Author: Aleksandras Gluchovas
5// Modified by:
6// Created: 07/09/98
7// RCS-ID: $Id$
8// Copyright: (c) Aleksandras Gluchovas
9// Licence: wxWindows license
10/////////////////////////////////////////////////////////////////////////////
11
12#ifndef __CONTROLAREA_G__
13#define __CONTROLAREA_G__
14
15#ifdef __GNUG__
16#pragma interface "controlarea.h"
17#endif
18
19#include "wx/defs.h"
20#include "wx/window.h"
21#include "wx/string.h"
22
23#define WXCONTROLAREA_VERSION 1.0
24
25// layout types for title bars of the tabs
26// (are selected up by evaluating the available free space )
27
28class twTabInfo; // forward decl.
29
30#define wxTITLE_IMG_AND_TEXT 0
31#define wxTITLE_IMG_ONLY 1
32#define wxTITLE_BORDER_ONLY 2
33
34/*
35 * class manages and decorates contained "tab"-windows.
36 * Draws decorations similar to those in "Project Workplace"
37 * of Microsoft Developer Studio 4.xx
38 */
39
40class wxTabbedWindow : public wxPanel
41{
42 DECLARE_DYNAMIC_CLASS( wxTabbedWindow )
43
44public:
45
46 friend class wxTabbedWindowSerializer;
47
48 wxList mTabs;
49 int mActiveTab;
50 int mTitleHeight;
51 int mLayoutType;
52
53 void HideInactiveTabs( bool andRepaint );
54
55 // overrride,to provide different font for tab-labels
56
57 virtual wxFont GetLabelingFont();
58
59 // FOR NOW:: scrollbars are actually related to wxPaggedWindow
60
61 wxScrollBar* mpTabScroll;
62 wxScrollBar* mpHorizScroll;
63 wxScrollBar* mpVertScroll;
64
65public:
66
67 // public properties (invoke ReclaclLayout(TRUE) to apply changes)
68
69 wxPen mWhitePen; // default: RGB(255,255,255)
8a704c2b
RS
70 wxPen mLightPen; // wxSYS_COLOUR_3DHIGHLIGHT
71 wxPen mGrayPen; // wxSYS_COLOUR_3DFACE
72 wxPen mDarkPen; // wxSYS_COLOUR_3DSHADOW
bd9396d5
HH
73 wxPen mBlackPen; // default: RGB( 0, 0, 0)
74
75 int mVertGap; // default: 3
76 int mHorizGap; // default: 5
77 int mTitleVertGap; // default: 3
78 int mTitleHorizGap; // default: 4
79 int mImageTextGap; // default: 2
80 int mFirstTitleGap; // default: 11
81 int mBorderOnlyWidth; // default: 8
82
83 // notifications (can be handled by derivatives)
84
85 virtual void OnTabAdded( twTabInfo* pInfo ) {}
86
87 virtual void SizeTabs(int x,int y, int width, int height, bool repant);
88
89public:
90 wxTabbedWindow();
91 virtual ~wxTabbedWindow();
92
93 // tabs can be also added when the window is
94 // already displayed - "on the fly"
95
96 virtual void AddTab( wxWindow* pContent, // contained window
97 wxString tabText, // tab label
98 wxString imageFileName = "", // if "", only text label is displayed
99 long imageType = wxBITMAP_TYPE_BMP );
100
101 // NOTE:: if this AddTab(..) overload is called, the
102 // image bitmap will not be serialized (if performed),
103 // use the above method instead, so that images could
104 // be restored using the given file names
105
106 virtual void AddTab( wxWindow* pContent,
107 wxString tabText,
108 wxBitmap* pImage = NULL );
109
110
111 virtual void RemoveTab( int tabNo );
112
113 /* misc accessors */
114
115 virtual int GetTabCount();
116 virtual wxWindow* GetTab( int tabNo );
117 virtual wxWindow* GetActiveTab();
118 virtual void SetActiveTab( int tabNo );
119
120 void DrawShadedRect( int x, int y, int width, int height,
121 wxPen& upperPen, wxPen& lowerPen, wxDC& dc );
122
123 virtual void DrawDecorations( wxDC& dc );
124
125 // return -1, if non of the title bars was hitted,
126 // otherwise the index of the hitted tab title bar
127
128 virtual int HitTest( const wxPoint& pos );
129
130 // should be invoked to redisplay window with changed properties
131
132 virtual void RecalcLayout( bool andRepaint = TRUE );
133
134 // event handlers
135
136 void OnPaint( wxPaintEvent& event );
137 void OnSize ( wxSizeEvent& event );
138
139 void OnBkErase( wxEraseEvent& event );
140 void OnLButtonDown( wxMouseEvent& event );
141
142 DECLARE_EVENT_TABLE()
143};
144
145/*
146 * class manages and decorates contained "sheets" (or pages).
147 * Draws decorations similar to those in "Output window"
148 * of Microsoft Developer Studio 4.xx
149 */
150
151class wxPaggedWindow : public wxTabbedWindow
152{
153 DECLARE_DYNAMIC_CLASS( wxPaggedWindow )
154protected:
155
156 bool mScrollEventInProgress;
157
158 // drag&drop state variables
159
160 bool mIsDragged;
161 int mDagOrigin;
162 wxCursor mResizeCursor;
163 wxCursor mNormalCursor;
164 bool mCursorChanged;
165 int mOriginalTitleRowLen;
166
167 void DrawPaperBar( twTabInfo& tab, int x, int y,
168 wxBrush& brush, wxPen& pen, wxDC& dc );
169
170 int GetWholeTabRowLen();
171
172 // adjusts scorllbars to fit around tabs
173
174 virtual void OnTabAdded( twTabInfo* pInfo );
175
176 // sets smaller font for page-labels
177
178 virtual wxFont GetLabelingFont();
179
180public:
181 int mTitleRowStart;
182 int mResizeNailGap;
183 int mTabTrianGap;
184 int mTitleRowLen; // actual title row length
185 int mAdjustableTitleRowLen; // setup by dragging mini-sash
186 // with the mosue pointer
187 int mCurentRowOfs;
188
189 wxBrush mGrayBrush;
190 wxBrush mWhiteBrush;
191
192public:
193 wxPaggedWindow();
194 ~wxPaggedWindow();
195
196 // NOTE:: use public methods of the base class
197 // to add "pages" to this window
198
199 /* misc accessors */
200
201 // below two methods should be called after
202 // the tabs were added (AddTab(..)). Set up
203 // these scrollbars to match the needs of the
204 // tabs added into this area
205
206 wxScrollBar& GetVerticalScrollBar();
207 wxScrollBar& GetHorizontalScrollBar();
208
209 virtual void DrawDecorations( wxDC& dc );
210
211 // return -1, if non of the title bars was hitted,
212 // otherwise the index of the hitted tab title bar
213
214 virtual int HitTest( const wxPoint& pos );
215
216 virtual void RecalcLayout( bool andRepaint = TRUE );
217
218 // event handlers
219
220 void OnPaint( wxPaintEvent& event );
221 void OnSize ( wxSizeEvent& event );
222 void OnLButtonDown( wxMouseEvent& event );
223 void OnLButtonUp ( wxMouseEvent& event );
224 void OnMouseMove ( wxMouseEvent& event );
225 void OnScroll ( wxScrollEvent& event );
226
227 DECLARE_EVENT_TABLE()
228};
229
230// helper structure of wxTabbedWindow
231
232class twTabInfo : public wxObject
233{
234 DECLARE_DYNAMIC_CLASS( twTabInfo )
235public:
236 twTabInfo();
237 ~twTabInfo();
238
239 int ImgWidth();
240 int ImgHeight();
241 int ImageToTxtGap( int prefGap );
242
243 bool HasImg();
244 wxBitmap& GetImg();
245 bool HasText();
246 wxString& GetText();
247 wxWindow& GetContent();
248
249public:
250 wxWindow* mpContent;
251 wxBitmap mBitMap;
252
253 wxString mText;
254 wxSize mDims;
255
256 // used for serialization
257 wxString mImageFile;
258 long mImageType;
259
260};
261
262#endif