]> git.saurik.com Git - wxWidgets.git/blob - src/palmos/notebook.cpp
improve best size calculation; notably account for wxDP_ALLOWNONE
[wxWidgets.git] / src / palmos / notebook.cpp
1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: src/palmos/notebook.cpp
3 // Purpose: implementation of wxNotebook
4 // Author: William Osborne - minimal working wxPalmOS port
5 // Modified by:
6 // Created: 10/13/04
7 // RCS-ID: $Id$
8 // Copyright: (c) William Osborne
9 // Licence: wxWindows licence
10 ///////////////////////////////////////////////////////////////////////////////
11
12 // For compilers that support precompilation, includes "wx.h".
13 #include "wx/wxprec.h"
14
15 #ifdef __BORLANDC__
16 #pragma hdrstop
17 #endif
18
19 #if wxUSE_NOTEBOOK
20
21 // wxWidgets
22 #ifndef WX_PRECOMP
23 #include "wx/string.h"
24 #endif // WX_PRECOMP
25
26 // ----------------------------------------------------------------------------
27 // macros
28 // ----------------------------------------------------------------------------
29
30 // check that the page index is valid
31 #define IS_VALID_PAGE(nPage) ((nPage) < GetPageCount())
32
33 // ----------------------------------------------------------------------------
34 // event table
35 // ----------------------------------------------------------------------------
36
37 #include "wx/listimpl.cpp"
38
39 WX_DEFINE_LIST( wxNotebookPageInfoList )
40
41 DEFINE_EVENT_TYPE(wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED)
42 DEFINE_EVENT_TYPE(wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGING)
43
44 BEGIN_EVENT_TABLE(wxNotebook, wxBookCtrlBase)
45 EVT_NOTEBOOK_PAGE_CHANGED(wxID_ANY, wxNotebook::OnSelChange)
46
47 EVT_SIZE(wxNotebook::OnSize)
48
49 EVT_NAVIGATION_KEY(wxNotebook::OnNavigationKey)
50 END_EVENT_TABLE()
51
52 #if wxUSE_EXTENDED_RTTI
53 WX_DEFINE_FLAGS( wxNotebookStyle )
54
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)
64
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)
72
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)
82
83 wxFLAGS_MEMBER(wxNB_FIXEDWIDTH)
84 wxFLAGS_MEMBER(wxBK_LEFT)
85 wxFLAGS_MEMBER(wxBK_RIGHT)
86 wxFLAGS_MEMBER(wxBK_BOTTOM)
87
88 wxEND_FLAGS( wxNotebookStyle )
89
90 IMPLEMENT_DYNAMIC_CLASS_XTI(wxNotebook, wxBookCtrlBase,"wx/notebook.h")
91 IMPLEMENT_DYNAMIC_CLASS_XTI(wxNotebookPageInfo, wxObject , "wx/notebook.h" )
92
93 wxCOLLECTION_TYPE_INFO( wxNotebookPageInfo * , wxNotebookPageInfoList ) ;
94
95 template<> void wxCollectionToVariantArray( wxNotebookPageInfoList const &theList, wxxVariantArray &value)
96 {
97 wxListCollectionToVariantArray<wxNotebookPageInfoList::compatibility_iterator>( theList , value ) ;
98 }
99
100 wxBEGIN_PROPERTIES_TABLE(wxNotebook)
101 wxEVENT_PROPERTY( PageChanging , wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGING , wxBookCtrlEvent )
102 wxEVENT_PROPERTY( PageChanged , wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED , wxBookCtrlEvent )
103
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()
107
108 wxBEGIN_HANDLERS_TABLE(wxNotebook)
109 wxEND_HANDLERS_TABLE()
110
111 wxCONSTRUCTOR_5( wxNotebook , wxWindow* , Parent , wxWindowID , Id , wxPoint , Position , wxSize , Size , long , WindowStyle)
112
113
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()
120
121 wxBEGIN_HANDLERS_TABLE(wxNotebookPageInfo)
122 wxEND_HANDLERS_TABLE()
123
124 wxCONSTRUCTOR_4( wxNotebookPageInfo , wxNotebookPage* , Page , wxString , Text , bool , Selected , int , ImageId )
125
126 #else
127 IMPLEMENT_DYNAMIC_CLASS(wxNotebook, wxBookCtrlBase)
128 IMPLEMENT_DYNAMIC_CLASS(wxNotebookPageInfo, wxObject )
129 #endif
130
131 // ============================================================================
132 // implementation
133 // ============================================================================
134
135 // ----------------------------------------------------------------------------
136 // wxNotebook construction
137 // ----------------------------------------------------------------------------
138
139 const wxNotebookPageInfoList& wxNotebook::GetPageInfos() const
140 {
141 wxNotebookPageInfoList* list;
142
143 return m_pageInfos ;
144 }
145
146 // common part of all ctors
147 void wxNotebook::Init()
148 {
149 }
150
151 // default for dynamic class
152 wxNotebook::wxNotebook()
153 {
154 }
155
156 // the same arguments as for wxControl
157 wxNotebook::wxNotebook(wxWindow *parent,
158 wxWindowID id,
159 const wxPoint& pos,
160 const wxSize& size,
161 long style,
162 const wxString& name)
163 {
164 }
165
166 // Create() function
167 bool wxNotebook::Create(wxWindow *parent,
168 wxWindowID id,
169 const wxPoint& pos,
170 const wxSize& size,
171 long style,
172 const wxString& name)
173 {
174 return false;
175 }
176
177 // ----------------------------------------------------------------------------
178 // wxNotebook accessors
179 // ----------------------------------------------------------------------------
180
181 size_t wxNotebook::GetPageCount() const
182 {
183 return 0;
184 }
185
186 int wxNotebook::GetRowCount() const
187 {
188 return 0;
189 }
190
191 int wxNotebook::SetSelection(size_t nPage)
192 {
193 return 0;
194 }
195
196 int wxNotebook::ChangeSelection(size_t nPage)
197 {
198 return 0;
199 }
200
201 bool wxNotebook::SetPageText(size_t nPage, const wxString& strText)
202 {
203 return false;
204 }
205
206 wxString wxNotebook::GetPageText(size_t nPage) const
207 {
208 return wxEmptyString;
209 }
210
211 int wxNotebook::GetPageImage(size_t nPage) const
212 {
213 return -1;
214 }
215
216 bool wxNotebook::SetPageImage(size_t nPage, int nImage)
217 {
218 return false;
219 }
220
221 void wxNotebook::SetImageList(wxImageList* imageList)
222 {
223 }
224
225 // ----------------------------------------------------------------------------
226 // wxNotebook size settings
227 // ----------------------------------------------------------------------------
228
229 void wxNotebook::SetPageSize(const wxSize& size)
230 {
231 }
232
233 void wxNotebook::SetPadding(const wxSize& padding)
234 {
235 }
236
237 void wxNotebook::SetTabSize(const wxSize& sz)
238 {
239 }
240
241 wxSize wxNotebook::CalcSizeFromPage(const wxSize& sizePage) const
242 {
243 return wxSize(0,0);
244 }
245
246 void wxNotebook::AdjustPageSize(wxNotebookPage *page)
247 {
248 }
249
250 // ----------------------------------------------------------------------------
251 // wxNotebook operations
252 // ----------------------------------------------------------------------------
253
254 // remove one page from the notebook, without deleting
255 wxNotebookPage *wxNotebook::DoRemovePage(size_t nPage)
256 {
257 return NULL;
258 }
259
260 // remove all pages
261 bool wxNotebook::DeleteAllPages()
262 {
263 return true;
264 }
265
266 // same as AddPage() but does it at given position
267 bool wxNotebook::InsertPage(size_t nPage,
268 wxNotebookPage *pPage,
269 const wxString& strText,
270 bool bSelect,
271 int imageId)
272 {
273 return false;
274 }
275
276 int wxNotebook::HitTest(const wxPoint& pt, long *flags) const
277 {
278 return 0;
279 }
280
281
282 // ----------------------------------------------------------------------------
283 // wxNotebook callbacks
284 // ----------------------------------------------------------------------------
285
286 void wxNotebook::OnSize(wxSizeEvent& event)
287 {
288 }
289
290 void wxNotebook::OnSelChange(wxBookCtrlEvent& event)
291 {
292 }
293
294 void wxNotebook::OnNavigationKey(wxNavigationKeyEvent& event)
295 {
296 }
297
298 // ----------------------------------------------------------------------------
299 // wxNotebook base class virtuals
300 // ----------------------------------------------------------------------------
301
302 #if wxUSE_CONSTRAINTS
303
304 // override these 2 functions to do nothing: everything is done in OnSize
305
306 void wxNotebook::SetConstraintSizes(bool WXUNUSED(recurse))
307 {
308 }
309
310 bool wxNotebook::DoPhase(int WXUNUSED(nPhase))
311 {
312 return true;
313 }
314
315 #endif // wxUSE_CONSTRAINTS
316
317 #endif // wxUSE_NOTEBOOK