]>
Commit | Line | Data |
---|---|---|
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 | |
8 | // Licence: wxWindows license | |
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 | |
30 | class WXDLLEXPORT wxImageList; | |
31 | class WXDLLEXPORT wxWindow; | |
32 | ||
33 | // array of notebook pages | |
34 | typedef wxWindow WXDLLEXPORT wxNotebookPage; // so far, any window can be a page | |
35 | ||
36 | #undef WXDLLEXPORTLOCAL | |
37 | #define WXDLLEXPORTLOCAL WXDLLEXPORT | |
38 | ||
39 | WX_DEFINE_ARRAY(wxNotebookPage *, wxArrayPages); | |
40 | ||
41 | #undef WXDLLEXPORTLOCAL | |
42 | #define WXDLLEXPORTLOCAL | |
43 | ||
44 | // ---------------------------------------------------------------------------- | |
45 | // wxNotebook | |
46 | // ---------------------------------------------------------------------------- | |
47 | ||
48 | // FIXME this class should really derive from wxTabCtrl, but the interface is not | |
49 | // exactly the same, so I can't do it right now and instead we reimplement | |
50 | // part of wxTabCtrl here | |
51 | class WXDLLEXPORT wxNotebook : public wxControl | |
52 | { | |
53 | public: | |
54 | // ctors | |
55 | // ----- | |
56 | // default for dynamic class | |
57 | wxNotebook(); | |
58 | // the same arguments as for wxControl (@@@ any special styles?) | |
59 | wxNotebook(wxWindow *parent, | |
60 | wxWindowID id, | |
61 | const wxPoint& pos = wxDefaultPosition, | |
62 | const wxSize& size = wxDefaultSize, | |
63 | long style = 0, | |
64 | const wxString& name = "notebook"); | |
65 | // Create() function | |
66 | bool Create(wxWindow *parent, | |
67 | wxWindowID id, | |
68 | const wxPoint& pos = wxDefaultPosition, | |
69 | const wxSize& size = wxDefaultSize, | |
70 | long style = 0, | |
71 | const wxString& name = "notebook"); | |
72 | // dtor | |
73 | ~wxNotebook(); | |
74 | ||
75 | // accessors | |
76 | // --------- | |
77 | // get number of pages in the dialog | |
78 | int GetPageCount() const; | |
79 | ||
80 | // set the currently selected page, return the index of the previously | |
81 | // selected one (or -1 on error) | |
82 | // NB: this function will _not_ generate wxEVT_NOTEBOOK_PAGE_xxx events | |
83 | int SetSelection(int nPage); | |
84 | // cycle thru the tabs | |
85 | void AdvanceSelection(bool bForward = TRUE); | |
86 | // get the currently selected page | |
87 | int GetSelection() const { return m_nSelection; } | |
88 | ||
89 | // set/get the title of a page | |
90 | bool SetPageText(int nPage, const wxString& strText); | |
91 | wxString GetPageText(int nPage) const; | |
92 | ||
93 | // image list stuff: each page may have an image associated with it. All | |
94 | // the images belong to an image list, so you have to | |
95 | // 1) create an image list | |
96 | // 2) associate it with the notebook | |
97 | // 3) set for each page it's image | |
98 | // associate image list with a control | |
99 | void SetImageList(wxImageList* imageList); | |
100 | // get pointer (may be NULL) to the associated image list | |
101 | wxImageList* GetImageList() const { return m_pImageList; } | |
102 | ||
103 | // sets/returns item's image index in the current image list | |
104 | int GetPageImage(int nPage) const; | |
105 | bool SetPageImage(int nPage, int nImage); | |
106 | ||
107 | // currently it's always 1 because wxGTK doesn't support multi-row | |
108 | // tab controls | |
109 | int GetRowCount() const; | |
110 | ||
111 | // control the appearance of the notebook pages | |
112 | // set the size (the same for all pages) | |
113 | void SetPageSize(const wxSize& size); | |
114 | // set the padding between tabs (in pixels) | |
115 | void SetPadding(const wxSize& padding); | |
116 | ||
117 | // operations | |
118 | // ---------- | |
119 | // remove one page from the notebook | |
120 | bool DeletePage(int nPage); | |
121 | // remove one page from the notebook, without deleting | |
122 | bool RemovePage(int nPage); | |
123 | // remove all pages | |
124 | bool DeleteAllPages(); | |
125 | // adds a new page to the notebook (it will be deleted ny the notebook, | |
126 | // don't delete it yourself). If bSelect, this page becomes active. | |
127 | bool AddPage(wxNotebookPage *pPage, | |
128 | const wxString& strText, | |
129 | bool bSelect = FALSE, | |
130 | int imageId = -1); | |
131 | // the same as AddPage(), but adds it at the specified position | |
132 | bool InsertPage(int nPage, | |
133 | wxNotebookPage *pPage, | |
134 | const wxString& strText, | |
135 | bool bSelect = FALSE, | |
136 | int imageId = -1); | |
137 | // get the panel which represents the given page | |
138 | wxNotebookPage *GetPage(int nPage) { return m_aPages[nPage]; } | |
139 | ||
140 | // Windows-only at present. Also, you must use the wxNB_FIXEDWIDTH | |
141 | // style. | |
142 | void SetTabSize(const wxSize& sz); | |
143 | ||
144 | // callbacks | |
145 | // --------- | |
146 | void OnWindowCreate(wxWindowCreateEvent& event); | |
147 | void OnSelChange(wxNotebookEvent& event); | |
148 | void OnSetFocus(wxFocusEvent& event); | |
149 | void OnNavigationKey(wxNavigationKeyEvent& event); | |
150 | ||
151 | // base class virtuals | |
152 | // ------------------- | |
153 | virtual bool MSWOnNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result); | |
154 | virtual void SetConstraintSizes(bool recurse = TRUE); | |
155 | virtual bool DoPhase(int nPhase); | |
156 | ||
157 | protected: | |
158 | // common part of all ctors | |
159 | void Init(); | |
160 | ||
161 | // helper functions | |
162 | void ChangePage(int nOldSel, int nSel); // change pages | |
163 | ||
164 | wxImageList *m_pImageList; // we can have an associated image list | |
165 | wxArrayPages m_aPages; // array of pages | |
166 | ||
167 | int m_nSelection; // the current selection (-1 if none) | |
168 | ||
169 | DECLARE_DYNAMIC_CLASS(wxNotebook) | |
170 | DECLARE_EVENT_TABLE() | |
171 | }; | |
172 | ||
173 | #endif // _NOTEBOOK_H |