]> git.saurik.com Git - wxWidgets.git/blob - include/wx/msw/notebook.h
Allow creating DIBs storing pixels in non-premultiplied format in wxMSW.
[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 wxNotebookPageInfo : public wxObject
27 {
28 public :
29 wxNotebookPageInfo() { m_page = NULL; m_imageId = -1; m_selected = false; }
30 virtual ~wxNotebookPageInfo() { }
31
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; }
46 int GetImageId() const { return m_imageId; }
47
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 };
56
57
58 WX_DECLARE_EXPORTED_LIST(wxNotebookPageInfo, wxNotebookPageInfoList );
59
60 class WXDLLIMPEXP_CORE wxNotebook : public wxNotebookBase
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,
69 wxWindowID id,
70 const wxPoint& pos = wxDefaultPosition,
71 const wxSize& size = wxDefaultSize,
72 long style = 0,
73 const wxString& name = wxNotebookNameStr);
74 // Create() function
75 bool Create(wxWindow *parent,
76 wxWindowID id,
77 const wxPoint& pos = wxDefaultPosition,
78 const wxSize& size = wxDefaultSize,
79 long style = 0,
80 const wxString& name = wxNotebookNameStr);
81 virtual ~wxNotebook();
82
83 // accessors
84 // ---------
85 // get number of pages in the dialog
86 virtual size_t GetPageCount() const;
87
88 // set the currently selected page, return the index of the previously
89 // selected one (or wxNOT_FOUND on error)
90 // NB: this function will _not_ generate wxEVT_NOTEBOOK_PAGE_xxx events
91 int SetSelection(size_t nPage);
92
93 // changes selected page without sending events
94 int ChangeSelection(size_t nPage);
95
96 // set/get the title of a page
97 bool SetPageText(size_t nPage, const wxString& strText);
98 wxString GetPageText(size_t nPage) const;
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);
107
108 // sets/returns item's image index in the current image list
109 int GetPageImage(size_t nPage) const;
110 bool SetPageImage(size_t nPage, int nImage);
111
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 // ----------
124 // remove all pages
125 bool DeleteAllPages();
126
127 // inserts a new page to the notebook (it will be deleted ny the notebook,
128 // don't delete it yourself). If bSelect, this page becomes active.
129 bool InsertPage(size_t nPage,
130 wxNotebookPage *pPage,
131 const wxString& strText,
132 bool bSelect = false,
133 int imageId = -1);
134
135 void AddPageInfo( wxNotebookPageInfo* info ) { AddPage( info->GetPage() , info->GetText() , info->GetSelected() , info->GetImageId() ); }
136 const wxNotebookPageInfoList& GetPageInfos() const;
137
138 // Windows-only at present. Also, you must use the wxNB_FIXEDWIDTH
139 // style.
140 void SetTabSize(const wxSize& sz);
141
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
146 virtual wxSize CalcSizeFromPage(const wxSize& sizePage) const;
147
148 // callbacks
149 // ---------
150 void OnSize(wxSizeEvent& event);
151 void OnSelChange(wxBookCtrlEvent& event);
152 void OnNavigationKey(wxNavigationKeyEvent& event);
153
154 // base class virtuals
155 // -------------------
156
157 virtual bool MSWOnNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result);
158 virtual bool MSWOnScroll(int orientation, WXWORD nSBCode,
159 WXWORD pos, WXHWND control);
160
161 #if wxUSE_CONSTRAINTS
162 virtual void SetConstraintSizes(bool recurse = true);
163 virtual bool DoPhase(int nPhase);
164 #endif // wxUSE_CONSTRAINTS
165
166 // Attempts to get colour for UX theme page background
167 wxColour GetThemeBackgroundColour() const;
168
169 // implementation only
170 // -------------------
171
172 #if wxUSE_UXTHEME
173 virtual bool SetBackgroundColour(const wxColour& colour)
174 {
175 if ( !wxNotebookBase::SetBackgroundColour(colour) )
176 return false;
177
178 UpdateBgBrush();
179
180 return true;
181 }
182
183 // return the themed brush for painting our children
184 virtual WXHBRUSH MSWGetBgBrushForChild(WXHDC hDC, wxWindow *child);
185
186 // draw child background
187 virtual bool MSWPrintChild(WXHDC hDC, wxWindow *win);
188
189 virtual bool MSWHasInheritableBackground() const { return true; }
190 #endif // wxUSE_UXTHEME
191
192 // translate wxWin styles to the Windows ones
193 virtual WXDWORD MSWGetStyle(long flags, WXDWORD *exstyle = NULL) const;
194
195 protected:
196 // common part of all ctors
197 void Init();
198
199 // hides the currently shown page and shows the given one (if not -1) and
200 // updates m_selection accordingly
201 void UpdateSelection(int selNew);
202
203 // remove one page from the notebook, without deleting
204 virtual wxNotebookPage *DoRemovePage(size_t nPage);
205
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
211 // set the size of the given page to fit in the notebook
212 void AdjustPageSize(wxNotebookPage *page);
213
214 #if wxUSE_UXTHEME
215 // gets the bitmap of notebook background and returns a brush from it
216 WXHBRUSH QueryBgBitmap();
217
218 // creates the brush to be used for drawing the tab control background
219 void UpdateBgBrush();
220
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);
225 #endif // wxUSE_UXTHEME
226
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
237
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
244
245
246 DECLARE_DYNAMIC_CLASS_NO_COPY(wxNotebook)
247 DECLARE_EVENT_TABLE()
248 };
249
250 #endif // wxUSE_NOTEBOOK
251
252 #endif // _NOTEBOOK_H