]> git.saurik.com Git - wxWidgets.git/blame - include/wx/msw/notebook.h
ItemDeleted now has (parent, item)
[wxWidgets.git] / include / wx / msw / notebook.h
CommitLineData
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
8acd402f
SC
26class WXDLLEXPORT wxNotebookPageInfo : public wxObject
27{
28public :
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
48private:
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 58WX_DECLARE_EXPORTED_LIST(wxNotebookPageInfo, wxNotebookPageInfoList );
8acd402f 59
1e6feb95 60class WXDLLEXPORT wxNotebook : public wxNotebookBase
b5f2afe5
VZ
61{
62public:
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
89 // selected one (or -1 on error)
90 // NB: this function will _not_ generate wxEVT_NOTEBOOK_PAGE_xxx events
15aad3b9 91 int SetSelection(size_t nPage);
b5f2afe5
VZ
92 // get the currently selected page
93 int GetSelection() const { return m_nSelection; }
94
1d6fcbcc
VZ
95 // changes selected page without sending events
96 int ChangeSelection(size_t nPage);
97
b5f2afe5 98 // set/get the title of a page
15aad3b9
VZ
99 bool SetPageText(size_t nPage, const wxString& strText);
100 wxString GetPageText(size_t nPage) const;
b5f2afe5
VZ
101
102 // image list stuff: each page may have an image associated with it. All
103 // the images belong to an image list, so you have to
104 // 1) create an image list
105 // 2) associate it with the notebook
106 // 3) set for each page it's image
107 // associate image list with a control
108 void SetImageList(wxImageList* imageList);
b5f2afe5
VZ
109
110 // sets/returns item's image index in the current image list
15aad3b9
VZ
111 int GetPageImage(size_t nPage) const;
112 bool SetPageImage(size_t nPage, int nImage);
b5f2afe5 113
b5f2afe5
VZ
114 // currently it's always 1 because wxGTK doesn't support multi-row
115 // tab controls
116 int GetRowCount() const;
117
118 // control the appearance of the notebook pages
119 // set the size (the same for all pages)
120 void SetPageSize(const wxSize& size);
121 // set the padding between tabs (in pixels)
122 void SetPadding(const wxSize& padding);
123
124 // operations
125 // ----------
b5f2afe5
VZ
126 // remove all pages
127 bool DeleteAllPages();
e450aa69 128
efa14cf2 129 // inserts a new page to the notebook (it will be deleted ny the notebook,
b5f2afe5 130 // don't delete it yourself). If bSelect, this page becomes active.
15aad3b9 131 bool InsertPage(size_t nPage,
b5f2afe5
VZ
132 wxNotebookPage *pPage,
133 const wxString& strText,
078cf5cb 134 bool bSelect = false,
8a33ea62 135 int imageId = -1);
b5f2afe5 136
3839f37e
VZ
137 void AddPageInfo( wxNotebookPageInfo* info ) { AddPage( info->GetPage() , info->GetText() , info->GetSelected() , info->GetImageId() ); }
138 const wxNotebookPageInfoList& GetPageInfos() const;
8acd402f 139
58a8ab88
JS
140 // Windows-only at present. Also, you must use the wxNB_FIXEDWIDTH
141 // style.
142 void SetTabSize(const wxSize& sz);
143
e450aa69
VZ
144 // hit test
145 virtual int HitTest(const wxPoint& pt, long *flags = NULL) const;
146
147 // calculate the size of the notebook from the size of its page
2ce7af35
JS
148 virtual wxSize CalcSizeFromPage(const wxSize& sizePage) const;
149
b5f2afe5
VZ
150 // callbacks
151 // ---------
9026ad85 152 void OnSize(wxSizeEvent& event);
b5f2afe5 153 void OnSelChange(wxNotebookEvent& event);
8a33ea62 154 void OnNavigationKey(wxNavigationKeyEvent& event);
35eca07c 155
b5f2afe5
VZ
156 // base class virtuals
157 // -------------------
0b481c72 158
a23fd0e1 159 virtual bool MSWOnNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result);
0df3fbd7
VZ
160 virtual bool MSWOnScroll(int orientation, WXWORD nSBCode,
161 WXWORD pos, WXHWND control);
0b481c72
VZ
162
163#if wxUSE_CONSTRAINTS
078cf5cb 164 virtual void SetConstraintSizes(bool recurse = true);
5475b960 165 virtual bool DoPhase(int nPhase);
0b481c72 166#endif // wxUSE_CONSTRAINTS
b5f2afe5 167
25057aba
JS
168 // Attempts to get colour for UX theme page background
169 wxColour GetThemeBackgroundColour() const;
caf95d2a
VZ
170
171 // implementation only
172 // -------------------
173
174#if wxUSE_UXTHEME
c4a95f6f
VZ
175 virtual bool SetBackgroundColour(const wxColour& colour)
176 {
177 if ( !wxNotebookBase::SetBackgroundColour(colour) )
178 return false;
caf95d2a 179
c4a95f6f 180 UpdateBgBrush();
9b7d2b81 181
c4a95f6f
VZ
182 return true;
183 }
6f02a879
VZ
184
185 // return the themed brush for painting our children
186 virtual WXHBRUSH MSWGetBgBrushForChild(WXHDC hDC, WXHWND hWnd);
187
188 // draw child background
189 virtual bool MSWPrintChild(WXHDC hDC, wxWindow *win);
bc8793f4
WS
190#endif // wxUSE_UXTHEME
191
192 // translate wxWin styles to the Windows ones
193 virtual WXDWORD MSWGetStyle(long flags, WXDWORD *exstyle = NULL) const;
6f02a879 194
b5f2afe5
VZ
195protected:
196 // common part of all ctors
197 void Init();
198
5482ee07
VZ
199 // hides the currently shown page and shows the given one (if not -1) and
200 // updates m_nSelection accordingly
201 void UpdateSelection(int selNew);
1d6fcbcc 202
1e6feb95 203 // remove one page from the notebook, without deleting
15aad3b9 204 virtual wxNotebookPage *DoRemovePage(size_t nPage);
1e6feb95 205
c3732409
VZ
206 // get the page rectangle for the current notebook size
207 //
208 // returns empty rectangle if an error occurs, do test for it
209 wxRect GetPageSize() const;
210
2015f2b3
VZ
211 // set the size of the given page to fit in the notebook
212 void AdjustPageSize(wxNotebookPage *page);
213
ffafd8a5 214#if wxUSE_UXTHEME
de359565
VZ
215 // gets the bitmap of notebook background and returns a brush from it
216 WXHBRUSH QueryBgBitmap();
c4a95f6f 217
caf95d2a
VZ
218 // creates the brush to be used for drawing the tab control background
219 void UpdateBgBrush();
07c19327 220
c3732409
VZ
221 // common part of QueryBgBitmap() and MSWPrintChild()
222 //
223 // if child == NULL, draw background for the entire notebook itself
224 bool DoDrawBackground(WXHDC hDC, wxWindow *child = NULL);
caf95d2a 225#endif // wxUSE_UXTHEME
2015f2b3 226
dfb47d83
VZ
227 // these function are only used for reducing flicker on notebook resize and
228 // we don't need to do this for WinCE
229#ifndef __WXWINCE__
230 void OnEraseBackground(wxEraseEvent& event);
231 void OnPaint(wxPaintEvent& event);
232
233 // true if we have already subclassed our updown control
234 bool m_hasSubclassedUpdown;
235#endif // __WXWINCE__
236
2b5f62a0
VZ
237 // the current selection (-1 if none)
238 int m_nSelection;
b5f2afe5 239
caf95d2a
VZ
240 wxNotebookPageInfoList m_pageInfos;
241
242#if wxUSE_UXTHEME
243 // background brush used to paint the tab control
244 WXHBRUSH m_hbrBackground;
245#endif // wxUSE_UXTHEME
8acd402f 246
2015f2b3 247
fc7a2a60 248 DECLARE_DYNAMIC_CLASS_NO_COPY(wxNotebook)
b5f2afe5
VZ
249 DECLARE_EVENT_TABLE()
250};
251
1e6feb95
VZ
252#endif // wxUSE_NOTEBOOK
253
b5f2afe5 254#endif // _NOTEBOOK_H