no changes, just removed some commented out code
[wxWidgets.git] / samples / widgets / widgets.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Program: wxWidgets Widgets Sample
3 // Name: samples/widgets/widgets.cpp
4 // Purpose: Sample showing most of the simple wxWidgets widgets
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"
31 #include "wx/frame.h"
32 #include "wx/menu.h"
33
34 #include "wx/button.h"
35 #include "wx/checkbox.h"
36 #include "wx/listbox.h"
37 #include "wx/statbox.h"
38 #include "wx/stattext.h"
39 #include "wx/textctrl.h"
40 #include "wx/msgdlg.h"
41 #endif
42
43 #include "wx/sysopt.h"
44 #include "wx/bookctrl.h"
45 #include "wx/sizer.h"
46 #include "wx/colordlg.h"
47 #include "wx/fontdlg.h"
48 #include "wx/textdlg.h"
49
50 #include "widgets.h"
51
52 // ----------------------------------------------------------------------------
53 // constants
54 // ----------------------------------------------------------------------------
55
56 // control ids
57 enum
58 {
59 Widgets_ClearLog = 100,
60 Widgets_Quit,
61
62 #if wxUSE_TOOLTIPS
63 Widgets_SetTooltip,
64 #endif // wxUSE_TOOLTIPS
65 Widgets_SetFgColour,
66 Widgets_SetBgColour,
67 Widgets_SetFont,
68 Widgets_Enable,
69
70 Widgets_BorderNone,
71 Widgets_BorderStatic,
72 Widgets_BorderSimple,
73 Widgets_BorderRaised,
74 Widgets_BorderSunken,
75 Widgets_BorderDouble,
76 Widgets_BorderDefault
77 };
78
79 // ----------------------------------------------------------------------------
80 // our classes
81 // ----------------------------------------------------------------------------
82
83 // Define a new application type, each program should derive a class from wxApp
84 class WidgetsApp : public wxApp
85 {
86 public:
87 // override base class virtuals
88 // ----------------------------
89
90 // this one is called on application startup and is a good place for the app
91 // initialization (doing it here and not in the ctor allows to have an error
92 // return: if OnInit() returns false, the application terminates)
93 virtual bool OnInit();
94 };
95
96 // Define a new frame type: this is going to be our main frame
97 class WidgetsFrame : public wxFrame
98 {
99 public:
100 // ctor(s) and dtor
101 WidgetsFrame(const wxString& title);
102 virtual ~WidgetsFrame();
103
104 protected:
105 // event handlers
106 #if USE_LOG
107 void OnButtonClearLog(wxCommandEvent& event);
108 #endif // USE_LOG
109 void OnExit(wxCommandEvent& event);
110
111 #if wxUSE_MENUS
112 #if wxUSE_TOOLTIPS
113 void OnSetTooltip(wxCommandEvent& event);
114 #endif // wxUSE_TOOLTIPS
115 void OnSetFgCol(wxCommandEvent& event);
116 void OnSetBgCol(wxCommandEvent& event);
117 void OnSetFont(wxCommandEvent& event);
118 void OnEnable(wxCommandEvent& event);
119 void OnSetBorder(wxCommandEvent& event);
120 #endif // wxUSE_MENUS
121
122 // initialize the book: add all pages to it
123 void InitBook();
124
125 private:
126 // the panel containing everything
127 wxPanel *m_panel;
128
129 #if USE_LOG
130 // the listbox for logging messages
131 wxListBox *m_lboxLog;
132
133 // the log target we use to redirect messages to the listbox
134 wxLog *m_logTarget;
135 #endif // USE_LOG
136
137 // the book containing the test pages
138 wxBookCtrlBase *m_book;
139
140 // and the image list for it
141 wxImageList *m_imaglist;
142
143 #if wxUSE_MENUS
144 // last chosen fg/bg colours and font
145 wxColour m_colFg,
146 m_colBg;
147 wxFont m_font;
148 #endif // wxUSE_MENUS
149
150 // any class wishing to process wxWidgets events must use this macro
151 DECLARE_EVENT_TABLE()
152 };
153
154 #if USE_LOG
155 // A log target which just redirects the messages to a listbox
156 class LboxLogger : public wxLog
157 {
158 public:
159 LboxLogger(wxListBox *lbox, wxLog *logOld)
160 {
161 m_lbox = lbox;
162 //m_lbox->Disable(); -- looks ugly under MSW
163 m_logOld = logOld;
164 }
165
166 virtual ~LboxLogger()
167 {
168 wxLog::SetActiveTarget(m_logOld);
169 }
170
171 private:
172 // implement sink functions
173 virtual void DoLog(wxLogLevel level, const wxChar *szString, time_t t)
174 {
175 // don't put trace messages into listbox or we can get into infinite
176 // recursion
177 if ( level == wxLOG_Trace )
178 {
179 if ( m_logOld )
180 {
181 // cast is needed to call protected method
182 ((LboxLogger *)m_logOld)->DoLog(level, szString, t);
183 }
184 }
185 else
186 {
187 wxLog::DoLog(level, szString, t);
188 }
189 }
190
191 virtual void DoLogString(const wxChar *szString, time_t WXUNUSED(t))
192 {
193 wxString msg;
194 TimeStamp(&msg);
195 msg += szString;
196
197 #ifdef __WXUNIVERSAL__
198 m_lbox->AppendAndEnsureVisible(msg);
199 #else // other ports don't have this method yet
200 m_lbox->Append(msg);
201 m_lbox->SetFirstItem(m_lbox->GetCount() - 1);
202 #endif
203 }
204
205 // the control we use
206 wxListBox *m_lbox;
207
208 // the old log target
209 wxLog *m_logOld;
210 };
211 #endif // USE_LOG
212
213 // array of pages
214 WX_DEFINE_ARRAY_PTR(WidgetsPage *, ArrayWidgetsPage);
215
216 // ----------------------------------------------------------------------------
217 // misc macros
218 // ----------------------------------------------------------------------------
219
220 IMPLEMENT_APP(WidgetsApp)
221
222 // ----------------------------------------------------------------------------
223 // event tables
224 // ----------------------------------------------------------------------------
225
226 BEGIN_EVENT_TABLE(WidgetsFrame, wxFrame)
227 #if USE_LOG
228 EVT_BUTTON(Widgets_ClearLog, WidgetsFrame::OnButtonClearLog)
229 #endif // USE_LOG
230 EVT_BUTTON(Widgets_Quit, WidgetsFrame::OnExit)
231
232 #if wxUSE_TOOLTIPS
233 EVT_MENU(Widgets_SetTooltip, WidgetsFrame::OnSetTooltip)
234 #endif // wxUSE_TOOLTIPS
235
236 EVT_MENU(Widgets_SetFgColour, WidgetsFrame::OnSetFgCol)
237 EVT_MENU(Widgets_SetBgColour, WidgetsFrame::OnSetBgCol)
238 EVT_MENU(Widgets_SetFont, WidgetsFrame::OnSetFont)
239 EVT_MENU(Widgets_Enable, WidgetsFrame::OnEnable)
240
241 EVT_MENU_RANGE(Widgets_BorderNone, Widgets_BorderDefault,
242 WidgetsFrame::OnSetBorder)
243
244 EVT_MENU(wxID_EXIT, WidgetsFrame::OnExit)
245 END_EVENT_TABLE()
246
247 // ============================================================================
248 // implementation
249 // ============================================================================
250
251 // ----------------------------------------------------------------------------
252 // app class
253 // ----------------------------------------------------------------------------
254
255 bool WidgetsApp::OnInit()
256 {
257 if ( !wxApp::OnInit() )
258 return false;
259
260 // the reason for having these ifdef's is that I often run two copies of
261 // this sample side by side and it is useful to see which one is which
262 wxString title;
263 #if defined(__WXUNIVERSAL__)
264 title = _T("wxUniv/");
265 #endif
266
267 #if defined(__WXMSW__)
268 title += _T("wxMSW");
269 #elif defined(__WXGTK__)
270 title += _T("wxGTK");
271 #elif defined(__WXMAC__)
272 title += _T("wxMAC");
273 #elif defined(__WXMOTIF__)
274 title += _T("wxMOTIF");
275 #else
276 title += _T("wxWidgets");
277 #endif
278
279 wxFrame *frame = new WidgetsFrame(title + _T(" widgets demo"));
280 frame->Show();
281
282 //wxLog::AddTraceMask(_T("listbox"));
283 //wxLog::AddTraceMask(_T("scrollbar"));
284 //wxLog::AddTraceMask(_T("focus"));
285
286 return true;
287 }
288
289 // ----------------------------------------------------------------------------
290 // WidgetsFrame construction
291 // ----------------------------------------------------------------------------
292
293 WidgetsFrame::WidgetsFrame(const wxString& title)
294 : wxFrame(NULL, wxID_ANY, title,
295 wxPoint(0, 50), wxDefaultSize,
296 wxDEFAULT_FRAME_STYLE |
297 wxNO_FULL_REPAINT_ON_RESIZE |
298 wxCLIP_CHILDREN |
299 wxTAB_TRAVERSAL)
300 {
301 // init everything
302 #if USE_LOG
303 m_lboxLog = (wxListBox *)NULL;
304 m_logTarget = (wxLog *)NULL;
305 #endif // USE_LOG
306 m_book = (wxBookCtrlBase *)NULL;
307 m_imaglist = (wxImageList *)NULL;
308
309 #if wxUSE_MENUS
310 // create the menubar
311 wxMenuBar *mbar = new wxMenuBar;
312 wxMenu *menuWidget = new wxMenu;
313 #if wxUSE_TOOLTIPS
314 menuWidget->Append(Widgets_SetTooltip, _T("Set &tooltip...\tCtrl-T"));
315 menuWidget->AppendSeparator();
316 #endif // wxUSE_TOOLTIPS
317 menuWidget->Append(Widgets_SetFgColour, _T("Set &foreground...\tCtrl-F"));
318 menuWidget->Append(Widgets_SetBgColour, _T("Set &background...\tCtrl-B"));
319 menuWidget->Append(Widgets_SetFont, _T("Set f&ont...\tCtrl-O"));
320 menuWidget->AppendCheckItem(Widgets_Enable, _T("&Enable/disable\tCtrl-E"));
321
322 wxMenu *menuBorders = new wxMenu;
323 menuBorders->AppendRadioItem(Widgets_BorderDefault, _T("De&fault\tCtrl-Shift-9"));
324 menuBorders->AppendRadioItem(Widgets_BorderNone, _T("&None\tCtrl-Shift-0"));
325 menuBorders->AppendRadioItem(Widgets_BorderSimple, _T("&Simple\tCtrl-Shift-1"));
326 menuBorders->AppendRadioItem(Widgets_BorderDouble, _T("&Double\tCtrl-Shift-2"));
327 menuBorders->AppendRadioItem(Widgets_BorderStatic, _T("Stati&c\tCtrl-Shift-3"));
328 menuBorders->AppendRadioItem(Widgets_BorderRaised, _T("&Raised\tCtrl-Shift-4"));
329 menuBorders->AppendRadioItem(Widgets_BorderSunken, _T("S&unken\tCtrl-Shift-5"));
330 menuWidget->AppendSubMenu(menuBorders, _T("Set &border"));
331
332 menuWidget->AppendSeparator();
333 menuWidget->Append(wxID_EXIT, _T("&Quit\tCtrl-Q"));
334 mbar->Append(menuWidget, _T("&Widget"));
335 SetMenuBar(mbar);
336
337 mbar->Check(Widgets_Enable, true);
338 #endif // wxUSE_MENUS
339
340 // create controls
341 m_panel = new wxPanel(this, wxID_ANY,
342 wxDefaultPosition, wxDefaultSize, wxCLIP_CHILDREN);
343
344 wxSizer *sizerTop = new wxBoxSizer(wxVERTICAL);
345
346 // we have 2 panes: book with pages demonstrating the controls in the
347 // upper one and the log window with some buttons in the lower
348
349 int style = wxNO_FULL_REPAINT_ON_RESIZE|wxCLIP_CHILDREN|wxBK_DEFAULT;
350 // Uncomment to suppress page theme (draw in solid colour)
351 //style |= wxNB_NOPAGETHEME;
352
353 m_book = new wxBookCtrl(m_panel, wxID_ANY, wxDefaultPosition,
354 #ifdef __WXMOTIF__
355 wxSize(500, wxDefaultCoord), // under Motif, height is a function of the width...
356 #else
357 wxDefaultSize,
358 #endif
359 style);
360 InitBook();
361
362 #ifndef __SMARTPHONE__
363 // the lower one only has the log listbox and a button to clear it
364 #if USE_LOG
365 wxSizer *sizerDown = new wxStaticBoxSizer(
366 new wxStaticBox( m_panel, wxID_ANY, _T("&Log window") ),
367 wxVERTICAL);
368
369 m_lboxLog = new wxListBox(m_panel, wxID_ANY);
370 sizerDown->Add(m_lboxLog, 1, wxGROW | wxALL, 5);
371 sizerDown->SetMinSize(100, 150);
372 #else
373 wxSizer *sizerDown = new wxBoxSizer(wxVERTICAL);
374 #endif // USE_LOG
375
376 wxBoxSizer *sizerBtns = new wxBoxSizer(wxHORIZONTAL);
377 wxButton *btn;
378 #if USE_LOG
379 btn = new wxButton(m_panel, Widgets_ClearLog, _T("Clear &log"));
380 sizerBtns->Add(btn);
381 sizerBtns->Add(10, 0); // spacer
382 #endif // USE_LOG
383 btn = new wxButton(m_panel, Widgets_Quit, _T("E&xit"));
384 sizerBtns->Add(btn);
385 sizerDown->Add(sizerBtns, 0, wxALL | wxALIGN_RIGHT, 5);
386
387 // put everything together
388 sizerTop->Add(m_book, 1, wxGROW | (wxALL & ~(wxTOP | wxBOTTOM)), 10);
389 sizerTop->Add(0, 5, 0, wxGROW); // spacer in between
390 sizerTop->Add(sizerDown, 0, wxGROW | (wxALL & ~wxTOP), 10);
391
392 #else // !__SMARTPHONE__/__SMARTPHONE__
393
394 sizerTop->Add(m_book, 1, wxGROW | wxALL );
395
396 #endif // __SMARTPHONE__
397
398 m_panel->SetSizer(sizerTop);
399
400 sizerTop->Fit(this);
401 sizerTop->SetSizeHints(this);
402
403 #if USE_LOG && !defined(__WXCOCOA__)
404 // wxCocoa's listbox is too flakey to use for logging right now
405 // now that everything is created we can redirect the log messages to the
406 // listbox
407 m_logTarget = new LboxLogger(m_lboxLog, wxLog::GetActiveTarget());
408 wxLog::SetActiveTarget(m_logTarget);
409 #endif
410 }
411
412 void WidgetsFrame::InitBook()
413 {
414 m_imaglist = new wxImageList(32, 32);
415
416 ArrayWidgetsPage pages;
417 wxArrayString labels;
418
419 // we need to first create all pages and only then add them to the book
420 // as we need the image list first
421 WidgetsPageInfo *info = WidgetsPage::ms_widgetPages;
422 while ( info )
423 {
424 WidgetsPage *page = (*info->GetCtor())(m_book, m_imaglist);
425 pages.Add(page);
426
427 labels.Add(info->GetLabel());
428
429 info = info->GetNext();
430 }
431
432 m_book->SetImageList(m_imaglist);
433
434 // now do add them
435 size_t count = pages.GetCount();
436 for ( size_t n = 0; n < count; n++ )
437 {
438 m_book->AddPage(
439 pages[n],
440 labels[n],
441 false, // don't select
442 n // image id
443 );
444 }
445 }
446
447 WidgetsFrame::~WidgetsFrame()
448 {
449 #if USE_LOG
450 delete m_logTarget;
451 #endif // USE_LOG
452 delete m_imaglist;
453 }
454
455 // ----------------------------------------------------------------------------
456 // WidgetsFrame event handlers
457 // ----------------------------------------------------------------------------
458
459 void WidgetsFrame::OnExit(wxCommandEvent& WXUNUSED(event))
460 {
461 Close();
462 }
463
464 #if USE_LOG
465 void WidgetsFrame::OnButtonClearLog(wxCommandEvent& WXUNUSED(event))
466 {
467 m_lboxLog->Clear();
468 }
469 #endif // USE_LOG
470
471 #if wxUSE_MENUS
472
473 #if wxUSE_TOOLTIPS
474
475 void WidgetsFrame::OnSetTooltip(wxCommandEvent& WXUNUSED(event))
476 {
477 static wxString s_tip = _T("This is a tooltip");
478
479 wxString s = wxGetTextFromUser
480 (
481 _T("Tooltip text: "),
482 _T("Widgets sample"),
483 s_tip,
484 this
485 );
486
487 if ( s.empty() )
488 return;
489
490 s_tip = s;
491
492 if( wxMessageBox( _T("Test multiline tooltip text?"),
493 _T("Widgets sample"),
494 wxYES_NO,
495 this
496 ) == wxYES )
497 {
498 s = _T("#1 ") + s_tip + _T("\n") + _T("#2 ") + s_tip;
499 }
500
501 WidgetsPage *page = wxStaticCast(m_book->GetCurrentPage(), WidgetsPage);
502 page->GetWidget()->SetToolTip(s);
503
504 wxControl *ctrl2 = page->GetWidget2();
505 if ( ctrl2 )
506 ctrl2->SetToolTip(s);
507 }
508
509 #endif // wxUSE_TOOLTIPS
510
511 void WidgetsFrame::OnSetFgCol(wxCommandEvent& WXUNUSED(event))
512 {
513 #if wxUSE_COLOURDLG
514 // allow for debugging the default colour the first time this is called
515 WidgetsPage *page = wxStaticCast(m_book->GetCurrentPage(), WidgetsPage);
516 if (!m_colFg.Ok())
517 m_colFg = page->GetForegroundColour();
518
519 wxColour col = wxGetColourFromUser(this, m_colFg);
520 if ( !col.Ok() )
521 return;
522
523 m_colFg = col;
524
525 page->GetWidget()->SetForegroundColour(m_colFg);
526 page->GetWidget()->Refresh();
527
528 wxControl *ctrl2 = page->GetWidget2();
529 if ( ctrl2 )
530 {
531 ctrl2->SetForegroundColour(m_colFg);
532 ctrl2->Refresh();
533 }
534 #else
535 wxLogMessage(_T("Colour selection dialog not available in current build."));
536 #endif
537 }
538
539 void WidgetsFrame::OnSetBgCol(wxCommandEvent& WXUNUSED(event))
540 {
541 #if wxUSE_COLOURDLG
542 WidgetsPage *page = wxStaticCast(m_book->GetCurrentPage(), WidgetsPage);
543 if ( !m_colBg.Ok() )
544 m_colBg = page->GetBackgroundColour();
545
546 wxColour col = wxGetColourFromUser(this, m_colBg);
547 if ( !col.Ok() )
548 return;
549
550 m_colBg = col;
551
552 page->GetWidget()->SetBackgroundColour(m_colBg);
553 page->GetWidget()->Refresh();
554
555 wxControl *ctrl2 = page->GetWidget2();
556 if ( ctrl2 )
557 {
558 ctrl2->SetBackgroundColour(m_colFg);
559 ctrl2->Refresh();
560 }
561 #else
562 wxLogMessage(_T("Colour selection dialog not available in current build."));
563 #endif
564 }
565
566 void WidgetsFrame::OnSetFont(wxCommandEvent& WXUNUSED(event))
567 {
568 #if wxUSE_FONTDLG
569 WidgetsPage *page = wxStaticCast(m_book->GetCurrentPage(), WidgetsPage);
570 if (!m_font.Ok())
571 m_font = page->GetFont();
572
573 wxFont font = wxGetFontFromUser(this, m_font);
574 if ( !font.Ok() )
575 return;
576
577 m_font = font;
578
579 page->GetWidget()->SetFont(m_font);
580 page->GetWidget()->Refresh();
581
582 wxControl *ctrl2 = page->GetWidget2();
583 if ( ctrl2 )
584 {
585 ctrl2->SetFont(m_font);
586 ctrl2->Refresh();
587 }
588 #else
589 wxLogMessage(_T("Font selection dialog not available in current build."));
590 #endif
591 }
592
593 void WidgetsFrame::OnEnable(wxCommandEvent& event)
594 {
595 WidgetsPage *page = wxStaticCast(m_book->GetCurrentPage(), WidgetsPage);
596 page->GetWidget()->Enable(event.IsChecked());
597 }
598
599 void WidgetsFrame::OnSetBorder(wxCommandEvent& event)
600 {
601 int border;
602 switch ( event.GetId() )
603 {
604 case Widgets_BorderNone: border = wxBORDER_NONE; break;
605 case Widgets_BorderStatic: border = wxBORDER_STATIC; break;
606 case Widgets_BorderSimple: border = wxBORDER_SIMPLE; break;
607 case Widgets_BorderRaised: border = wxBORDER_RAISED; break;
608 case Widgets_BorderSunken: border = wxBORDER_SUNKEN; break;
609 case Widgets_BorderDouble: border = wxBORDER_DOUBLE; break;
610
611 default:
612 wxFAIL_MSG( _T("unknown border style") );
613 // fall through
614
615 case Widgets_BorderDefault: border = wxBORDER_DEFAULT; break;
616 }
617
618 WidgetsPage::ms_defaultFlags &= ~wxBORDER_MASK;
619 WidgetsPage::ms_defaultFlags |= border;
620
621 WidgetsPage *page = wxStaticCast(m_book->GetCurrentPage(), WidgetsPage);
622 page->RecreateWidget();
623 }
624
625 #endif // wxUSE_MENUS
626
627 // ----------------------------------------------------------------------------
628 // WidgetsPageInfo
629 // ----------------------------------------------------------------------------
630
631 WidgetsPageInfo::WidgetsPageInfo(Constructor ctor, const wxChar *label)
632 : m_label(label)
633 {
634 m_ctor = ctor;
635
636 m_next = NULL;
637
638 // dummy sorting: add and immediately sort in the list according to label
639 if(WidgetsPage::ms_widgetPages)
640 {
641 WidgetsPageInfo *node_prev = WidgetsPage::ms_widgetPages;
642 if ( wxStrcmp(label, node_prev->GetLabel().c_str()) < 0 )
643 {
644 // add as first
645 m_next = node_prev;
646 WidgetsPage::ms_widgetPages = this;
647 }
648 else
649 {
650 WidgetsPageInfo *node_next;
651 do
652 {
653 node_next = node_prev->GetNext();
654 if ( node_next )
655 {
656 // add if between two
657 if ( wxStrcmp(label, node_next->GetLabel().c_str()) < 0 )
658 {
659 node_prev->SetNext(this);
660 m_next = node_next;
661 // force to break loop
662 node_next = NULL;
663 }
664 }
665 else
666 {
667 // add as last
668 node_prev->SetNext(this);
669 m_next = node_next;
670 }
671 node_prev = node_next;
672 }
673 while ( node_next );
674 }
675 }
676 else
677 {
678 // add when first
679 WidgetsPage::ms_widgetPages = this;
680 }
681 }
682
683 // ----------------------------------------------------------------------------
684 // WidgetsPage
685 // ----------------------------------------------------------------------------
686
687 int WidgetsPage::ms_defaultFlags = wxBORDER_DEFAULT;
688 WidgetsPageInfo *WidgetsPage::ms_widgetPages = NULL;
689
690 WidgetsPage::WidgetsPage(wxBookCtrlBase *book)
691 : wxPanel(book, wxID_ANY,
692 wxDefaultPosition, wxDefaultSize,
693 wxNO_FULL_REPAINT_ON_RESIZE |
694 wxCLIP_CHILDREN |
695 wxTAB_TRAVERSAL)
696 {
697 }
698
699 wxSizer *WidgetsPage::CreateSizerWithText(wxControl *control,
700 wxWindowID id,
701 wxTextCtrl **ppText)
702 {
703 wxSizer *sizerRow = new wxBoxSizer(wxHORIZONTAL);
704 wxTextCtrl *text = new wxTextCtrl(this, id, wxEmptyString,
705 wxDefaultPosition, wxDefaultSize, wxTE_PROCESS_ENTER);
706
707 sizerRow->Add(control, 0, wxRIGHT | wxALIGN_CENTRE_VERTICAL, 5);
708 sizerRow->Add(text, 1, wxLEFT | wxALIGN_CENTRE_VERTICAL, 5);
709
710 if ( ppText )
711 *ppText = text;
712
713 return sizerRow;
714 }
715
716 // create a sizer containing a label and a text ctrl
717 wxSizer *WidgetsPage::CreateSizerWithTextAndLabel(const wxString& label,
718 wxWindowID id,
719 wxTextCtrl **ppText)
720 {
721 return CreateSizerWithText(new wxStaticText(this, wxID_ANY, label),
722 id, ppText);
723 }
724
725 // create a sizer containing a button and a text ctrl
726 wxSizer *WidgetsPage::CreateSizerWithTextAndButton(wxWindowID idBtn,
727 const wxString& label,
728 wxWindowID id,
729 wxTextCtrl **ppText)
730 {
731 return CreateSizerWithText(new wxButton(this, idBtn, label), id, ppText);
732 }
733
734 wxCheckBox *WidgetsPage::CreateCheckBoxAndAddToSizer(wxSizer *sizer,
735 const wxString& label,
736 wxWindowID id)
737 {
738 wxCheckBox *checkbox = new wxCheckBox(this, id, label);
739 sizer->Add(checkbox, 0, wxLEFT | wxRIGHT, 5);
740 sizer->Add(0, 2, 0, wxGROW); // spacer
741
742 return checkbox;
743 }