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 #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
13 #pragma implementation "notebook.h"
16 // For compilers that support precompilation, includes "wx.h".
17 #include "wx/wxprec.h"
27 #include "wx/string.h"
30 // ----------------------------------------------------------------------------
32 // ----------------------------------------------------------------------------
34 // check that the page index is valid
35 #define IS_VALID_PAGE(nPage) ((nPage) < GetPageCount())
37 // ----------------------------------------------------------------------------
39 // ----------------------------------------------------------------------------
41 #include <wx/listimpl.cpp>
43 WX_DEFINE_LIST( wxNotebookPageInfoList
) ;
45 DEFINE_EVENT_TYPE(wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED
)
46 DEFINE_EVENT_TYPE(wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGING
)
48 BEGIN_EVENT_TABLE(wxNotebook
, wxControl
)
49 EVT_NOTEBOOK_PAGE_CHANGED(-1, wxNotebook::OnSelChange
)
51 EVT_SIZE(wxNotebook::OnSize
)
53 EVT_NAVIGATION_KEY(wxNotebook::OnNavigationKey
)
56 #if wxUSE_EXTENDED_RTTI
57 WX_DEFINE_FLAGS( wxNotebookStyle
)
59 wxBEGIN_FLAGS( wxNotebookStyle
)
60 // new style border flags, we put them first to
61 // use them for streaming out
62 wxFLAGS_MEMBER(wxBORDER_SIMPLE
)
63 wxFLAGS_MEMBER(wxBORDER_SUNKEN
)
64 wxFLAGS_MEMBER(wxBORDER_DOUBLE
)
65 wxFLAGS_MEMBER(wxBORDER_RAISED
)
66 wxFLAGS_MEMBER(wxBORDER_STATIC
)
67 wxFLAGS_MEMBER(wxBORDER_NONE
)
69 // old style border flags
70 wxFLAGS_MEMBER(wxSIMPLE_BORDER
)
71 wxFLAGS_MEMBER(wxSUNKEN_BORDER
)
72 wxFLAGS_MEMBER(wxDOUBLE_BORDER
)
73 wxFLAGS_MEMBER(wxRAISED_BORDER
)
74 wxFLAGS_MEMBER(wxSTATIC_BORDER
)
75 wxFLAGS_MEMBER(wxBORDER
)
77 // standard window styles
78 wxFLAGS_MEMBER(wxTAB_TRAVERSAL
)
79 wxFLAGS_MEMBER(wxCLIP_CHILDREN
)
80 wxFLAGS_MEMBER(wxTRANSPARENT_WINDOW
)
81 wxFLAGS_MEMBER(wxWANTS_CHARS
)
82 wxFLAGS_MEMBER(wxFULL_REPAINT_ON_RESIZE
)
83 wxFLAGS_MEMBER(wxALWAYS_SHOW_SB
)
84 wxFLAGS_MEMBER(wxVSCROLL
)
85 wxFLAGS_MEMBER(wxHSCROLL
)
87 wxFLAGS_MEMBER(wxNB_FIXEDWIDTH
)
88 wxFLAGS_MEMBER(wxNB_LEFT
)
89 wxFLAGS_MEMBER(wxNB_RIGHT
)
90 wxFLAGS_MEMBER(wxNB_BOTTOM
)
92 wxEND_FLAGS( wxNotebookStyle
)
94 IMPLEMENT_DYNAMIC_CLASS_XTI(wxNotebook
, wxControl
,"wx/notebook.h")
95 IMPLEMENT_DYNAMIC_CLASS_XTI(wxNotebookPageInfo
, wxObject
, "wx/notebook.h" )
97 wxCOLLECTION_TYPE_INFO( wxNotebookPageInfo
* , wxNotebookPageInfoList
) ;
99 template<> void wxCollectionToVariantArray( wxNotebookPageInfoList
const &theList
, wxxVariantArray
&value
)
101 wxListCollectionToVariantArray
<wxNotebookPageInfoList::compatibility_iterator
>( theList
, value
) ;
104 wxBEGIN_PROPERTIES_TABLE(wxNotebook
)
105 wxEVENT_PROPERTY( PageChanging
, wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGING
, wxNotebookEvent
)
106 wxEVENT_PROPERTY( PageChanged
, wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED
, wxNotebookEvent
)
108 wxPROPERTY_COLLECTION( PageInfos
, wxNotebookPageInfoList
, wxNotebookPageInfo
* , AddPageInfo
, GetPageInfos
, 0 /*flags*/ , wxT("Helpstring") , wxT("group"))
109 wxPROPERTY_FLAGS( WindowStyle
, wxNotebookStyle
, long , SetWindowStyleFlag
, GetWindowStyleFlag
, EMPTY_MACROVALUE
, 0 /*flags*/ , wxT("Helpstring") , wxT("group")) // style
110 wxEND_PROPERTIES_TABLE()
112 wxBEGIN_HANDLERS_TABLE(wxNotebook
)
113 wxEND_HANDLERS_TABLE()
115 wxCONSTRUCTOR_5( wxNotebook
, wxWindow
* , Parent
, wxWindowID
, Id
, wxPoint
, Position
, wxSize
, Size
, long , WindowStyle
)
118 wxBEGIN_PROPERTIES_TABLE(wxNotebookPageInfo
)
119 wxREADONLY_PROPERTY( Page
, wxNotebookPage
* , GetPage
, EMPTY_MACROVALUE
, 0 /*flags*/ , wxT("Helpstring") , wxT("group"))
120 wxREADONLY_PROPERTY( Text
, wxString
, GetText
, wxString() , 0 /*flags*/ , wxT("Helpstring") , wxT("group"))
121 wxREADONLY_PROPERTY( Selected
, bool , GetSelected
, false, 0 /*flags*/ , wxT("Helpstring") , wxT("group") )
122 wxREADONLY_PROPERTY( ImageId
, int , GetImageId
, -1 , 0 /*flags*/ , wxT("Helpstring") , wxT("group"))
123 wxEND_PROPERTIES_TABLE()
125 wxBEGIN_HANDLERS_TABLE(wxNotebookPageInfo
)
126 wxEND_HANDLERS_TABLE()
128 wxCONSTRUCTOR_4( wxNotebookPageInfo
, wxNotebookPage
* , Page
, wxString
, Text
, bool , Selected
, int , ImageId
)
131 IMPLEMENT_DYNAMIC_CLASS(wxNotebook
, wxControl
)
132 IMPLEMENT_DYNAMIC_CLASS(wxNotebookPageInfo
, wxObject
)
134 IMPLEMENT_DYNAMIC_CLASS(wxNotebookEvent
, wxNotifyEvent
)
136 // ============================================================================
138 // ============================================================================
140 // ----------------------------------------------------------------------------
141 // wxNotebook construction
142 // ----------------------------------------------------------------------------
144 const wxNotebookPageInfoList
& wxNotebook::GetPageInfos() const
146 wxNotebookPageInfoList
* list
;
151 // common part of all ctors
152 void wxNotebook::Init()
156 // default for dynamic class
157 wxNotebook::wxNotebook()
161 // the same arguments as for wxControl
162 wxNotebook::wxNotebook(wxWindow
*parent
,
167 const wxString
& name
)
172 bool wxNotebook::Create(wxWindow
*parent
,
177 const wxString
& name
)
182 // ----------------------------------------------------------------------------
183 // wxNotebook accessors
184 // ----------------------------------------------------------------------------
186 size_t wxNotebook::GetPageCount() const
191 int wxNotebook::GetRowCount() const
196 int wxNotebook::SetSelection(size_t nPage
)
201 bool wxNotebook::SetPageText(size_t nPage
, const wxString
& strText
)
206 wxString
wxNotebook::GetPageText(size_t nPage
) const
208 return wxEmptyString
;
211 int wxNotebook::GetPageImage(size_t nPage
) const
216 bool wxNotebook::SetPageImage(size_t nPage
, int nImage
)
221 void wxNotebook::SetImageList(wxImageList
* imageList
)
225 // ----------------------------------------------------------------------------
226 // wxNotebook size settings
227 // ----------------------------------------------------------------------------
229 void wxNotebook::SetPageSize(const wxSize
& size
)
233 void wxNotebook::SetPadding(const wxSize
& padding
)
237 void wxNotebook::SetTabSize(const wxSize
& sz
)
241 wxSize
wxNotebook::CalcSizeFromPage(const wxSize
& sizePage
) const
246 void wxNotebook::AdjustPageSize(wxNotebookPage
*page
)
250 // ----------------------------------------------------------------------------
251 // wxNotebook operations
252 // ----------------------------------------------------------------------------
254 // remove one page from the notebook, without deleting
255 wxNotebookPage
*wxNotebook::DoRemovePage(size_t nPage
)
261 bool wxNotebook::DeleteAllPages()
266 // same as AddPage() but does it at given position
267 bool wxNotebook::InsertPage(size_t nPage
,
268 wxNotebookPage
*pPage
,
269 const wxString
& strText
,
276 int wxNotebook::HitTest(const wxPoint
& pt
, long *flags
) const
282 // ----------------------------------------------------------------------------
283 // wxNotebook callbacks
284 // ----------------------------------------------------------------------------
286 void wxNotebook::OnSize(wxSizeEvent
& event
)
290 void wxNotebook::OnSelChange(wxNotebookEvent
& event
)
294 void wxNotebook::OnNavigationKey(wxNavigationKeyEvent
& event
)
298 // ----------------------------------------------------------------------------
299 // wxNotebook base class virtuals
300 // ----------------------------------------------------------------------------
302 #if wxUSE_CONSTRAINTS
304 // override these 2 functions to do nothing: everything is done in OnSize
306 void wxNotebook::SetConstraintSizes(bool WXUNUSED(recurse
))
310 bool wxNotebook::DoPhase(int WXUNUSED(nPhase
))
315 #endif // wxUSE_CONSTRAINTS
317 #endif // wxUSE_NOTEBOOK