]> git.saurik.com Git - wxWidgets.git/blame - include/wx/notebook.h
Added DialogBlocks file for configtool
[wxWidgets.git] / include / wx / notebook.h
CommitLineData
1e6feb95
VZ
1///////////////////////////////////////////////////////////////////////////////
2// Name: wx/notebook.h
3// Purpose: wxNotebook interface
4// Author: Vadim Zeitlin
5// Modified by:
6// Created: 01.02.01
7// RCS-ID: $Id$
8// Copyright: (c) 1996-2000 wxWindows team
9// Licence: wxWindows licence
10///////////////////////////////////////////////////////////////////////////////
11
34138703
JS
12#ifndef _WX_NOTEBOOK_H_BASE_
13#define _WX_NOTEBOOK_H_BASE_
53b28675 14
af49c4b8 15#if defined(__GNUG__) && !defined(__APPLE__)
07b8d7ec
VZ
16 #pragma interface "notebookbase.h"
17#endif
18
4d0f3cd6
VZ
19// ----------------------------------------------------------------------------
20// headers
21// ----------------------------------------------------------------------------
22
1e6feb95
VZ
23#include "wx/defs.h"
24
25#if wxUSE_NOTEBOOK
26
27#include "wx/control.h"
28#include "wx/dynarray.h"
3cd94a0d 29#include "wx/imaglist.h"
1e6feb95
VZ
30
31// ----------------------------------------------------------------------------
32// types
33// ----------------------------------------------------------------------------
34
35// array of notebook pages
36typedef wxWindow wxNotebookPage; // so far, any window can be a page
37
38WX_DEFINE_EXPORTED_ARRAY(wxNotebookPage *, wxArrayPages);
39
40#define wxNOTEBOOK_NAME _T("notebook")
41
42// ----------------------------------------------------------------------------
43// wxNotebookBase: define wxNotebook interface
44// ----------------------------------------------------------------------------
45
46class WXDLLEXPORT wxNotebookBase : public wxControl
47{
48public:
49 // ctor
50 wxNotebookBase()
51 {
07b8d7ec 52 Init();
1e6feb95
VZ
53 }
54
55 // quasi ctor
56 bool Create(wxWindow *parent,
57 wxWindowID id,
58 const wxPoint& pos = wxDefaultPosition,
59 const wxSize& size = wxDefaultSize,
60 long style = 0,
61 const wxString& name = wxNOTEBOOK_NAME);
62
07b8d7ec
VZ
63 // dtor
64 virtual ~wxNotebookBase();
65
1e6feb95
VZ
66 // accessors
67 // ---------
68
69 // get number of pages in the dialog
083f7497 70 int GetPageCount() const { return (int) m_pages.GetCount(); }
1e6feb95
VZ
71
72 // get the panel which represents the given page
73 wxNotebookPage *GetPage(int nPage) { return m_pages[nPage]; }
74
75 // get the currently selected page
76 virtual int GetSelection() const = 0;
77
78 // set/get the title of a page
79 virtual bool SetPageText(int nPage, const wxString& strText) = 0;
80 virtual wxString GetPageText(int nPage) const = 0;
81
82 // image list stuff: each page may have an image associated with it (all
83 // images belong to the same image list)
07b8d7ec
VZ
84 virtual void SetImageList(wxImageList* imageList);
85
86 // as SetImageList() but we will delete the image list ourselves
87 void AssignImageList(wxImageList* imageList);
1e6feb95
VZ
88
89 // get pointer (may be NULL) to the associated image list
90 wxImageList* GetImageList() const { return m_imageList; }
91
92 // sets/returns item's image index in the current image list
93 virtual int GetPageImage(int nPage) const = 0;
94 virtual bool SetPageImage(int nPage, int nImage) = 0;
95
96 // get the number of rows for a control with wxNB_MULTILINE style (not all
97 // versions support it - they will always return 1 then)
98 virtual int GetRowCount() const { return 1; }
99
100 // set the size (the same for all pages)
101 virtual void SetPageSize(const wxSize& size) = 0;
102
103 // set the padding between tabs (in pixels)
104 virtual void SetPadding(const wxSize& padding) = 0;
105
106 // set the size of the tabs for wxNB_FIXEDWIDTH controls
107 virtual void SetTabSize(const wxSize& sz) = 0;
108
109 // calculate the size of the notebook from the size of its page
2ce7af35 110 virtual wxSize CalcSizeFromPage(const wxSize& sizePage) const;
1e6feb95
VZ
111
112 // operations
113 // ----------
114
115 // remove one page from the notebook and delete it
07b8d7ec 116 virtual bool DeletePage(int nPage);
1e6feb95
VZ
117
118 // remove one page from the notebook, without deleting it
119 virtual bool RemovePage(int nPage) { return DoRemovePage(nPage) != NULL; }
120
121 // remove all pages and delete them
122 virtual bool DeleteAllPages() { WX_CLEAR_ARRAY(m_pages); return TRUE; }
123
124 // adds a new page to the notebook (it will be deleted by the notebook,
125 // don't delete it yourself) and make it the current one if bSelect
126 virtual bool AddPage(wxNotebookPage *pPage,
127 const wxString& strText,
128 bool bSelect = FALSE,
129 int imageId = -1)
130 {
131 return InsertPage(GetPageCount(), pPage, strText, bSelect, imageId);
132 }
133
134 // the same as AddPage(), but adds the page at the specified position
135 virtual bool InsertPage(int nPage,
136 wxNotebookPage *pPage,
137 const wxString& strText,
138 bool bSelect = FALSE,
139 int imageId = -1) = 0;
140
141 // set the currently selected page, return the index of the previously
142 // selected one (or -1 on error)
143 //
144 // NB: this function will _not_ generate wxEVT_NOTEBOOK_PAGE_xxx events
145 virtual int SetSelection(int nPage) = 0;
146
147 // cycle thru the tabs
148 void AdvanceSelection(bool forward = TRUE)
149 {
150 int nPage = GetNextPage(forward);
151 if ( nPage != -1 )
152 SetSelection(nPage);
153 }
154
155protected:
156 // remove the page and return a pointer to it
10199e27 157 virtual wxNotebookPage *DoRemovePage(int page);
2ce7af35
JS
158 // return the minimum size large enough to display the largest page entirely
159 virtual wxSize DoGetBestSize() const;
1e6feb95 160
07b8d7ec
VZ
161 // common part of all ctors
162 void Init();
1e6feb95 163
07b8d7ec
VZ
164 // get the next page wrapping if we reached the end
165 int GetNextPage(bool forward) const;
1e6feb95 166
07b8d7ec
VZ
167 wxArrayPages m_pages; // array of pages
168 wxImageList *m_imageList; // we can have an associated image list
169 bool m_ownsImageList; // true if we must delete m_imageList
22f3361e
VZ
170
171 DECLARE_NO_COPY_CLASS(wxNotebookBase)
1e6feb95 172};
4d0f3cd6
VZ
173
174// ----------------------------------------------------------------------------
175// notebook event class (used by NOTEBOOK_PAGE_CHANGED/ING events)
176// ----------------------------------------------------------------------------
177
178class WXDLLEXPORT wxNotebookEvent : public wxNotifyEvent
179{
180public:
181 wxNotebookEvent(wxEventType commandType = wxEVT_NULL, int id = 0,
182 int nSel = -1, int nOldSel = -1)
183 : wxNotifyEvent(commandType, id)
184 {
185 m_nSel = nSel;
186 m_nOldSel = nOldSel;
187 }
188
189 // accessors
190 // the currently selected page (-1 if none)
191 int GetSelection() const { return m_nSel; }
192 void SetSelection(int nSel) { m_nSel = nSel; }
193 // the page that was selected before the change (-1 if none)
194 int GetOldSelection() const { return m_nOldSel; }
195 void SetOldSelection(int nOldSel) { m_nOldSel = nOldSel; }
196
197private:
198 int m_nSel, // currently selected page
199 m_nOldSel; // previously selected page
200
201 DECLARE_DYNAMIC_CLASS(wxNotebookEvent)
202};
203
204// ----------------------------------------------------------------------------
2e4df4bf 205// event types and macros for them
4d0f3cd6
VZ
206// ----------------------------------------------------------------------------
207
2e4df4bf
VZ
208#if defined(__BORLANDC__) && defined(__WIN16__)
209 // For 16-bit BC++, these 2 would be identical otherwise (truncated)
210 #define wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED wxEVT_COMMAND_NB_PAGE_CHANGED
211 #define wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGING wxEVT_COMMAND_NB_PAGE_CHANGING
212#endif
213
214BEGIN_DECLARE_EVENT_TYPES()
215 DECLARE_EVENT_TYPE(wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED, 802)
216 DECLARE_EVENT_TYPE(wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGING, 803)
217END_DECLARE_EVENT_TYPES()
218
4d0f3cd6
VZ
219typedef void (wxEvtHandler::*wxNotebookEventFunction)(wxNotebookEvent&);
220
25889d3c
JS
221// Truncation in 16-bit BC++ means we need to define these differently
222#if defined(__BORLANDC__) && defined(__WIN16__)
223#define EVT_NOTEBOOK_PAGE_CHANGED(id, fn) \
2e4df4bf 224 DECLARE_EVENT_TABLE_ENTRY( \
82a5f02c 225 wxEVT_COMMAND_NB_PAGE_CHANGED, \
25889d3c
JS
226 id, \
227 -1, \
228 (wxObjectEventFunction)(wxEventFunction)(wxNotebookEventFunction) &fn, \
229 NULL \
82a5f02c 230 ),
25889d3c
JS
231
232#define EVT_NOTEBOOK_PAGE_CHANGING(id, fn) \
2e4df4bf 233 DECLARE_EVENT_TABLE_ENTRY( \
82a5f02c 234 wxEVT_COMMAND_NB_PAGE_CHANGING, \
25889d3c
JS
235 id, \
236 -1, \
237 (wxObjectEventFunction)(wxEventFunction)(wxNotebookEventFunction) &fn, \
238 NULL \
82a5f02c 239 ),
25889d3c
JS
240
241#else
242
4d0f3cd6 243#define EVT_NOTEBOOK_PAGE_CHANGED(id, fn) \
2e4df4bf 244 DECLARE_EVENT_TABLE_ENTRY( \
4d0f3cd6
VZ
245 wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED, \
246 id, \
247 -1, \
248 (wxObjectEventFunction)(wxEventFunction)(wxNotebookEventFunction) &fn, \
249 NULL \
82a5f02c 250 ),
4d0f3cd6
VZ
251
252#define EVT_NOTEBOOK_PAGE_CHANGING(id, fn) \
2e4df4bf 253 DECLARE_EVENT_TABLE_ENTRY( \
4d0f3cd6
VZ
254 wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGING, \
255 id, \
256 -1, \
257 (wxObjectEventFunction)(wxEventFunction)(wxNotebookEventFunction) &fn, \
258 NULL \
82a5f02c 259 ),
4d0f3cd6 260
25889d3c
JS
261#endif
262
4d0f3cd6
VZ
263// ----------------------------------------------------------------------------
264// wxNotebook class itself
265// ----------------------------------------------------------------------------
266
1e6feb95
VZ
267#if defined(__WXUNIVERSAL__)
268 #include "wx/univ/notebook.h"
269#elif defined(__WXMSW__)
270 #ifdef __WIN16__
271 #include "wx/generic/notebook.h"
272 #else
273 #include "wx/msw/notebook.h"
274 #endif
2049ba38 275#elif defined(__WXMOTIF__)
1e6feb95 276 #include "wx/generic/notebook.h"
2049ba38 277#elif defined(__WXGTK__)
1e6feb95 278 #include "wx/gtk/notebook.h"
34138703 279#elif defined(__WXMAC__)
1e6feb95 280 #include "wx/mac/notebook.h"
0201182b
DE
281#elif defined(__WXCOCOA__)
282 #include "wx/generic/notebook.h"
1777b9bb 283#elif defined(__WXPM__)
1e6feb95 284 #include "wx/os2/notebook.h"
53b28675
RR
285#endif
286
1e6feb95
VZ
287#endif // wxUSE_NOTEBOOK
288
53b28675 289#endif
34138703 290 // _WX_NOTEBOOK_H_BASE_