File: tabpgwin.h

package info (click to toggle)
wxwidgets2.6 2.6.3.2.1.5%2Betch1
  • links: PTS
  • area: main
  • in suites: etch
  • size: 83,228 kB
  • ctags: 130,941
  • sloc: cpp: 820,043; ansic: 113,030; python: 107,485; makefile: 42,996; sh: 10,305; lex: 194; yacc: 128; xml: 95; pascal: 74
file content (272 lines) | stat: -rw-r--r-- 7,275 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
/////////////////////////////////////////////////////////////////////////////
// Name:        tabpgwin.h
// Purpose:     Contrib. demo
// Author:      Aleksandras Gluchovas
// Modified by: 19990908 : mj
//              19990909 :
//              - rename to tabpgwin
//              - restruction of Variable declaration
//              - to prevent Warnings under MingGW32
// Modified by: 19990909 : mj
//              - mNoVertScroll true = no / false = Original Code
//                the Original Code Paints a Vertical Scroll in wxPagedWindow
//                which is not needed in this Version. Use true for this.
// Created:     07/09/98
// RCS-ID:      $Id: tabpgwin.h,v 1.10 2004/10/05 15:38:01 ABX Exp $
// Copyright:   (c) Aleksandras Gluchovas
// Licence:     wxWindows license
/////////////////////////////////////////////////////////////////////////////

#ifndef __TABPGWIN_G__
#define __TABPGWIN_G__

//#ifdef __GNUG__
//#pragma interface
//#endif

#include "wx/defs.h"
#include "wx/window.h"
#include "wx/string.h"

#define WXCONTROLAREA_VERSION      1.0

// layout types for title bars of the tabs
// (are selected up by evaluating the available free space )

class twTabInfo; // forward decl.

#define wxTITLE_IMG_AND_TEXT 0
#define wxTITLE_IMG_ONLY     1
#define wxTITLE_BORDER_ONLY  2

/*
 * class manages and decorates contained "tab"-windows.
 * Draws decorations similar to those in "Project Workplace"
 * of Microsoft Developer Studio 4.xx
 */

class wxTabbedWindow : public wxPanel
{
 DECLARE_DYNAMIC_CLASS( wxTabbedWindow )

public:

 friend class wxTabbedWindowSerializer;

 wxList mTabs;
 void HideInactiveTabs( bool andRepaint );

 // overrride,to provide different font for tab-labels

 virtual wxFont GetLabelingFont();

 // FOR NOW:: scrollbars are actually related to wxPagedWindow

 wxScrollBar* mpTabScroll;
 wxScrollBar* mpHorizScroll;
 wxScrollBar* mpVertScroll;

public:

 // public properties (invoke ReclaclLayout(true) to apply changes)

 int    mVertGap;         // default: 3
 int    mHorizGap;        // default: 5
 int    mTitleVertGap;    // default: 3
 int    mTitleHorizGap;   // default: 4
 int    mImageTextGap;    // default: 2
 int    mFirstTitleGap;   // default: 11
 int    mBorderOnlyWidth; // default: 8

 wxPen  mWhitePen;        // default: RGB(255,255,255)
 wxPen  mGrayPen;         // default: RGB(192,192,192)
 wxPen  mDarkPen;         // default: RGB(128,128,128)
 wxPen  mBlackPen;        // default: RGB(  0,  0,  0)

 size_t mActiveTab;
 int    mTitleHeight;
 int    mLayoutType;

 // notifications (can be handled by derivatives)

 virtual void OnTabAdded( twTabInfo* WXUNUSED(pInfo) ) {}

 virtual void SizeTabs(int x,int y, int width, int height, bool repant);

public:
 wxTabbedWindow();
 virtual ~wxTabbedWindow();

 // tabs can be also added when the window is
 // already displayed - "on the fly"

 virtual void AddTab( wxWindow*    pContent,           // contained window
                      wxString     tabText,            // tab label
                      wxString     imageFileName = _T(""), // if "", only text label is displayed
                      wxBitmapType imageType     = wxBITMAP_TYPE_BMP );

 // NOTE:: if this AddTab(..) overload is called, the
 //        image bitmap will not be serialized (if performed),
 //        use the above method instead, so that images could
 //        be restored using the given file names

 virtual void AddTab( wxWindow* pContent,
                      wxString  tabText,
                      wxBitmap* pImage );

