1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: palmos/notebook.cpp
3 // Purpose: implementation of wxNotebook
4 // Author: William Osborne
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"
31 #include "wx/imaglist.h"
33 #include "wx/control.h"
34 #include "wx/notebook.h"
37 #include "wx/palmos/private.h"
39 #include "wx/palmos/winundef.h"
42 #include "wx/palmos/uxtheme.h"
44 #include "wx/radiobut.h"
45 #include "wx/radiobox.h"
46 #include "wx/checkbox.h"
47 #include "wx/bmpbuttn.h"
48 #include "wx/statline.h"
49 #include "wx/statbox.h"
50 #include "wx/stattext.h"
51 #include "wx/slider.h"
52 #include "wx/scrolwin.h"
56 // ----------------------------------------------------------------------------
58 // ----------------------------------------------------------------------------
60 // check that the page index is valid
61 #define IS_VALID_PAGE(nPage) ((nPage) < GetPageCount())
64 #define m_hwnd (HWND)GetHWND()
66 // ----------------------------------------------------------------------------
68 // ----------------------------------------------------------------------------
70 // This is a work-around for missing defines in gcc-2.95 headers
72 #define TCS_RIGHT 0x0002
76 #define TCS_VERTICAL 0x0080
80 #define TCS_BOTTOM TCS_RIGHT
83 // ----------------------------------------------------------------------------
85 // ----------------------------------------------------------------------------
87 #include <wx/listimpl.cpp>
89 WX_DEFINE_LIST( wxNotebookPageInfoList
) ;
91 DEFINE_EVENT_TYPE(wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED
)
92 DEFINE_EVENT_TYPE(wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGING
)
94 BEGIN_EVENT_TABLE(wxNotebook
, wxControl
)
95 EVT_NOTEBOOK_PAGE_CHANGED(-1, wxNotebook::OnSelChange
)
97 EVT_SIZE(wxNotebook::OnSize
)
99 EVT_NAVIGATION_KEY(wxNotebook::OnNavigationKey
)
102 #if wxUSE_EXTENDED_RTTI
103 WX_DEFINE_FLAGS( wxNotebookStyle
)
105 wxBEGIN_FLAGS( wxNotebookStyle
)
106 // new style border flags, we put them first to
107 // use them for streaming out
108 wxFLAGS_MEMBER(wxBORDER_SIMPLE
)
109 wxFLAGS_MEMBER(wxBORDER_SUNKEN
)
110 wxFLAGS_MEMBER(wxBORDER_DOUBLE
)
111 wxFLAGS_MEMBER(wxBORDER_RAISED
)
112 wxFLAGS_MEMBER(wxBORDER_STATIC
)
113 wxFLAGS_MEMBER(wxBORDER_NONE
)
115 // old style border flags
116 wxFLAGS_MEMBER(wxSIMPLE_BORDER
)
117 wxFLAGS_MEMBER(wxSUNKEN_BORDER
)
118 wxFLAGS_MEMBER(wxDOUBLE_BORDER
)
119 wxFLAGS_MEMBER(wxRAISED_BORDER
)
120 wxFLAGS_MEMBER(wxSTATIC_BORDER
)
121 wxFLAGS_MEMBER(wxBORDER
)
123 // standard window styles
124 wxFLAGS_MEMBER(wxTAB_TRAVERSAL
)
125 wxFLAGS_MEMBER(wxCLIP_CHILDREN
)
126 wxFLAGS_MEMBER(wxTRANSPARENT_WINDOW
)
127 wxFLAGS_MEMBER(wxWANTS_CHARS
)
128 wxFLAGS_MEMBER(wxFULL_REPAINT_ON_RESIZE
)
129 wxFLAGS_MEMBER(wxALWAYS_SHOW_SB
)
130 wxFLAGS_MEMBER(wxVSCROLL
)
131 wxFLAGS_MEMBER(wxHSCROLL
)
133 wxFLAGS_MEMBER(wxNB_FIXEDWIDTH
)
134 wxFLAGS_MEMBER(wxNB_LEFT
)
135 wxFLAGS_MEMBER(wxNB_RIGHT
)
136 wxFLAGS_MEMBER(wxNB_BOTTOM
)
138 wxEND_FLAGS( wxNotebookStyle
)
140 IMPLEMENT_DYNAMIC_CLASS_XTI(wxNotebook
, wxControl
,"wx/notebook.h")
141 IMPLEMENT_DYNAMIC_CLASS_XTI(wxNotebookPageInfo
, wxObject
, "wx/notebook.h" )
143 wxCOLLECTION_TYPE_INFO( wxNotebookPageInfo
* , wxNotebookPageInfoList
) ;
145 template<> void wxCollectionToVariantArray( wxNotebookPageInfoList
const &theList
, wxxVariantArray
&value
)
147 wxListCollectionToVariantArray
<wxNotebookPageInfoList::compatibility_iterator
>( theList
, value
) ;
150 wxBEGIN_PROPERTIES_TABLE(wxNotebook
)
151 wxEVENT_PROPERTY( PageChanging
, wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGING
, wxNotebookEvent
)
152 wxEVENT_PROPERTY( PageChanged
, wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED
, wxNotebookEvent
)
154 wxPROPERTY_COLLECTION( PageInfos
, wxNotebookPageInfoList
, wxNotebookPageInfo
* , AddPageInfo
, GetPageInfos
, 0 /*flags*/ , wxT("Helpstring") , wxT("group"))
155 wxPROPERTY_FLAGS( WindowStyle
, wxNotebookStyle
, long , SetWindowStyleFlag
, GetWindowStyleFlag
, EMPTY_MACROVALUE
, 0 /*flags*/ , wxT("Helpstring") , wxT("group")) // style
156 wxEND_PROPERTIES_TABLE()
158 wxBEGIN_HANDLERS_TABLE(wxNotebook
)
159 wxEND_HANDLERS_TABLE()
161 wxCONSTRUCTOR_5( wxNotebook
, wxWindow
* , Parent
, wxWindowID
, Id
, wxPoint
, Position
, wxSize
, Size
, long , WindowStyle
)
164 wxBEGIN_PROPERTIES_TABLE(wxNotebookPageInfo
)
165 wxREADONLY_PROPERTY( Page
, wxNotebookPage
* , GetPage
, EMPTY_MACROVALUE
, 0 /*flags*/ , wxT("Helpstring") , wxT("group"))
166 wxREADONLY_PROPERTY( Text
, wxString
, GetText
, wxString() , 0 /*flags*/ , wxT("Helpstring") , wxT("group"))
167 wxREADONLY_PROPERTY( Selected
, bool , GetSelected
, false, 0 /*flags*/ , wxT("Helpstring") , wxT("group") )
168 wxREADONLY_PROPERTY( ImageId
, int , GetImageId
, -1 , 0 /*flags*/ , wxT("Helpstring") , wxT("group"))
169 wxEND_PROPERTIES_TABLE()
171 wxBEGIN_HANDLERS_TABLE(wxNotebookPageInfo
)
172 wxEND_HANDLERS_TABLE()
174 wxCONSTRUCTOR_4( wxNotebookPageInfo
, wxNotebookPage
* , Page
, wxString
, Text
, bool , Selected
, int , ImageId
)
177 IMPLEMENT_DYNAMIC_CLASS(wxNotebook
, wxControl
)
178 IMPLEMENT_DYNAMIC_CLASS(wxNotebookPageInfo
, wxObject
)
180 IMPLEMENT_DYNAMIC_CLASS(wxNotebookEvent
, wxNotifyEvent
)
182 // ============================================================================
184 // ============================================================================
186 // ----------------------------------------------------------------------------
187 // wxNotebook construction
188 // ----------------------------------------------------------------------------
190 const wxNotebookPageInfoList
& wxNotebook::GetPageInfos() const
192 wxNotebookPageInfoList
* list
;
197 // common part of all ctors
198 void wxNotebook::Init()
202 // default for dynamic class
203 wxNotebook::wxNotebook()
207 // the same arguments as for wxControl
208 wxNotebook::wxNotebook(wxWindow
*parent
,
213 const wxString
& name
)
218 bool wxNotebook::Create(wxWindow
*parent
,
223 const wxString
& name
)
228 WXDWORD
wxNotebook::MSWGetStyle(long style
, WXDWORD
*exstyle
) const
233 // ----------------------------------------------------------------------------
234 // wxNotebook accessors
235 // ----------------------------------------------------------------------------
237 size_t wxNotebook::GetPageCount() const
242 int wxNotebook::GetRowCount() const
247 int wxNotebook::SetSelection(size_t nPage
)
252 bool wxNotebook::SetPageText(size_t nPage
, const wxString
& strText
)
257 wxString
wxNotebook::GetPageText(size_t nPage
) const
264 int wxNotebook::GetPageImage(size_t nPage
) const
269 bool wxNotebook::SetPageImage(size_t nPage
, int nImage
)
274 void wxNotebook::SetImageList(wxImageList
* imageList
)
278 // ----------------------------------------------------------------------------
279 // wxNotebook size settings
280 // ----------------------------------------------------------------------------
282 void wxNotebook::SetPageSize(const wxSize
& size
)
286 void wxNotebook::SetPadding(const wxSize
& padding
)
290 void wxNotebook::SetTabSize(const wxSize
& sz
)
294 wxSize
wxNotebook::CalcSizeFromPage(const wxSize
& sizePage
) const
299 void wxNotebook::AdjustPageSize(wxNotebookPage
*page
)
303 // ----------------------------------------------------------------------------
304 // wxNotebook operations
305 // ----------------------------------------------------------------------------
307 // remove one page from the notebook, without deleting
308 wxNotebookPage
*wxNotebook::DoRemovePage(size_t nPage
)
314 bool wxNotebook::DeleteAllPages()
319 // same as AddPage() but does it at given position
320 bool wxNotebook::InsertPage(size_t nPage
,
321 wxNotebookPage
*pPage
,
322 const wxString
& strText
,
329 int wxNotebook::HitTest(const wxPoint
& pt
, long *flags
) const
335 // ----------------------------------------------------------------------------
336 // wxNotebook callbacks
337 // ----------------------------------------------------------------------------
339 void wxNotebook::OnSize(wxSizeEvent
& event
)
343 void wxNotebook::OnSelChange(wxNotebookEvent
& event
)
347 bool wxNotebook::MSWTranslateMessage(WXMSG
*wxmsg
)
352 void wxNotebook::OnNavigationKey(wxNavigationKeyEvent
& event
)
356 // ----------------------------------------------------------------------------
357 // wxNotebook base class virtuals
358 // ----------------------------------------------------------------------------
360 #if wxUSE_CONSTRAINTS
362 // override these 2 functions to do nothing: everything is done in OnSize
364 void wxNotebook::SetConstraintSizes(bool WXUNUSED(recurse
))
368 bool wxNotebook::DoPhase(int WXUNUSED(nPhase
))
373 #endif // wxUSE_CONSTRAINTS
375 // ----------------------------------------------------------------------------
376 // wxNotebook Windows message handlers
377 // ----------------------------------------------------------------------------
379 bool wxNotebook::MSWOnScroll(int orientation
, WXWORD nSBCode
,
380 WXWORD pos
, WXHWND control
)
385 bool wxNotebook::MSWOnNotify(int idCtrl
, WXLPARAM lParam
, WXLPARAM
* result
)
390 // Windows only: attempts to get colour for UX theme page background
391 wxColour
wxNotebook::GetThemeBackgroundColour()
396 // Windows only: attempts to apply the UX theme page background to this page
398 void wxNotebook::ApplyThemeBackground(wxWindow
* window
, const wxColour
& colour
)
400 void wxNotebook::ApplyThemeBackground(wxWindow
*, const wxColour
&)
406 WXLRESULT
wxNotebook::MSWWindowProc(WXUINT nMsg
, WXWPARAM wParam
, WXLPARAM lParam
)
410 #endif // #if wxUSE_UXTHEME
412 #endif // wxUSE_NOTEBOOK