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
7 // Copyright: (c) Julian Smart
8 // Licence: wxWindows licence
9 /////////////////////////////////////////////////////////////////////////////
16 // ----------------------------------------------------------------------------
18 // ----------------------------------------------------------------------------
20 #include "wx/control.h"
22 // ----------------------------------------------------------------------------
24 // ----------------------------------------------------------------------------
26 class WXDLLIMPEXP_CORE wxNotebookPageInfo
: public wxObject
29 wxNotebookPageInfo() { m_page
= NULL
; m_imageId
= -1; m_selected
= false; }
30 virtual ~wxNotebookPageInfo() { }
32 void Create(wxNotebookPage
*page
,
39 m_selected
= selected
;
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
; }
49 wxNotebookPage
*m_page
;
54 DECLARE_DYNAMIC_CLASS(wxNotebookPageInfo
)
58 WX_DECLARE_EXPORTED_LIST(wxNotebookPageInfo
, wxNotebookPageInfoList
);
60 class WXDLLIMPEXP_CORE wxNotebook
: public wxNotebookBase
65 // default for dynamic class
67 // the same arguments as for wxControl (@@@ any special styles?)
68 wxNotebook(wxWindow
*parent
,
70 const wxPoint
& pos
= wxDefaultPosition
,
71 const wxSize
& size
= wxDefaultSize
,
73 const wxString
& name
= wxNotebookNameStr
);
75 bool Create(wxWindow
*parent
,
77 const wxPoint
& pos
= wxDefaultPosition
,
78 const wxSize
& size
= wxDefaultSize
,
80 const wxString
& name
= wxNotebookNameStr
);
81 virtual ~wxNotebook();
85 // get number of pages in the dialog
86 virtual size_t GetPageCount() const;
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 // get the currently selected page
93 int GetSelection() const { return m_nSelection
; }
95 // changes selected page without sending events
96 int ChangeSelection(size_t nPage
);
98 // set/get the title of a page
99 bool SetPageText(size_t nPage
, const wxString
& strText
);
100 wxString
GetPageText(size_t nPage
) const;
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
);
110 // sets/returns item's image index in the current image list
111 int GetPageImage(size_t nPage
) const;
112 bool SetPageImage(size_t nPage
, int nImage
);
114 // currently it's always 1 because wxGTK doesn't support multi-row
116 int GetRowCount() const;
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
);
127 bool DeleteAllPages();
129 // inserts a new page to the notebook (it will be deleted ny the notebook,
130 // don't delete it yourself). If bSelect, this page becomes active.
131 bool InsertPage(size_t nPage
,
132 wxNotebookPage
*pPage
,
133 const wxString
& strText
,
134 bool bSelect
= false,
137 void AddPageInfo( wxNotebookPageInfo
* info
) { AddPage( info
->GetPage() , info
->GetText() , info
->GetSelected() , info
->GetImageId() ); }
138 const wxNotebookPageInfoList
& GetPageInfos() const;
140 // Windows-only at present. Also, you must use the wxNB_FIXEDWIDTH
142 void SetTabSize(const wxSize
& sz
);
145 virtual int HitTest(const wxPoint
& pt
, long *flags
= NULL
) const;
147 // calculate the size of the notebook from the size of its page
148 virtual wxSize
CalcSizeFromPage(const wxSize
& sizePage
) const;
152 void OnSize(wxSizeEvent
& event
);
153 void OnSelChange(wxBookCtrlEvent
& event
);
154 void OnNavigationKey(wxNavigationKeyEvent
& event
);
156 // base class virtuals
157 // -------------------
159 virtual bool MSWOnNotify(int idCtrl
, WXLPARAM lParam
, WXLPARAM
*result
);
160 virtual bool MSWOnScroll(int orientation
, WXWORD nSBCode
,
161 WXWORD pos
, WXHWND control
);
163 #if wxUSE_CONSTRAINTS
164 virtual void SetConstraintSizes(bool recurse
= true);
165 virtual bool DoPhase(int nPhase
);
166 #endif // wxUSE_CONSTRAINTS
168 // Attempts to get colour for UX theme page background
169 wxColour
GetThemeBackgroundColour() const;
171 // implementation only
172 // -------------------
175 virtual bool SetBackgroundColour(const wxColour
& colour
)
177 if ( !wxNotebookBase::SetBackgroundColour(colour
) )
185 // return the themed brush for painting our children
186 virtual WXHBRUSH
MSWGetBgBrushForChild(WXHDC hDC
, wxWindow
*child
);
188 // draw child background
189 virtual bool MSWPrintChild(WXHDC hDC
, wxWindow
*win
);
191 virtual bool MSWHasInheritableBackground() const { return true; }
192 #endif // wxUSE_UXTHEME
194 // translate wxWin styles to the Windows ones
195 virtual WXDWORD
MSWGetStyle(long flags
, WXDWORD
*exstyle
= NULL
) const;
198 // common part of all ctors
201 // hides the currently shown page and shows the given one (if not -1) and
202 // updates m_nSelection accordingly
203 void UpdateSelection(int selNew
);
205 // remove one page from the notebook, without deleting
206 virtual wxNotebookPage
*DoRemovePage(size_t nPage
);
208 // get the page rectangle for the current notebook size
210 // returns empty rectangle if an error occurs, do test for it
211 wxRect
GetPageSize() const;
213 // set the size of the given page to fit in the notebook
214 void AdjustPageSize(wxNotebookPage
*page
);
217 // gets the bitmap of notebook background and returns a brush from it
218 WXHBRUSH
QueryBgBitmap();
220 // creates the brush to be used for drawing the tab control background
221 void UpdateBgBrush();
223 // common part of QueryBgBitmap() and MSWPrintChild()
225 // if child == NULL, draw background for the entire notebook itself
226 bool DoDrawBackground(WXHDC hDC
, wxWindow
*child
= NULL
);
227 #endif // wxUSE_UXTHEME
229 // these function are only used for reducing flicker on notebook resize and
230 // we don't need to do this for WinCE
232 void OnEraseBackground(wxEraseEvent
& event
);
233 void OnPaint(wxPaintEvent
& event
);
235 // true if we have already subclassed our updown control
236 bool m_hasSubclassedUpdown
;
237 #endif // __WXWINCE__
239 // the current selection (-1 if none)
242 wxNotebookPageInfoList m_pageInfos
;
245 // background brush used to paint the tab control
246 WXHBRUSH m_hbrBackground
;
247 #endif // wxUSE_UXTHEME
250 DECLARE_DYNAMIC_CLASS_NO_COPY(wxNotebook
)
251 DECLARE_EVENT_TABLE()
254 #endif // wxUSE_NOTEBOOK
256 #endif // _NOTEBOOK_H