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