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 wxNotebook
: public wxNotebookBase
31 // default for dynamic class
33 // the same arguments as for wxControl (@@@ any special styles?)
34 wxNotebook(wxWindow
*parent
,
36 const wxPoint
& pos
= wxDefaultPosition
,
37 const wxSize
& size
= wxDefaultSize
,
39 const wxString
& name
= wxNotebookNameStr
);
41 bool Create(wxWindow
*parent
,
43 const wxPoint
& pos
= wxDefaultPosition
,
44 const wxSize
& size
= wxDefaultSize
,
46 const wxString
& name
= wxNotebookNameStr
);
47 virtual ~wxNotebook();
51 // get number of pages in the dialog
52 virtual size_t GetPageCount() const;
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
);
59 // changes selected page without sending events
60 int ChangeSelection(size_t nPage
);
62 // set/get the title of a page
63 bool SetPageText(size_t nPage
, const wxString
& strText
);
64 wxString
GetPageText(size_t nPage
) const;
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
);
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
);
78 // currently it's always 1 because wxGTK doesn't support multi-row
80 int GetRowCount() const;
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
);
91 bool DeleteAllPages();
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
,
99 int imageId
= NO_IMAGE
);
101 // Windows-only at present. Also, you must use the wxNB_FIXEDWIDTH
103 void SetTabSize(const wxSize
& sz
);
106 virtual int HitTest(const wxPoint
& pt
, long *flags
= NULL
) const;
108 // calculate the size of the notebook from the size of its page
109 virtual wxSize
CalcSizeFromPage(const wxSize
& sizePage
) const;
113 void OnSize(wxSizeEvent
& event
);
114 void OnNavigationKey(wxNavigationKeyEvent
& event
);
116 // base class virtuals
117 // -------------------
119 virtual bool MSWOnNotify(int idCtrl
, WXLPARAM lParam
, WXLPARAM
*result
);
120 virtual bool MSWOnScroll(int orientation
, WXWORD nSBCode
,
121 WXWORD pos
, WXHWND control
);
123 #if wxUSE_CONSTRAINTS
124 virtual void SetConstraintSizes(bool recurse
= true);
125 virtual bool DoPhase(int nPhase
);
126 #endif // wxUSE_CONSTRAINTS
128 // Attempts to get colour for UX theme page background
129 wxColour
GetThemeBackgroundColour() const;
131 // implementation only
132 // -------------------
135 virtual bool SetBackgroundColour(const wxColour
& colour
)
137 if ( !wxNotebookBase::SetBackgroundColour(colour
) )
145 // draw child background
146 virtual bool MSWPrintChild(WXHDC hDC
, wxWindow
*win
);
148 virtual bool MSWHasInheritableBackground() const { return true; }
149 #endif // wxUSE_UXTHEME
151 // translate wxWin styles to the Windows ones
152 virtual WXDWORD
MSWGetStyle(long flags
, WXDWORD
*exstyle
= NULL
) const;
155 // common part of all ctors
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
);
162 // remove one page from the notebook, without deleting
163 virtual wxNotebookPage
*DoRemovePage(size_t nPage
);
165 // get the page rectangle for the current notebook size
167 // returns empty rectangle if an error occurs, do test for it
168 wxRect
GetPageSize() const;
170 // set the size of the given page to fit in the notebook
171 void AdjustPageSize(wxNotebookPage
*page
);
174 // return the themed brush for painting our children
175 virtual WXHBRUSH
MSWGetCustomBgBrush() { return m_hbrBackground
; }
177 // gets the bitmap of notebook background and returns a brush from it
178 WXHBRUSH
QueryBgBitmap();
180 // creates the brush to be used for drawing the tab control background
181 void UpdateBgBrush();
183 // common part of QueryBgBitmap() and MSWPrintChild()
185 // if child == NULL, draw background for the entire notebook itself
186 bool DoDrawBackground(WXHDC hDC
, wxWindow
*child
= NULL
);
187 #endif // wxUSE_UXTHEME
189 // these function are only used for reducing flicker on notebook resize and
190 // we don't need to do this for WinCE
192 void OnEraseBackground(wxEraseEvent
& event
);
193 void OnPaint(wxPaintEvent
& event
);
195 // true if we have already subclassed our updown control
196 bool m_hasSubclassedUpdown
;
197 #endif // __WXWINCE__
200 // background brush used to paint the tab control
201 WXHBRUSH m_hbrBackground
;
202 #endif // wxUSE_UXTHEME
205 DECLARE_DYNAMIC_CLASS_NO_COPY(wxNotebook
)
206 DECLARE_EVENT_TABLE()
209 #endif // wxUSE_NOTEBOOK
211 #endif // _NOTEBOOK_H