]>
Commit | Line | Data |
---|---|---|
b5f2afe5 | 1 | ///////////////////////////////////////////////////////////////////////////// |
bc8793f4 | 2 | // Name: wx/msw/notebook.h |
b5f2afe5 VZ |
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$ | |
371a5b4e | 7 | // Copyright: (c) Julian Smart |
65571936 | 8 | // Licence: wxWindows licence |
b5f2afe5 VZ |
9 | ///////////////////////////////////////////////////////////////////////////// |
10 | ||
11 | #ifndef _NOTEBOOK_H | |
12 | #define _NOTEBOOK_H | |
13 | ||
1e6feb95 VZ |
14 | #if wxUSE_NOTEBOOK |
15 | ||
b5f2afe5 VZ |
16 | // ---------------------------------------------------------------------------- |
17 | // headers | |
18 | // ---------------------------------------------------------------------------- | |
74b31181 | 19 | |
7c0ea335 | 20 | #include "wx/control.h" |
b5f2afe5 | 21 | |
b5f2afe5 VZ |
22 | // ---------------------------------------------------------------------------- |
23 | // wxNotebook | |
24 | // ---------------------------------------------------------------------------- | |
25 | ||
53a2db12 | 26 | class WXDLLIMPEXP_CORE wxNotebookPageInfo : public wxObject |
8acd402f SC |
27 | { |
28 | public : | |
3839f37e | 29 | wxNotebookPageInfo() { m_page = NULL; m_imageId = -1; m_selected = false; } |
8acd402f SC |
30 | virtual ~wxNotebookPageInfo() { } |
31 | ||
3839f37e VZ |
32 | void Create(wxNotebookPage *page, |
33 | const wxString& text, | |
34 | bool selected, | |
35 | int imageId) | |
36 | { | |
37 | m_page = page; | |
38 | m_text = text; | |
39 | m_selected = selected; | |
40 | m_imageId = imageId; | |
41 | } | |
42 | ||
43 | wxNotebookPage* GetPage() const { return m_page; } | |
44 | wxString GetText() const { return m_text; } | |
45 | bool GetSelected() const { return m_selected; } | |
8acd402f | 46 | int GetImageId() const { return m_imageId; } |
8acd402f | 47 | |
3839f37e VZ |
48 | private: |
49 | wxNotebookPage *m_page; | |
50 | wxString m_text; | |
51 | bool m_selected; | |
52 | int m_imageId; | |
53 | ||
54 | DECLARE_DYNAMIC_CLASS(wxNotebookPageInfo) | |
55 | }; | |
8acd402f SC |
56 | |
57 | ||
91c9dbdc | 58 | WX_DECLARE_EXPORTED_LIST(wxNotebookPageInfo, wxNotebookPageInfoList ); |
8acd402f | 59 | |
53a2db12 | 60 | class WXDLLIMPEXP_CORE wxNotebook : public wxNotebookBase |
b5f2afe5 VZ |
61 | { |
62 | public: | |
63 | // ctors | |
64 | // ----- | |
65 | // default for dynamic class | |
66 | wxNotebook(); | |
67 | // the same arguments as for wxControl (@@@ any special styles?) | |
68 | wxNotebook(wxWindow *parent, | |
35eca07c | 69 | wxWindowID id, |
b5f2afe5 VZ |
70 | const wxPoint& pos = wxDefaultPosition, |
71 | const wxSize& size = wxDefaultSize, | |
debe6624 | 72 | long style = 0, |
630ad6c6 | 73 | const wxString& name = wxNotebookNameStr); |
b5f2afe5 VZ |
74 | // Create() function |
75 | bool Create(wxWindow *parent, | |
35eca07c | 76 | wxWindowID id, |
b5f2afe5 VZ |
77 | const wxPoint& pos = wxDefaultPosition, |
78 | const wxSize& size = wxDefaultSize, | |
debe6624 | 79 | long style = 0, |
630ad6c6 | 80 | const wxString& name = wxNotebookNameStr); |
caf95d2a | 81 | virtual ~wxNotebook(); |
b5f2afe5 VZ |
82 | |
83 | // accessors | |
84 | // --------- | |
85 | // get number of pages in the dialog | |
8d34bf5c | 86 | virtual size_t GetPageCount() const; |
b5f2afe5 VZ |
87 | |
88 | // set the currently selected page, return the index of the previously | |
7e837615 | 89 | // selected one (or wxNOT_FOUND on error) |
b5f2afe5 | 90 | // NB: this function will _not_ generate wxEVT_NOTEBOOK_PAGE_xxx events |
15aad3b9 | 91 | int SetSelection(size_t nPage); |
b5f2afe5 | 92 | |
1d6fcbcc VZ |
93 | // changes selected page without sending events |
94 | int ChangeSelection(size_t nPage); | |
95 | ||
b5f2afe5 | 96 | // set/get the title of a page |
15aad3b9 VZ |
97 | bool SetPageText(size_t nPage, const wxString& strText); |
98 | wxString GetPageText(size_t nPage) const; | |
b5f2afe5 VZ |
99 | |
100 | // image list stuff: each page may have an image associated with it. All | |
101 | // the images belong to an image list, so you have to | |
102 | // 1) create an image list | |
103 | // 2) associate it with the notebook | |
104 | // 3) set for each page it's image | |
105 | // associate image list with a control | |
106 | void SetImageList(wxImageList* imageList); | |
b5f2afe5 VZ |
107 | |
108 | // sets/returns item's image index in the current image list | |
15aad3b9 VZ |
109 | int GetPageImage(size_t nPage) const; |
110 | bool SetPageImage(size_t nPage, int nImage); | |
b5f2afe5 | 111 | |
b5f2afe5 VZ |
112 | // currently it's always 1 because wxGTK doesn't support multi-row |
113 | // tab controls | |
114 | int GetRowCount() const; | |
115 | ||
116 | // control the appearance of the notebook pages | |
117 | // set the size (the same for all pages) | |
118 | void SetPageSize(const wxSize& size); | |
119 | // set the padding between tabs (in pixels) | |
120 | void SetPadding(const wxSize& padding); | |
121 | ||
122 | // operations | |
123 | // ---------- | |
b5f2afe5 VZ |
124 | // remove all pages |
125 | bool DeleteAllPages(); | |
e450aa69 | 126 | |
efa14cf2 | 127 | // inserts a new page to the notebook (it will be deleted ny the notebook, |
b5f2afe5 | 128 | // don't delete it yourself). If bSelect, this page becomes active. |
15aad3b9 | 129 | bool InsertPage(size_t nPage, |
b5f2afe5 VZ |
130 | wxNotebookPage *pPage, |
131 | const wxString& strText, | |
078cf5cb | 132 | bool bSelect = false, |
8a33ea62 | 133 | int imageId = -1); |
b5f2afe5 | 134 | |
3839f37e VZ |
135 | void AddPageInfo( wxNotebookPageInfo* info ) { AddPage( info->GetPage() , info->GetText() , info->GetSelected() , info->GetImageId() ); } |
136 | const wxNotebookPageInfoList& GetPageInfos() const; | |
8acd402f | 137 | |
58a8ab88 JS |
138 | // Windows-only at present. Also, you must use the wxNB_FIXEDWIDTH |
139 | // style. | |
140 | void SetTabSize(const wxSize& sz); | |
141 | ||
e450aa69 VZ |
142 | // hit test |
143 | virtual int HitTest(const wxPoint& pt, long *flags = NULL) const; | |
144 | ||
145 | // calculate the size of the notebook from the size of its page | |
2ce7af35 JS |
146 | virtual wxSize CalcSizeFromPage(const wxSize& sizePage) const; |
147 | ||
b5f2afe5 VZ |
148 | // callbacks |
149 | // --------- | |
9026ad85 | 150 | void OnSize(wxSizeEvent& event); |
8a33ea62 | 151 | void OnNavigationKey(wxNavigationKeyEvent& event); |
35eca07c | 152 | |
b5f2afe5 VZ |
153 | // base class virtuals |
154 | // ------------------- | |
0b481c72 | 155 | |
a23fd0e1 | 156 | virtual bool MSWOnNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result); |
0df3fbd7 VZ |
157 | virtual bool MSWOnScroll(int orientation, WXWORD nSBCode, |
158 | WXWORD pos, WXHWND control); | |
0b481c72 VZ |
159 | |
160 | #if wxUSE_CONSTRAINTS | |
078cf5cb | 161 | virtual void SetConstraintSizes(bool recurse = true); |
5475b960 | 162 | virtual bool DoPhase(int nPhase); |
0b481c72 | 163 | #endif // wxUSE_CONSTRAINTS |
b5f2afe5 | 164 | |
25057aba JS |
165 | // Attempts to get colour for UX theme page background |
166 | wxColour GetThemeBackgroundColour() const; | |
caf95d2a VZ |
167 | |
168 | // implementation only | |
169 | // ------------------- | |
170 | ||
171 | #if wxUSE_UXTHEME | |
c4a95f6f VZ |
172 | virtual bool SetBackgroundColour(const wxColour& colour) |
173 | { | |
174 | if ( !wxNotebookBase::SetBackgroundColour(colour) ) | |
175 | return false; | |
caf95d2a | 176 | |
c4a95f6f | 177 | UpdateBgBrush(); |
9b7d2b81 | 178 | |
c4a95f6f VZ |
179 | return true; |
180 | } | |
6f02a879 VZ |
181 | |
182 | // return the themed brush for painting our children | |
b8797d96 | 183 | virtual WXHBRUSH MSWGetBgBrushForChild(WXHDC hDC, wxWindow *child); |
6f02a879 VZ |
184 | |
185 | // draw child background | |
186 | virtual bool MSWPrintChild(WXHDC hDC, wxWindow *win); | |
d9317033 VZ |
187 | |
188 | virtual bool MSWHasInheritableBackground() const { return true; } | |
bc8793f4 WS |
189 | #endif // wxUSE_UXTHEME |
190 | ||
191 | // translate wxWin styles to the Windows ones | |
192 | virtual WXDWORD MSWGetStyle(long flags, WXDWORD *exstyle = NULL) const; | |
6f02a879 | 193 | |
b5f2afe5 VZ |
194 | protected: |
195 | // common part of all ctors | |
196 | void Init(); | |
197 | ||
5482ee07 | 198 | // hides the currently shown page and shows the given one (if not -1) and |
681be2ef | 199 | // updates m_selection accordingly |
5482ee07 | 200 | void UpdateSelection(int selNew); |
1d6fcbcc | 201 | |
1e6feb95 | 202 | // remove one page from the notebook, without deleting |
15aad3b9 | 203 | virtual wxNotebookPage *DoRemovePage(size_t nPage); |
1e6feb95 | 204 | |
c3732409 VZ |
205 | // get the page rectangle for the current notebook size |
206 | // | |
207 | // returns empty rectangle if an error occurs, do test for it | |
208 | wxRect GetPageSize() const; | |
209 | ||
2015f2b3 VZ |
210 | // set the size of the given page to fit in the notebook |
211 | void AdjustPageSize(wxNotebookPage *page); | |
212 | ||
ffafd8a5 | 213 | #if wxUSE_UXTHEME |
de359565 VZ |
214 | // gets the bitmap of notebook background and returns a brush from it |
215 | WXHBRUSH QueryBgBitmap(); | |
c4a95f6f | 216 | |
caf95d2a VZ |
217 | // creates the brush to be used for drawing the tab control background |
218 | void UpdateBgBrush(); | |
07c19327 | 219 | |
c3732409 VZ |
220 | // common part of QueryBgBitmap() and MSWPrintChild() |
221 | // | |
222 | // if child == NULL, draw background for the entire notebook itself | |
223 | bool DoDrawBackground(WXHDC hDC, wxWindow *child = NULL); | |
caf95d2a | 224 | #endif // wxUSE_UXTHEME |
2015f2b3 | 225 | |
dfb47d83 VZ |
226 | // these function are only used for reducing flicker on notebook resize and |
227 | // we don't need to do this for WinCE | |
228 | #ifndef __WXWINCE__ | |
229 | void OnEraseBackground(wxEraseEvent& event); | |
230 | void OnPaint(wxPaintEvent& event); | |
231 | ||
232 | // true if we have already subclassed our updown control | |
233 | bool m_hasSubclassedUpdown; | |
234 | #endif // __WXWINCE__ | |
235 | ||
b5f2afe5 | 236 | |
caf95d2a VZ |
237 | wxNotebookPageInfoList m_pageInfos; |
238 | ||
239 | #if wxUSE_UXTHEME | |
240 | // background brush used to paint the tab control | |
241 | WXHBRUSH m_hbrBackground; | |
242 | #endif // wxUSE_UXTHEME | |
8acd402f | 243 | |
2015f2b3 | 244 | |
fc7a2a60 | 245 | DECLARE_DYNAMIC_CLASS_NO_COPY(wxNotebook) |
b5f2afe5 VZ |
246 | DECLARE_EVENT_TABLE() |
247 | }; | |
248 | ||
1e6feb95 VZ |
249 | #endif // wxUSE_NOTEBOOK |
250 | ||
b5f2afe5 | 251 | #endif // _NOTEBOOK_H |