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 BEGIN_EVENT_TABLE(wxNotebook
, wxBookCtrlBase
)
42 EVT_NOTEBOOK_PAGE_CHANGED(wxID_ANY
, wxNotebook::OnSelChange
)
44 EVT_SIZE(wxNotebook::OnSize
)
46 EVT_NAVIGATION_KEY(wxNotebook::OnNavigationKey
)
49 #if wxUSE_EXTENDED_RTTI
50 WX_DEFINE_FLAGS( wxNotebookStyle
)
52 wxBEGIN_FLAGS( wxNotebookStyle
)
53 // new style border flags, we put them first to
54 // use them for streaming out
55 wxFLAGS_MEMBER(wxBORDER_SIMPLE
)
56 wxFLAGS_MEMBER(wxBORDER_SUNKEN
)
57 wxFLAGS_MEMBER(wxBORDER_DOUBLE
)
58 wxFLAGS_MEMBER(wxBORDER_RAISED
)
59 wxFLAGS_MEMBER(wxBORDER_STATIC
)
60 wxFLAGS_MEMBER(wxBORDER_NONE
)
62 // old style border flags
63 wxFLAGS_MEMBER(wxSIMPLE_BORDER
)
64 wxFLAGS_MEMBER(wxSUNKEN_BORDER
)
65 wxFLAGS_MEMBER(wxDOUBLE_BORDER
)
66 wxFLAGS_MEMBER(wxRAISED_BORDER
)
67 wxFLAGS_MEMBER(wxSTATIC_BORDER
)
68 wxFLAGS_MEMBER(wxBORDER
)
70 // standard window styles
71 wxFLAGS_MEMBER(wxTAB_TRAVERSAL
)
72 wxFLAGS_MEMBER(wxCLIP_CHILDREN
)
73 wxFLAGS_MEMBER(wxTRANSPARENT_WINDOW
)
74 wxFLAGS_MEMBER(wxWANTS_CHARS
)
75 wxFLAGS_MEMBER(wxFULL_REPAINT_ON_RESIZE
)
76 wxFLAGS_MEMBER(wxALWAYS_SHOW_SB
)
77 wxFLAGS_MEMBER(wxVSCROLL
)
78 wxFLAGS_MEMBER(wxHSCROLL
)
80 wxFLAGS_MEMBER(wxNB_FIXEDWIDTH
)
81 wxFLAGS_MEMBER(wxBK_LEFT
)
82 wxFLAGS_MEMBER(wxBK_RIGHT
)
83 wxFLAGS_MEMBER(wxBK_BOTTOM
)
85 wxEND_FLAGS( wxNotebookStyle
)
87 IMPLEMENT_DYNAMIC_CLASS_XTI(wxNotebook
, wxBookCtrlBase
,"wx/notebook.h")
88 IMPLEMENT_DYNAMIC_CLASS_XTI(wxNotebookPageInfo
, wxObject
, "wx/notebook.h" )
90 wxCOLLECTION_TYPE_INFO( wxNotebookPageInfo
* , wxNotebookPageInfoList
) ;
92 template<> void wxCollectionToVariantArray( wxNotebookPageInfoList
const &theList
, wxxVariantArray
&value
)
94 wxListCollectionToVariantArray
<wxNotebookPageInfoList::compatibility_iterator
>( theList
, value
) ;
97 wxBEGIN_PROPERTIES_TABLE(wxNotebook
)
98 wxEVENT_PROPERTY( PageChanging
, wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGING
, wxBookCtrlEvent
)
99 wxEVENT_PROPERTY( PageChanged
, wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED
, wxBookCtrlEvent
)
101 wxPROPERTY_COLLECTION( PageInfos
, wxNotebookPageInfoList
, wxNotebookPageInfo
* , AddPageInfo
, GetPageInfos
, 0 /*flags*/ , wxT("Helpstring") , wxT("group"))
102 wxPROPERTY_FLAGS( WindowStyle
, wxNotebookStyle
, long , SetWindowStyleFlag
, GetWindowStyleFlag
, EMPTY_MACROVALUE
, 0 /*flags*/ , wxT("Helpstring") , wxT("group")) // style
103 wxEND_PROPERTIES_TABLE()
105 wxBEGIN_HANDLERS_TABLE(wxNotebook
)
106 wxEND_HANDLERS_TABLE()
108 wxCONSTRUCTOR_5( wxNotebook
, wxWindow
* , Parent
, wxWindowID
, Id
, wxPoint
, Position
, wxSize
, Size
, long , WindowStyle
)
111 wxBEGIN_PROPERTIES_TABLE(wxNotebookPageInfo
)
112 wxREADONLY_PROPERTY( Page
, wxNotebookPage
* , GetPage
, EMPTY_MACROVALUE
, 0 /*flags*/ , wxT("Helpstring") , wxT("group"))
113 wxREADONLY_PROPERTY( Text
, wxString
, GetText
, wxString() , 0 /*flags*/ , wxT("Helpstring") , wxT("group"))
114 wxREADONLY_PROPERTY( Selected
, bool , GetSelected
, false, 0 /*flags*/ , wxT("Helpstring") , wxT("group") )
115 wxREADONLY_PROPERTY( ImageId
, int , GetImageId
, -1 , 0 /*flags*/ , wxT("Helpstring") , wxT("group"))
116 wxEND_PROPERTIES_TABLE()
118 wxBEGIN_HANDLERS_TABLE(wxNotebookPageInfo
)
119 wxEND_HANDLERS_TABLE()
121 wxCONSTRUCTOR_4( wxNotebookPageInfo
, wxNotebookPage
* , Page
, wxString
, Text
, bool , Selected
, int , ImageId
)
124 IMPLEMENT_DYNAMIC_CLASS(wxNotebook
, wxBookCtrlBase
)
125 IMPLEMENT_DYNAMIC_CLASS(wxNotebookPageInfo
, wxObject
)
128 // ============================================================================
130 // ============================================================================
132 // ----------------------------------------------------------------------------
133 // wxNotebook construction
134 // ----------------------------------------------------------------------------
136 const wxNotebookPageInfoList
& wxNotebook::GetPageInfos() const
138 wxNotebookPageInfoList
* list
;
143 // common part of all ctors
144 void wxNotebook::Init()
148 // default for dynamic class
149 wxNotebook::wxNotebook()
153 // the same arguments as for wxControl
154 wxNotebook::wxNotebook(wxWindow
*parent
,
159 const wxString
& name
)
164 bool wxNotebook::Create(wxWindow
*parent
,
169 const wxString
& name
)
174 // ----------------------------------------------------------------------------
175 // wxNotebook accessors
176 // ----------------------------------------------------------------------------
178 size_t wxNotebook::GetPageCount() const
183 int wxNotebook::GetRowCount() const
188 int wxNotebook::SetSelection(size_t nPage
)
193 int wxNotebook::ChangeSelection(size_t nPage
)
198 bool wxNotebook::SetPageText(size_t nPage
, const wxString
& strText
)
203 wxString
wxNotebook::GetPageText(size_t nPage
) const
205 return wxEmptyString
;
208 int wxNotebook::GetPageImage(size_t nPage
) const
213 bool wxNotebook::SetPageImage(size_t nPage
, int nImage
)
218 void wxNotebook::SetImageList(wxImageList
* imageList
)
222 // ----------------------------------------------------------------------------
223 // wxNotebook size settings
224 // ----------------------------------------------------------------------------
226 void wxNotebook::SetPageSize(const wxSize
& size
)
230 void wxNotebook::SetPadding(const wxSize
& padding
)
234 void wxNotebook::SetTabSize(const wxSize
& sz
)
238 wxSize
wxNotebook::CalcSizeFromPage(const wxSize
& sizePage
) const
243 void wxNotebook::AdjustPageSize(wxNotebookPage
*page
)
247 // ----------------------------------------------------------------------------
248 // wxNotebook operations
249 // ----------------------------------------------------------------------------
251 // remove one page from the notebook, without deleting
252 wxNotebookPage
*wxNotebook::DoRemovePage(size_t nPage
)
258 bool wxNotebook::DeleteAllPages()
263 // same as AddPage() but does it at given position
264 bool wxNotebook::InsertPage(size_t nPage
,
265 wxNotebookPage
*pPage
,
266 const wxString
& strText
,
273 int wxNotebook::HitTest(const wxPoint
& pt
, long *flags
) const
279 // ----------------------------------------------------------------------------
280 // wxNotebook callbacks
281 // ----------------------------------------------------------------------------
283 void wxNotebook::OnSize(wxSizeEvent
& event
)
287 void wxNotebook::OnSelChange(wxBookCtrlEvent
& event
)
291 void wxNotebook::OnNavigationKey(wxNavigationKeyEvent
& event
)
295 // ----------------------------------------------------------------------------
296 // wxNotebook base class virtuals
297 // ----------------------------------------------------------------------------
299 #if wxUSE_CONSTRAINTS
301 // override these 2 functions to do nothing: everything is done in OnSize
303 void wxNotebook::SetConstraintSizes(bool WXUNUSED(recurse
))
307 bool wxNotebook::DoPhase(int WXUNUSED(nPhase
))
312 #endif // wxUSE_CONSTRAINTS
314 #endif // wxUSE_NOTEBOOK