]>
Commit | Line | Data |
---|---|---|
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 | ||
28 | class 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 | ||
40 | class wxTabbedWindow : public wxPanel | |
41 | { | |
42 | DECLARE_DYNAMIC_CLASS( wxTabbedWindow ) | |
43 | ||
44 | public: | |
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 | ||
65 | public: | |
66 | ||
67 | // public properties (invoke ReclaclLayout(TRUE) to apply changes) | |
68 | ||
69 | wxPen mWhitePen; // default: RGB(255,255,255) | |
70 | wxPen mGrayPen; // default: RGB(192,192,192) | |
71 | wxPen mDarkPen; // default: RGB(128,128,128) | |
72 | wxPen mBlackPen; // default: RGB( 0, 0, 0) | |
73 | ||
74 | int mVertGap; // default: 3 | |
75 | int mHorizGap; // default: 5 | |
76 | int mTitleVertGap; // default: 3 | |
77 | int mTitleHorizGap; // default: 4 | |
78 | int mImageTextGap; // default: 2 | |
79 | int mFirstTitleGap; // default: 11 | |
80 | int mBorderOnlyWidth; // default: 8 | |
81 | ||
82 | // notifications (can be handled by derivatives) | |
83 | ||
84 | virtual void OnTabAdded( twTabInfo* pInfo ) {} | |
85 | ||
86 | virtual void SizeTabs(int x,int y, int width, int height, bool repant); | |
87 | ||
88 | public: | |
89 | wxTabbedWindow(); | |
90 | virtual ~wxTabbedWindow(); | |
91 | ||
92 | // tabs can be also added when the window is | |
93 | // already displayed - "on the fly" | |
94 | ||
95 | virtual void AddTab( wxWindow* pContent, // contained window | |
96 | wxString tabText, // tab label | |
97 | wxString imageFileName = "", // if "", only text label is displayed | |
98 | long imageType = wxBITMAP_TYPE_BMP ); | |
99 | ||
100 | // NOTE:: if this AddTab(..) overload is called, the | |
101 | // image bitmap will not be serialized (if performed), | |
102 | // use the above method instead, so that images could | |
103 | // be restored using the given file names | |
104 | ||
105 | virtual void AddTab( wxWindow* pContent, | |
106 | wxString tabText, | |
107 | wxBitmap* pImage = NULL ); | |
108 | ||
109 | ||
110 | virtual void RemoveTab( int tabNo ); | |
111 | ||
112 | /* misc accessors */ | |
113 | ||
114 | virtual int GetTabCount(); | |
115 | virtual wxWindow* GetTab( int tabNo ); | |
116 | virtual wxWindow* GetActiveTab(); | |
117 | virtual void SetActiveTab( int tabNo ); | |
118 | ||
119 | void DrawShadedRect( int x, int y, int width, int height, | |
120 | wxPen& upperPen, wxPen& lowerPen, wxDC& dc ); | |
121 | ||
122 | virtual void DrawDecorations( wxDC& dc ); | |
123 | ||
124 | // return -1, if non of the title bars was hitted, | |
125 | // otherwise the index of the hitted tab title bar | |
126 | ||
127 | virtual int HitTest( const wxPoint& pos ); | |
128 | ||
129 | // should be invoked to redisplay window with changed properties | |
130 | ||
131 | virtual void RecalcLayout( bool andRepaint = TRUE ); | |
132 | ||
133 | // event handlers | |
134 | ||
135 | void OnPaint( wxPaintEvent& event ); | |
136 | void OnSize ( wxSizeEvent& event ); | |
137 | ||
138 | void OnBkErase( wxEraseEvent& event ); | |
139 | void OnLButtonDown( wxMouseEvent& event ); | |
140 | ||
141 | DECLARE_EVENT_TABLE() | |
142 | }; | |
143 | ||
144 | /* | |
145 | * class manages and decorates contained "sheets" (or pages). | |
146 | * Draws decorations similar to those in "Output window" | |
147 | * of Microsoft Developer Studio 4.xx | |
148 | */ | |
149 | ||
150 | class wxPaggedWindow : public wxTabbedWindow | |
151 | { | |
152 | DECLARE_DYNAMIC_CLASS( wxPaggedWindow ) | |
153 | protected: | |
154 | ||
155 | bool mScrollEventInProgress; | |
156 | ||
157 | // drag&drop state variables | |
158 | ||
159 | bool mIsDragged; | |
160 | int mDagOrigin; | |
161 | wxCursor mResizeCursor; | |
162 | wxCursor mNormalCursor; | |
163 | bool mCursorChanged; | |
164 | int mOriginalTitleRowLen; | |
165 | ||
166 | void DrawPaperBar( twTabInfo& tab, int x, int y, | |
167 | wxBrush& brush, wxPen& pen, wxDC& dc ); | |
168 | ||
169 | int GetWholeTabRowLen(); | |
170 | ||
171 | // adjusts scorllbars to fit around tabs | |
172 | ||
173 | virtual void OnTabAdded( twTabInfo* pInfo ); | |
174 | ||
175 | // sets smaller font for page-labels | |
176 | ||
177 | virtual wxFont GetLabelingFont(); | |
178 | ||
179 | public: | |
180 | int mTitleRowStart; | |
181 | int mResizeNailGap; | |
182 | int mTabTrianGap; | |
183 | int mTitleRowLen; // actual title row length | |
184 | int mAdjustableTitleRowLen; // setup by dragging mini-sash | |
185 | // with the mosue pointer | |
186 | int mCurentRowOfs; | |
187 | ||
188 | wxBrush mGrayBrush; | |
189 | wxBrush mWhiteBrush; | |
190 | ||
191 | public: | |
192 | wxPaggedWindow(); | |
193 | ~wxPaggedWindow(); | |
194 | ||
195 | // NOTE:: use public methods of the base class | |
196 | // to add "pages" to this window | |
197 | ||
198 | /* misc accessors */ | |
199 | ||
200 | // below two methods should be called after | |
201 | // the tabs were added (AddTab(..)). Set up | |
202 | // these scrollbars to match the needs of the | |
203 | // tabs added into this area | |
204 | ||
205 | wxScrollBar& GetVerticalScrollBar(); | |
206 | wxScrollBar& GetHorizontalScrollBar(); | |
207 | ||
208 | virtual void DrawDecorations( wxDC& dc ); | |
209 | ||
210 | // return -1, if non of the title bars was hitted, | |
211 | // otherwise the index of the hitted tab title bar | |
212 | ||
213 | virtual int HitTest( const wxPoint& pos ); | |
214 | ||
215 | virtual void RecalcLayout( bool andRepaint = TRUE ); | |
216 | ||
217 | // event handlers | |
218 | ||
219 | void OnPaint( wxPaintEvent& event ); | |
220 | void OnSize ( wxSizeEvent& event ); | |
221 | void OnLButtonDown( wxMouseEvent& event ); | |
222 | void OnLButtonUp ( wxMouseEvent& event ); | |
223 | void OnMouseMove ( wxMouseEvent& event ); | |
224 | void OnScroll ( wxScrollEvent& event ); | |
225 | ||
226 | DECLARE_EVENT_TABLE() | |
227 | }; | |
228 | ||
229 | // helper structure of wxTabbedWindow | |
230 | ||
231 | class twTabInfo : public wxObject | |
232 | { | |
233 | DECLARE_DYNAMIC_CLASS( twTabInfo ) | |
234 | public: | |
235 | twTabInfo(); | |
236 | ~twTabInfo(); | |
237 | ||
238 | int ImgWidth(); | |
239 | int ImgHeight(); | |
240 | int ImageToTxtGap( int prefGap ); | |
241 | ||
242 | bool HasImg(); | |
243 | wxBitmap& GetImg(); | |
244 | bool HasText(); | |
245 | wxString& GetText(); | |
246 | wxWindow& GetContent(); | |
247 | ||
248 | public: | |
249 | wxWindow* mpContent; | |
250 | wxBitmap mBitMap; | |
251 | ||
252 | wxString mText; | |
253 | wxSize mDims; | |
254 | ||
255 | // used for serialization | |
256 | wxString mImageFile; | |
257 | long mImageType; | |
258 | ||
259 | }; | |
260 | ||
261 | #endif |