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