 virtual void RemoveTab( int tabNo );

 /* misc accessors */

 virtual int GetTabCount();
 virtual wxWindow* GetTab( int tabNo );
 virtual wxWindow* GetActiveTab();
 virtual void SetActiveTab( int tabNo );

 void DrawShadedRect( int x, int y, int width, int height,
                                          wxPen& upperPen, wxPen& lowerPen, wxDC& dc );

 virtual void DrawDecorations( wxDC& dc );

 // return -1, if non of the title bars was hitted,
 // otherwise the index of the hitted tab title bar

 virtual int HitTest( const wxPoint& pos );

 // should be invoked to redisplay window with changed properties

 virtual void RecalcLayout( bool andRepaint = true );

 // event handlers

 void OnPaint( wxPaintEvent& event );
 void OnSize ( wxSizeEvent& event );

 void OnBkErase( wxEraseEvent& event );
 void OnLButtonDown( wxMouseEvent& event );

 DECLARE_EVENT_TABLE()
};

/*
 * class manages and decorates contained "sheets" (or pages).
 * Draws decorations similar to those in "Output window"
 * of Microsoft Developer Studio 4.xx
 */

class wxPagedWindow : public wxTabbedWindow
{
 DECLARE_DYNAMIC_CLASS( wxPagedWindow )
 // the protected: public: changes prevents Warnings in gcc
protected:
 bool         mScrollEventInProgress;
public:
 int          mTabTrianGap;
 wxBrush      mWhiteBrush;
 wxBrush      mGrayBrush;
 int          mCurentRowOfs;
 int          mAdjustableTitleRowLen; // setup by dragging mini-sash
                                      // with the mosue pointer
protected:
 // drag&drop state variables
 bool         mIsDragged;
 int          mDagOrigin;
 bool         mCursorChanged;
 wxCursor     mResizeCursor;
 wxCursor     mNormalCursor;
 int          mOriginalTitleRowLen;

public:
 int          mTitleRowStart;
 int          mResizeNailGap;
 int          mTitleRowLen;               // actual title row length
 int          mNoVertScroll;              // No Vertical Scroll  true/false

 void DrawPaperBar( twTabInfo& tab, int x, int y,
                                    wxBrush& brush, wxPen& pen, wxDC& dc );

 int GetWholeTabRowLen();

 // adjusts scorllbars to fit around tabs

 virtual void OnTabAdded( twTabInfo* pInfo );

 // sets smaller font for page-labels

 virtual wxFont GetLabelingFont();

public:


public:
 wxPagedWindow();
 ~wxPagedWindow(){};

 // NOTE:: use public methods of the base class
 //        to add "pages" to this window

 /* misc accessors */

 // below two methods should be called after
 // the tabs were added (AddTab(..)). Set up
 // these scrollbars to match the needs of the
 // tabs added into this area

 wxScrollBar& GetVerticalScrollBar();
 wxScrollBar& GetHorizontalScrollBar();

 virtual void DrawDecorations( wxDC& dc );

 // return -1, if non of the title bars was hitted,
 // otherwise the index of the hitted tab title bar

 virtual int HitTest( const wxPoint& pos );

 virtual void RecalcLayout( bool andRepaint = true );

 // event handlers

 void OnPaint( wxPaintEvent& event );
 void OnSize ( wxSizeEvent& event );
 void OnLButtonDown( wxMouseEvent& event );
 void OnLButtonUp  ( wxMouseEvent& event );
 void OnMouseMove  ( wxMouseEvent& event );
 void OnScroll     ( wxScrollEvent& event );

 DECLARE_EVENT_TABLE()
};

// helper structure of wxTabbedWindow

class twTabInfo : public wxObject
{
 DECLARE_DYNAMIC_CLASS( twTabInfo )
public:
 twTabInfo();
 ~twTabInfo(){};

 int ImgWidth();
 int ImgHeight();
 int ImageToTxtGap( int prefGap );

 bool HasImg();
 wxBitmap& GetImg();
 // bool HasText();
 unsigned int HasText();
 wxString& GetText();
 wxWindow& GetContent();

public:
 wxWindow* mpContent;
 wxBitmap  mBitMap;

 wxString  mText;
 wxSize    mDims;

 // used for serialization
 wxString  mImageFile;
 long      mImageType;

};

#endif