]> git.saurik.com Git - wxWidgets.git/blob - include/wx/msw/notebook.h
a62f72f6b0fd305d0c91143f57376bea529c0fc3
[wxWidgets.git] / include / wx / msw / notebook.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/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
8 // Licence: wxWindows licence
9 /////////////////////////////////////////////////////////////////////////////
10
11 #ifndef _NOTEBOOK_H
12 #define _NOTEBOOK_H
13
14 #if wxUSE_NOTEBOOK
15
16 // ----------------------------------------------------------------------------
17 // headers
18 // ----------------------------------------------------------------------------
19
20 #include "wx/control.h"
21
22 // ----------------------------------------------------------------------------
23 // wxNotebook
24 // ----------------------------------------------------------------------------
25
26 class WXDLLIMPEXP_CORE wxNotebook : public wxNotebookBase
27 {
28 public:
29 // ctors
30 // -----
31 // default for dynamic class
32 wxNotebook();
33 // the same arguments as for wxControl (@@@ any special styles?)
34 wxNotebook(wxWindow *parent,
35 wxWindowID id,
36 const wxPoint& pos = wxDefaultPosition,
37 const wxSize& size = wxDefaultSize,
38 long style = 0,
39 const wxString& name = wxNotebookNameStr);
40 // Create() function
41 bool Create(wxWindow *parent,
42 wxWindowID id,
43 const wxPoint& pos = wxDefaultPosition,
44 const wxSize& size = wxDefaultSize,
45 long style = 0,
46 const wxString& name = wxNotebookNameStr);
47 virtual ~wxNotebook();
48
49 // accessors
50 // ---------
51 // get number of pages in the dialog
52 virtual size_t GetPageCount() const;
53
54 // set the currently selected page, return the index of the previously
55 // selected one (or wxNOT_FOUND on error)
56 // NB: this function will _not_ generate wxEVT_NOTEBOOK_PAGE_xxx events
57 int SetSelection(size_t nPage);
58
59 // changes selected page without sending events
60 int ChangeSelection(size_t nPage);
61
62 // set/get the title of a page
63 bool SetPageText(size_t nPage, const wxString& strText);
64 wxString GetPageText(size_t nPage) const;
65
66 // image list stuff: each page may have an image associated with it. All
67 // the images belong to an image list, so you have to
68 // 1) create an image list
69 // 2) associate it with the notebook
70 // 3) set for each page it's image
71 // associate image list with a control
72 void SetImageList(wxImageList* imageList);
73
74 // sets/returns item's image index in the current image list
75 int GetPageImage(size_t nPage) const;
76 bool SetPageImage(size_t nPage, int nImage);
77
78 // currently it's always 1 because wxGTK doesn't support multi-row
79 // tab controls
80 int GetRowCount() const;
81
82 // control the appearance of the notebook pages
83 // set the size (the same for all pages)
84 void SetPageSize(const wxSize& size);
85 // set the padding between tabs (in pixels)
86 void SetPadding(const wxSize& padding);
87
88 // operations
89 // ----------
90 // remove all pages
91 bool DeleteAllPages();
92
93 // inserts a new page to the notebook (it will be deleted ny the notebook,
94 // don't delete it yourself). If bSelect, this page becomes active.
95 bool InsertPage(size_t nPage,
96 wxNotebookPage *pPage,
97 const wxString& strText,
98 bool bSelect = false,
99 int imageId = NO_IMAGE);
100
101 // Windows-only at present. Also, you must use the wxNB_FIXEDWIDTH
102 // style.
103 void SetTabSize(const wxSize& sz);
104
105 // hit test
106 virtual int HitTest(const wxPoint& pt, long *flags = NULL) const;
107
108 // calculate the size of the notebook from the size of its page
109 virtual wxSize CalcSizeFromPage(const wxSize& sizePage) const;
110
111 // callbacks
112 // ---------
113 void OnSize(wxSizeEvent& event);
114 void OnNavigationKey(wxNavigationKeyEvent& event);
115
116 // base class virtuals
117 // -------------------
118
119 virtual bool MSWOnNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result);
120 virtual bool MSWOnScroll(int orientation, WXWORD nSBCode,
121 WXWORD pos, WXHWND control);
122
123 #if wxUSE_CONSTRAINTS
124 virtual void SetConstraintSizes(bool recurse = true);
125 virtual bool DoPhase(int nPhase);
126 #endif // wxUSE_CONSTRAINTS
127
128 // Attempts to get colour for UX theme page background
129 wxColour GetThemeBackgroundColour() const;
130
131 // implementation only
132 // -------------------
133
134 #if wxUSE_UXTHEME
135 virtual bool SetBackgroundColour(const wxColour& colour)
136 {
137 if ( !wxNotebookBase::SetBackgroundColour(colour) )
138 return false;
139
140 UpdateBgBrush();
141
142 return true;
143 }
144
145 // draw child background
146 virtual bool MSWPrintChild(WXHDC hDC, wxWindow *win);
147
148 virtual bool MSWHasInheritableBackground() const { return true; }
149 #endif // wxUSE_UXTHEME
150
151 // translate wxWin styles to the Windows ones
152 virtual WXDWORD MSWGetStyle(long flags, WXDWORD *exstyle = NULL) const;
153
154 protected:
155 // common part of all ctors
156 void Init();
157
158 // hides the currently shown page and shows the given one (if not -1) and
159 // updates m_selection accordingly
160 void UpdateSelection(int selNew);
161
162 // remove one page from the notebook, without deleting
163 virtual wxNotebookPage *DoRemovePage(size_t nPage);
164
165 // get the page rectangle for the current notebook size
166 //
167 // returns empty rectangle if an error occurs, do test for it
168 wxRect GetPageSize() const;
169
170 // set the size of the given page to fit in the notebook
171 void AdjustPageSize(wxNotebookPage *page);
172
173 #if wxUSE_UXTHEME
174 // return the themed brush for painting our children
175 virtual WXHBRUSH MSWGetCustomBgBrush() { return m_hbrBackground; }
176
177 // gets the bitmap of notebook background and returns a brush from it
178 WXHBRUSH QueryBgBitmap();
179
180 // creates the brush to be used for drawing the tab control background
181 void UpdateBgBrush();
182
183 // common part of QueryBgBitmap() and MSWPrintChild()
184 //
185 // if child == NULL, draw background for the entire notebook itself
186 bool DoDrawBackground(WXHDC hDC, wxWindow *child = NULL);
187 #endif // wxUSE_UXTHEME
188
189 // these function are only used for reducing flicker on notebook resize and
190 // we don't need to do this for WinCE
191 #ifndef __WXWINCE__
192 void OnEraseBackground(wxEraseEvent& event);
193 void OnPaint(wxPaintEvent& event);
194
195 // true if we have already subclassed our updown control
196 bool m_hasSubclassedUpdown;
197
198 // true if we already refreshed the current page after showing the window
199 bool m_doneUpdateHack;
200 #endif // __WXWINCE__
201
202 #if wxUSE_UXTHEME
203 // background brush used to paint the tab control
204 WXHBRUSH m_hbrBackground;
205 #endif // wxUSE_UXTHEME
206
207
208 DECLARE_DYNAMIC_CLASS_NO_COPY(wxNotebook)
209 DECLARE_EVENT_TABLE()
210 };
211
212 #endif // wxUSE_NOTEBOOK
213
214 #endif // _NOTEBOOK_H