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