]> git.saurik.com Git - wxWidgets.git/blob - include/wx/msw/notebook.h
Changed floats to doubles in wxexpr.h; added a flag in accel.h (wxACCEL_NONE for
[wxWidgets.git] / include / wx / msw / notebook.h
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 wxImageList;
31 class 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
37 // ----------------------------------------------------------------------------
38 // notebook events
39 // ----------------------------------------------------------------------------
40 class WXDLLEXPORT wxNotebookEvent : public wxCommandEvent
41 {
42 public:
43 wxNotebookEvent(wxEventType commandType = wxEVT_NULL, int id = 0,
44 int nSel = -1, int nOldSel = -1)
45 : wxCommandEvent(commandType, id) { m_nSel = nSel; m_nOldSel = nOldSel; }
46
47 // accessors
48 // the currently selected page (-1 if none)
49 int GetSelection() const { return m_nSel; }
50 void SetSelection(int nSel) { m_nSel = nSel; }
51 // the page that was selected before the change (-1 if none)
52 int GetOldSelection() const { return m_nOldSel; }
53 void SetOldSelection(int nOldSel) { m_nOldSel = nOldSel; }
54
55 private:
56 int m_nSel, // currently selected page
57 m_nOldSel; // previously selected page
58
59 DECLARE_DYNAMIC_CLASS(wxNotebookEvent)
60 };
61
62 // ----------------------------------------------------------------------------
63 // wxNotebook
64 // ----------------------------------------------------------------------------
65
66 // @@@ this class should really derive from wxTabCtrl, but the interface is not
67 // exactly the same, so I can't do it right now and instead we reimplement
68 // part of wxTabCtrl here
69 class WXDLLEXPORT wxNotebook : public wxControl
70 {
71 public:
72 // ctors
73 // -----
74 // default for dynamic class
75 wxNotebook();
76 // the same arguments as for wxControl (@@@ any special styles?)
77 wxNotebook(wxWindow *parent,
78 wxWindowID id,
79 const wxPoint& pos = wxDefaultPosition,
80 const wxSize& size = wxDefaultSize,
81 long style = 0,
82 const wxString& name = "notebook");
83 // Create() function
84 bool Create(wxWindow *parent,
85 wxWindowID id,
86 const wxPoint& pos = wxDefaultPosition,
87 const wxSize& size = wxDefaultSize,
88 long style = 0,
89 const wxString& name = "notebook");
90 // dtor
91 ~wxNotebook();
92
93 // accessors
94 // ---------
95 // get number of pages in the dialog
96 int GetPageCount() const;
97
98 // set the currently selected page, return the index of the previously
99 // selected one (or -1 on error)
100 // NB: this function will _not_ generate wxEVT_NOTEBOOK_PAGE_xxx events
101 int SetSelection(int nPage);
102 // cycle thru the tabs
103 void AdvanceSelection(bool bForward = TRUE);
104 // get the currently selected page
105 int GetSelection() const { return m_nSelection; }
106
107 // set/get the title of a page
108 bool SetPageText(int nPage, const wxString& strText);
109 wxString GetPageText(int nPage) const;
110
111 // image list stuff: each page may have an image associated with it. All
112 // the images belong to an image list, so you have to
113 // 1) create an image list
114 // 2) associate it with the notebook
115 // 3) set for each page it's image
116 // associate image list with a control
117 void SetImageList(wxImageList* imageList);
118 // get pointer (may be NULL) to the associated image list
119 wxImageList* GetImageList() const { return m_pImageList; }
120
121 // sets/returns item's image index in the current image list
122 int GetPageImage(int nPage) const;
123 bool SetPageImage(int nPage, int nImage);
124
125 // currently it's always 1 because wxGTK doesn't support multi-row
126 // tab controls
127 int GetRowCount() const;
128
129 // control the appearance of the notebook pages
130 // set the size (the same for all pages)
131 void SetPageSize(const wxSize& size);
132 // set the padding between tabs (in pixels)
133 void SetPadding(const wxSize& padding);
134
135 // operations
136 // ----------
137 // remove one page from the notebook
138 bool DeletePage(int nPage);
139 // remove all pages
140 bool DeleteAllPages();
141 // adds a new page to the notebook (it will be deleted ny the notebook,
142 // don't delete it yourself). If bSelect, this page becomes active.
143 bool AddPage(wxNotebookPage *pPage,
144 const wxString& strText,
145 bool bSelect = FALSE,
146 int imageId = -1);
147 // the same as AddPage(), but adds it at the specified position
148 bool InsertPage(int nPage,
149 wxNotebookPage *pPage,
150 const wxString& strText,
151 bool bSelect = FALSE,
152 int imageId = -1);
153 // get the panel which represents the given page
154 wxNotebookPage *GetPage(int nPage) { return m_aPages[nPage]; }
155
156 // callbacks
157 // ---------
158 void OnSize(wxSizeEvent& event);
159 void OnSelChange(wxNotebookEvent& event);
160 void OnSetFocus(wxFocusEvent& event);
161 void OnNavigationKey(wxNavigationKeyEvent& event);
162
163 // base class virtuals
164 // -------------------
165 virtual void Command(wxCommandEvent& event);
166 virtual bool MSWNotify(WXWPARAM wParam, WXLPARAM lParam);
167 virtual void SetConstraintSizes(bool recurse = TRUE);
168 virtual bool DoPhase(int nPhase);
169
170 protected:
171 // common part of all ctors
172 void Init();
173
174 // helper functions
175 void ChangePage(int nOldSel, int nSel); // change pages
176
177 wxImageList *m_pImageList; // we can have an associated image list
178 wxArrayPages m_aPages; // array of pages
179
180 int m_nSelection; // the current selection (-1 if none)
181
182 DECLARE_DYNAMIC_CLASS(wxNotebook)
183 DECLARE_EVENT_TABLE()
184 };
185
186 // ----------------------------------------------------------------------------
187 // event macros
188 // ----------------------------------------------------------------------------
189 typedef void (wxEvtHandler::*wxNotebookEventFunction)(wxNotebookEvent&);
190
191 #define EVT_NOTEBOOK_PAGE_CHANGED(id, fn) \
192 { \
193 wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED, \
194 id, \
195 -1, \
196 (wxObjectEventFunction)(wxEventFunction)(wxNotebookEventFunction) &fn, \
197 NULL \
198 },
199
200 #define EVT_NOTEBOOK_PAGE_CHANGING(id, fn) \
201 { \
202 wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGING, \ \
203 id, \
204 -1, \
205 (wxObjectEventFunction)(wxEventFunction)(wxNotebookEventFunction) &fn, \
206 NULL \
207 },
208
209 #endif // _NOTEBOOK_H