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