]>
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$ | |
7 | // Copyright: (c) Julian Smart and Markus Holzem | |
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 | |
ff829f3f VZ |
35 | class wxNotebookEvent : public wxCommandEvent |
36 | { | |
37 | public: | |
003a43dc | 38 | wxNotebookEvent(wxEventType commandType = wxEVT_NULL, int id = 0, |
ff829f3f VZ |
39 | int nSel = -1, int nOldSel = -1) |
40 | : wxCommandEvent(commandType, id) { m_nSel = nSel; m_nOldSel = nOldSel; } | |
53b28675 | 41 | |
ff829f3f VZ |
42 | // accessors |
43 | int GetSelection() const { return m_nSel; } | |
44 | int GetOldSelection() const { return m_nOldSel; } | |
53b28675 | 45 | |
ff829f3f VZ |
46 | private: |
47 | int m_nSel, // currently selected page | |
48 | m_nOldSel; // previously selected page | |
53b28675 | 49 | |
ff829f3f | 50 | DECLARE_DYNAMIC_CLASS(wxNotebookEvent) |
53b28675 RR |
51 | }; |
52 | ||
53 | //----------------------------------------------------------------------------- | |
ff829f3f | 54 | // wxNotebook |
53b28675 RR |
55 | //----------------------------------------------------------------------------- |
56 | ||
ff829f3f | 57 | class wxNotebook : public wxControl |
53b28675 | 58 | { |
ff829f3f VZ |
59 | public: |
60 | // ctors | |
61 | // ----- | |
62 | // default for dynamic class | |
63 | wxNotebook(); | |
64 | // the same arguments as for wxControl (@@@ any special styles?) | |
65 | wxNotebook(wxWindow *parent, | |
debe6624 | 66 | wxWindowID id, |
ff829f3f VZ |
67 | const wxPoint& pos = wxDefaultPosition, |
68 | const wxSize& size = wxDefaultSize, | |
debe6624 | 69 | long style = 0, |
ff829f3f VZ |
70 | const wxString& name = "notebook"); |
71 | // Create() function | |
72 | bool Create(wxWindow *parent, | |
debe6624 | 73 | wxWindowID id, |
ff829f3f VZ |
74 | const wxPoint& pos = wxDefaultPosition, |
75 | const wxSize& size = wxDefaultSize, | |
debe6624 | 76 | long style = 0, |
ff829f3f VZ |
77 | const wxString& name = "notebook"); |
78 | // dtor | |
79 | ~wxNotebook(); | |
80 | ||
81 | // accessors | |
82 | // --------- | |
83 | // get number of pages in the dialog | |
84 | int GetPageCount() const; | |
85 | ||
86 | // set the currently selected page, return the index of the previously | |
87 | // selected one (or -1 on error) | |
88 | // NB: this function will _not_ generate wxEVT_NOTEBOOK_PAGE_xxx events | |
89 | int SetSelection(int nPage); | |
90 | // cycle thru the tabs | |
91 | void AdvanceSelection(bool bForward = TRUE); | |
92 | // get the currently selected page | |
93 | int GetSelection() const; | |
94 | ||
95 | // set/get the title of a page | |
96 | bool SetPageText(int nPage, const wxString& strText); | |
97 | wxString GetPageText(int nPage) const; | |
98 | ||
99 | // image list stuff: each page may have an image associated with it. All | |
100 | // the images belong to an image list, so you have to | |
101 | // 1) create an image list | |
102 | // 2) associate it with the notebook | |
103 | // 3) set for each page it's image | |
104 | // associate image list with a control | |
105 | void SetImageList(wxImageList* imageList); | |
106 | // get pointer (may be NULL) to the associated image list | |
107 | wxImageList* GetImageList() const { return m_imageList; } | |
108 | ||
109 | // sets/returns item's image index in the current image list | |
110 | int GetPageImage(int nPage) const; | |
111 | bool SetPageImage(int nPage, int nImage); | |
112 | ||
113 | // currently it's always 1 because wxGTK doesn't support multi-row | |
114 | // tab controls | |
115 | int GetRowCount() const; | |
116 | ||
117 | // control the appearance of the notebook pages | |
118 | // set the size (the same for all pages) | |
119 | void SetPageSize(const wxSize& size); | |
120 | // set the padding between tabs (in pixels) | |
121 | void SetPadding(const wxSize& padding); | |
122 | ||
123 | // operations | |
124 | // ---------- | |
125 | // remove one page from the notebook | |
126 | bool DeletePage(int nPage); | |
127 | // remove all pages | |
128 | bool DeleteAllPages(); | |
129 | // adds a new page to the notebook (it will be deleted ny the notebook, | |
130 | // don't delete it yourself). If bSelect, this page becomes active. | |
131 | bool AddPage(wxWindow *pPage, | |
132 | const wxString& strText, | |
133 | bool bSelect = FALSE, | |
134 | int imageId = -1); | |
135 | // @@@@ VZ: I don't know how to implement InsertPage() | |
136 | ||
137 | // get the panel which represents the given page | |
138 | wxWindow *GetPage(int nPage) const; | |
139 | ||
6ca41e57 | 140 | |
5a8c929e | 141 | // implementation |
58614078 | 142 | |
58614078 RR |
143 | void SetConstraintSizes(bool recurse); |
144 | bool DoPhase(int phase); | |
145 | void ApplyWidgetStyle(); | |
ff829f3f | 146 | |
ff829f3f VZ |
147 | // common part of all ctors |
148 | void Init(); | |
149 | ||
150 | // helper function | |
151 | wxNotebookPage* GetNotebookPage(int page) const; | |
152 | ||
153 | wxImageList* m_imageList; | |
154 | wxList m_pages; | |
c86f1403 | 155 | size_t m_idHandler; // the change page handler id |
53b28675 | 156 | |
ff829f3f | 157 | DECLARE_DYNAMIC_CLASS(wxNotebook) |
53b28675 RR |
158 | }; |
159 | ||
ff829f3f VZ |
160 | // ---------------------------------------------------------------------------- |
161 | // event macros | |
162 | // ---------------------------------------------------------------------------- | |
163 | typedef void (wxEvtHandler::*wxNotebookEventFunction)(wxNotebookEvent&); | |
164 | ||
165 | #define EVT_NOTEBOOK_PAGE_CHANGED(id, fn) \ | |
166 | { \ | |
167 | wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED, \ | |
168 | id, \ | |
169 | -1, \ | |
170 | (wxObjectEventFunction)(wxEventFunction)(wxNotebookEventFunction) &fn, \ | |
171 | NULL \ | |
172 | }, | |
173 | ||
174 | #define EVT_NOTEBOOK_PAGE_CHANGING(id, fn) \ | |
175 | { \ | |
7ce404dd | 176 | wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGING, \ |
ff829f3f VZ |
177 | id, \ |
178 | -1, \ | |
179 | (wxObjectEventFunction)(wxEventFunction)(wxNotebookEventFunction) &fn, \ | |
180 | NULL \ | |
181 | }, | |
53b28675 RR |
182 | |
183 | #endif | |
6ca41e57 | 184 | // __GTKNOTEBOOKH__ |