]> git.saurik.com Git - wxWidgets.git/blame - include/wx/generic/tabg.h
added wxSYS_ICONTITLE_FONT (patch 816026)
[wxWidgets.git] / include / wx / generic / tabg.h
CommitLineData
c801d85f
KB
1/////////////////////////////////////////////////////////////////////////////
2// Name: tabg.h
3// Purpose: Generic tabbed dialogs
4// Author: Julian Smart
5// Modified by:
6// Created: 01/02/97
7// RCS-ID: $Id$
8// Copyright: (c)
a6f6393c 9// Licence: wxWindows licence
c801d85f
KB
10/////////////////////////////////////////////////////////////////////////////
11
12#ifndef __TABGH_G__
13#define __TABGH_G__
14
12028905 15#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
c801d85f
KB
16#pragma interface "tabg.h"
17#endif
18
19#define WXTAB_VERSION 1.1
20
4410d619 21#include "wx/hashmap.h"
c801d85f 22#include "wx/string.h"
4b5f3fe6 23#include "wx/dialog.h"
798a4529 24#include "wx/panel.h"
4410d619 25#include "wx/list.h"
c801d85f 26
4b5f3fe6 27class WXDLLEXPORT wxTabView;
c801d85f
KB
28
29/*
30 * A wxTabControl is the internal and visual representation
31 * of the tab.
32 */
a6f6393c 33
4b5f3fe6 34class WXDLLEXPORT wxTabControl: public wxObject
c801d85f
KB
35{
36DECLARE_DYNAMIC_CLASS(wxTabControl)
37public:
c67daf87 38 wxTabControl(wxTabView *v = (wxTabView *) NULL);
c801d85f 39 ~wxTabControl(void);
a6f6393c 40
c801d85f 41 virtual void OnDraw(wxDC& dc, bool lastInRow);
bfc6fde4
VZ
42 void SetLabel(const wxString& str) { m_controlLabel = str; }
43 wxString GetLabel(void) const { return m_controlLabel; }
c801d85f 44
bfc6fde4
VZ
45 void SetFont(const wxFont& f) { m_labelFont = f; }
46 wxFont *GetFont(void) const { return (wxFont*) & m_labelFont; }
c801d85f 47
bfc6fde4
VZ
48 void SetSelected(bool sel) { m_isSelected = sel; }
49 bool IsSelected(void) const { return m_isSelected; }
c801d85f 50
bfc6fde4
VZ
51 void SetPosition(int x, int y) { m_offsetX = x; m_offsetY = y; }
52 void SetSize(int x, int y) { m_width = x; m_height = y; }
a6f6393c 53
bfc6fde4
VZ
54 void SetRowPosition(int r) { m_rowPosition = r; }
55 int GetRowPosition() const { return m_rowPosition; }
56 void SetColPosition(int c) { m_colPosition = c; }
57 int GetColPosition() const { return m_colPosition; }
a6f6393c 58
bfc6fde4
VZ
59 int GetX(void) const { return m_offsetX; }
60 int GetY(void) const { return m_offsetY; }
61 int GetWidth(void) const { return m_width; }
62 int GetHeight(void) const { return m_height; }
a6f6393c 63
bfc6fde4
VZ
64 int GetId(void) const { return m_id; }
65 void SetId(int i) { m_id = i; }
a6f6393c 66
c801d85f
KB
67 virtual bool HitTest(int x, int y) const ;
68
69protected:
70 wxTabView* m_view;
71 wxString m_controlLabel;
72 bool m_isSelected;
02800301 73 wxFont m_labelFont;
c801d85f
KB
74 int m_offsetX; // Offsets from top-left of tab view area (the area below the tabs)
75 int m_offsetY;
76 int m_width;
77 int m_height;
78 int m_id;
79 int m_rowPosition; // Position in row from 0
80 int m_colPosition; // Position in col from 0
81};
a6f6393c 82
c801d85f
KB
83/*
84 * Each wxTabLayer is a list of tabs. E.g. there
85 * are 3 layers in the MS Word Options dialog.
86 */
a6f6393c 87
4b5f3fe6 88class WXDLLEXPORT wxTabLayer: public wxList
c801d85f 89{
c801d85f
KB
90};
91
92/*
93 * The wxTabView controls and draws the tabbed object
94 */
95
4410d619
MB
96WX_DECLARE_LIST(wxTabLayer, wxTabLayerList);
97
c801d85f
KB
98#define wxTAB_STYLE_DRAW_BOX 1 // Draws 3D boxes round tab layers
99#define wxTAB_STYLE_COLOUR_INTERIOR 2 // Colours interior of tabs, otherwise draws outline
100
4b5f3fe6 101class WXDLLEXPORT wxTabView: public wxObject
c801d85f
KB
102{
103DECLARE_DYNAMIC_CLASS(wxTabView)
104public:
105 wxTabView(long style = wxTAB_STYLE_DRAW_BOX | wxTAB_STYLE_COLOUR_INTERIOR);
106 ~wxTabView();
107
0ec6fd04 108 inline int GetNumberOfLayers() const { return m_layers.GetCount(); }
4410d619 109 inline wxList& GetLayers() { return (wxList&)m_layers; }
c801d85f
KB
110
111 inline void SetWindow(wxWindow* wnd) { m_window = wnd; }
112 inline wxWindow* GetWindow(void) const { return m_window; }
113
114 // Automatically positions tabs
c67daf87 115 wxTabControl *AddTab(int id, const wxString& label, wxTabControl *existingTab = (wxTabControl *) NULL);
621793f4
JS
116
117 // Remove the tab without deleting the window
118 bool RemoveTab(int id);
c801d85f
KB
119
120 void ClearTabs(bool deleteTabs = TRUE);
121
7fe7d506
JS
122 bool SetTabText(int id, const wxString& label);
123 wxString GetTabText(int id) const;
124
c801d85f 125 // Layout tabs (optional, e.g. if resizing window)
f03fc89f 126 void LayoutTabs();
c801d85f
KB
127
128 // Draw all tabs
129 virtual void Draw(wxDC& dc);
130
131 // Process mouse event, return FALSE if we didn't process it
132 virtual bool OnEvent(wxMouseEvent& event);
133
134 // Called when a tab is activated
135 virtual void OnTabActivate(int activateId, int deactivateId);
136 // Allows vetoing
137 virtual bool OnTabPreActivate(int WXUNUSED(activateId), int WXUNUSED(deactivateId) ) { return TRUE; };
138
139 // Allows use of application-supplied wxTabControl classes.
140 virtual wxTabControl *OnCreateTabControl(void) { return new wxTabControl(this); }
141
142 void SetHighlightColour(const wxColour& col);
143 void SetShadowColour(const wxColour& col);
144 void SetBackgroundColour(const wxColour& col);
145 inline void SetTextColour(const wxColour& col) { m_textColour = col; }
146
147 inline wxColour GetHighlightColour(void) const { return m_highlightColour; }
148 inline wxColour GetShadowColour(void) const { return m_shadowColour; }
149 inline wxColour GetBackgroundColour(void) const { return m_backgroundColour; }
150 inline wxColour GetTextColour(void) const { return m_textColour; }
151 inline wxPen *GetHighlightPen(void) const { return m_highlightPen; }
152 inline wxPen *GetShadowPen(void) const { return m_shadowPen; }
153 inline wxPen *GetBackgroundPen(void) const { return m_backgroundPen; }
154 inline wxBrush *GetBackgroundBrush(void) const { return m_backgroundBrush; }
155
16e93305 156 inline void SetViewRect(const wxRect& rect) { m_tabViewRect = rect; }
c801d85f
KB
157 inline wxRect GetViewRect(void) const { return m_tabViewRect; }
158
159 // Calculate tab width to fit to view, and optionally adjust the view
160 // to fit the tabs exactly.
161 int CalculateTabWidth(int noTabs, bool adjustView = FALSE);
162
163 inline void SetTabStyle(long style) { m_tabStyle = style; }
164 inline long GetTabStyle(void) const { return m_tabStyle; }
165
166 inline void SetTabSize(int w, int h) { m_tabWidth = w; m_tabHeight = h; }
167 inline int GetTabWidth(void) const { return m_tabWidth; }
168 inline int GetTabHeight(void) const { return m_tabHeight; }
169 inline void SetTabSelectionHeight(int h) { m_tabSelectionHeight = h; }
170 inline int GetTabSelectionHeight(void) const { return m_tabSelectionHeight; }
4b5f3fe6
JS
171
172 // Returns the total height of the tabs component -- this may be several
173 // times the height of a tab, if there are several tab layers (rows).
174 int GetTotalTabHeight();
c801d85f
KB
175
176 inline int GetTopMargin(void) const { return m_topMargin; }
177 inline void SetTopMargin(int margin) { m_topMargin = margin; }
178
179 void SetTabSelection(int sel, bool activateTool = TRUE);
180 inline int GetTabSelection() const { return m_tabSelection; }
181
182 // Find tab control for id
183 wxTabControl *FindTabControlForId(int id) const ;
184
185 // Find tab control for layer, position (starting from zero)
186 wxTabControl *FindTabControlForPosition(int layer, int position) const ;
187
188 inline int GetHorizontalTabOffset() const { return m_tabHorizontalOffset; }
189 inline int GetHorizontalTabSpacing() const { return m_tabHorizontalSpacing; }
190 inline void SetHorizontalTabOffset(int sp) { m_tabHorizontalOffset = sp; }
191 inline void SetHorizontalTabSpacing(int sp) { m_tabHorizontalSpacing = sp; }
192
193 inline void SetVerticalTabTextSpacing(int s) { m_tabVerticalTextSpacing = s; }
194 inline int GetVerticalTabTextSpacing() const { return m_tabVerticalTextSpacing; }
195
02800301
JS
196 inline wxFont *GetTabFont() const { return (wxFont*) & m_tabFont; }
197 inline void SetTabFont(const wxFont& f) { m_tabFont = f; }
c801d85f 198
02800301
JS
199 inline wxFont *GetSelectedTabFont() const { return (wxFont*) & m_tabSelectedFont; }
200 inline void SetSelectedTabFont(const wxFont& f) { m_tabSelectedFont = f; }
c801d85f 201 // Find the node and the column at which this control is positioned.
4410d619 202 wxList::compatibility_iterator FindTabNodeAndColumn(wxTabControl *control, int *col) const ;
c801d85f
KB
203
204 // Do the necessary to change to this tab
205 virtual bool ChangeTab(wxTabControl *control);
206
207 // Move the selected tab to the bottom layer, if necessary,
208 // without calling app activation code
209 bool MoveSelectionTab(wxTabControl *control);
210
211 inline int GetNumberOfTabs() const { return m_noTabs; }
212
213protected:
214 // List of layers, from front to back.
4410d619 215 wxTabLayerList m_layers;
c801d85f
KB
216
217 // Selected tab
218 int m_tabSelection;
219
220 // Usual tab height
221 int m_tabHeight;
222
223 // The height of the selected tab
224 int m_tabSelectionHeight;
225
226 // Usual tab width
227 int m_tabWidth;
228
229 // Space between tabs
230 int m_tabHorizontalSpacing;
231
232 // Space between top of normal tab and text
233 int m_tabVerticalTextSpacing;
234
235 // Horizontal offset of each tab row above the first
236 int m_tabHorizontalOffset;
237
238 // The distance between the bottom of the first tab row
239 // and the top of the client area (i.e. the margin)
240 int m_topMargin;
241
242 // The position and size of the view above which the tabs are placed.
243 // I.e., the internal client area of the sheet.
244 wxRect m_tabViewRect;
245
246 // Bitlist of styles
247 long m_tabStyle;
248
249 // Colours
250 wxColour m_highlightColour;
251 wxColour m_shadowColour;
252 wxColour m_backgroundColour;
253 wxColour m_textColour;
254
255 // Pen and brush cache
256 wxPen* m_highlightPen;
257 wxPen* m_shadowPen;
258 wxPen* m_backgroundPen;
259 wxBrush* m_backgroundBrush;
260
02800301
JS
261 wxFont m_tabFont;
262 wxFont m_tabSelectedFont;
c801d85f
KB
263
264 int m_noTabs;
265
266 wxWindow* m_window;
267};
268
269/*
270 * A dialog box class that is tab-friendly
271 */
272
4b5f3fe6 273class WXDLLEXPORT wxTabbedDialog: public wxDialog
c801d85f
KB
274{
275DECLARE_DYNAMIC_CLASS(wxTabbedDialog)
276
277public:
278
debe6624 279 wxTabbedDialog(wxWindow *parent, wxWindowID id, const wxString& title,
c801d85f
KB
280 const wxPoint& pos = wxDefaultPosition,
281 const wxSize& size = wxDefaultSize,
debe6624 282 long windowStyle = wxDEFAULT_DIALOG_STYLE, const wxString& name = wxDialogNameStr);
c801d85f
KB
283 ~wxTabbedDialog(void);
284
285 inline wxTabView *GetTabView() const { return m_tabView; }
286 inline void SetTabView(wxTabView *v) { m_tabView = v; }
287
288 void OnCloseWindow(wxCloseEvent& event);
289 void OnMouseEvent(wxMouseEvent& event);
290 void OnPaint(wxPaintEvent& event);
291
292protected:
293 wxTabView* m_tabView;
294
295DECLARE_EVENT_TABLE()
296};
297
298/*
299 * A panel class that is tab-friendly
300 */
301
4b5f3fe6 302class WXDLLEXPORT wxTabbedPanel: public wxPanel
c801d85f
KB
303{
304DECLARE_DYNAMIC_CLASS(wxTabbedPanel)
305
306public:
307
debe6624 308 wxTabbedPanel(wxWindow *parent, wxWindowID id,
c801d85f
KB
309 const wxPoint& pos = wxDefaultPosition,
310 const wxSize& size = wxDefaultSize,
debe6624 311 long windowStyle = 0, const wxString& name = wxPanelNameStr);
c801d85f
KB
312 ~wxTabbedPanel(void);
313
314 inline wxTabView *GetTabView() const { return m_tabView; }
315 inline void SetTabView(wxTabView *v) { m_tabView = v; }
316
317 void OnMouseEvent(wxMouseEvent& event);
318 void OnPaint(wxPaintEvent& event);
319
320protected:
321 wxTabView* m_tabView;
322
323DECLARE_EVENT_TABLE()
324};
325
4410d619
MB
326WX_DECLARE_HASH_MAP(int, wxWindow*, wxIntegerHash, wxIntegerEqual,
327 wxIntToWindowHashMap);
328
4b5f3fe6 329class WXDLLEXPORT wxPanelTabView: public wxTabView
c801d85f
KB
330{
331DECLARE_DYNAMIC_CLASS(wxPanelTabView)
332public:
333 wxPanelTabView(wxPanel *pan, long style = wxTAB_STYLE_DRAW_BOX | wxTAB_STYLE_COLOUR_INTERIOR);
334 ~wxPanelTabView(void);
335
336 // Called when a tab is activated
337 virtual void OnTabActivate(int activateId, int deactivateId);
338
339 // Specific to this class
340 void AddTabWindow(int id, wxWindow *window);
341 wxWindow *GetTabWindow(int id) const ;
342 void ClearWindows(bool deleteWindows = TRUE);
343 inline wxWindow *GetCurrentWindow() const { return m_currentWindow; }
344
345 void ShowWindowForTab(int id);
4410d619 346 // inline wxList& GetWindows() const { return (wxList&) m_tabWindows; }
c801d85f
KB
347
348protected:
349 // List of panels, one for each tab. Indexed
350 // by tab ID.
4410d619
MB
351 wxIntToWindowHashMap m_tabWindows;
352 wxWindow* m_currentWindow;
353 wxPanel* m_panel;
c801d85f
KB
354};
355
356#endif
357