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