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 /////////////////////////////////////////////////////////////////////////////
15 // ----------------------------------------------------------------------------
17 // ----------------------------------------------------------------------------
19 #include "wx/control.h"
21 // ----------------------------------------------------------------------------
23 // ----------------------------------------------------------------------------
25 class WXDLLIMPEXP_CORE wxNotebook
: public wxNotebookBase
30 // default for dynamic class
32 // the same arguments as for wxControl (@@@ any special styles?)
33 wxNotebook(wxWindow
*parent
,
35 const wxPoint
& pos
= wxDefaultPosition
,
36 const wxSize
& size
= wxDefaultSize
,
38 const wxString
& name
= wxNotebookNameStr
);
40 bool Create(wxWindow
*parent
,
42 const wxPoint
& pos
= wxDefaultPosition
,
43 const wxSize
& size
= wxDefaultSize
,
45 const wxString
& name
= wxNotebookNameStr
);
46 virtual ~wxNotebook();
50 // get number of pages in the dialog
51 virtual size_t GetPageCount() const;
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
);
58 // changes selected page without sending events
59 int ChangeSelection(size_t nPage
);
61 // set/get the title of a page
62 bool SetPageText(size_t nPage
, const wxString
& strText
);
63 wxString
GetPageText(size_t nPage
) const;
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
);
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
);
77 // currently it's always 1 because wxGTK doesn't support multi-row
79 int GetRowCount() const;
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
);
90 bool DeleteAllPages();
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
,
98 int imageId
= NO_IMAGE
);
100 // Windows-only at present. Also, you must use the wxNB_FIXEDWIDTH
102 void SetTabSize(const wxSize
& sz
);
105 virtual int HitTest(const wxPoint
& pt
, long *flags
= NULL
) const;
107 // calculate the size of the notebook from the size of its page
108 virtual wxSize
CalcSizeFromPage(const wxSize
& sizePage
) const;
112 void OnSize(wxSizeEvent
& event
);
113 void OnNavigationKey(wxNavigationKeyEvent
& event
);
115 // base class virtuals
116 // -------------------
118 virtual bool MSWOnNotify(int idCtrl
, WXLPARAM lParam
, WXLPARAM
*result
);
119 virtual bool MSWOnScroll(int orientation
, WXWORD nSBCode
,
120 WXWORD pos
, WXHWND control
);
122 #if wxUSE_CONSTRAINTS
123 virtual void SetConstraintSizes(bool recurse
= true);
124 virtual bool DoPhase(int nPhase
);
125 #endif // wxUSE_CONSTRAINTS
127 // Attempts to get colour for UX theme page background
128 wxColour
GetThemeBackgroundColour() const;
130 // implementation only
131 // -------------------
134 virtual bool SetBackgroundColour(const wxColour
& colour
)
136 if ( !wxNotebookBase::SetBackgroundColour(colour
) )
144 // draw child background
145 virtual bool MSWPrintChild(WXHDC hDC
, wxWindow
*win
);
147 virtual bool MSWHasInheritableBackground() const { return true; }
148 #endif // wxUSE_UXTHEME
150 // translate wxWin styles to the Windows ones
151 virtual WXDWORD
MSWGetStyle(long flags
, WXDWORD
*exstyle
= NULL
) const;
154 // common part of all ctors
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
);
161 // remove one page from the notebook, without deleting
162 virtual wxNotebookPage
*DoRemovePage(size_t nPage
);
164 // get the page rectangle for the current notebook size
166 // returns empty rectangle if an error occurs, do test for it
167 wxRect
GetPageSize() const;
169 // set the size of the given page to fit in the notebook
170 void AdjustPageSize(wxNotebookPage
*page
);
173 // return the themed brush for painting our children
174 virtual WXHBRUSH
MSWGetCustomBgBrush() { return m_hbrBackground
; }
176 // gets the bitmap of notebook background and returns a brush from it
177 WXHBRUSH
QueryBgBitmap();
179 // creates the brush to be used for drawing the tab control background
180 void UpdateBgBrush();
182 // common part of QueryBgBitmap() and MSWPrintChild()
184 // if child == NULL, draw background for the entire notebook itself
185 bool DoDrawBackground(WXHDC hDC
, wxWindow
*child
= NULL
);
186 #endif // wxUSE_UXTHEME
188 // these function are only used for reducing flicker on notebook resize and
189 // we don't need to do this for WinCE
191 void OnEraseBackground(wxEraseEvent
& event
);
192 void OnPaint(wxPaintEvent
& event
);
194 // true if we have already subclassed our updown control
195 bool m_hasSubclassedUpdown
;
197 // true if we already refreshed the current page after showing the window
198 bool m_doneUpdateHack
;
199 #endif // __WXWINCE__
202 // background brush used to paint the tab control
203 WXHBRUSH m_hbrBackground
;
204 #endif // wxUSE_UXTHEME
207 DECLARE_DYNAMIC_CLASS_NO_COPY(wxNotebook
)
208 DECLARE_EVENT_TABLE()
211 #endif // wxUSE_NOTEBOOK
213 #endif // _NOTEBOOK_H