1 /////////////////////////////////////////////////////////////////////////////
2 // Name: 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 /////////////////////////////////////////////////////////////////////////////
14 #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
15 #pragma interface "notebook.h"
20 // ----------------------------------------------------------------------------
22 // ----------------------------------------------------------------------------
24 #include "wx/control.h"
26 // ----------------------------------------------------------------------------
28 // ----------------------------------------------------------------------------
30 class WXDLLEXPORT wxNotebookPageInfo
: public wxObject
33 wxNotebookPageInfo() { m_page
= NULL
; m_imageId
= -1; m_selected
= false; }
34 virtual ~wxNotebookPageInfo() { }
36 void Create(wxNotebookPage
*page
,
43 m_selected
= selected
;
47 wxNotebookPage
* GetPage() const { return m_page
; }
48 wxString
GetText() const { return m_text
; }
49 bool GetSelected() const { return m_selected
; }
50 int GetImageId() const { return m_imageId
; }
53 wxNotebookPage
*m_page
;
58 DECLARE_DYNAMIC_CLASS(wxNotebookPageInfo
)
62 WX_DECLARE_EXPORTED_LIST(wxNotebookPageInfo
, wxNotebookPageInfoList
);
64 class WXDLLEXPORT wxNotebook
: public wxNotebookBase
69 // default for dynamic class
71 // the same arguments as for wxControl (@@@ any special styles?)
72 wxNotebook(wxWindow
*parent
,
74 const wxPoint
& pos
= wxDefaultPosition
,
75 const wxSize
& size
= wxDefaultSize
,
77 const wxString
& name
= wxNotebookNameStr
);
79 bool Create(wxWindow
*parent
,
81 const wxPoint
& pos
= wxDefaultPosition
,
82 const wxSize
& size
= wxDefaultSize
,
84 const wxString
& name
= wxNotebookNameStr
);
85 virtual ~wxNotebook();
89 // get number of pages in the dialog
90 virtual size_t GetPageCount() const;
92 // set the currently selected page, return the index of the previously
93 // selected one (or -1 on error)
94 // NB: this function will _not_ generate wxEVT_NOTEBOOK_PAGE_xxx events
95 int SetSelection(size_t nPage
);
96 // get the currently selected page
97 int GetSelection() const { return m_nSelection
; }
99 // set/get the title of a page
100 bool SetPageText(size_t nPage
, const wxString
& strText
);
101 wxString
GetPageText(size_t nPage
) const;
103 // image list stuff: each page may have an image associated with it. All
104 // the images belong to an image list, so you have to
105 // 1) create an image list
106 // 2) associate it with the notebook
107 // 3) set for each page it's image
108 // associate image list with a control
109 void SetImageList(wxImageList
* imageList
);
111 // sets/returns item's image index in the current image list
112 int GetPageImage(size_t nPage
) const;
113 bool SetPageImage(size_t nPage
, int nImage
);
115 // currently it's always 1 because wxGTK doesn't support multi-row
117 int GetRowCount() const;
119 // control the appearance of the notebook pages
120 // set the size (the same for all pages)
121 void SetPageSize(const wxSize
& size
);
122 // set the padding between tabs (in pixels)
123 void SetPadding(const wxSize
& padding
);
128 bool DeleteAllPages();
130 // inserts a new page to the notebook (it will be deleted ny the notebook,
131 // don't delete it yourself). If bSelect, this page becomes active.
132 bool InsertPage(size_t nPage
,
133 wxNotebookPage
*pPage
,
134 const wxString
& strText
,
135 bool bSelect
= false,
138 void AddPageInfo( wxNotebookPageInfo
* info
) { AddPage( info
->GetPage() , info
->GetText() , info
->GetSelected() , info
->GetImageId() ); }
139 const wxNotebookPageInfoList
& GetPageInfos() const;
141 // Windows-only at present. Also, you must use the wxNB_FIXEDWIDTH
143 void SetTabSize(const wxSize
& sz
);
146 virtual int HitTest(const wxPoint
& pt
, long *flags
= NULL
) const;
148 // calculate the size of the notebook from the size of its page
149 virtual wxSize
CalcSizeFromPage(const wxSize
& sizePage
) const;
153 void OnSize(wxSizeEvent
& event
);
154 void OnSelChange(wxNotebookEvent
& event
);
155 void OnNavigationKey(wxNavigationKeyEvent
& event
);
157 // base class virtuals
158 // -------------------
160 virtual bool MSWOnNotify(int idCtrl
, WXLPARAM lParam
, WXLPARAM
*result
);
161 virtual bool MSWOnScroll(int orientation
, WXWORD nSBCode
,
162 WXWORD pos
, WXHWND control
);
163 virtual bool MSWTranslateMessage(WXMSG
*wxmsg
);
165 #if wxUSE_CONSTRAINTS
166 virtual void SetConstraintSizes(bool recurse
= true);
167 virtual bool DoPhase(int nPhase
);
168 #endif // wxUSE_CONSTRAINTS
170 // Attempts to get colour for UX theme page background
171 wxColour
GetThemeBackgroundColour() const;
173 // implementation only
174 // -------------------
177 virtual bool SetBackgroundColour(const wxColour
& colour
)
179 if ( !wxNotebookBase::SetBackgroundColour(colour
) )
186 #endif // wxUSE_UXTHEME
189 // common part of all ctors
192 // translate wxWin styles to the Windows ones
193 virtual WXDWORD
MSWGetStyle(long flags
, WXDWORD
*exstyle
= NULL
) const;
195 // remove one page from the notebook, without deleting
196 virtual wxNotebookPage
*DoRemovePage(size_t nPage
);
198 // get the page rectangle for the current notebook size
200 // returns empty rectangle if an error occurs, do test for it
201 wxRect
GetPageSize() const;
203 // set the size of the given page to fit in the notebook
204 void AdjustPageSize(wxNotebookPage
*page
);
207 // gets the bitmap of notebook background and returns a brush from it
208 WXHBRUSH
QueryBgBitmap();
210 // creates the brush to be used for drawing the tab control background
211 void UpdateBgBrush();
213 // return the themed brush for painting our children
214 virtual WXHBRUSH
MSWGetBgBrushForChild(WXHDC hDC
, WXHWND hWnd
);
216 // draw child background
217 virtual bool MSWPrintChild(WXHDC hDC
, wxWindow
*win
);
219 // common part of QueryBgBitmap() and MSWPrintChild()
221 // if child == NULL, draw background for the entire notebook itself
222 bool DoDrawBackground(WXHDC hDC
, wxWindow
*child
= NULL
);
223 #endif // wxUSE_UXTHEME
225 // the current selection (-1 if none)
228 wxNotebookPageInfoList m_pageInfos
;
231 // background brush used to paint the tab control
232 WXHBRUSH m_hbrBackground
;
233 #endif // wxUSE_UXTHEME
235 // No need to optimize for WinCE
237 void OnEraseBackground(wxEraseEvent
& event
);
238 void OnPaint(wxPaintEvent
& event
);
241 DECLARE_DYNAMIC_CLASS_NO_COPY(wxNotebook
)
242 DECLARE_EVENT_TABLE()
245 #endif // wxUSE_NOTEBOOK
247 #endif // _NOTEBOOK_H