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