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