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
8 // Copyright: (c) 2001 Vadim Zeitlin
9 // License: wxWindows license
10 /////////////////////////////////////////////////////////////////////////////
12 // ============================================================================
14 // ============================================================================
16 // ----------------------------------------------------------------------------
18 // ----------------------------------------------------------------------------
20 // for compilers that support precompilation, includes "wx/wx.h".
21 #include "wx/wxprec.h"
27 // for all others, include the necessary headers
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"
41 #include "wx/msgdlg.h"
44 #include "wx/sysopt.h"
45 #include "wx/bookctrl.h"
46 #include "wx/treebook.h"
48 #include "wx/colordlg.h"
49 #include "wx/fontdlg.h"
50 #include "wx/textdlg.h"
51 #include "wx/imaglist.h"
52 #include "wx/wupdlock.h"
56 #include "../sample.xpm"
58 // ----------------------------------------------------------------------------
60 // ----------------------------------------------------------------------------
65 Widgets_ClearLog
= 100,
72 #endif // wxUSE_TOOLTIPS
84 Widgets_BorderDefault
,
86 Widgets_GlobalBusyCursor
,
90 Widgets_GoToPageLast
= Widgets_GoToPage
+ 100
93 const wxChar
*WidgetsCategories
[MAX_PAGES
] = {
94 #if defined(__WXUNIVERSAL__)
108 // ----------------------------------------------------------------------------
110 // ----------------------------------------------------------------------------
112 // Define a new application type, each program should derive a class from wxApp
113 class WidgetsApp
: public wxApp
116 // override base class virtuals
117 // ----------------------------
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();
125 // Define a new frame type: this is going to be our main frame
126 class WidgetsFrame
: public wxFrame
130 WidgetsFrame(const wxString
& title
);
131 virtual ~WidgetsFrame();
136 void OnButtonClearLog(wxCommandEvent
& event
);
138 void OnExit(wxCommandEvent
& event
);
141 void OnPageChanging(WidgetsBookCtrlEvent
& event
);
142 void OnPageChanged(WidgetsBookCtrlEvent
& event
);
143 void OnGoToPage(wxCommandEvent
& event
);
146 void OnSetTooltip(wxCommandEvent
& event
);
147 #endif // wxUSE_TOOLTIPS
148 void OnSetFgCol(wxCommandEvent
& event
);
149 void OnSetBgCol(wxCommandEvent
& event
);
150 void OnSetFont(wxCommandEvent
& event
);
151 void OnEnable(wxCommandEvent
& event
);
152 void OnSetBorder(wxCommandEvent
& event
);
154 void OnToggleGlobalBusyCursor(wxCommandEvent
& event
);
155 void OnToggleBusyCursor(wxCommandEvent
& event
);
156 #endif // wxUSE_MENUS
158 // initialize the book: add all pages to it
161 // return the currently selected page (never NULL)
162 WidgetsPage
*CurrentPage();
165 // the panel containing everything
169 // the listbox for logging messages
170 wxListBox
*m_lboxLog
;
172 // the log target we use to redirect messages to the listbox
176 // the book containing the test pages
177 WidgetsBookCtrl
*m_book
;
180 // last chosen fg/bg colours and font
184 #endif // wxUSE_MENUS
186 // any class wishing to process wxWidgets events must use this macro
187 DECLARE_EVENT_TABLE()
191 // A log target which just redirects the messages to a listbox
192 class LboxLogger
: public wxLog
195 LboxLogger(wxListBox
*lbox
, wxLog
*logOld
)
198 //m_lbox->Disable(); -- looks ugly under MSW
202 virtual ~LboxLogger()
204 wxLog::SetActiveTarget(m_logOld
);
208 // implement sink functions
209 virtual void DoLog(wxLogLevel level
, const wxString
& str
, time_t t
)
211 // don't put trace messages into listbox or we can get into infinite
213 if ( level
== wxLOG_Trace
)
217 // cast is needed to call protected method
218 ((LboxLogger
*)m_logOld
)->DoLog(level
, str
, t
);
223 wxLog::DoLog(level
, str
, t
);
227 virtual void DoLogString(const wxString
& str
, time_t WXUNUSED(t
))
233 #ifdef __WXUNIVERSAL__
234 m_lbox
->AppendAndEnsureVisible(msg
);
235 #else // other ports don't have this method yet
237 m_lbox
->SetFirstItem(m_lbox
->GetCount() - 1);
241 // the control we use
244 // the old log target
250 WX_DEFINE_ARRAY_PTR(WidgetsPage
*, ArrayWidgetsPage
);
252 // ----------------------------------------------------------------------------
254 // ----------------------------------------------------------------------------
256 IMPLEMENT_APP(WidgetsApp
)
258 // ----------------------------------------------------------------------------
260 // ----------------------------------------------------------------------------
262 BEGIN_EVENT_TABLE(WidgetsFrame
, wxFrame
)
264 EVT_BUTTON(Widgets_ClearLog
, WidgetsFrame::OnButtonClearLog
)
266 EVT_BUTTON(Widgets_Quit
, WidgetsFrame::OnExit
)
269 EVT_MENU(Widgets_SetTooltip
, WidgetsFrame::OnSetTooltip
)
270 #endif // wxUSE_TOOLTIPS
273 EVT_WIDGETS_PAGE_CHANGING(wxID_ANY
, WidgetsFrame::OnPageChanging
)
274 EVT_MENU_RANGE(Widgets_GoToPage
, Widgets_GoToPageLast
,
275 WidgetsFrame::OnGoToPage
)
277 EVT_MENU(Widgets_SetFgColour
, WidgetsFrame::OnSetFgCol
)
278 EVT_MENU(Widgets_SetBgColour
, WidgetsFrame::OnSetBgCol
)
279 EVT_MENU(Widgets_SetFont
, WidgetsFrame::OnSetFont
)
280 EVT_MENU(Widgets_Enable
, WidgetsFrame::OnEnable
)
282 EVT_MENU_RANGE(Widgets_BorderNone
, Widgets_BorderDefault
,
283 WidgetsFrame::OnSetBorder
)
285 EVT_MENU(Widgets_GlobalBusyCursor
, WidgetsFrame::OnToggleGlobalBusyCursor
)
286 EVT_MENU(Widgets_BusyCursor
, WidgetsFrame::OnToggleBusyCursor
)
288 EVT_MENU(wxID_EXIT
, WidgetsFrame::OnExit
)
289 #endif // wxUSE_MENUS
292 // ============================================================================
294 // ============================================================================
296 // ----------------------------------------------------------------------------
298 // ----------------------------------------------------------------------------
300 bool WidgetsApp::OnInit()
302 if ( !wxApp::OnInit() )
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
308 #if defined(__WXUNIVERSAL__)
309 title
= _T("wxUniv/");
312 #if defined(__WXMSW__)
313 title
+= _T("wxMSW");
314 #elif defined(__WXGTK__)
315 title
+= _T("wxGTK");
316 #elif defined(__WXMAC__)
317 title
+= _T("wxMAC");
318 #elif defined(__WXMOTIF__)
319 title
+= _T("wxMOTIF");
321 title
+= _T("wxWidgets");
324 wxFrame
*frame
= new WidgetsFrame(title
+ _T(" widgets demo"));
327 //wxLog::AddTraceMask(_T("listbox"));
328 //wxLog::AddTraceMask(_T("scrollbar"));
329 //wxLog::AddTraceMask(_T("focus"));
334 // ----------------------------------------------------------------------------
335 // WidgetsFrame construction
336 // ----------------------------------------------------------------------------
338 WidgetsFrame::WidgetsFrame(const wxString
& title
)
339 : wxFrame(NULL
, wxID_ANY
, title
)
341 // set the frame icon
342 SetIcon(wxICON(sample
));
346 m_lboxLog
= (wxListBox
*)NULL
;
347 m_logTarget
= (wxLog
*)NULL
;
349 m_book
= (WidgetsBookCtrl
*)NULL
;
352 // create the menubar
353 wxMenuBar
*mbar
= new wxMenuBar
;
354 wxMenu
*menuWidget
= new wxMenu
;
356 menuWidget
->Append(Widgets_SetTooltip
, _T("Set &tooltip...\tCtrl-T"));
357 menuWidget
->AppendSeparator();
358 #endif // wxUSE_TOOLTIPS
359 menuWidget
->Append(Widgets_SetFgColour
, _T("Set &foreground...\tCtrl-F"));
360 menuWidget
->Append(Widgets_SetBgColour
, _T("Set &background...\tCtrl-B"));
361 menuWidget
->Append(Widgets_SetFont
, _T("Set f&ont...\tCtrl-O"));
362 menuWidget
->AppendCheckItem(Widgets_Enable
, _T("&Enable/disable\tCtrl-E"));
364 wxMenu
*menuBorders
= new wxMenu
;
365 menuBorders
->AppendRadioItem(Widgets_BorderDefault
, _T("De&fault\tCtrl-Shift-9"));
366 menuBorders
->AppendRadioItem(Widgets_BorderNone
, _T("&None\tCtrl-Shift-0"));
367 menuBorders
->AppendRadioItem(Widgets_BorderSimple
, _T("&Simple\tCtrl-Shift-1"));
368 menuBorders
->AppendRadioItem(Widgets_BorderDouble
, _T("&Double\tCtrl-Shift-2"));
369 menuBorders
->AppendRadioItem(Widgets_BorderStatic
, _T("Stati&c\tCtrl-Shift-3"));
370 menuBorders
->AppendRadioItem(Widgets_BorderRaised
, _T("&Raised\tCtrl-Shift-4"));
371 menuBorders
->AppendRadioItem(Widgets_BorderSunken
, _T("S&unken\tCtrl-Shift-5"));
372 menuWidget
->AppendSubMenu(menuBorders
, _T("Set &border"));
374 menuWidget
->AppendSeparator();
375 menuWidget
->AppendCheckItem(Widgets_GlobalBusyCursor
,
376 _T("Toggle &global busy cursor\tCtrl-Shift-U"));
377 menuWidget
->AppendCheckItem(Widgets_BusyCursor
,
378 _T("Toggle b&usy cursor\tCtrl-U"));
380 menuWidget
->AppendSeparator();
381 menuWidget
->Append(wxID_EXIT
, _T("&Quit\tCtrl-Q"));
382 mbar
->Append(menuWidget
, _T("&Widget"));
385 mbar
->Check(Widgets_Enable
, true);
386 #endif // wxUSE_MENUS
389 m_panel
= new wxPanel(this, wxID_ANY
);
391 wxSizer
*sizerTop
= new wxBoxSizer(wxVERTICAL
);
393 // we have 2 panes: book with pages demonstrating the controls in the
394 // upper one and the log window with some buttons in the lower
396 int style
= wxBK_DEFAULT
;
397 // Uncomment to suppress page theme (draw in solid colour)
398 //style |= wxNB_NOPAGETHEME;
400 m_book
= new WidgetsBookCtrl(m_panel
, Widgets_BookCtrl
, wxDefaultPosition
,
402 wxSize(500, wxDefaultCoord
), // under Motif, height is a function of the width...
409 #ifndef __WXHANDHELD__
410 // the lower one only has the log listbox and a button to clear it
412 wxSizer
*sizerDown
= new wxStaticBoxSizer(
413 new wxStaticBox( m_panel
, wxID_ANY
, _T("&Log window") ),
416 m_lboxLog
= new wxListBox(m_panel
, wxID_ANY
);
417 sizerDown
->Add(m_lboxLog
, 1, wxGROW
| wxALL
, 5);
418 sizerDown
->SetMinSize(100, 150);
420 wxSizer
*sizerDown
= new wxBoxSizer(wxVERTICAL
);
423 wxBoxSizer
*sizerBtns
= new wxBoxSizer(wxHORIZONTAL
);
426 btn
= new wxButton(m_panel
, Widgets_ClearLog
, _T("Clear &log"));
428 sizerBtns
->Add(10, 0); // spacer
430 btn
= new wxButton(m_panel
, Widgets_Quit
, _T("E&xit"));
432 sizerDown
->Add(sizerBtns
, 0, wxALL
| wxALIGN_RIGHT
, 5);
434 // put everything together
435 sizerTop
->Add(m_book
, 1, wxGROW
| (wxALL
& ~(wxTOP
| wxBOTTOM
)), 10);
436 sizerTop
->Add(0, 5, 0, wxGROW
); // spacer in between
437 sizerTop
->Add(sizerDown
, 0, wxGROW
| (wxALL
& ~wxTOP
), 10);
439 #else // !__WXHANDHELD__/__WXHANDHELD__
441 sizerTop
->Add(m_book
, 1, wxGROW
| wxALL
);
443 #endif // __WXHANDHELD__
445 m_panel
->SetSizer(sizerTop
);
448 sizerTop
->SetSizeHints(this);
450 #if USE_LOG && !defined(__WXCOCOA__)
451 // wxCocoa's listbox is too flakey to use for logging right now
452 // now that everything is created we can redirect the log messages to the
454 m_logTarget
= new LboxLogger(m_lboxLog
, wxLog::GetActiveTarget());
455 wxLog::SetActiveTarget(m_logTarget
);
459 void WidgetsFrame::InitBook()
461 #if USE_ICONS_IN_BOOK
462 wxImageList
*imageList
= new wxImageList(ICON_SIZE
, ICON_SIZE
);
464 wxImage
img(sample_xpm
);
465 imageList
->Add(wxBitmap(img
.Scale(ICON_SIZE
, ICON_SIZE
)));
467 wxImageList
*imageList
= NULL
;
471 WidgetsBookCtrl
*books
[MAX_PAGES
];
474 ArrayWidgetsPage pages
[MAX_PAGES
];
475 wxArrayString labels
[MAX_PAGES
];
477 wxMenu
*menuPages
= new wxMenu
;
478 unsigned int nPage
= 0, nFKey
= 0;
479 int cat
, imageId
= 1;
481 // we need to first create all pages and only then add them to the book
482 // as we need the image list first
484 // we also construct the pages menu during this first iteration
485 for ( cat
= 0; cat
< MAX_PAGES
; cat
++ )
488 nPage
++; // increase for parent page
490 books
[cat
] = new WidgetsBookCtrl(m_book
,
497 for ( WidgetsPageInfo
*info
= WidgetsPage::ms_widgetPages
;
499 info
= info
->GetNext() )
501 if( (info
->GetCategories() & ( 1 << cat
)) == 0)
504 WidgetsPage
*page
= (*info
->GetCtor())(
511 pages
[cat
].Add(page
);
513 labels
[cat
].Add(info
->GetLabel());
514 if ( cat
== ALL_PAGE
)
516 wxString
radioLabel(info
->GetLabel());
520 radioLabel
<< wxT("\tF" ) << nFKey
;
523 menuPages
->AppendRadioItem(
524 Widgets_GoToPage
+ nPage
,
528 // consider only for book in book architecture
534 // consider only for treebook architecture (with subpages)
540 GetMenuBar()->Append(menuPages
, _T("&Page"));
542 #if USE_ICONS_IN_BOOK
543 m_book
->AssignImageList(imageList
);
546 for ( cat
= 0; cat
< MAX_PAGES
; cat
++ )
549 m_book
->AddPage(NULL
,WidgetsCategories
[cat
],false,0);
551 m_book
->AddPage(books
[cat
],WidgetsCategories
[cat
],false,0);
552 #if USE_ICONS_IN_BOOK
553 books
[cat
]->SetImageList(imageList
);
558 size_t count
= pages
[cat
].GetCount();
559 for ( size_t n
= 0; n
< count
; n
++ )
569 false, // don't select
576 wxEVT_COMMAND_WIDGETS_PAGE_CHANGED
,
577 wxWidgetsbookEventHandler(WidgetsFrame::OnPageChanged
) );
580 // for treebook page #0 is empty parent page only so select the first page
581 // with some contents
582 m_book
->SetSelection(1);
584 // but ensure that the top of the tree is shown nevertheless
585 wxTreeCtrl
* const tree
= m_book
->GetTreeCtrl();
587 wxTreeItemIdValue cookie
;
588 tree
->EnsureVisible(tree
->GetFirstChild(tree
->GetRootItem(), cookie
));
590 // for other books set selection twice to force connected event handler
591 // to force lazy creation of initial visible content
592 m_book
->SetSelection(1);
593 m_book
->SetSelection(0);
594 #endif // USE_TREEBOOK
597 WidgetsPage
*WidgetsFrame::CurrentPage()
599 wxWindow
*page
= m_book
->GetCurrentPage();
602 WidgetsBookCtrl
*subBook
= wxStaticCast(page
, WidgetsBookCtrl
);
603 wxCHECK_MSG( subBook
, NULL
, _T("no WidgetsBookCtrl?") );
605 page
= subBook
->GetCurrentPage();
606 #endif // !USE_TREEBOOK
608 return wxStaticCast(page
, WidgetsPage
);
611 WidgetsFrame::~WidgetsFrame()
618 // ----------------------------------------------------------------------------
619 // WidgetsFrame event handlers
620 // ----------------------------------------------------------------------------
622 void WidgetsFrame::OnExit(wxCommandEvent
& WXUNUSED(event
))
628 void WidgetsFrame::OnButtonClearLog(wxCommandEvent
& WXUNUSED(event
))
636 void WidgetsFrame::OnPageChanging(WidgetsBookCtrlEvent
& event
)
639 // don't allow selection of entries without pages (categories)
640 if ( !m_book
->GetPage(event
.GetSelection()) )
647 void WidgetsFrame::OnPageChanged(WidgetsBookCtrlEvent
& event
)
649 const int sel
= event
.GetSelection();
651 // adjust "Page" menu selection
652 wxMenuItem
*item
= GetMenuBar()->FindItem(Widgets_GoToPage
+ sel
);
656 GetMenuBar()->Check(Widgets_BusyCursor
, false);
658 // create the pages on demand, otherwise the sample startup is too slow as
659 // it creates hundreds of controls
660 WidgetsPage
*page
= CurrentPage();
661 if ( page
->GetChildren().empty() )
663 wxWindowUpdateLocker
noUpdates(page
);
664 page
->CreateContent();
666 page
->GetSizer()->Fit(page
);
668 WidgetsBookCtrl
*book
= wxStaticCast(page
->GetParent(), WidgetsBookCtrl
);
670 for ( size_t i
= 0; i
< book
->GetPageCount(); ++i
)
672 wxWindow
*page
= book
->GetPage(i
);
675 size
.IncTo(page
->GetSize());
684 void WidgetsFrame::OnGoToPage(wxCommandEvent
& event
)
687 m_book
->SetSelection(event
.GetId() - Widgets_GoToPage
);
689 m_book
->SetSelection(m_book
->GetPageCount()-1);
690 WidgetsBookCtrl
*book
= wxStaticCast(m_book
->GetCurrentPage(), WidgetsBookCtrl
);
691 book
->SetSelection(event
.GetId() - Widgets_GoToPage
);
697 void WidgetsFrame::OnSetTooltip(wxCommandEvent
& WXUNUSED(event
))
699 static wxString s_tip
= _T("This is a tooltip");
701 wxTextEntryDialog dialog
704 _T("Tooltip text (may use \\n, leave empty to remove): "),
705 _T("Widgets sample"),
709 if ( dialog
.ShowModal() != wxID_OK
)
712 s_tip
= dialog
.GetValue();
713 s_tip
.Replace(_T("\\n"), _T("\n"));
715 WidgetsPage
*page
= CurrentPage();
717 page
->GetWidget()->SetToolTip(s_tip
);
719 wxControl
*ctrl2
= page
->GetWidget2();
721 ctrl2
->SetToolTip(s_tip
);
724 #endif // wxUSE_TOOLTIPS
726 void WidgetsFrame::OnSetFgCol(wxCommandEvent
& WXUNUSED(event
))
729 // allow for debugging the default colour the first time this is called
730 WidgetsPage
*page
= CurrentPage();
733 m_colFg
= page
->GetForegroundColour();
735 wxColour col
= wxGetColourFromUser(this, m_colFg
);
741 page
->GetWidget()->SetForegroundColour(m_colFg
);
742 page
->GetWidget()->Refresh();
744 wxControl
*ctrl2
= page
->GetWidget2();
747 ctrl2
->SetForegroundColour(m_colFg
);
751 wxLogMessage(_T("Colour selection dialog not available in current build."));
755 void WidgetsFrame::OnSetBgCol(wxCommandEvent
& WXUNUSED(event
))
758 WidgetsPage
*page
= CurrentPage();
761 m_colBg
= page
->GetBackgroundColour();
763 wxColour col
= wxGetColourFromUser(this, m_colBg
);
769 page
->GetWidget()->SetBackgroundColour(m_colBg
);
770 page
->GetWidget()->Refresh();
772 wxControl
*ctrl2
= page
->GetWidget2();
775 ctrl2
->SetBackgroundColour(m_colFg
);
779 wxLogMessage(_T("Colour selection dialog not available in current build."));
783 void WidgetsFrame::OnSetFont(wxCommandEvent
& WXUNUSED(event
))
786 WidgetsPage
*page
= CurrentPage();
789 m_font
= page
->GetFont();
791 wxFont font
= wxGetFontFromUser(this, m_font
);
797 page
->GetWidget()->SetFont(m_font
);
798 page
->GetWidget()->Refresh();
800 wxControl
*ctrl2
= page
->GetWidget2();
803 ctrl2
->SetFont(m_font
);
807 wxLogMessage(_T("Font selection dialog not available in current build."));
811 void WidgetsFrame::OnEnable(wxCommandEvent
& event
)
813 CurrentPage()->GetWidget()->Enable(event
.IsChecked());
816 void WidgetsFrame::OnSetBorder(wxCommandEvent
& event
)
819 switch ( event
.GetId() )
821 case Widgets_BorderNone
: border
= wxBORDER_NONE
; break;
822 case Widgets_BorderStatic
: border
= wxBORDER_STATIC
; break;
823 case Widgets_BorderSimple
: border
= wxBORDER_SIMPLE
; break;
824 case Widgets_BorderRaised
: border
= wxBORDER_RAISED
; break;
825 case Widgets_BorderSunken
: border
= wxBORDER_SUNKEN
; break;
826 case Widgets_BorderDouble
: border
= wxBORDER_DOUBLE
; break;
829 wxFAIL_MSG( _T("unknown border style") );
832 case Widgets_BorderDefault
: border
= wxBORDER_DEFAULT
; break;
835 WidgetsPage::ms_defaultFlags
&= ~wxBORDER_MASK
;
836 WidgetsPage::ms_defaultFlags
|= border
;
838 WidgetsPage
*page
= CurrentPage();
840 page
->RecreateWidget();
843 void WidgetsFrame::OnToggleGlobalBusyCursor(wxCommandEvent
& event
)
845 if ( event
.IsChecked() )
851 void WidgetsFrame::OnToggleBusyCursor(wxCommandEvent
& event
)
853 CurrentPage()->GetWidget()->SetCursor(*(event
.IsChecked()
855 : wxSTANDARD_CURSOR
));
858 #endif // wxUSE_MENUS
860 // ----------------------------------------------------------------------------
862 // ----------------------------------------------------------------------------
864 WidgetsPageInfo::WidgetsPageInfo(Constructor ctor
, const wxChar
*label
, int categories
)
866 , m_categories(categories
)
872 // dummy sorting: add and immediately sort in the list according to label
873 if ( WidgetsPage::ms_widgetPages
)
875 WidgetsPageInfo
*node_prev
= WidgetsPage::ms_widgetPages
;
876 if ( wxStrcmp(label
, node_prev
->GetLabel().c_str()) < 0 )
880 WidgetsPage::ms_widgetPages
= this;
884 WidgetsPageInfo
*node_next
;
887 node_next
= node_prev
->GetNext();
890 // add if between two
891 if ( wxStrcmp(label
, node_next
->GetLabel().c_str()) < 0 )
893 node_prev
->SetNext(this);
895 // force to break loop
902 node_prev
->SetNext(this);
905 node_prev
= node_next
;
913 WidgetsPage::ms_widgetPages
= this;
917 // ----------------------------------------------------------------------------
919 // ----------------------------------------------------------------------------
921 int WidgetsPage::ms_defaultFlags
= wxBORDER_DEFAULT
;
922 WidgetsPageInfo
*WidgetsPage::ms_widgetPages
= NULL
;
924 WidgetsPage::WidgetsPage(WidgetsBookCtrl
*book
,
925 wxImageList
*imaglist
,
927 : wxPanel(book
, wxID_ANY
,
928 wxDefaultPosition
, wxDefaultSize
,
929 wxNO_FULL_REPAINT_ON_RESIZE
|
933 #if USE_ICONS_IN_BOOK
934 imaglist
->Add(wxBitmap(wxImage(icon
).Scale(ICON_SIZE
, ICON_SIZE
)));
936 wxUnusedVar(imaglist
);
941 wxSizer
*WidgetsPage::CreateSizerWithText(wxControl
*control
,
945 wxSizer
*sizerRow
= new wxBoxSizer(wxHORIZONTAL
);
946 wxTextCtrl
*text
= new wxTextCtrl(this, id
, wxEmptyString
,
947 wxDefaultPosition
, wxDefaultSize
, wxTE_PROCESS_ENTER
);
949 sizerRow
->Add(control
, 0, wxRIGHT
| wxALIGN_CENTRE_VERTICAL
, 5);
950 sizerRow
->Add(text
, 1, wxLEFT
| wxALIGN_CENTRE_VERTICAL
, 5);
958 // create a sizer containing a label and a text ctrl
959 wxSizer
*WidgetsPage::CreateSizerWithTextAndLabel(const wxString
& label
,
963 return CreateSizerWithText(new wxStaticText(this, wxID_ANY
, label
),
967 // create a sizer containing a button and a text ctrl
968 wxSizer
*WidgetsPage::CreateSizerWithTextAndButton(wxWindowID idBtn
,
969 const wxString
& label
,
973 return CreateSizerWithText(new wxButton(this, idBtn
, label
), id
, ppText
);
976 wxCheckBox
*WidgetsPage::CreateCheckBoxAndAddToSizer(wxSizer
*sizer
,
977 const wxString
& label
,
980 wxCheckBox
*checkbox
= new wxCheckBox(this, id
, label
);
981 sizer
->Add(checkbox
, 0, wxLEFT
| wxRIGHT
, 5);
982 sizer
->Add(0, 2, 0, wxGROW
); // spacer