1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: src/palmos/notebook.cpp
3 // Purpose: implementation of wxNotebook
4 // Author: William Osborne - minimal working wxPalmOS port
8 // Copyright: (c) William Osborne
9 // Licence: wxWindows licence
10 ///////////////////////////////////////////////////////////////////////////////
12 // For compilers that support precompilation, includes "wx.h".
13 #include "wx/wxprec.h"
23 #include "wx/string.h"
26 // ----------------------------------------------------------------------------
28 // ----------------------------------------------------------------------------
30 // check that the page index is valid
31 #define IS_VALID_PAGE(nPage) ((nPage) < GetPageCount())
33 // ----------------------------------------------------------------------------
35 // ----------------------------------------------------------------------------
37 #include "wx/listimpl.cpp"
39 WX_DEFINE_LIST( wxNotebookPageInfoList
)
41 DEFINE_EVENT_TYPE(wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED
)
42 DEFINE_EVENT_TYPE(wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGING
)
44 BEGIN_EVENT_TABLE(wxNotebook
, wxControl
)
45 EVT_NOTEBOOK_PAGE_CHANGED(wxID_ANY
, wxNotebook::OnSelChange
)
47 EVT_SIZE(wxNotebook::OnSize
)
49 EVT_NAVIGATION_KEY(wxNotebook::OnNavigationKey
)
52 #if wxUSE_EXTENDED_RTTI
53 WX_DEFINE_FLAGS( wxNotebookStyle
)
55 wxBEGIN_FLAGS( wxNotebookStyle
)
56 // new style border flags, we put them first to
57 // use them for streaming out
58 wxFLAGS_MEMBER(wxBORDER_SIMPLE
)
59 wxFLAGS_MEMBER(wxBORDER_SUNKEN
)
60 wxFLAGS_MEMBER(wxBORDER_DOUBLE
)
61 wxFLAGS_MEMBER(wxBORDER_RAISED
)
62 wxFLAGS_MEMBER(wxBORDER_STATIC
)
63 wxFLAGS_MEMBER(wxBORDER_NONE
)
65 // old style border flags
66 wxFLAGS_MEMBER(wxSIMPLE_BORDER
)
67 wxFLAGS_MEMBER(wxSUNKEN_BORDER
)
68 wxFLAGS_MEMBER(wxDOUBLE_BORDER
)
69 wxFLAGS_MEMBER(wxRAISED_BORDER
)
70 wxFLAGS_MEMBER(wxSTATIC_BORDER
)
71 wxFLAGS_MEMBER(wxBORDER
)
73 // standard window styles
74 wxFLAGS_MEMBER(wxTAB_TRAVERSAL
)
75 wxFLAGS_MEMBER(wxCLIP_CHILDREN
)
76 wxFLAGS_MEMBER(wxTRANSPARENT_WINDOW
)
77 wxFLAGS_MEMBER(wxWANTS_CHARS
)
78 wxFLAGS_MEMBER(wxFULL_REPAINT_ON_RESIZE
)
79 wxFLAGS_MEMBER(wxALWAYS_SHOW_SB
)
80 wxFLAGS_MEMBER(wxVSCROLL
)
81 wxFLAGS_MEMBER(wxHSCROLL
)
83 wxFLAGS_MEMBER(wxNB_FIXEDWIDTH
)
84 wxFLAGS_MEMBER(wxBK_LEFT
)
85 wxFLAGS_MEMBER(wxBK_RIGHT
)
86 wxFLAGS_MEMBER(wxBK_BOTTOM
)
88 wxEND_FLAGS( wxNotebookStyle
)
90 IMPLEMENT_DYNAMIC_CLASS_XTI(wxNotebook
, wxControl
,"wx/notebook.h")
91 IMPLEMENT_DYNAMIC_CLASS_XTI(wxNotebookPageInfo
, wxObject
, "wx/notebook.h" )
93 wxCOLLECTION_TYPE_INFO( wxNotebookPageInfo
* , wxNotebookPageInfoList
) ;
95 template<> void wxCollectionToVariantArray( wxNotebookPageInfoList
const &theList
, wxxVariantArray
&value
)
97 wxListCollectionToVariantArray
<wxNotebookPageInfoList::compatibility_iterator
>( theList
, value
) ;
100 wxBEGIN_PROPERTIES_TABLE(wxNotebook
)
101 wxEVENT_PROPERTY( PageChanging
, wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGING
, wxNotebookEvent
)
102 wxEVENT_PROPERTY( PageChanged
, wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED
, wxNotebookEvent
)
104 wxPROPERTY_COLLECTION( PageInfos
, wxNotebookPageInfoList
, wxNotebookPageInfo
* , AddPageInfo
, GetPageInfos
, 0 /*flags*/ , wxT("Helpstring") , wxT("group"))
105 wxPROPERTY_FLAGS( WindowStyle
, wxNotebookStyle
, long , SetWindowStyleFlag
, GetWindowStyleFlag
, EMPTY_MACROVALUE
, 0 /*flags*/ , wxT("Helpstring") , wxT("group")) // style
106 wxEND_PROPERTIES_TABLE()
108 wxBEGIN_HANDLERS_TABLE(wxNotebook
)
109 wxEND_HANDLERS_TABLE()
111 wxCONSTRUCTOR_5( wxNotebook
, wxWindow
* , Parent
, wxWindowID
, Id
, wxPoint
, Position
, wxSize
, Size
, long , WindowStyle
)
114 wxBEGIN_PROPERTIES_TABLE(wxNotebookPageInfo
)
115 wxREADONLY_PROPERTY( Page
, wxNotebookPage
* , GetPage
, EMPTY_MACROVALUE
, 0 /*flags*/ , wxT("Helpstring") , wxT("group"))
116 wxREADONLY_PROPERTY( Text
, wxString
, GetText
, wxString() , 0 /*flags*/ , wxT("Helpstring") , wxT("group"))
117 wxREADONLY_PROPERTY( Selected
, bool , GetSelected
, false, 0 /*flags*/ , wxT("Helpstring") , wxT("group") )
118 wxREADONLY_PROPERTY( ImageId
, int , GetImageId
, -1 , 0 /*flags*/ , wxT("Helpstring") , wxT("group"))
119 wxEND_PROPERTIES_TABLE()
121 wxBEGIN_HANDLERS_TABLE(wxNotebookPageInfo
)
122 wxEND_HANDLERS_TABLE()
124 wxCONSTRUCTOR_4( wxNotebookPageInfo
, wxNotebookPage
* , Page
, wxString
, Text
, bool , Selected
, int , ImageId
)
127 IMPLEMENT_DYNAMIC_CLASS(wxNotebook
, wxControl
)
128 IMPLEMENT_DYNAMIC_CLASS(wxNotebookPageInfo
, wxObject
)
130 IMPLEMENT_DYNAMIC_CLASS(wxNotebookEvent
, wxNotifyEvent
)
132 // ============================================================================
134 // ============================================================================
136 // ----------------------------------------------------------------------------
137 // wxNotebook construction
138 // ----------------------------------------------------------------------------
140 const wxNotebookPageInfoList
& wxNotebook::GetPageInfos() const
142 wxNotebookPageInfoList
* list
;
147 // common part of all ctors
148 void wxNotebook::Init()
152 // default for dynamic class
153 wxNotebook::wxNotebook()
157 // the same arguments as for wxControl
158 wxNotebook::wxNotebook(wxWindow
*parent
,
163 const wxString
& name
)
168 bool wxNotebook::Create(wxWindow
*parent
,
173 const wxString
& name
)
178 // ----------------------------------------------------------------------------
179 // wxNotebook accessors
180 // ----------------------------------------------------------------------------
182 size_t wxNotebook::GetPageCount() const
187 int wxNotebook::GetRowCount() const
192 int wxNotebook::SetSelection(size_t nPage
)
197 bool wxNotebook::SetPageText(size_t nPage
, const wxString
& strText
)
202 wxString
wxNotebook::GetPageText(size_t nPage
) const
204 return wxEmptyString
;
207 int wxNotebook::GetPageImage(size_t nPage
) const
212 bool wxNotebook::SetPageImage(size_t nPage
, int nImage
)
217 void wxNotebook::SetImageList(wxImageList
* imageList
)
221 // ----------------------------------------------------------------------------
222 // wxNotebook size settings
223 // ----------------------------------------------------------------------------
225 void wxNotebook::SetPageSize(const wxSize
& size
)
229 void wxNotebook::SetPadding(const wxSize
& padding
)
233 void wxNotebook::SetTabSize(const wxSize
& sz
)
237 wxSize
wxNotebook::CalcSizeFromPage(const wxSize
& sizePage
) const
242 void wxNotebook::AdjustPageSize(wxNotebookPage
*page
)
246 // ----------------------------------------------------------------------------
247 // wxNotebook operations
248 // ----------------------------------------------------------------------------
250 // remove one page from the notebook, without deleting
251 wxNotebookPage
*wxNotebook::DoRemovePage(size_t nPage
)
257 bool wxNotebook::DeleteAllPages()
262 // same as AddPage() but does it at given position
263 bool wxNotebook::InsertPage(size_t nPage
,
264 wxNotebookPage
*pPage
,
265 const wxString
& strText
,
272 int wxNotebook::HitTest(const wxPoint
& pt
, long *flags
) const
278 // ----------------------------------------------------------------------------
279 // wxNotebook callbacks
280 // ----------------------------------------------------------------------------
282 void wxNotebook::OnSize(wxSizeEvent
& event
)
286 void wxNotebook::OnSelChange(wxNotebookEvent
& event
)
290 void wxNotebook::OnNavigationKey(wxNavigationKeyEvent
& event
)
294 // ----------------------------------------------------------------------------
295 // wxNotebook base class virtuals
296 // ----------------------------------------------------------------------------
298 #if wxUSE_CONSTRAINTS
300 // override these 2 functions to do nothing: everything is done in OnSize
302 void wxNotebook::SetConstraintSizes(bool WXUNUSED(recurse
))
306 bool wxNotebook::DoPhase(int WXUNUSED(nPhase
))
311 #endif // wxUSE_CONSTRAINTS
313 #endif // wxUSE_NOTEBOOK