]>
Commit | Line | Data |
---|---|---|
b5f2afe5 VZ |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: msw/notebook.h | |
3 | // Purpose: MSW/GTK compatible notebook (a.k.a. property sheet) | |
4 | // Author: Robert Roebling | |
5 | // Modified by: Vadim Zeitlin for Windows version | |
6 | // RCS-ID: $Id$ | |
7 | // Copyright: (c) Julian Smart and Markus Holzem | |
a3622daa | 8 | // Licence: wxWindows license |
b5f2afe5 VZ |
9 | ///////////////////////////////////////////////////////////////////////////// |
10 | ||
11 | #ifndef _NOTEBOOK_H | |
12 | #define _NOTEBOOK_H | |
13 | ||
14 | #ifdef __GNUG__ | |
15 | #pragma interface "notebook.h" | |
16 | #endif | |
17 | ||
18 | // ---------------------------------------------------------------------------- | |
19 | // headers | |
20 | // ---------------------------------------------------------------------------- | |
21 | #ifndef _DYNARRAY_H | |
22 | #include <wx/dynarray.h> | |
23 | #endif //_DYNARRAY_H | |
24 | ||
25 | // ---------------------------------------------------------------------------- | |
26 | // types | |
27 | // ---------------------------------------------------------------------------- | |
28 | ||
29 | // fwd declarations | |
fbc535ff JS |
30 | class WXDLLEXPORT wxImageList; |
31 | class WXDLLEXPORT wxWindow; | |
b5f2afe5 VZ |
32 | |
33 | // array of notebook pages | |
fbc535ff | 34 | typedef wxWindow WXDLLEXPORT wxNotebookPage; // so far, any window can be a page |
184b5d99 JS |
35 | |
36 | #undef WXDLLEXPORTLOCAL | |
37 | #define WXDLLEXPORTLOCAL WXDLLEXPORT | |
38 | ||
b5f2afe5 VZ |
39 | WX_DEFINE_ARRAY(wxNotebookPage *, wxArrayPages); |
40 | ||
184b5d99 JS |
41 | #undef WXDLLEXPORTLOCAL |
42 | #define WXDLLEXPORTLOCAL | |
43 | ||
b5f2afe5 VZ |
44 | // ---------------------------------------------------------------------------- |
45 | // notebook events | |
46 | // ---------------------------------------------------------------------------- | |
fd3f686c | 47 | class WXDLLEXPORT wxNotebookEvent : public wxNotifyEvent |
b5f2afe5 VZ |
48 | { |
49 | public: | |
35eca07c | 50 | wxNotebookEvent(wxEventType commandType = wxEVT_NULL, int id = 0, |
b5f2afe5 | 51 | int nSel = -1, int nOldSel = -1) |
fd3f686c VZ |
52 | : wxNotifyEvent(commandType, id) |
53 | { | |
54 | m_nSel = nSel; | |
55 | m_nOldSel = nOldSel; | |
56 | } | |
b5f2afe5 VZ |
57 | |
58 | // accessors | |
6d966945 | 59 | // the currently selected page (-1 if none) |
b5f2afe5 | 60 | int GetSelection() const { return m_nSel; } |
6d966945 VZ |
61 | void SetSelection(int nSel) { m_nSel = nSel; } |
62 | // the page that was selected before the change (-1 if none) | |
b5f2afe5 | 63 | int GetOldSelection() const { return m_nOldSel; } |
6d966945 | 64 | void SetOldSelection(int nOldSel) { m_nOldSel = nOldSel; } |
b5f2afe5 VZ |
65 | |
66 | private: | |
67 | int m_nSel, // currently selected page | |
68 | m_nOldSel; // previously selected page | |
69 | ||
70 | DECLARE_DYNAMIC_CLASS(wxNotebookEvent) | |
71 | }; | |
72 | ||
73 | // ---------------------------------------------------------------------------- | |
74 | // wxNotebook | |
75 | // ---------------------------------------------------------------------------- | |
76 | ||
77 | // @@@ this class should really derive from wxTabCtrl, but the interface is not | |
78 | // exactly the same, so I can't do it right now and instead we reimplement | |
79 | // part of wxTabCtrl here | |
a3622daa | 80 | class WXDLLEXPORT wxNotebook : public wxControl |
b5f2afe5 VZ |
81 | { |
82 | public: | |
83 | // ctors | |
84 | // ----- | |
85 | // default for dynamic class | |
86 | wxNotebook(); | |
87 | // the same arguments as for wxControl (@@@ any special styles?) | |
88 | wxNotebook(wxWindow *parent, | |
35eca07c | 89 | wxWindowID id, |
b5f2afe5 VZ |
90 | const wxPoint& pos = wxDefaultPosition, |
91 | const wxSize& size = wxDefaultSize, | |
debe6624 | 92 | long style = 0, |
b5f2afe5 VZ |
93 | const wxString& name = "notebook"); |
94 | // Create() function | |
95 | bool Create(wxWindow *parent, | |
35eca07c | 96 | wxWindowID id, |
b5f2afe5 VZ |
97 | const wxPoint& pos = wxDefaultPosition, |
98 | const wxSize& size = wxDefaultSize, | |
debe6624 | 99 | long style = 0, |
b5f2afe5 VZ |
100 | const wxString& name = "notebook"); |
101 | // dtor | |
102 | ~wxNotebook(); | |
103 | ||
104 | // accessors | |
105 | // --------- | |
106 | // get number of pages in the dialog | |
107 | int GetPageCount() const; | |
108 | ||
109 | // set the currently selected page, return the index of the previously | |
110 | // selected one (or -1 on error) | |
111 | // NB: this function will _not_ generate wxEVT_NOTEBOOK_PAGE_xxx events | |
112 | int SetSelection(int nPage); | |
113 | // cycle thru the tabs | |
114 | void AdvanceSelection(bool bForward = TRUE); | |
115 | // get the currently selected page | |
116 | int GetSelection() const { return m_nSelection; } | |
117 | ||
118 | // set/get the title of a page | |
119 | bool SetPageText(int nPage, const wxString& strText); | |
120 | wxString GetPageText(int nPage) const; | |
121 | ||
122 | // image list stuff: each page may have an image associated with it. All | |
123 | // the images belong to an image list, so you have to | |
124 | // 1) create an image list | |
125 | // 2) associate it with the notebook | |
126 | // 3) set for each page it's image | |
127 | // associate image list with a control | |
128 | void SetImageList(wxImageList* imageList); | |
129 | // get pointer (may be NULL) to the associated image list | |
130 | wxImageList* GetImageList() const { return m_pImageList; } | |
131 | ||
132 | // sets/returns item's image index in the current image list | |
133 | int GetPageImage(int nPage) const; | |
134 | bool SetPageImage(int nPage, int nImage); | |
135 | ||
b5f2afe5 VZ |
136 | // currently it's always 1 because wxGTK doesn't support multi-row |
137 | // tab controls | |
138 | int GetRowCount() const; | |
139 | ||
140 | // control the appearance of the notebook pages | |
141 | // set the size (the same for all pages) | |
142 | void SetPageSize(const wxSize& size); | |
143 | // set the padding between tabs (in pixels) | |
144 | void SetPadding(const wxSize& padding); | |
145 | ||
146 | // operations | |
147 | // ---------- | |
148 | // remove one page from the notebook | |
149 | bool DeletePage(int nPage); | |
621793f4 JS |
150 | // remove one page from the notebook, without deleting |
151 | bool RemovePage(int nPage); | |
b5f2afe5 VZ |
152 | // remove all pages |
153 | bool DeleteAllPages(); | |
154 | // adds a new page to the notebook (it will be deleted ny the notebook, | |
155 | // don't delete it yourself). If bSelect, this page becomes active. | |
156 | bool AddPage(wxNotebookPage *pPage, | |
157 | const wxString& strText, | |
158 | bool bSelect = FALSE, | |
8a33ea62 | 159 | int imageId = -1); |
b5f2afe5 VZ |
160 | // the same as AddPage(), but adds it at the specified position |
161 | bool InsertPage(int nPage, | |
162 | wxNotebookPage *pPage, | |
163 | const wxString& strText, | |
164 | bool bSelect = FALSE, | |
8a33ea62 | 165 | int imageId = -1); |
b5f2afe5 VZ |
166 | // get the panel which represents the given page |
167 | wxNotebookPage *GetPage(int nPage) { return m_aPages[nPage]; } | |
168 | ||
58a8ab88 JS |
169 | // Windows-only at present. Also, you must use the wxNB_FIXEDWIDTH |
170 | // style. | |
171 | void SetTabSize(const wxSize& sz); | |
172 | ||
b5f2afe5 VZ |
173 | // callbacks |
174 | // --------- | |
42e69d6b | 175 | void OnWindowCreate(wxWindowCreateEvent& event); |
b5f2afe5 | 176 | void OnSelChange(wxNotebookEvent& event); |
8a33ea62 VZ |
177 | void OnSetFocus(wxFocusEvent& event); |
178 | void OnNavigationKey(wxNavigationKeyEvent& event); | |
35eca07c | 179 | |
b5f2afe5 VZ |
180 | // base class virtuals |
181 | // ------------------- | |
a23fd0e1 | 182 | virtual bool MSWOnNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result); |
5475b960 VZ |
183 | virtual void SetConstraintSizes(bool recurse = TRUE); |
184 | virtual bool DoPhase(int nPhase); | |
b5f2afe5 VZ |
185 | |
186 | protected: | |
187 | // common part of all ctors | |
188 | void Init(); | |
189 | ||
190 | // helper functions | |
191 | void ChangePage(int nOldSel, int nSel); // change pages | |
b5f2afe5 VZ |
192 | |
193 | wxImageList *m_pImageList; // we can have an associated image list | |
194 | wxArrayPages m_aPages; // array of pages | |
195 | ||
196 | int m_nSelection; // the current selection (-1 if none) | |
197 | ||
198 | DECLARE_DYNAMIC_CLASS(wxNotebook) | |
199 | DECLARE_EVENT_TABLE() | |
200 | }; | |
201 | ||
202 | // ---------------------------------------------------------------------------- | |
203 | // event macros | |
204 | // ---------------------------------------------------------------------------- | |
205 | typedef void (wxEvtHandler::*wxNotebookEventFunction)(wxNotebookEvent&); | |
206 | ||
207 | #define EVT_NOTEBOOK_PAGE_CHANGED(id, fn) \ | |
208 | { \ | |
209 | wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED, \ | |
210 | id, \ | |
211 | -1, \ | |
212 | (wxObjectEventFunction)(wxEventFunction)(wxNotebookEventFunction) &fn, \ | |
213 | NULL \ | |
214 | }, | |
215 | ||
216 | #define EVT_NOTEBOOK_PAGE_CHANGING(id, fn) \ | |
217 | { \ | |
6184444c | 218 | wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGING, \ |
b5f2afe5 VZ |
219 | id, \ |
220 | -1, \ | |
221 | (wxObjectEventFunction)(wxEventFunction)(wxNotebookEventFunction) &fn, \ | |
222 | NULL \ | |
223 | }, | |
224 | ||
225 | #endif // _NOTEBOOK_H |