]> git.saurik.com Git - wxWidgets.git/blob - include/wx/notebook.h
Somehow, setting a tint color makes gauge work :/.
[wxWidgets.git] / include / wx / notebook.h
1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: wx/notebook.h
3 // Purpose: wxNotebook interface
4 // Author: Vadim Zeitlin
5 // Modified by:
6 // Created: 01.02.01
7 // Copyright: (c) 1996-2000 Vadim Zeitlin
8 // Licence: wxWindows licence
9 ///////////////////////////////////////////////////////////////////////////////
10
11 #ifndef _WX_NOTEBOOK_H_BASE_
12 #define _WX_NOTEBOOK_H_BASE_
13
14 // ----------------------------------------------------------------------------
15 // headers
16 // ----------------------------------------------------------------------------
17
18 #include "wx/defs.h"
19
20 #if wxUSE_NOTEBOOK
21
22 #include "wx/bookctrl.h"
23
24 // ----------------------------------------------------------------------------
25 // constants
26 // ----------------------------------------------------------------------------
27
28 // wxNotebook hit results, use wxBK_HITTEST so other book controls can share them
29 // if wxUSE_NOTEBOOK is disabled
30 enum
31 {
32 wxNB_HITTEST_NOWHERE = wxBK_HITTEST_NOWHERE,
33 wxNB_HITTEST_ONICON = wxBK_HITTEST_ONICON,
34 wxNB_HITTEST_ONLABEL = wxBK_HITTEST_ONLABEL,
35 wxNB_HITTEST_ONITEM = wxBK_HITTEST_ONITEM,
36 wxNB_HITTEST_ONPAGE = wxBK_HITTEST_ONPAGE
37 };
38
39 // wxNotebook flags
40
41 // use common book wxBK_* flags for describing alignment
42 #define wxNB_DEFAULT wxBK_DEFAULT
43 #define wxNB_TOP wxBK_TOP
44 #define wxNB_BOTTOM wxBK_BOTTOM
45 #define wxNB_LEFT wxBK_LEFT
46 #define wxNB_RIGHT wxBK_RIGHT
47
48 #define wxNB_FIXEDWIDTH 0x0100
49 #define wxNB_MULTILINE 0x0200
50 #define wxNB_NOPAGETHEME 0x0400
51 #define wxNB_FLAT 0x0800
52
53
54 typedef wxWindow wxNotebookPage; // so far, any window can be a page
55
56 extern WXDLLIMPEXP_DATA_CORE(const char) wxNotebookNameStr[];
57
58 #if wxUSE_EXTENDED_RTTI
59
60 // ----------------------------------------------------------------------------
61 // XTI accessor
62 // ----------------------------------------------------------------------------
63
64 class WXDLLEXPORT wxNotebookPageInfo : public wxObject
65 {
66 public:
67 wxNotebookPageInfo() { m_page = NULL; m_imageId = -1; m_selected = false; }
68 virtual ~wxNotebookPageInfo() { }
69
70 bool Create(wxNotebookPage *page,
71 const wxString& text,
72 bool selected,
73 int imageId)
74 {
75 m_page = page;
76 m_text = text;
77 m_selected = selected;
78 m_imageId = imageId;
79 return true;
80 }
81
82 wxNotebookPage* GetPage() const { return m_page; }
83 wxString GetText() const { return m_text; }
84 bool GetSelected() const { return m_selected; }
85 int GetImageId() const { return m_imageId; }
86
87 private:
88 wxNotebookPage *m_page;
89 wxString m_text;
90 bool m_selected;
91 int m_imageId;
92
93 DECLARE_DYNAMIC_CLASS(wxNotebookPageInfo)
94 };
95
96 WX_DECLARE_EXPORTED_LIST(wxNotebookPageInfo, wxNotebookPageInfoList );
97
98 #endif
99
100 // ----------------------------------------------------------------------------
101 // wxNotebookBase: define wxNotebook interface
102 // ----------------------------------------------------------------------------
103
104 class WXDLLIMPEXP_CORE wxNotebookBase : public wxBookCtrlBase
105 {
106 public:
107 // ctors
108 // -----
109
110 wxNotebookBase() { }
111
112 // wxNotebook-specific additions to wxBookCtrlBase interface
113 // ---------------------------------------------------------
114
115 // get the number of rows for a control with wxNB_MULTILINE style (not all
116 // versions support it - they will always return 1 then)
117 virtual int GetRowCount() const { return 1; }
118
119 // set the padding between tabs (in pixels)
120 virtual void SetPadding(const wxSize& padding) = 0;
121
122 // set the size of the tabs for wxNB_FIXEDWIDTH controls
123 virtual void SetTabSize(const wxSize& sz) = 0;
124
125
126
127 // implement some base class functions
128 virtual wxSize CalcSizeFromPage(const wxSize& sizePage) const;
129
130 // On platforms that support it, get the theme page background colour, else invalid colour
131 virtual wxColour GetThemeBackgroundColour() const { return wxNullColour; }
132
133
134 // send wxEVT_NOTEBOOK_PAGE_CHANGING/ED events
135
136 // returns false if the change to nPage is vetoed by the program
137 bool SendPageChangingEvent(int nPage);
138
139 // sends the event about page change from old to new (or GetSelection() if
140 // new is wxNOT_FOUND)
141 void SendPageChangedEvent(int nPageOld, int nPageNew = wxNOT_FOUND);
142
143 // wxBookCtrlBase overrides this method to return false but we do need
144 // focus because we have tabs
145 virtual bool AcceptsFocus() const { return wxControl::AcceptsFocus(); }
146
147 #if wxUSE_EXTENDED_RTTI
148 // XTI accessors
149 virtual void AddPageInfo( wxNotebookPageInfo* info );
150 virtual const wxNotebookPageInfoList& GetPageInfos() const;
151 #endif
152
153 protected:
154 #if wxUSE_EXTENDED_RTTI
155 wxNotebookPageInfoList m_pageInfos;
156 #endif
157 wxDECLARE_NO_COPY_CLASS(wxNotebookBase);
158 };
159
160 // ----------------------------------------------------------------------------
161 // notebook event class and related stuff
162 // ----------------------------------------------------------------------------
163
164 // wxNotebookEvent is obsolete and defined for compatibility only (notice that
165 // we use #define and not typedef to also keep compatibility with the existing
166 // code which forward declares it)
167 #define wxNotebookEvent wxBookCtrlEvent
168 typedef wxBookCtrlEventFunction wxNotebookEventFunction;
169 #define wxNotebookEventHandler(func) wxBookCtrlEventHandler(func)
170
171 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE, wxEVT_NOTEBOOK_PAGE_CHANGED, wxBookCtrlEvent );
172 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE, wxEVT_NOTEBOOK_PAGE_CHANGING, wxBookCtrlEvent );
173
174 #define EVT_NOTEBOOK_PAGE_CHANGED(winid, fn) \
175 wx__DECLARE_EVT1(wxEVT_NOTEBOOK_PAGE_CHANGED, winid, wxBookCtrlEventHandler(fn))
176
177 #define EVT_NOTEBOOK_PAGE_CHANGING(winid, fn) \
178 wx__DECLARE_EVT1(wxEVT_NOTEBOOK_PAGE_CHANGING, winid, wxBookCtrlEventHandler(fn))
179
180 // ----------------------------------------------------------------------------
181 // wxNotebook class itself
182 // ----------------------------------------------------------------------------
183
184 #if defined(__WXUNIVERSAL__)
185 #include "wx/univ/notebook.h"
186 #elif defined(__WXMSW__)
187 #include "wx/msw/notebook.h"
188 #elif defined(__WXMOTIF__)
189 #include "wx/generic/notebook.h"
190 #elif defined(__WXGTK20__)
191 #include "wx/gtk/notebook.h"
192 #elif defined(__WXGTK__)
193 #include "wx/gtk1/notebook.h"
194 #elif defined(__WXMAC__)
195 #include "wx/osx/notebook.h"
196 #elif defined(__WXCOCOA__)
197 #include "wx/cocoa/notebook.h"
198 #elif defined(__WXPM__)
199 #include "wx/os2/notebook.h"
200 #endif
201
202 // old wxEVT_COMMAND_* constants
203 #define wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED wxEVT_NOTEBOOK_PAGE_CHANGED
204 #define wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGING wxEVT_NOTEBOOK_PAGE_CHANGING
205
206 #endif // wxUSE_NOTEBOOK
207
208 #endif
209 // _WX_NOTEBOOK_H_BASE_