1 ///////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxNotebook interface
4 // Author: Vadim Zeitlin
7 // Copyright: (c) 1996-2000 Vadim Zeitlin
8 // Licence: wxWindows licence
9 ///////////////////////////////////////////////////////////////////////////////
11 #ifndef _WX_NOTEBOOK_H_BASE_
12 #define _WX_NOTEBOOK_H_BASE_
14 // ----------------------------------------------------------------------------
16 // ----------------------------------------------------------------------------
22 #include "wx/bookctrl.h"
24 // ----------------------------------------------------------------------------
26 // ----------------------------------------------------------------------------
28 // wxNotebook hit results, use wxBK_HITTEST so other book controls can share them
29 // if wxUSE_NOTEBOOK is disabled
32 wxNB_HITTEST_NOWHERE
= wxBK_HITTEST_NOWHERE
,
33 wxNB_HITTEST_ONICON
= wxBK_HITTEST_ONICON
,
34 wxNB_HITTEST_ONLABEL
= wxBK_HITTEST_ONLABEL
,
35 wxNB_HITTEST_ONITEM
= wxBK_HITTEST_ONITEM
,
36 wxNB_HITTEST_ONPAGE
= wxBK_HITTEST_ONPAGE
41 // use common book wxBK_* flags for describing alignment
42 #define wxNB_DEFAULT wxBK_DEFAULT
43 #define wxNB_TOP wxBK_TOP
44 #define wxNB_BOTTOM wxBK_BOTTOM
45 #define wxNB_LEFT wxBK_LEFT
46 #define wxNB_RIGHT wxBK_RIGHT
48 #define wxNB_FIXEDWIDTH 0x0100
49 #define wxNB_MULTILINE 0x0200
50 #define wxNB_NOPAGETHEME 0x0400
51 #define wxNB_FLAT 0x0800
54 typedef wxWindow wxNotebookPage
; // so far, any window can be a page
56 extern WXDLLIMPEXP_DATA_CORE(const char) wxNotebookNameStr
[];
58 #if wxUSE_EXTENDED_RTTI
60 // ----------------------------------------------------------------------------
62 // ----------------------------------------------------------------------------
64 class WXDLLEXPORT wxNotebookPageInfo
: public wxObject
67 wxNotebookPageInfo() { m_page
= NULL
; m_imageId
= -1; m_selected
= false; }
68 virtual ~wxNotebookPageInfo() { }
70 bool Create(wxNotebookPage
*page
,
77 m_selected
= selected
;
82 wxNotebookPage
* GetPage() const { return m_page
; }
83 wxString
GetText() const { return m_text
; }
84 bool GetSelected() const { return m_selected
; }
85 int GetImageId() const { return m_imageId
; }
88 wxNotebookPage
*m_page
;
93 DECLARE_DYNAMIC_CLASS(wxNotebookPageInfo
)
96 WX_DECLARE_EXPORTED_LIST(wxNotebookPageInfo
, wxNotebookPageInfoList
);
100 // ----------------------------------------------------------------------------
101 // wxNotebookBase: define wxNotebook interface
102 // ----------------------------------------------------------------------------
104 class WXDLLIMPEXP_CORE wxNotebookBase
: public wxBookCtrlBase
112 // wxNotebook-specific additions to wxBookCtrlBase interface
113 // ---------------------------------------------------------
115 // get the number of rows for a control with wxNB_MULTILINE style (not all
116 // versions support it - they will always return 1 then)
117 virtual int GetRowCount() const { return 1; }
119 // set the padding between tabs (in pixels)
120 virtual void SetPadding(const wxSize
& padding
) = 0;
122 // set the size of the tabs for wxNB_FIXEDWIDTH controls
123 virtual void SetTabSize(const wxSize
& sz
) = 0;
127 // implement some base class functions
128 virtual wxSize
CalcSizeFromPage(const wxSize
& sizePage
) const;
130 // On platforms that support it, get the theme page background colour, else invalid colour
131 virtual wxColour
GetThemeBackgroundColour() const { return wxNullColour
; }
134 // send wxEVT_NOTEBOOK_PAGE_CHANGING/ED events
136 // returns false if the change to nPage is vetoed by the program
137 bool SendPageChangingEvent(int nPage
);
139 // sends the event about page change from old to new (or GetSelection() if
140 // new is wxNOT_FOUND)
141 void SendPageChangedEvent(int nPageOld
, int nPageNew
= wxNOT_FOUND
);
143 // wxBookCtrlBase overrides this method to return false but we do need
144 // focus because we have tabs
145 virtual bool AcceptsFocus() const { return wxControl::AcceptsFocus(); }
147 #if wxUSE_EXTENDED_RTTI
149 virtual void AddPageInfo( wxNotebookPageInfo
* info
);
150 virtual const wxNotebookPageInfoList
& GetPageInfos() const;
154 #if wxUSE_EXTENDED_RTTI
155 wxNotebookPageInfoList m_pageInfos
;
157 wxDECLARE_NO_COPY_CLASS(wxNotebookBase
);
160 // ----------------------------------------------------------------------------
161 // notebook event class and related stuff
162 // ----------------------------------------------------------------------------
164 // wxNotebookEvent is obsolete and defined for compatibility only (notice that
165 // we use #define and not typedef to also keep compatibility with the existing
166 // code which forward declares it)
167 #define wxNotebookEvent wxBookCtrlEvent
168 typedef wxBookCtrlEventFunction wxNotebookEventFunction
;
169 #define wxNotebookEventHandler(func) wxBookCtrlEventHandler(func)
171 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE
, wxEVT_NOTEBOOK_PAGE_CHANGED
, wxBookCtrlEvent
);
172 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE
, wxEVT_NOTEBOOK_PAGE_CHANGING
, wxBookCtrlEvent
);
174 #define EVT_NOTEBOOK_PAGE_CHANGED(winid, fn) \
175 wx__DECLARE_EVT1(wxEVT_NOTEBOOK_PAGE_CHANGED, winid, wxBookCtrlEventHandler(fn))
177 #define EVT_NOTEBOOK_PAGE_CHANGING(winid, fn) \
178 wx__DECLARE_EVT1(wxEVT_NOTEBOOK_PAGE_CHANGING, winid, wxBookCtrlEventHandler(fn))
180 // ----------------------------------------------------------------------------
181 // wxNotebook class itself
182 // ----------------------------------------------------------------------------
184 #if defined(__WXUNIVERSAL__)
185 #include "wx/univ/notebook.h"
186 #elif defined(__WXMSW__)
187 #include "wx/msw/notebook.h"
188 #elif defined(__WXMOTIF__)
189 #include "wx/generic/notebook.h"
190 #elif defined(__WXGTK20__)
191 #include "wx/gtk/notebook.h"
192 #elif defined(__WXGTK__)
193 #include "wx/gtk1/notebook.h"
194 #elif defined(__WXMAC__)
195 #include "wx/osx/notebook.h"
196 #elif defined(__WXCOCOA__)
197 #include "wx/cocoa/notebook.h"
198 #elif defined(__WXPM__)
199 #include "wx/os2/notebook.h"
202 // old wxEVT_COMMAND_* constants
203 #define wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED wxEVT_NOTEBOOK_PAGE_CHANGED
204 #define wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGING wxEVT_NOTEBOOK_PAGE_CHANGING
206 #endif // wxUSE_NOTEBOOK
209 // _WX_NOTEBOOK_H_BASE_