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("wxPALMOS5");
323 title
+= _T("wxPALMOS6");
325 title
+= _T("wxWidgets");
328 wxFrame
*frame
= new WidgetsFrame(title
+ _T(" widgets demo"));
331 //wxLog::AddTraceMask(_T("listbox"));
332 //wxLog::AddTraceMask(_T("scrollbar"));
333 //wxLog::AddTraceMask(_T("focus"));
338 // ----------------------------------------------------------------------------
339 // WidgetsFrame construction
340 // ----------------------------------------------------------------------------
342 WidgetsFrame::WidgetsFrame(const wxString
& title
)
343 : wxFrame(NULL
, wxID_ANY
, title
)
345 // set the frame icon
346 SetIcon(wxICON(sample
));
350 m_lboxLog
= (wxListBox
*)NULL
;
351 m_logTarget
= (wxLog
*)NULL
;
353 m_book
= (WidgetsBookCtrl
*)NULL
;
356 // create the menubar
357 wxMenuBar
*mbar
= new wxMenuBar
;
358 wxMenu
*menuWidget
= new wxMenu
;
360 menuWidget
->Append(Widgets_SetTooltip
, _T("Set &tooltip...\tCtrl-T"));
361 menuWidget
->AppendSeparator();
362 #endif // wxUSE_TOOLTIPS
363 menuWidget
->Append(Widgets_SetFgColour
, _T("Set &foreground...\tCtrl-F"));
364 menuWidget
->Append(Widgets_SetBgColour
, _T("Set &background...\tCtrl-B"));
365 menuWidget
->Append(Widgets_SetFont
, _T("Set f&ont...\tCtrl-O"));
366 menuWidget
->AppendCheckItem(Widgets_Enable
, _T("&Enable/disable\tCtrl-E"));
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"));
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"));
384 menuWidget
->AppendSeparator();
385 menuWidget
->Append(wxID_EXIT
, _T("&Quit\tCtrl-Q"));
386 mbar
->Append(menuWidget
, _T("&Widget"));
389 mbar
->Check(Widgets_Enable
, true);
390 #endif // wxUSE_MENUS
393 m_panel
= new wxPanel(this, wxID_ANY
);
395 wxSizer
*sizerTop
= new wxBoxSizer(wxVERTICAL
);
397 // we have 2 panes: book with pages demonstrating the controls in the
398 // upper one and the log window with some buttons in the lower
400 int style
= wxBK_DEFAULT
;
401 // Uncomment to suppress page theme (draw in solid colour)
402 //style |= wxNB_NOPAGETHEME;
404 m_book
= new WidgetsBookCtrl(m_panel
, Widgets_BookCtrl
, wxDefaultPosition
,
406 wxSize(500, wxDefaultCoord
), // under Motif, height is a function of the width...
413 #ifndef __WXHANDHELD__
414 // the lower one only has the log listbox and a button to clear it
416 wxSizer
*sizerDown
= new wxStaticBoxSizer(
417 new wxStaticBox( m_panel
, wxID_ANY
, _T("&Log window") ),
420 m_lboxLog
= new wxListBox(m_panel
, wxID_ANY
);
421 sizerDown
->Add(m_lboxLog
, 1, wxGROW
| wxALL
, 5);
422 sizerDown
->SetMinSize(100, 150);
424 wxSizer
*sizerDown
= new wxBoxSizer(wxVERTICAL
);
427 wxBoxSizer
*sizerBtns
= new wxBoxSizer(wxHORIZONTAL
);
430 btn
= new wxButton(m_panel
, Widgets_ClearLog
, _T("Clear &log"));
432 sizerBtns
->Add(10, 0); // spacer
434 btn
= new wxButton(m_panel
, Widgets_Quit
, _T("E&xit"));
436 sizerDown
->Add(sizerBtns
, 0, wxALL
| wxALIGN_RIGHT
, 5);
438 // put everything together
439 sizerTop
->Add(m_book
, 1, wxGROW
| (wxALL
& ~(wxTOP
| wxBOTTOM
)), 10);
440 sizerTop
->Add(0, 5, 0, wxGROW
); // spacer in between
441 sizerTop
->Add(sizerDown
, 0, wxGROW
| (wxALL
& ~wxTOP
), 10);
443 #else // !__WXHANDHELD__/__WXHANDHELD__
445 sizerTop
->Add(m_book
, 1, wxGROW
| wxALL
);
447 #endif // __WXHANDHELD__
449 m_panel
->SetSizer(sizerTop
);
451 sizerTop
->SetSizeHints(this);
453 #if USE_LOG && !defined(__WXCOCOA__)
454 // wxCocoa's listbox is too flakey to use for logging right now
455 // now that everything is created we can redirect the log messages to the
457 m_logTarget
= new LboxLogger(m_lboxLog
, wxLog::GetActiveTarget());
458 wxLog::SetActiveTarget(m_logTarget
);
462 void WidgetsFrame::InitBook()
464 #if USE_ICONS_IN_BOOK
465 wxImageList
*imageList
= new wxImageList(ICON_SIZE
, ICON_SIZE
);
467 wxImage
img(sample_xpm
);
468 imageList
->Add(wxBitmap(img
.Scale(ICON_SIZE
, ICON_SIZE
)));
470 wxImageList
*imageList
= NULL
;
474 WidgetsBookCtrl
*books
[MAX_PAGES
];
477 ArrayWidgetsPage pages
[MAX_PAGES
];
478 wxArrayString labels
[MAX_PAGES
];
480 wxMenu
*menuPages
= new wxMenu
;
481 unsigned int nPage
= 0, nFKey
= 0;
482 int cat
, imageId
= 1;
484 // we need to first create all pages and only then add them to the book
485 // as we need the image list first
487 // we also construct the pages menu during this first iteration
488 for ( cat
= 0; cat
< MAX_PAGES
; cat
++ )
491 nPage
++; // increase for parent page
493 books
[cat
] = new WidgetsBookCtrl(m_book
,
500 for ( WidgetsPageInfo
*info
= WidgetsPage::ms_widgetPages
;
502 info
= info
->GetNext() )
504 if( (info
->GetCategories() & ( 1 << cat
)) == 0)
507 WidgetsPage
*page
= (*info
->GetCtor())(
514 pages
[cat
].Add(page
);
516 labels
[cat
].Add(info
->GetLabel());
517 if ( cat
== ALL_PAGE
)
519 wxString
radioLabel(info
->GetLabel());
523 radioLabel
<< wxT("\tF" ) << nFKey
;
526 menuPages
->AppendRadioItem(
527 Widgets_GoToPage
+ nPage
,
531 // consider only for book in book architecture
537 // consider only for treebook architecture (with subpages)
543 GetMenuBar()->Append(menuPages
, _T("&Page"));
545 #if USE_ICONS_IN_BOOK
546 m_book
->AssignImageList(imageList
);
549 for ( cat
= 0; cat
< MAX_PAGES
; cat
++ )
552 m_book
->AddPage(NULL
,WidgetsCategories
[cat
],false,0);
554 m_book
->AddPage(books
[cat
],WidgetsCategories
[cat
],false,0);
555 #if USE_ICONS_IN_BOOK
556 books
[cat
]->SetImageList(imageList
);
561 size_t count
= pages
[cat
].GetCount();
562 for ( size_t n
= 0; n
< count
; n
++ )
572 false, // don't select
579 wxEVT_COMMAND_WIDGETS_PAGE_CHANGED
,
580 wxWidgetsbookEventHandler(WidgetsFrame::OnPageChanged
) );
583 // for treebook page #0 is empty parent page only so select the first page
584 // with some contents
585 m_book
->SetSelection(1);
587 // but ensure that the top of the tree is shown nevertheless
588 wxTreeCtrl
* const tree
= m_book
->GetTreeCtrl();
590 wxTreeItemIdValue cookie
;
591 tree
->EnsureVisible(tree
->GetFirstChild(tree
->GetRootItem(), cookie
));
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);
597 #endif // USE_TREEBOOK
600 WidgetsPage
*WidgetsFrame::CurrentPage()
602 wxWindow
*page
= m_book
->GetCurrentPage();
605 WidgetsBookCtrl
*subBook
= wxStaticCast(page
, WidgetsBookCtrl
);
606 wxCHECK_MSG( subBook
, NULL
, _T("no WidgetsBookCtrl?") );
608 page
= subBook
->GetCurrentPage();
609 #endif // !USE_TREEBOOK
611 return wxStaticCast(page
, WidgetsPage
);
614 WidgetsFrame::~WidgetsFrame()
621 // ----------------------------------------------------------------------------
622 // WidgetsFrame event handlers
623 // ----------------------------------------------------------------------------
625 void WidgetsFrame::OnExit(wxCommandEvent
& WXUNUSED(event
))
631 void WidgetsFrame::OnButtonClearLog(wxCommandEvent
& WXUNUSED(event
))
639 void WidgetsFrame::OnPageChanging(WidgetsBookCtrlEvent
& event
)
642 // don't allow selection of entries without pages (categories)
643 if ( !m_book
->GetPage(event
.GetSelection()) )
650 void WidgetsFrame::OnPageChanged(WidgetsBookCtrlEvent
& event
)
652 const int sel
= event
.GetSelection();
654 // adjust "Page" menu selection
655 wxMenuItem
*item
= GetMenuBar()->FindItem(Widgets_GoToPage
+ sel
);
659 GetMenuBar()->Check(Widgets_BusyCursor
, false);
661 // create the pages on demand, otherwise the sample startup is too slow as
662 // it creates hundreds of controls
663 WidgetsPage
*page
= CurrentPage();
664 if ( page
->GetChildren().empty() )
666 wxWindowUpdateLocker
noUpdates(page
);
667 page
->CreateContent();
669 page
->GetSizer()->Fit(page
);
671 WidgetsBookCtrl
*book
= wxStaticCast(page
->GetParent(), WidgetsBookCtrl
);
673 for ( size_t i
= 0; i
< book
->GetPageCount(); ++i
)
675 wxWindow
*page
= book
->GetPage(i
);
678 size
.IncTo(page
->GetSize());
687 void WidgetsFrame::OnGoToPage(wxCommandEvent
& event
)
690 m_book
->SetSelection(event
.GetId() - Widgets_GoToPage
);
692 m_book
->SetSelection(m_book
->GetPageCount()-1);
693 WidgetsBookCtrl
*book
= wxStaticCast(m_book
->GetCurrentPage(), WidgetsBookCtrl
);
694 book
->SetSelection(event
.GetId() - Widgets_GoToPage
);
700 void WidgetsFrame::OnSetTooltip(wxCommandEvent
& WXUNUSED(event
))
702 static wxString s_tip
= _T("This is a tooltip");
704 wxTextEntryDialog dialog
707 _T("Tooltip text (may use \\n, leave empty to remove): "),
708 _T("Widgets sample"),
712 if ( dialog
.ShowModal() != wxID_OK
)
715 s_tip
= dialog
.GetValue();
716 s_tip
.Replace(_T("\\n"), _T("\n"));
718 WidgetsPage
*page
= CurrentPage();
720 page
->GetWidget()->SetToolTip(s_tip
);
722 wxControl
*ctrl2
= page
->GetWidget2();
724 ctrl2
->SetToolTip(s_tip
);
727 #endif // wxUSE_TOOLTIPS
729 void WidgetsFrame::OnSetFgCol(wxCommandEvent
& WXUNUSED(event
))
732 // allow for debugging the default colour the first time this is called
733 WidgetsPage
*page
= CurrentPage();
736 m_colFg
= page
->GetForegroundColour();
738 wxColour col
= wxGetColourFromUser(this, m_colFg
);
744 page
->GetWidget()->SetForegroundColour(m_colFg
);
745 page
->GetWidget()->Refresh();
747 wxControl
*ctrl2
= page
->GetWidget2();
750 ctrl2
->SetForegroundColour(m_colFg
);
754 wxLogMessage(_T("Colour selection dialog not available in current build."));
758 void WidgetsFrame::OnSetBgCol(wxCommandEvent
& WXUNUSED(event
))
761 WidgetsPage
*page
= CurrentPage();
764 m_colBg
= page
->GetBackgroundColour();
766 wxColour col
= wxGetColourFromUser(this, m_colBg
);
772 page
->GetWidget()->SetBackgroundColour(m_colBg
);
773 page
->GetWidget()->Refresh();
775 wxControl
*ctrl2
= page
->GetWidget2();
778 ctrl2
->SetBackgroundColour(m_colFg
);
782 wxLogMessage(_T("Colour selection dialog not available in current build."));
786 void WidgetsFrame::OnSetFont(wxCommandEvent
& WXUNUSED(event
))
789 WidgetsPage
*page
= CurrentPage();
792 m_font
= page
->GetFont();
794 wxFont font
= wxGetFontFromUser(this, m_font
);
800 page
->GetWidget()->SetFont(m_font
);
801 page
->GetWidget()->Refresh();
803 wxControl
*ctrl2
= page
->GetWidget2();
806 ctrl2
->SetFont(m_font
);
810 wxLogMessage(_T("Font selection dialog not available in current build."));
814 void WidgetsFrame::OnEnable(wxCommandEvent
& event
)
816 CurrentPage()->GetWidget()->Enable(event
.IsChecked());
819 void WidgetsFrame::OnSetBorder(wxCommandEvent
& event
)
822 switch ( event
.GetId() )
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;
832 wxFAIL_MSG( _T("unknown border style") );
835 case Widgets_BorderDefault
: border
= wxBORDER_DEFAULT
; break;
838 WidgetsPage::ms_defaultFlags
&= ~wxBORDER_MASK
;
839 WidgetsPage::ms_defaultFlags
|= border
;
841 WidgetsPage
*page
= CurrentPage();
843 page
->RecreateWidget();
846 void WidgetsFrame::OnToggleGlobalBusyCursor(wxCommandEvent
& event
)
848 if ( event
.IsChecked() )
854 void WidgetsFrame::OnToggleBusyCursor(wxCommandEvent
& event
)
856 CurrentPage()->GetWidget()->SetCursor(*(event
.IsChecked()
858 : wxSTANDARD_CURSOR
));
861 #endif // wxUSE_MENUS
863 // ----------------------------------------------------------------------------
865 // ----------------------------------------------------------------------------
867 WidgetsPageInfo::WidgetsPageInfo(Constructor ctor
, const wxChar
*label
, int categories
)
869 , m_categories(categories
)
875 // dummy sorting: add and immediately sort in the list according to label
876 if ( WidgetsPage::ms_widgetPages
)
878 WidgetsPageInfo
*node_prev
= WidgetsPage::ms_widgetPages
;
879 if ( wxStrcmp(label
, node_prev
->GetLabel().c_str()) < 0 )
883 WidgetsPage::ms_widgetPages
= this;
887 WidgetsPageInfo
*node_next
;
890 node_next
= node_prev
->GetNext();
893 // add if between two
894 if ( wxStrcmp(label
, node_next
->GetLabel().c_str()) < 0 )
896 node_prev
->SetNext(this);
898 // force to break loop
905 node_prev
->SetNext(this);
908 node_prev
= node_next
;
916 WidgetsPage::ms_widgetPages
= this;
920 // ----------------------------------------------------------------------------
922 // ----------------------------------------------------------------------------
924 int WidgetsPage::ms_defaultFlags
= wxBORDER_DEFAULT
;
925 WidgetsPageInfo
*WidgetsPage::ms_widgetPages
= NULL
;
927 WidgetsPage::WidgetsPage(WidgetsBookCtrl
*book
,
928 wxImageList
*imaglist
,
929 const char *const icon
[])
930 : wxPanel(book
, wxID_ANY
,
931 wxDefaultPosition
, wxDefaultSize
,
932 wxNO_FULL_REPAINT_ON_RESIZE
|
936 #if USE_ICONS_IN_BOOK
937 imaglist
->Add(wxBitmap(wxImage(icon
).Scale(ICON_SIZE
, ICON_SIZE
)));
939 wxUnusedVar(imaglist
);
944 wxSizer
*WidgetsPage::CreateSizerWithText(wxControl
*control
,
948 wxSizer
*sizerRow
= new wxBoxSizer(wxHORIZONTAL
);
949 wxTextCtrl
*text
= new wxTextCtrl(this, id
, wxEmptyString
,
950 wxDefaultPosition
, wxDefaultSize
, wxTE_PROCESS_ENTER
);
952 sizerRow
->Add(control
, 0, wxRIGHT
| wxALIGN_CENTRE_VERTICAL
, 5);
953 sizerRow
->Add(text
, 1, wxLEFT
| wxALIGN_CENTRE_VERTICAL
, 5);
961 // create a sizer containing a label and a text ctrl
962 wxSizer
*WidgetsPage::CreateSizerWithTextAndLabel(const wxString
& label
,
966 return CreateSizerWithText(new wxStaticText(this, wxID_ANY
, label
),
970 // create a sizer containing a button and a text ctrl
971 wxSizer
*WidgetsPage::CreateSizerWithTextAndButton(wxWindowID idBtn
,
972 const wxString
& label
,
976 return CreateSizerWithText(new wxButton(this, idBtn
, label
), id
, ppText
);
979 wxCheckBox
*WidgetsPage::CreateCheckBoxAndAddToSizer(wxSizer
*sizer
,
980 const wxString
& label
,
983 wxCheckBox
*checkbox
= new wxCheckBox(this, id
, label
);
984 sizer
->Add(checkbox
, 0, wxLEFT
| wxRIGHT
, 5);
985 sizer
->Add(0, 2, 0, wxGROW
); // spacer