]>
Commit | Line | Data |
---|---|---|
53b28675 | 1 | ///////////////////////////////////////////////////////////////////////////// |
716b7364 RR |
2 | // Name: notebook.h |
3 | // Purpose: wxNotebook class | |
53b28675 RR |
4 | // Author: Robert Roebling |
5 | // Modified by: | |
6 | // RCS-ID: $Id$ | |
b2b3ccc5 | 7 | // Copyright: (c) Julian Smart and Robert Roebling |
ff829f3f | 8 | // Licence: wxWindows license |
53b28675 RR |
9 | ///////////////////////////////////////////////////////////////////////////// |
10 | ||
6ca41e57 RR |
11 | #ifndef __GTKNOTEBOOKH__ |
12 | #define __GTKNOTEBOOKH__ | |
53b28675 RR |
13 | |
14 | #ifdef __GNUG__ | |
6ca41e57 | 15 | #pragma interface |
53b28675 RR |
16 | #endif |
17 | ||
18 | #include "wx/defs.h" | |
19 | #include "wx/object.h" | |
20 | #include "wx/string.h" | |
21 | #include "wx/control.h" | |
22 | ||
23 | //----------------------------------------------------------------------------- | |
24 | // classes | |
25 | //----------------------------------------------------------------------------- | |
26 | ||
27 | class wxImageList; | |
53b28675 | 28 | class wxNotebook; |
8aadf227 | 29 | class wxNotebookPage; |
53b28675 | 30 | |
ff829f3f VZ |
31 | // ---------------------------------------------------------------------------- |
32 | // notebook events | |
33 | // ---------------------------------------------------------------------------- | |
219f895a | 34 | |
92976ab6 | 35 | class wxNotebookEvent : public wxNotifyEvent |
ff829f3f VZ |
36 | { |
37 | public: | |
003a43dc | 38 | wxNotebookEvent(wxEventType commandType = wxEVT_NULL, int id = 0, |
ff829f3f | 39 | int nSel = -1, int nOldSel = -1) |
92976ab6 | 40 | : wxNotifyEvent(commandType, id) |
fd3f686c VZ |
41 | { |
42 | m_bAllow = TRUE; | |
43 | m_nSel = nSel; | |
44 | m_nOldSel = nOldSel; | |
45 | } | |
53b28675 | 46 | |
ff829f3f VZ |
47 | // accessors |
48 | int GetSelection() const { return m_nSel; } | |
49 | int GetOldSelection() const { return m_nOldSel; } | |
53b28675 | 50 | |
fd3f686c VZ |
51 | // for wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGING event this method may be called |
52 | // to disallow the page change | |
53 | void Veto() { m_bAllow = FALSE; } | |
54 | ||
55 | // implementation: for wxNotebook usage only | |
56 | bool Allowed() const { return m_bAllow; } | |
57 | ||
ff829f3f | 58 | private: |
fd3f686c VZ |
59 | bool m_bAllow; |
60 | ||
ff829f3f VZ |
61 | int m_nSel, // currently selected page |
62 | m_nOldSel; // previously selected page | |
53b28675 | 63 | |
ff829f3f | 64 | DECLARE_DYNAMIC_CLASS(wxNotebookEvent) |
53b28675 RR |
65 | }; |
66 | ||
67 | //----------------------------------------------------------------------------- | |
ff829f3f | 68 | // wxNotebook |
53b28675 RR |
69 | //----------------------------------------------------------------------------- |
70 | ||
ff829f3f | 71 | class wxNotebook : public wxControl |
53b28675 | 72 | { |
ff829f3f VZ |
73 | public: |
74 | // ctors | |
75 | // ----- | |
76 | // default for dynamic class | |
77 | wxNotebook(); | |
78 | // the same arguments as for wxControl (@@@ any special styles?) | |
79 | wxNotebook(wxWindow *parent, | |
debe6624 | 80 | wxWindowID id, |
ff829f3f VZ |
81 | const wxPoint& pos = wxDefaultPosition, |
82 | const wxSize& size = wxDefaultSize, | |
debe6624 | 83 | long style = 0, |
ff829f3f VZ |
84 | const wxString& name = "notebook"); |
85 | // Create() function | |
86 | bool Create(wxWindow *parent, | |
debe6624 | 87 | wxWindowID id, |
ff829f3f VZ |
88 | const wxPoint& pos = wxDefaultPosition, |
89 | const wxSize& size = wxDefaultSize, | |
debe6624 | 90 | long style = 0, |
ff829f3f VZ |
91 | const wxString& name = "notebook"); |
92 | // dtor | |
93 | ~wxNotebook(); | |
94 | ||
95 | // accessors | |
96 | // --------- | |
97 | // get number of pages in the dialog | |
98 | int GetPageCount() const; | |
99 | ||
100 | // set the currently selected page, return the index of the previously | |
101 | // selected one (or -1 on error) | |
102 | // NB: this function will _not_ generate wxEVT_NOTEBOOK_PAGE_xxx events | |
103 | int SetSelection(int nPage); | |
104 | // cycle thru the tabs | |
105 | void AdvanceSelection(bool bForward = TRUE); | |
106 | // get the currently selected page | |
107 | int GetSelection() const; | |
108 | ||
109 | // set/get the title of a page | |
110 | bool SetPageText(int nPage, const wxString& strText); | |
111 | wxString GetPageText(int nPage) const; | |
112 | ||
113 | // image list stuff: each page may have an image associated with it. All | |
114 | // the images belong to an image list, so you have to | |
115 | // 1) create an image list | |
116 | // 2) associate it with the notebook | |
117 | // 3) set for each page it's image | |
118 | // associate image list with a control | |
119 | void SetImageList(wxImageList* imageList); | |
120 | // get pointer (may be NULL) to the associated image list | |
121 | wxImageList* GetImageList() const { return m_imageList; } | |
122 | ||
123 | // sets/returns item's image index in the current image list | |
124 | int GetPageImage(int nPage) const; | |
125 | bool SetPageImage(int nPage, int nImage); | |
126 | ||
127 | // currently it's always 1 because wxGTK doesn't support multi-row | |
128 | // tab controls | |
129 | int GetRowCount() const; | |
130 | ||
131 | // control the appearance of the notebook pages | |
132 | // set the size (the same for all pages) | |
133 | void SetPageSize(const wxSize& size); | |
134 | // set the padding between tabs (in pixels) | |
135 | void SetPadding(const wxSize& padding); | |
136 | ||
137 | // operations | |
138 | // ---------- | |
fed46e72 RR |
139 | // remove one page from the notebook but do not destroy it |
140 | bool RemovePage(int nPage); | |
ff829f3f VZ |
141 | // remove one page from the notebook |
142 | bool DeletePage(int nPage); | |
143 | // remove all pages | |
144 | bool DeleteAllPages(); | |
145 | // adds a new page to the notebook (it will be deleted ny the notebook, | |
146 | // don't delete it yourself). If bSelect, this page becomes active. | |
147 | bool AddPage(wxWindow *pPage, | |
148 | const wxString& strText, | |
149 | bool bSelect = FALSE, | |
150 | int imageId = -1); | |
151 | // @@@@ VZ: I don't know how to implement InsertPage() | |
152 | ||
153 | // get the panel which represents the given page | |
154 | wxWindow *GetPage(int nPage) const; | |
155 | ||
6ca41e57 | 156 | |
5a8c929e | 157 | // implementation |
58614078 | 158 | |
58614078 RR |
159 | void SetConstraintSizes(bool recurse); |
160 | bool DoPhase(int phase); | |
161 | void ApplyWidgetStyle(); | |
ff829f3f | 162 | |
ff829f3f VZ |
163 | // common part of all ctors |
164 | void Init(); | |
165 | ||
166 | // helper function | |
167 | wxNotebookPage* GetNotebookPage(int page) const; | |
168 | ||
169 | wxImageList* m_imageList; | |
170 | wxList m_pages; | |
c86f1403 | 171 | size_t m_idHandler; // the change page handler id |
53b28675 | 172 | |
ff829f3f | 173 | DECLARE_DYNAMIC_CLASS(wxNotebook) |
53b28675 RR |
174 | }; |
175 | ||
ff829f3f VZ |
176 | // ---------------------------------------------------------------------------- |
177 | // event macros | |
178 | // ---------------------------------------------------------------------------- | |
179 | typedef void (wxEvtHandler::*wxNotebookEventFunction)(wxNotebookEvent&); | |
180 | ||
181 | #define EVT_NOTEBOOK_PAGE_CHANGED(id, fn) \ | |
182 | { \ | |
183 | wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED, \ | |
184 | id, \ | |
185 | -1, \ | |
186 | (wxObjectEventFunction)(wxEventFunction)(wxNotebookEventFunction) &fn, \ | |
187 | NULL \ | |
188 | }, | |
189 | ||
190 | #define EVT_NOTEBOOK_PAGE_CHANGING(id, fn) \ | |
191 | { \ | |
7ce404dd | 192 | wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGING, \ |
ff829f3f VZ |
193 | id, \ |
194 | -1, \ | |
195 | (wxObjectEventFunction)(wxEventFunction)(wxNotebookEventFunction) &fn, \ | |
196 | NULL \ | |
197 | }, | |
53b28675 RR |
198 | |
199 | #endif | |
6ca41e57 | 200 | // __GTKNOTEBOOKH__ |