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