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