]>
Commit | Line | Data |
---|---|---|
32b8ec41 | 1 | ///////////////////////////////////////////////////////////////////////////// |
be5a51fb | 2 | // Program: wxWidgets Widgets Sample |
2ddb4d13 | 3 | // Name: samples/widgets/widgets.cpp |
be5a51fb | 4 | // Purpose: Sample showing most of the simple wxWidgets widgets |
32b8ec41 VZ |
5 | // Author: Vadim Zeitlin |
6 | // Created: 27.03.01 | |
7 | // Id: $Id$ | |
8 | // Copyright: (c) 2001 Vadim Zeitlin | |
9 | // License: wxWindows license | |
10 | ///////////////////////////////////////////////////////////////////////////// | |
11 | ||
12 | // ============================================================================ | |
13 | // declarations | |
14 | // ============================================================================ | |
15 | ||
16 | // ---------------------------------------------------------------------------- | |
17 | // headers | |
18 | // ---------------------------------------------------------------------------- | |
19 | ||
20 | // for compilers that support precompilation, includes "wx/wx.h". | |
21 | #include "wx/wxprec.h" | |
22 | ||
23 | #ifdef __BORLANDC__ | |
24 | #pragma hdrstop | |
25 | #endif | |
26 | ||
27 | // for all others, include the necessary headers | |
28 | #ifndef WX_PRECOMP | |
29 | #include "wx/app.h" | |
30 | #include "wx/log.h" | |
32b8ec41 | 31 | #include "wx/frame.h" |
e6f3cbd2 | 32 | #include "wx/menu.h" |
e273c962 | 33 | #include "wx/image.h" |
e6f3cbd2 | 34 | |
32b8ec41 VZ |
35 | #include "wx/button.h" |
36 | #include "wx/checkbox.h" | |
37 | #include "wx/listbox.h" | |
38 | #include "wx/statbox.h" | |
39 | #include "wx/stattext.h" | |
40 | #include "wx/textctrl.h" | |
bd018e7e | 41 | #include "wx/msgdlg.h" |
32b8ec41 VZ |
42 | #endif |
43 | ||
25057aba | 44 | #include "wx/sysopt.h" |
61c083e7 | 45 | #include "wx/bookctrl.h" |
f2fdc4d5 | 46 | #include "wx/treebook.h" |
32b8ec41 | 47 | #include "wx/sizer.h" |
195df7a7 | 48 | #include "wx/colordlg.h" |
822b9009 | 49 | #include "wx/fontdlg.h" |
1bdd1007 | 50 | #include "wx/textdlg.h" |
261357eb | 51 | #include "wx/imaglist.h" |
453535a7 | 52 | #include "wx/wupdlock.h" |
32b8ec41 VZ |
53 | |
54 | #include "widgets.h" | |
55 | ||
f2fdc4d5 WS |
56 | #include "../sample.xpm" |
57 | ||
32b8ec41 VZ |
58 | // ---------------------------------------------------------------------------- |
59 | // constants | |
60 | // ---------------------------------------------------------------------------- | |
61 | ||
62 | // control ids | |
63 | enum | |
64 | { | |
65 | Widgets_ClearLog = 100, | |
195df7a7 | 66 | Widgets_Quit, |
1301e228 | 67 | |
3700e21b VZ |
68 | Widgets_BookCtrl, |
69 | ||
1c01dd16 VZ |
70 | #if wxUSE_TOOLTIPS |
71 | Widgets_SetTooltip, | |
72 | #endif // wxUSE_TOOLTIPS | |
195df7a7 | 73 | Widgets_SetFgColour, |
822b9009 | 74 | Widgets_SetBgColour, |
a17c1df4 | 75 | Widgets_SetFont, |
1301e228 VZ |
76 | Widgets_Enable, |
77 | ||
78 | Widgets_BorderNone, | |
79 | Widgets_BorderStatic, | |
80 | Widgets_BorderSimple, | |
81 | Widgets_BorderRaised, | |
82 | Widgets_BorderSunken, | |
83 | Widgets_BorderDouble, | |
3700e21b VZ |
84 | Widgets_BorderDefault, |
85 | ||
e32bcef6 VZ |
86 | Widgets_GlobalBusyCursor, |
87 | Widgets_BusyCursor, | |
88 | ||
3700e21b VZ |
89 | Widgets_GoToPage, |
90 | Widgets_GoToPageLast = Widgets_GoToPage + 100 | |
32b8ec41 VZ |
91 | }; |
92 | ||
f2fdc4d5 | 93 | const wxChar *WidgetsCategories[MAX_PAGES] = { |
d8d07a79 WS |
94 | #if defined(__WXUNIVERSAL__) |
95 | wxT("Universal"), | |
96 | #else | |
f2fdc4d5 | 97 | wxT("Native"), |
d8d07a79 | 98 | #endif |
f2fdc4d5 WS |
99 | wxT("Generic"), |
100 | wxT("Pickers"), | |
101 | wxT("Comboboxes"), | |
102 | wxT("With items"), | |
103 | wxT("Editable"), | |
104 | wxT("Books"), | |
105 | wxT("All controls") | |
106 | }; | |
107 | ||
32b8ec41 VZ |
108 | // ---------------------------------------------------------------------------- |
109 | // our classes | |
110 | // ---------------------------------------------------------------------------- | |
111 | ||
112 | // Define a new application type, each program should derive a class from wxApp | |
113 | class WidgetsApp : public wxApp | |
114 | { | |
115 | public: | |
116 | // override base class virtuals | |
117 | // ---------------------------- | |
118 | ||
119 | // this one is called on application startup and is a good place for the app | |
120 | // initialization (doing it here and not in the ctor allows to have an error | |
121 | // return: if OnInit() returns false, the application terminates) | |
122 | virtual bool OnInit(); | |
123 | }; | |
124 | ||
125 | // Define a new frame type: this is going to be our main frame | |
126 | class WidgetsFrame : public wxFrame | |
127 | { | |
128 | public: | |
129 | // ctor(s) and dtor | |
130 | WidgetsFrame(const wxString& title); | |
131 | virtual ~WidgetsFrame(); | |
132 | ||
133 | protected: | |
134 | // event handlers | |
49abcb2f | 135 | #if USE_LOG |
32b8ec41 | 136 | void OnButtonClearLog(wxCommandEvent& event); |
49abcb2f | 137 | #endif // USE_LOG |
195df7a7 | 138 | void OnExit(wxCommandEvent& event); |
a17c1df4 | 139 | |
195df7a7 | 140 | #if wxUSE_MENUS |
3e859739 | 141 | void OnPageChanging(WidgetsBookCtrlEvent& event); |
f2fdc4d5 | 142 | void OnPageChanged(WidgetsBookCtrlEvent& event); |
3700e21b VZ |
143 | void OnGoToPage(wxCommandEvent& event); |
144 | ||
1c01dd16 VZ |
145 | #if wxUSE_TOOLTIPS |
146 | void OnSetTooltip(wxCommandEvent& event); | |
147 | #endif // wxUSE_TOOLTIPS | |
195df7a7 VZ |
148 | void OnSetFgCol(wxCommandEvent& event); |
149 | void OnSetBgCol(wxCommandEvent& event); | |
822b9009 | 150 | void OnSetFont(wxCommandEvent& event); |
a17c1df4 | 151 | void OnEnable(wxCommandEvent& event); |
1301e228 | 152 | void OnSetBorder(wxCommandEvent& event); |
e32bcef6 VZ |
153 | |
154 | void OnToggleGlobalBusyCursor(wxCommandEvent& event); | |
155 | void OnToggleBusyCursor(wxCommandEvent& event); | |
195df7a7 | 156 | #endif // wxUSE_MENUS |
32b8ec41 | 157 | |
61c083e7 WS |
158 | // initialize the book: add all pages to it |
159 | void InitBook(); | |
32b8ec41 | 160 | |
3e859739 | 161 | // return the currently selected page (never NULL) |
f2fdc4d5 WS |
162 | WidgetsPage *CurrentPage(); |
163 | ||
32b8ec41 VZ |
164 | private: |
165 | // the panel containing everything | |
166 | wxPanel *m_panel; | |
167 | ||
49abcb2f | 168 | #if USE_LOG |
32b8ec41 VZ |
169 | // the listbox for logging messages |
170 | wxListBox *m_lboxLog; | |
171 | ||
172 | // the log target we use to redirect messages to the listbox | |
173 | wxLog *m_logTarget; | |
49abcb2f | 174 | #endif // USE_LOG |
32b8ec41 | 175 | |
61c083e7 | 176 | // the book containing the test pages |
f2fdc4d5 | 177 | WidgetsBookCtrl *m_book; |
32b8ec41 | 178 | |
195df7a7 | 179 | #if wxUSE_MENUS |
822b9009 | 180 | // last chosen fg/bg colours and font |
195df7a7 VZ |
181 | wxColour m_colFg, |
182 | m_colBg; | |
822b9009 | 183 | wxFont m_font; |
195df7a7 VZ |
184 | #endif // wxUSE_MENUS |
185 | ||
be5a51fb | 186 | // any class wishing to process wxWidgets events must use this macro |
32b8ec41 VZ |
187 | DECLARE_EVENT_TABLE() |
188 | }; | |
189 | ||
49abcb2f | 190 | #if USE_LOG |
32b8ec41 VZ |
191 | // A log target which just redirects the messages to a listbox |
192 | class LboxLogger : public wxLog | |
193 | { | |
194 | public: | |
195 | LboxLogger(wxListBox *lbox, wxLog *logOld) | |
196 | { | |
197 | m_lbox = lbox; | |
198 | //m_lbox->Disable(); -- looks ugly under MSW | |
199 | m_logOld = logOld; | |
200 | } | |
201 | ||
202 | virtual ~LboxLogger() | |
203 | { | |
204 | wxLog::SetActiveTarget(m_logOld); | |
205 | } | |
206 | ||
207 | private: | |
208 | // implement sink functions | |
8c714e06 | 209 | virtual void DoLog(wxLogLevel level, const wxString& str, time_t t) |
32b8ec41 VZ |
210 | { |
211 | // don't put trace messages into listbox or we can get into infinite | |
212 | // recursion | |
213 | if ( level == wxLOG_Trace ) | |
214 | { | |
215 | if ( m_logOld ) | |
216 | { | |
217 | // cast is needed to call protected method | |
8c714e06 | 218 | ((LboxLogger *)m_logOld)->DoLog(level, str, t); |
32b8ec41 VZ |
219 | } |
220 | } | |
221 | else | |
222 | { | |
8c714e06 | 223 | wxLog::DoLog(level, str, t); |
32b8ec41 VZ |
224 | } |
225 | } | |
226 | ||
8c714e06 | 227 | virtual void DoLogString(const wxString& str, time_t WXUNUSED(t)) |
32b8ec41 VZ |
228 | { |
229 | wxString msg; | |
230 | TimeStamp(&msg); | |
8c714e06 | 231 | msg += str; |
32b8ec41 VZ |
232 | |
233 | #ifdef __WXUNIVERSAL__ | |
234 | m_lbox->AppendAndEnsureVisible(msg); | |
235 | #else // other ports don't have this method yet | |
236 | m_lbox->Append(msg); | |
237 | m_lbox->SetFirstItem(m_lbox->GetCount() - 1); | |
238 | #endif | |
239 | } | |
240 | ||
241 | // the control we use | |
242 | wxListBox *m_lbox; | |
243 | ||
244 | // the old log target | |
245 | wxLog *m_logOld; | |
246 | }; | |
49abcb2f | 247 | #endif // USE_LOG |
32b8ec41 VZ |
248 | |
249 | // array of pages | |
38d6b957 | 250 | WX_DEFINE_ARRAY_PTR(WidgetsPage *, ArrayWidgetsPage); |
32b8ec41 VZ |
251 | |
252 | // ---------------------------------------------------------------------------- | |
253 | // misc macros | |
254 | // ---------------------------------------------------------------------------- | |
255 | ||
256 | IMPLEMENT_APP(WidgetsApp) | |
257 | ||
32b8ec41 VZ |
258 | // ---------------------------------------------------------------------------- |
259 | // event tables | |
260 | // ---------------------------------------------------------------------------- | |
261 | ||
262 | BEGIN_EVENT_TABLE(WidgetsFrame, wxFrame) | |
49abcb2f | 263 | #if USE_LOG |
32b8ec41 | 264 | EVT_BUTTON(Widgets_ClearLog, WidgetsFrame::OnButtonClearLog) |
49abcb2f | 265 | #endif // USE_LOG |
195df7a7 VZ |
266 | EVT_BUTTON(Widgets_Quit, WidgetsFrame::OnExit) |
267 | ||
1c01dd16 VZ |
268 | #if wxUSE_TOOLTIPS |
269 | EVT_MENU(Widgets_SetTooltip, WidgetsFrame::OnSetTooltip) | |
270 | #endif // wxUSE_TOOLTIPS | |
271 | ||
3700e21b | 272 | #if wxUSE_MENUS |
3e859739 | 273 | EVT_WIDGETS_PAGE_CHANGING(wxID_ANY, WidgetsFrame::OnPageChanging) |
3700e21b VZ |
274 | EVT_MENU_RANGE(Widgets_GoToPage, Widgets_GoToPageLast, |
275 | WidgetsFrame::OnGoToPage) | |
276 | ||
195df7a7 VZ |
277 | EVT_MENU(Widgets_SetFgColour, WidgetsFrame::OnSetFgCol) |
278 | EVT_MENU(Widgets_SetBgColour, WidgetsFrame::OnSetBgCol) | |
822b9009 | 279 | EVT_MENU(Widgets_SetFont, WidgetsFrame::OnSetFont) |
a17c1df4 | 280 | EVT_MENU(Widgets_Enable, WidgetsFrame::OnEnable) |
1c01dd16 | 281 | |
1301e228 VZ |
282 | EVT_MENU_RANGE(Widgets_BorderNone, Widgets_BorderDefault, |
283 | WidgetsFrame::OnSetBorder) | |
284 | ||
e32bcef6 VZ |
285 | EVT_MENU(Widgets_GlobalBusyCursor, WidgetsFrame::OnToggleGlobalBusyCursor) |
286 | EVT_MENU(Widgets_BusyCursor, WidgetsFrame::OnToggleBusyCursor) | |
287 | ||
1c01dd16 | 288 | EVT_MENU(wxID_EXIT, WidgetsFrame::OnExit) |
3700e21b | 289 | #endif // wxUSE_MENUS |
32b8ec41 VZ |
290 | END_EVENT_TABLE() |
291 | ||
292 | // ============================================================================ | |
293 | // implementation | |
294 | // ============================================================================ | |
295 | ||
296 | // ---------------------------------------------------------------------------- | |
297 | // app class | |
298 | // ---------------------------------------------------------------------------- | |
299 | ||
300 | bool WidgetsApp::OnInit() | |
301 | { | |
bf188f1a | 302 | if ( !wxApp::OnInit() ) |
206d3a16 | 303 | return false; |
1bdd1007 | 304 | |
32b8ec41 VZ |
305 | // the reason for having these ifdef's is that I often run two copies of |
306 | // this sample side by side and it is useful to see which one is which | |
24e78d27 | 307 | wxString title; |
32b8ec41 | 308 | #if defined(__WXUNIVERSAL__) |
085a1f3c | 309 | title = _T("wxUniv/"); |
24e78d27 VZ |
310 | #endif |
311 | ||
312 | #if defined(__WXMSW__) | |
313 | title += _T("wxMSW"); | |
32b8ec41 | 314 | #elif defined(__WXGTK__) |
24e78d27 | 315 | title += _T("wxGTK"); |
0f9390c3 GD |
316 | #elif defined(__WXMAC__) |
317 | title += _T("wxMAC"); | |
318 | #elif defined(__WXMOTIF__) | |
319 | title += _T("wxMOTIF"); | |
027fe16c VZ |
320 | #elif __WXPALMOS5__ |
321 | title += _T("wxPALMOS5"); | |
322 | #elif __WXPALMOS6__ | |
323 | title += _T("wxPALMOS6"); | |
32b8ec41 | 324 | #else |
be5a51fb | 325 | title += _T("wxWidgets"); |
32b8ec41 | 326 | #endif |
32b8ec41 VZ |
327 | |
328 | wxFrame *frame = new WidgetsFrame(title + _T(" widgets demo")); | |
329 | frame->Show(); | |
330 | ||
331 | //wxLog::AddTraceMask(_T("listbox")); | |
332 | //wxLog::AddTraceMask(_T("scrollbar")); | |
58ec2255 | 333 | //wxLog::AddTraceMask(_T("focus")); |
32b8ec41 | 334 | |
206d3a16 | 335 | return true; |
32b8ec41 VZ |
336 | } |
337 | ||
338 | // ---------------------------------------------------------------------------- | |
339 | // WidgetsFrame construction | |
340 | // ---------------------------------------------------------------------------- | |
341 | ||
342 | WidgetsFrame::WidgetsFrame(const wxString& title) | |
1e3fc113 | 343 | : wxFrame(NULL, wxID_ANY, title) |
32b8ec41 | 344 | { |
f2fdc4d5 WS |
345 | // set the frame icon |
346 | SetIcon(wxICON(sample)); | |
347 | ||
32b8ec41 | 348 | // init everything |
49abcb2f | 349 | #if USE_LOG |
32b8ec41 VZ |
350 | m_lboxLog = (wxListBox *)NULL; |
351 | m_logTarget = (wxLog *)NULL; | |
49abcb2f | 352 | #endif // USE_LOG |
f2fdc4d5 | 353 | m_book = (WidgetsBookCtrl *)NULL; |
32b8ec41 | 354 | |
195df7a7 VZ |
355 | #if wxUSE_MENUS |
356 | // create the menubar | |
357 | wxMenuBar *mbar = new wxMenuBar; | |
358 | wxMenu *menuWidget = new wxMenu; | |
1c01dd16 VZ |
359 | #if wxUSE_TOOLTIPS |
360 | menuWidget->Append(Widgets_SetTooltip, _T("Set &tooltip...\tCtrl-T")); | |
361 | menuWidget->AppendSeparator(); | |
362 | #endif // wxUSE_TOOLTIPS | |
195df7a7 VZ |
363 | menuWidget->Append(Widgets_SetFgColour, _T("Set &foreground...\tCtrl-F")); |
364 | menuWidget->Append(Widgets_SetBgColour, _T("Set &background...\tCtrl-B")); | |
822b9009 | 365 | menuWidget->Append(Widgets_SetFont, _T("Set f&ont...\tCtrl-O")); |
a17c1df4 | 366 | menuWidget->AppendCheckItem(Widgets_Enable, _T("&Enable/disable\tCtrl-E")); |
1301e228 VZ |
367 | |
368 | wxMenu *menuBorders = new wxMenu; | |
369 | menuBorders->AppendRadioItem(Widgets_BorderDefault, _T("De&fault\tCtrl-Shift-9")); | |
370 | menuBorders->AppendRadioItem(Widgets_BorderNone, _T("&None\tCtrl-Shift-0")); | |
371 | menuBorders->AppendRadioItem(Widgets_BorderSimple, _T("&Simple\tCtrl-Shift-1")); | |
372 | menuBorders->AppendRadioItem(Widgets_BorderDouble, _T("&Double\tCtrl-Shift-2")); | |
373 | menuBorders->AppendRadioItem(Widgets_BorderStatic, _T("Stati&c\tCtrl-Shift-3")); | |
374 | menuBorders->AppendRadioItem(Widgets_BorderRaised, _T("&Raised\tCtrl-Shift-4")); | |
375 | menuBorders->AppendRadioItem(Widgets_BorderSunken, _T("S&unken\tCtrl-Shift-5")); | |
376 | menuWidget->AppendSubMenu(menuBorders, _T("Set &border")); | |
377 | ||
e32bcef6 VZ |
378 | menuWidget->AppendSeparator(); |
379 | menuWidget->AppendCheckItem(Widgets_GlobalBusyCursor, | |
380 | _T("Toggle &global busy cursor\tCtrl-Shift-U")); | |
381 | menuWidget->AppendCheckItem(Widgets_BusyCursor, | |
382 | _T("Toggle b&usy cursor\tCtrl-U")); | |
383 | ||
195df7a7 VZ |
384 | menuWidget->AppendSeparator(); |
385 | menuWidget->Append(wxID_EXIT, _T("&Quit\tCtrl-Q")); | |
386 | mbar->Append(menuWidget, _T("&Widget")); | |
387 | SetMenuBar(mbar); | |
a17c1df4 VZ |
388 | |
389 | mbar->Check(Widgets_Enable, true); | |
195df7a7 VZ |
390 | #endif // wxUSE_MENUS |
391 | ||
32b8ec41 | 392 | // create controls |
1e3fc113 | 393 | m_panel = new wxPanel(this, wxID_ANY); |
32b8ec41 VZ |
394 | |
395 | wxSizer *sizerTop = new wxBoxSizer(wxVERTICAL); | |
396 | ||
25057aba | 397 | // we have 2 panes: book with pages demonstrating the controls in the |
32b8ec41 | 398 | // upper one and the log window with some buttons in the lower |
1bdd1007 | 399 | |
1e3fc113 | 400 | int style = wxBK_DEFAULT; |
25057aba | 401 | // Uncomment to suppress page theme (draw in solid colour) |
8c9f8f91 | 402 | //style |= wxNB_NOPAGETHEME; |
32b8ec41 | 403 | |
f2fdc4d5 | 404 | m_book = new WidgetsBookCtrl(m_panel, Widgets_BookCtrl, wxDefaultPosition, |
6bae6726 | 405 | #ifdef __WXMOTIF__ |
2ddb4d13 | 406 | wxSize(500, wxDefaultCoord), // under Motif, height is a function of the width... |
6bae6726 MB |
407 | #else |
408 | wxDefaultSize, | |
409 | #endif | |
410 | style); | |
61c083e7 | 411 | InitBook(); |
32b8ec41 | 412 | |
261357eb | 413 | #ifndef __WXHANDHELD__ |
32b8ec41 | 414 | // the lower one only has the log listbox and a button to clear it |
49abcb2f | 415 | #if USE_LOG |
206d3a16 JS |
416 | wxSizer *sizerDown = new wxStaticBoxSizer( |
417 | new wxStaticBox( m_panel, wxID_ANY, _T("&Log window") ), | |
418 | wxVERTICAL); | |
419 | ||
420 | m_lboxLog = new wxListBox(m_panel, wxID_ANY); | |
32b8ec41 | 421 | sizerDown->Add(m_lboxLog, 1, wxGROW | wxALL, 5); |
7b127900 | 422 | sizerDown->SetMinSize(100, 150); |
b29903d4 WS |
423 | #else |
424 | wxSizer *sizerDown = new wxBoxSizer(wxVERTICAL); | |
49abcb2f | 425 | #endif // USE_LOG |
88633ca7 | 426 | |
32b8ec41 | 427 | wxBoxSizer *sizerBtns = new wxBoxSizer(wxHORIZONTAL); |
b29903d4 | 428 | wxButton *btn; |
49abcb2f | 429 | #if USE_LOG |
b29903d4 | 430 | btn = new wxButton(m_panel, Widgets_ClearLog, _T("Clear &log")); |
32b8ec41 VZ |
431 | sizerBtns->Add(btn); |
432 | sizerBtns->Add(10, 0); // spacer | |
49abcb2f | 433 | #endif // USE_LOG |
32b8ec41 VZ |
434 | btn = new wxButton(m_panel, Widgets_Quit, _T("E&xit")); |
435 | sizerBtns->Add(btn); | |
436 | sizerDown->Add(sizerBtns, 0, wxALL | wxALIGN_RIGHT, 5); | |
437 | ||
438 | // put everything together | |
61c083e7 | 439 | sizerTop->Add(m_book, 1, wxGROW | (wxALL & ~(wxTOP | wxBOTTOM)), 10); |
32b8ec41 VZ |
440 | sizerTop->Add(0, 5, 0, wxGROW); // spacer in between |
441 | sizerTop->Add(sizerDown, 0, wxGROW | (wxALL & ~wxTOP), 10); | |
442 | ||
261357eb | 443 | #else // !__WXHANDHELD__/__WXHANDHELD__ |
49abcb2f WS |
444 | |
445 | sizerTop->Add(m_book, 1, wxGROW | wxALL ); | |
446 | ||
261357eb | 447 | #endif // __WXHANDHELD__ |
49abcb2f | 448 | |
32b8ec41 VZ |
449 | m_panel->SetSizer(sizerTop); |
450 | ||
32b8ec41 VZ |
451 | sizerTop->SetSizeHints(this); |
452 | ||
49abcb2f | 453 | #if USE_LOG && !defined(__WXCOCOA__) |
7bb70733 | 454 | // wxCocoa's listbox is too flakey to use for logging right now |
32b8ec41 VZ |
455 | // now that everything is created we can redirect the log messages to the |
456 | // listbox | |
457 | m_logTarget = new LboxLogger(m_lboxLog, wxLog::GetActiveTarget()); | |
458 | wxLog::SetActiveTarget(m_logTarget); | |
b29903d4 | 459 | #endif |
32b8ec41 VZ |
460 | } |
461 | ||
61c083e7 | 462 | void WidgetsFrame::InitBook() |
32b8ec41 | 463 | { |
261357eb | 464 | #if USE_ICONS_IN_BOOK |
993b016d | 465 | wxImageList *imageList = new wxImageList(ICON_SIZE, ICON_SIZE); |
32b8ec41 | 466 | |
993b016d VZ |
467 | wxImage img(sample_xpm); |
468 | imageList->Add(wxBitmap(img.Scale(ICON_SIZE, ICON_SIZE))); | |
261357eb WS |
469 | #else |
470 | wxImageList *imageList = NULL; | |
471 | #endif | |
f2fdc4d5 WS |
472 | |
473 | #if !USE_TREEBOOK | |
474 | WidgetsBookCtrl *books[MAX_PAGES]; | |
475 | #endif | |
476 | ||
477 | ArrayWidgetsPage pages[MAX_PAGES]; | |
478 | wxArrayString labels[MAX_PAGES]; | |
32b8ec41 | 479 | |
3700e21b | 480 | wxMenu *menuPages = new wxMenu; |
f2fdc4d5 WS |
481 | unsigned int nPage = 0, nFKey = 0; |
482 | int cat, imageId = 1; | |
3700e21b | 483 | |
61c083e7 | 484 | // we need to first create all pages and only then add them to the book |
32b8ec41 | 485 | // as we need the image list first |
3700e21b VZ |
486 | // |
487 | // we also construct the pages menu during this first iteration | |
f2fdc4d5 | 488 | for ( cat = 0; cat < MAX_PAGES; cat++ ) |
32b8ec41 | 489 | { |
f2fdc4d5 WS |
490 | #if USE_TREEBOOK |
491 | nPage++; // increase for parent page | |
492 | #else | |
261357eb WS |
493 | books[cat] = new WidgetsBookCtrl(m_book, |
494 | wxID_ANY, | |
495 | wxDefaultPosition, | |
496 | wxDefaultSize, | |
895cc205 | 497 | wxBK_DEFAULT); |
f2fdc4d5 WS |
498 | #endif |
499 | ||
500 | for ( WidgetsPageInfo *info = WidgetsPage::ms_widgetPages; | |
501 | info; | |
502 | info = info->GetNext() ) | |
503 | { | |
504 | if( (info->GetCategories() & ( 1 << cat )) == 0) | |
505 | continue; | |
506 | ||
507 | WidgetsPage *page = (*info->GetCtor())( | |
508 | #if USE_TREEBOOK | |
509 | m_book | |
510 | #else | |
511 | books[cat] | |
512 | #endif | |
513 | , imageList); | |
514 | pages[cat].Add(page); | |
515 | ||
516 | labels[cat].Add(info->GetLabel()); | |
517 | if ( cat == ALL_PAGE ) | |
518 | { | |
519 | wxString radioLabel(info->GetLabel()); | |
520 | nFKey++; | |
521 | if ( nFKey <= 12 ) | |
522 | { | |
523 | radioLabel << wxT("\tF" ) << nFKey; | |
524 | } | |
525 | ||
526 | menuPages->AppendRadioItem( | |
527 | Widgets_GoToPage + nPage, | |
528 | radioLabel | |
529 | ); | |
530 | #if !USE_TREEBOOK | |
531 | // consider only for book in book architecture | |
532 | nPage++; | |
533 | #endif | |
534 | } | |
535 | ||
536 | #if USE_TREEBOOK | |
537 | // consider only for treebook architecture (with subpages) | |
538 | nPage++; | |
539 | #endif | |
540 | } | |
32b8ec41 VZ |
541 | } |
542 | ||
3700e21b VZ |
543 | GetMenuBar()->Append(menuPages, _T("&Page")); |
544 | ||
261357eb | 545 | #if USE_ICONS_IN_BOOK |
f2fdc4d5 | 546 | m_book->AssignImageList(imageList); |
261357eb | 547 | #endif |
32b8ec41 | 548 | |
f2fdc4d5 | 549 | for ( cat = 0; cat < MAX_PAGES; cat++ ) |
32b8ec41 | 550 | { |
f2fdc4d5 WS |
551 | #if USE_TREEBOOK |
552 | m_book->AddPage(NULL,WidgetsCategories[cat],false,0); | |
553 | #else | |
554 | m_book->AddPage(books[cat],WidgetsCategories[cat],false,0); | |
261357eb | 555 | #if USE_ICONS_IN_BOOK |
f2fdc4d5 | 556 | books[cat]->SetImageList(imageList); |
261357eb | 557 | #endif |
f2fdc4d5 WS |
558 | #endif |
559 | ||
560 | // now do add them | |
561 | size_t count = pages[cat].GetCount(); | |
562 | for ( size_t n = 0; n < count; n++ ) | |
563 | { | |
564 | #if USE_TREEBOOK | |
3e859739 | 565 | m_book->AddSubPage |
f2fdc4d5 | 566 | #else |
3e859739 | 567 | books[cat]->AddPage |
f2fdc4d5 | 568 | #endif |
3e859739 | 569 | ( |
f2fdc4d5 WS |
570 | pages[cat][n], |
571 | labels[cat][n], | |
572 | false, // don't select | |
573 | imageId++ | |
574 | ); | |
575 | } | |
32b8ec41 | 576 | } |
f2fdc4d5 | 577 | |
0cebbfc2 WS |
578 | Connect( wxID_ANY, |
579 | wxEVT_COMMAND_WIDGETS_PAGE_CHANGED, | |
580 | wxWidgetsbookEventHandler(WidgetsFrame::OnPageChanged) ); | |
581 | ||
f2fdc4d5 | 582 | #if USE_TREEBOOK |
3e859739 VZ |
583 | // for treebook page #0 is empty parent page only so select the first page |
584 | // with some contents | |
f2fdc4d5 | 585 | m_book->SetSelection(1); |
3e859739 VZ |
586 | |
587 | // but ensure that the top of the tree is shown nevertheless | |
588 | wxTreeCtrl * const tree = m_book->GetTreeCtrl(); | |
23c2b62b VZ |
589 | |
590 | wxTreeItemIdValue cookie; | |
591 | tree->EnsureVisible(tree->GetFirstChild(tree->GetRootItem(), cookie)); | |
0cebbfc2 WS |
592 | #else |
593 | // for other books set selection twice to force connected event handler | |
594 | // to force lazy creation of initial visible content | |
595 | m_book->SetSelection(1); | |
596 | m_book->SetSelection(0); | |
3e859739 | 597 | #endif // USE_TREEBOOK |
f2fdc4d5 WS |
598 | } |
599 | ||
600 | WidgetsPage *WidgetsFrame::CurrentPage() | |
601 | { | |
453535a7 | 602 | wxWindow *page = m_book->GetCurrentPage(); |
453535a7 | 603 | |
3e859739 | 604 | #if !USE_TREEBOOK |
453535a7 | 605 | WidgetsBookCtrl *subBook = wxStaticCast(page, WidgetsBookCtrl); |
3e859739 VZ |
606 | wxCHECK_MSG( subBook, NULL, _T("no WidgetsBookCtrl?") ); |
607 | ||
453535a7 | 608 | page = subBook->GetCurrentPage(); |
3e859739 VZ |
609 | #endif // !USE_TREEBOOK |
610 | ||
453535a7 | 611 | return wxStaticCast(page, WidgetsPage); |
32b8ec41 VZ |
612 | } |
613 | ||
614 | WidgetsFrame::~WidgetsFrame() | |
615 | { | |
49abcb2f | 616 | #if USE_LOG |
32b8ec41 | 617 | delete m_logTarget; |
49abcb2f | 618 | #endif // USE_LOG |
32b8ec41 VZ |
619 | } |
620 | ||
621 | // ---------------------------------------------------------------------------- | |
622 | // WidgetsFrame event handlers | |
623 | // ---------------------------------------------------------------------------- | |
624 | ||
195df7a7 | 625 | void WidgetsFrame::OnExit(wxCommandEvent& WXUNUSED(event)) |
32b8ec41 VZ |
626 | { |
627 | Close(); | |
628 | } | |
629 | ||
49abcb2f | 630 | #if USE_LOG |
c02e5a31 | 631 | void WidgetsFrame::OnButtonClearLog(wxCommandEvent& WXUNUSED(event)) |
32b8ec41 VZ |
632 | { |
633 | m_lboxLog->Clear(); | |
634 | } | |
49abcb2f | 635 | #endif // USE_LOG |
32b8ec41 | 636 | |
195df7a7 VZ |
637 | #if wxUSE_MENUS |
638 | ||
3e859739 VZ |
639 | void WidgetsFrame::OnPageChanging(WidgetsBookCtrlEvent& event) |
640 | { | |
0cebbfc2 WS |
641 | #if USE_TREEBOOK |
642 | // don't allow selection of entries without pages (categories) | |
3e859739 VZ |
643 | if ( !m_book->GetPage(event.GetSelection()) ) |
644 | event.Veto(); | |
b2b98dfd WS |
645 | #else |
646 | wxUnusedVar(event); | |
0cebbfc2 | 647 | #endif |
3e859739 VZ |
648 | } |
649 | ||
f2fdc4d5 | 650 | void WidgetsFrame::OnPageChanged(WidgetsBookCtrlEvent& event) |
3700e21b | 651 | { |
3e859739 VZ |
652 | const int sel = event.GetSelection(); |
653 | ||
453535a7 | 654 | // adjust "Page" menu selection |
3e859739 VZ |
655 | wxMenuItem *item = GetMenuBar()->FindItem(Widgets_GoToPage + sel); |
656 | if ( item ) | |
657 | item->Check(); | |
453535a7 | 658 | |
fe24a945 VZ |
659 | GetMenuBar()->Check(Widgets_BusyCursor, false); |
660 | ||
be16b859 VZ |
661 | // create the pages on demand, otherwise the sample startup is too slow as |
662 | // it creates hundreds of controls | |
3e859739 VZ |
663 | WidgetsPage *page = CurrentPage(); |
664 | if ( page->GetChildren().empty() ) | |
453535a7 WS |
665 | { |
666 | wxWindowUpdateLocker noUpdates(page); | |
667 | page->CreateContent(); | |
be16b859 VZ |
668 | //page->Layout(); |
669 | page->GetSizer()->Fit(page); | |
670 | ||
453535a7 WS |
671 | WidgetsBookCtrl *book = wxStaticCast(page->GetParent(), WidgetsBookCtrl); |
672 | wxSize size; | |
673 | for ( size_t i = 0; i < book->GetPageCount(); ++i ) | |
674 | { | |
675 | wxWindow *page = book->GetPage(i); | |
3e859739 | 676 | if ( page ) |
453535a7 WS |
677 | { |
678 | size.IncTo(page->GetSize()); | |
679 | } | |
680 | } | |
681 | page->SetSize(size); | |
682 | } | |
683 | ||
3700e21b VZ |
684 | event.Skip(); |
685 | } | |
686 | ||
687 | void WidgetsFrame::OnGoToPage(wxCommandEvent& event) | |
688 | { | |
f2fdc4d5 | 689 | #if USE_TREEBOOK |
3700e21b | 690 | m_book->SetSelection(event.GetId() - Widgets_GoToPage); |
f2fdc4d5 WS |
691 | #else |
692 | m_book->SetSelection(m_book->GetPageCount()-1); | |
693 | WidgetsBookCtrl *book = wxStaticCast(m_book->GetCurrentPage(), WidgetsBookCtrl); | |
694 | book->SetSelection(event.GetId() - Widgets_GoToPage); | |
695 | #endif | |
3700e21b VZ |
696 | } |
697 | ||
1c01dd16 VZ |
698 | #if wxUSE_TOOLTIPS |
699 | ||
700 | void WidgetsFrame::OnSetTooltip(wxCommandEvent& WXUNUSED(event)) | |
701 | { | |
702 | static wxString s_tip = _T("This is a tooltip"); | |
703 | ||
60c84f85 VZ |
704 | wxTextEntryDialog dialog |
705 | ( | |
706 | this, | |
707 | _T("Tooltip text (may use \\n, leave empty to remove): "), | |
708 | _T("Widgets sample"), | |
709 | s_tip | |
710 | ); | |
711 | ||
712 | if ( dialog.ShowModal() != wxID_OK ) | |
1c01dd16 VZ |
713 | return; |
714 | ||
60c84f85 | 715 | s_tip = dialog.GetValue(); |
0c113874 | 716 | s_tip.Replace(_T("\\n"), _T("\n")); |
bd018e7e | 717 | |
3e859739 VZ |
718 | WidgetsPage *page = CurrentPage(); |
719 | ||
60c84f85 | 720 | page->GetWidget()->SetToolTip(s_tip); |
1c01dd16 VZ |
721 | |
722 | wxControl *ctrl2 = page->GetWidget2(); | |
723 | if ( ctrl2 ) | |
60c84f85 | 724 | ctrl2->SetToolTip(s_tip); |
1c01dd16 VZ |
725 | } |
726 | ||
727 | #endif // wxUSE_TOOLTIPS | |
728 | ||
195df7a7 VZ |
729 | void WidgetsFrame::OnSetFgCol(wxCommandEvent& WXUNUSED(event)) |
730 | { | |
923f4e79 | 731 | #if wxUSE_COLOURDLG |
822b9009 | 732 | // allow for debugging the default colour the first time this is called |
f2fdc4d5 | 733 | WidgetsPage *page = CurrentPage(); |
63da71ba | 734 | |
822b9009 VZ |
735 | if (!m_colFg.Ok()) |
736 | m_colFg = page->GetForegroundColour(); | |
737 | ||
195df7a7 VZ |
738 | wxColour col = wxGetColourFromUser(this, m_colFg); |
739 | if ( !col.Ok() ) | |
740 | return; | |
741 | ||
742 | m_colFg = col; | |
743 | ||
195df7a7 | 744 | page->GetWidget()->SetForegroundColour(m_colFg); |
750972ab | 745 | page->GetWidget()->Refresh(); |
1c01dd16 VZ |
746 | |
747 | wxControl *ctrl2 = page->GetWidget2(); | |
748 | if ( ctrl2 ) | |
749 | { | |
750 | ctrl2->SetForegroundColour(m_colFg); | |
751 | ctrl2->Refresh(); | |
752 | } | |
923f4e79 | 753 | #else |
1c01dd16 | 754 | wxLogMessage(_T("Colour selection dialog not available in current build.")); |
923f4e79 | 755 | #endif |
195df7a7 VZ |
756 | } |
757 | ||
758 | void WidgetsFrame::OnSetBgCol(wxCommandEvent& WXUNUSED(event)) | |
759 | { | |
923f4e79 | 760 | #if wxUSE_COLOURDLG |
f2fdc4d5 | 761 | WidgetsPage *page = CurrentPage(); |
63da71ba | 762 | |
822b9009 VZ |
763 | if ( !m_colBg.Ok() ) |
764 | m_colBg = page->GetBackgroundColour(); | |
765 | ||
195df7a7 VZ |
766 | wxColour col = wxGetColourFromUser(this, m_colBg); |
767 | if ( !col.Ok() ) | |
768 | return; | |
769 | ||
770 | m_colBg = col; | |
771 | ||
195df7a7 | 772 | page->GetWidget()->SetBackgroundColour(m_colBg); |
750972ab | 773 | page->GetWidget()->Refresh(); |
1c01dd16 VZ |
774 | |
775 | wxControl *ctrl2 = page->GetWidget2(); | |
776 | if ( ctrl2 ) | |
777 | { | |
778 | ctrl2->SetBackgroundColour(m_colFg); | |
779 | ctrl2->Refresh(); | |
780 | } | |
923f4e79 | 781 | #else |
1c01dd16 | 782 | wxLogMessage(_T("Colour selection dialog not available in current build.")); |
923f4e79 | 783 | #endif |
195df7a7 VZ |
784 | } |
785 | ||
822b9009 VZ |
786 | void WidgetsFrame::OnSetFont(wxCommandEvent& WXUNUSED(event)) |
787 | { | |
788 | #if wxUSE_FONTDLG | |
f2fdc4d5 | 789 | WidgetsPage *page = CurrentPage(); |
63da71ba | 790 | |
822b9009 VZ |
791 | if (!m_font.Ok()) |
792 | m_font = page->GetFont(); | |
793 | ||
794 | wxFont font = wxGetFontFromUser(this, m_font); | |
795 | if ( !font.Ok() ) | |
796 | return; | |
797 | ||
798 | m_font = font; | |
799 | ||
800 | page->GetWidget()->SetFont(m_font); | |
801 | page->GetWidget()->Refresh(); | |
802 | ||
803 | wxControl *ctrl2 = page->GetWidget2(); | |
804 | if ( ctrl2 ) | |
805 | { | |
806 | ctrl2->SetFont(m_font); | |
807 | ctrl2->Refresh(); | |
808 | } | |
809 | #else | |
810 | wxLogMessage(_T("Font selection dialog not available in current build.")); | |
811 | #endif | |
812 | } | |
813 | ||
a17c1df4 VZ |
814 | void WidgetsFrame::OnEnable(wxCommandEvent& event) |
815 | { | |
3e859739 | 816 | CurrentPage()->GetWidget()->Enable(event.IsChecked()); |
a17c1df4 VZ |
817 | } |
818 | ||
1301e228 VZ |
819 | void WidgetsFrame::OnSetBorder(wxCommandEvent& event) |
820 | { | |
821 | int border; | |
822 | switch ( event.GetId() ) | |
823 | { | |
824 | case Widgets_BorderNone: border = wxBORDER_NONE; break; | |
825 | case Widgets_BorderStatic: border = wxBORDER_STATIC; break; | |
826 | case Widgets_BorderSimple: border = wxBORDER_SIMPLE; break; | |
827 | case Widgets_BorderRaised: border = wxBORDER_RAISED; break; | |
828 | case Widgets_BorderSunken: border = wxBORDER_SUNKEN; break; | |
829 | case Widgets_BorderDouble: border = wxBORDER_DOUBLE; break; | |
830 | ||
831 | default: | |
832 | wxFAIL_MSG( _T("unknown border style") ); | |
833 | // fall through | |
834 | ||
835 | case Widgets_BorderDefault: border = wxBORDER_DEFAULT; break; | |
836 | } | |
837 | ||
838 | WidgetsPage::ms_defaultFlags &= ~wxBORDER_MASK; | |
839 | WidgetsPage::ms_defaultFlags |= border; | |
840 | ||
f2fdc4d5 | 841 | WidgetsPage *page = CurrentPage(); |
63da71ba | 842 | |
1301e228 VZ |
843 | page->RecreateWidget(); |
844 | } | |
845 | ||
e32bcef6 VZ |
846 | void WidgetsFrame::OnToggleGlobalBusyCursor(wxCommandEvent& event) |
847 | { | |
848 | if ( event.IsChecked() ) | |
849 | wxBeginBusyCursor(); | |
850 | else | |
851 | wxEndBusyCursor(); | |
852 | } | |
853 | ||
854 | void WidgetsFrame::OnToggleBusyCursor(wxCommandEvent& event) | |
855 | { | |
3e859739 VZ |
856 | CurrentPage()->GetWidget()->SetCursor(*(event.IsChecked() |
857 | ? wxHOURGLASS_CURSOR | |
858 | : wxSTANDARD_CURSOR)); | |
e32bcef6 VZ |
859 | } |
860 | ||
195df7a7 VZ |
861 | #endif // wxUSE_MENUS |
862 | ||
32b8ec41 VZ |
863 | // ---------------------------------------------------------------------------- |
864 | // WidgetsPageInfo | |
865 | // ---------------------------------------------------------------------------- | |
866 | ||
f2fdc4d5 | 867 | WidgetsPageInfo::WidgetsPageInfo(Constructor ctor, const wxChar *label, int categories) |
32b8ec41 | 868 | : m_label(label) |
f2fdc4d5 | 869 | , m_categories(categories) |
32b8ec41 VZ |
870 | { |
871 | m_ctor = ctor; | |
872 | ||
2673bcb0 DS |
873 | m_next = NULL; |
874 | ||
fdfe568d | 875 | // dummy sorting: add and immediately sort in the list according to label |
3700e21b | 876 | if ( WidgetsPage::ms_widgetPages ) |
2673bcb0 DS |
877 | { |
878 | WidgetsPageInfo *node_prev = WidgetsPage::ms_widgetPages; | |
fdfe568d | 879 | if ( wxStrcmp(label, node_prev->GetLabel().c_str()) < 0 ) |
2673bcb0 DS |
880 | { |
881 | // add as first | |
882 | m_next = node_prev; | |
883 | WidgetsPage::ms_widgetPages = this; | |
884 | } | |
885 | else | |
886 | { | |
887 | WidgetsPageInfo *node_next; | |
888 | do | |
889 | { | |
890 | node_next = node_prev->GetNext(); | |
fdfe568d | 891 | if ( node_next ) |
2673bcb0 DS |
892 | { |
893 | // add if between two | |
fdfe568d | 894 | if ( wxStrcmp(label, node_next->GetLabel().c_str()) < 0 ) |
2673bcb0 DS |
895 | { |
896 | node_prev->SetNext(this); | |
897 | m_next = node_next; | |
898 | // force to break loop | |
899 | node_next = NULL; | |
900 | } | |
901 | } | |
902 | else | |
903 | { | |
904 | // add as last | |
905 | node_prev->SetNext(this); | |
906 | m_next = node_next; | |
907 | } | |
908 | node_prev = node_next; | |
fdfe568d VZ |
909 | } |
910 | while ( node_next ); | |
2673bcb0 DS |
911 | } |
912 | } | |
913 | else | |
914 | { | |
915 | // add when first | |
2673bcb0 | 916 | WidgetsPage::ms_widgetPages = this; |
2673bcb0 | 917 | } |
32b8ec41 VZ |
918 | } |
919 | ||
920 | // ---------------------------------------------------------------------------- | |
921 | // WidgetsPage | |
922 | // ---------------------------------------------------------------------------- | |
923 | ||
1301e228 VZ |
924 | int WidgetsPage::ms_defaultFlags = wxBORDER_DEFAULT; |
925 | WidgetsPageInfo *WidgetsPage::ms_widgetPages = NULL; | |
926 | ||
261357eb WS |
927 | WidgetsPage::WidgetsPage(WidgetsBookCtrl *book, |
928 | wxImageList *imaglist, | |
747d7d7c | 929 | const char *const icon[]) |
61c083e7 | 930 | : wxPanel(book, wxID_ANY, |
df0787b6 VZ |
931 | wxDefaultPosition, wxDefaultSize, |
932 | wxNO_FULL_REPAINT_ON_RESIZE | | |
933 | wxCLIP_CHILDREN | | |
934 | wxTAB_TRAVERSAL) | |
32b8ec41 | 935 | { |
261357eb | 936 | #if USE_ICONS_IN_BOOK |
993b016d | 937 | imaglist->Add(wxBitmap(wxImage(icon).Scale(ICON_SIZE, ICON_SIZE))); |
261357eb WS |
938 | #else |
939 | wxUnusedVar(imaglist); | |
940 | wxUnusedVar(icon); | |
941 | #endif | |
32b8ec41 VZ |
942 | } |
943 | ||
944 | wxSizer *WidgetsPage::CreateSizerWithText(wxControl *control, | |
945 | wxWindowID id, | |
946 | wxTextCtrl **ppText) | |
947 | { | |
948 | wxSizer *sizerRow = new wxBoxSizer(wxHORIZONTAL); | |
206d3a16 JS |
949 | wxTextCtrl *text = new wxTextCtrl(this, id, wxEmptyString, |
950 | wxDefaultPosition, wxDefaultSize, wxTE_PROCESS_ENTER); | |
4589ec39 | 951 | |
32b8ec41 VZ |
952 | sizerRow->Add(control, 0, wxRIGHT | wxALIGN_CENTRE_VERTICAL, 5); |
953 | sizerRow->Add(text, 1, wxLEFT | wxALIGN_CENTRE_VERTICAL, 5); | |
954 | ||
955 | if ( ppText ) | |
956 | *ppText = text; | |
957 | ||
958 | return sizerRow; | |
959 | } | |
960 | ||
961 | // create a sizer containing a label and a text ctrl | |
962 | wxSizer *WidgetsPage::CreateSizerWithTextAndLabel(const wxString& label, | |
963 | wxWindowID id, | |
964 | wxTextCtrl **ppText) | |
965 | { | |
206d3a16 JS |
966 | return CreateSizerWithText(new wxStaticText(this, wxID_ANY, label), |
967 | id, ppText); | |
32b8ec41 VZ |
968 | } |
969 | ||
970 | // create a sizer containing a button and a text ctrl | |
971 | wxSizer *WidgetsPage::CreateSizerWithTextAndButton(wxWindowID idBtn, | |
972 | const wxString& label, | |
973 | wxWindowID id, | |
974 | wxTextCtrl **ppText) | |
975 | { | |
976 | return CreateSizerWithText(new wxButton(this, idBtn, label), id, ppText); | |
977 | } | |
978 | ||
979 | wxCheckBox *WidgetsPage::CreateCheckBoxAndAddToSizer(wxSizer *sizer, | |
980 | const wxString& label, | |
981 | wxWindowID id) | |
982 | { | |
983 | wxCheckBox *checkbox = new wxCheckBox(this, id, label); | |
984 | sizer->Add(checkbox, 0, wxLEFT | wxRIGHT, 5); | |
985 | sizer->Add(0, 2, 0, wxGROW); // spacer | |
986 | ||
987 | return checkbox; | |
988 | } |