]> git.saurik.com Git - wxWidgets.git/blame - demos/dbbrowse/tabpgwin.h
fixing region clipping
[wxWidgets.git] / demos / dbbrowse / tabpgwin.h
CommitLineData
b5ffecfc 1/////////////////////////////////////////////////////////////////////////////
9e4d1095 2// Name: tabpgwin.h
b5ffecfc
GT
3// Purpose: Contrib. demo
4// Author: Aleksandras Gluchovas
829c421b 5// Modified by: 19990908 : mj
b5ffecfc
GT
6// 19990909 :
7// - rename to tabpgwin
8// - restruction of Variable declaration
9// - to prevent Warnings under MingGW32
829c421b 10// Modified by: 19990909 : mj
5151c7af 11// - mNoVertScroll true = no / false = Original Code
645889ad 12// the Original Code Paints a Vertical Scroll in wxPagedWindow
5151c7af 13// which is not needed in this Version. Use true for this.
b5ffecfc
GT
14// Created: 07/09/98
15// RCS-ID: $Id$
16// Copyright: (c) Aleksandras Gluchovas
17// Licence: wxWindows license
18/////////////////////////////////////////////////////////////////////////////
19
9e4d1095
GT
20#ifndef __TABPGWIN_G__
21#define __TABPGWIN_G__
b5ffecfc 22
b5ffecfc
GT
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
32class 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
44class wxTabbedWindow : public wxPanel
45{
46 DECLARE_DYNAMIC_CLASS( wxTabbedWindow )
47
48public:
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
645889ad 59 // FOR NOW:: scrollbars are actually related to wxPagedWindow
b5ffecfc
GT
60
61 wxScrollBar* mpTabScroll;
62 wxScrollBar* mpHorizScroll;
63 wxScrollBar* mpVertScroll;
64
65public:
66
5151c7af 67 // public properties (invoke ReclaclLayout(true) to apply changes)
b5ffecfc
GT
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
74de91cc 82 size_t mActiveTab;
b5ffecfc
GT
83 int mTitleHeight;
84 int mLayoutType;
85
86 // notifications (can be handled by derivatives)
87
d1f47235 88 virtual void OnTabAdded( twTabInfo* WXUNUSED(pInfo) ) {}
b5ffecfc
GT
89
90 virtual void SizeTabs(int x,int y, int width, int height, bool repant);
91
92public:
93 wxTabbedWindow();
94 virtual ~wxTabbedWindow();
95
96 // tabs can be also added when the window is
97 // already displayed - "on the fly"
98
0147a7c1
GD
99 virtual void AddTab( wxWindow* pContent, // contained window
100 wxString tabText, // tab label
daf06bb8 101 wxString imageFileName = _T(""), // if "", only text label is displayed
0147a7c1 102 wxBitmapType imageType = wxBITMAP_TYPE_BMP );
b5ffecfc
GT
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,
254a2129 111 wxBitmap* pImage );
b5ffecfc
GT
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
5151c7af 134 virtual void RecalcLayout( bool andRepaint = true );
b5ffecfc
GT
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
645889ad 153class wxPagedWindow : public wxTabbedWindow
b5ffecfc 154{
645889ad 155 DECLARE_DYNAMIC_CLASS( wxPagedWindow )
b5ffecfc
GT
156 // the protected: public: changes prevents Warnings in gcc
157protected:
158 bool mScrollEventInProgress;
159public:
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
166protected:
167 // drag&drop state variables
168 bool mIsDragged;
169 int mDagOrigin;
170 bool mCursorChanged;
171 wxCursor mResizeCursor;
172 wxCursor mNormalCursor;
173 int mOriginalTitleRowLen;
174
175public:
176 int mTitleRowStart;
177 int mResizeNailGap;
178 int mTitleRowLen; // actual title row length
5151c7af 179 int mNoVertScroll; // No Vertical Scroll true/false
b5ffecfc
GT
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
194public:
195
196
197public:
645889ad 198 wxPagedWindow();
254a2129 199 ~wxPagedWindow(){};
b5ffecfc
GT
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
5151c7af 221 virtual void RecalcLayout( bool andRepaint = true );
b5ffecfc
GT
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
237class twTabInfo : public wxObject
238{
239 DECLARE_DYNAMIC_CLASS( twTabInfo )
240public:
241 twTabInfo();
254a2129 242 ~twTabInfo(){};
b5ffecfc
GT
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
255public:
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