diff --git a/samples/widgets/button.cpp b/samples/widgets/button.cpp index 1c2304b364..7c4dd08266 100644 --- a/samples/widgets/button.cpp +++ b/samples/widgets/button.cpp @@ -164,10 +164,8 @@ IMPLEMENT_WIDGETS_PAGE(ButtonWidgetsPage, _T("Button"), FAMILY_CTRLS ); ButtonWidgetsPage::ButtonWidgetsPage(WidgetsBookCtrl *book, wxImageList *imaglist) - : WidgetsPage(book) + : WidgetsPage(book, imaglist, button_xpm) { - imaglist->Add(wxBitmap(button_xpm)); - // init everything m_chkBitmap = m_chkImage = diff --git a/samples/widgets/checkbox.cpp b/samples/widgets/checkbox.cpp index 375a7a370f..384d4156e8 100644 --- a/samples/widgets/checkbox.cpp +++ b/samples/widgets/checkbox.cpp @@ -158,10 +158,8 @@ IMPLEMENT_WIDGETS_PAGE(CheckBoxWidgetsPage, wxT("CheckBox"), FAMILY_CTRLS ); CheckBoxWidgetsPage::CheckBoxWidgetsPage(WidgetsBookCtrl *book, wxImageList *imaglist) - : WidgetsPage(book) + : WidgetsPage(book, imaglist, checkbox_xpm) { - imaglist->Add(wxBitmap(checkbox_xpm)); - wxSizer *sizerTop = new wxBoxSizer(wxHORIZONTAL); // left pane diff --git a/samples/widgets/combobox.cpp b/samples/widgets/combobox.cpp index aa9a6a8a05..77e8962012 100644 --- a/samples/widgets/combobox.cpp +++ b/samples/widgets/combobox.cpp @@ -204,7 +204,7 @@ IMPLEMENT_WIDGETS_PAGE(ComboboxWidgetsPage, _T("Combobox"), ComboboxWidgetsPage::ComboboxWidgetsPage(WidgetsBookCtrl *book, wxImageList *imaglist) - : WidgetsPage(book) + : WidgetsPage(book, imaglist, combobox_xpm) { // init everything m_chkSort = @@ -213,8 +213,6 @@ ComboboxWidgetsPage::ComboboxWidgetsPage(WidgetsBookCtrl *book, m_combobox = (wxComboBox *)NULL; m_sizerCombo = (wxSizer *)NULL; - imaglist->Add(wxBitmap(combobox_xpm)); - /* What we create here is a frame having 3 panes: style pane is the leftmost one, in the middle the pane with buttons allowing to perform diff --git a/samples/widgets/datepick.cpp b/samples/widgets/datepick.cpp index 9babbf8c02..65c5f84b87 100644 --- a/samples/widgets/datepick.cpp +++ b/samples/widgets/datepick.cpp @@ -131,10 +131,8 @@ IMPLEMENT_WIDGETS_PAGE(DatePickerWidgetsPage, wxT("DatePicker"), DatePickerWidgetsPage::DatePickerWidgetsPage(WidgetsBookCtrl *book, wxImageList *imaglist) - :WidgetsPage(book) + :WidgetsPage(book, imaglist, datepick_xpm) { - imaglist->Add(wxBitmap(datepick_xpm)); - wxSizer *sizerTop = new wxBoxSizer(wxHORIZONTAL); // left pane diff --git a/samples/widgets/gauge.cpp b/samples/widgets/gauge.cpp index 4affd9ab33..f7cd1bb582 100644 --- a/samples/widgets/gauge.cpp +++ b/samples/widgets/gauge.cpp @@ -167,10 +167,8 @@ IMPLEMENT_WIDGETS_PAGE(GaugeWidgetsPage, _T("Gauge"), FAMILY_CTRLS ); GaugeWidgetsPage::GaugeWidgetsPage(WidgetsBookCtrl *book, wxImageList *imaglist) - :WidgetsPage(book) + :WidgetsPage(book, imaglist, gauge_xpm) { - imaglist->Add(wxBitmap(gauge_xpm)); - // init everything m_range = 100; diff --git a/samples/widgets/listbox.cpp b/samples/widgets/listbox.cpp index 90de90af97..82e6021245 100644 --- a/samples/widgets/listbox.cpp +++ b/samples/widgets/listbox.cpp @@ -205,10 +205,8 @@ IMPLEMENT_WIDGETS_PAGE(ListboxWidgetsPage, _T("Listbox"), ListboxWidgetsPage::ListboxWidgetsPage(WidgetsBookCtrl *book, wxImageList *imaglist) - : WidgetsPage(book) + : WidgetsPage(book, imaglist, listbox_xpm) { - imaglist->Add(wxBitmap(listbox_xpm)); - // init everything m_radioSelMode = (wxRadioBox *)NULL; diff --git a/samples/widgets/notebook.cpp b/samples/widgets/notebook.cpp index 357ac05684..add4b52b3d 100644 --- a/samples/widgets/notebook.cpp +++ b/samples/widgets/notebook.cpp @@ -44,6 +44,7 @@ #include "wx/sizer.h" #include "wx/bookctrl.h" #include "wx/artprov.h" +#include "wx/imaglist.h" #include "widgets.h" @@ -85,7 +86,7 @@ enum Orient class BookWidgetsPage : public WidgetsPage { public: - BookWidgetsPage(WidgetsBookCtrl *book); + BookWidgetsPage(WidgetsBookCtrl *book, wxImageList *imaglist, char* icon[]); virtual ~BookWidgetsPage(); virtual wxControl *GetWidget() const { return m_book; } @@ -184,8 +185,8 @@ END_EVENT_TABLE() // implementation // ============================================================================ -BookWidgetsPage::BookWidgetsPage(WidgetsBookCtrl *book) - :WidgetsPage(book) +BookWidgetsPage::BookWidgetsPage(WidgetsBookCtrl *book, wxImageList *imaglist, char* icon[]) + :WidgetsPage(book, imaglist, icon) { // init everything m_chkImages = NULL; @@ -519,9 +520,8 @@ class NotebookWidgetsPage : public BookWidgetsPage { public: NotebookWidgetsPage(WidgetsBookCtrl *book, wxImageList *imaglist) - : BookWidgetsPage(book) + : BookWidgetsPage(book, imaglist, notebook_xpm) { - imaglist->Add(wxBitmap(notebook_xpm)); RecreateBook(); } virtual ~NotebookWidgetsPage() {} @@ -602,9 +602,8 @@ class ListbookWidgetsPage : public BookWidgetsPage { public: ListbookWidgetsPage(WidgetsBookCtrl *book, wxImageList *imaglist) - : BookWidgetsPage(book) + : BookWidgetsPage(book, imaglist, listbook_xpm) { - imaglist->Add(wxBitmap(listbook_xpm)); RecreateBook(); } virtual ~ListbookWidgetsPage() {} @@ -677,9 +676,8 @@ class ChoicebookWidgetsPage : public BookWidgetsPage { public: ChoicebookWidgetsPage(WidgetsBookCtrl *book, wxImageList *imaglist) - : BookWidgetsPage(book) + : BookWidgetsPage(book, imaglist, choicebk_xpm) { - imaglist->Add(wxBitmap(choicebk_xpm)); RecreateBook(); } virtual ~ChoicebookWidgetsPage() {} diff --git a/samples/widgets/radiobox.cpp b/samples/widgets/radiobox.cpp index 088da04a98..9f647fd92e 100644 --- a/samples/widgets/radiobox.cpp +++ b/samples/widgets/radiobox.cpp @@ -185,10 +185,8 @@ IMPLEMENT_WIDGETS_PAGE(RadioWidgetsPage, _T("Radio"), RadioWidgetsPage::RadioWidgetsPage(WidgetsBookCtrl *book, wxImageList *imaglist) - : WidgetsPage(book) + : WidgetsPage(book, imaglist, radio_xpm) { - imaglist->Add(wxBitmap(radio_xpm)); - // init everything m_chkVert = (wxCheckBox *)NULL; m_chkEnableItem = (wxCheckBox *)NULL; diff --git a/samples/widgets/slider.cpp b/samples/widgets/slider.cpp index 75c5839332..4502d6c871 100644 --- a/samples/widgets/slider.cpp +++ b/samples/widgets/slider.cpp @@ -208,10 +208,8 @@ IMPLEMENT_WIDGETS_PAGE(SliderWidgetsPage, _T("Slider"), FAMILY_CTRLS ); SliderWidgetsPage::SliderWidgetsPage(WidgetsBookCtrl *book, wxImageList *imaglist) - : WidgetsPage(book) + : WidgetsPage(book, imaglist, slider_xpm) { - imaglist->Add(wxBitmap(slider_xpm)); - // init everything m_min = 0; m_max = 100; diff --git a/samples/widgets/spinbtn.cpp b/samples/widgets/spinbtn.cpp index 9cb2f46153..125d533bf3 100644 --- a/samples/widgets/spinbtn.cpp +++ b/samples/widgets/spinbtn.cpp @@ -178,7 +178,7 @@ IMPLEMENT_WIDGETS_PAGE(SpinBtnWidgetsPage, _T("Spin"), SpinBtnWidgetsPage::SpinBtnWidgetsPage(WidgetsBookCtrl *book, wxImageList *imaglist) - : WidgetsPage(book) + : WidgetsPage(book, imaglist, spinbtn_xpm) { m_chkVert = NULL; m_chkWrap = NULL; @@ -187,7 +187,6 @@ SpinBtnWidgetsPage::SpinBtnWidgetsPage(WidgetsBookCtrl *book, m_textValue = NULL; m_textMin = NULL; m_textMax = NULL; - imaglist->Add(wxBitmap(spinbtn_xpm)); // init everything m_min = 0; diff --git a/samples/widgets/static.cpp b/samples/widgets/static.cpp index 0082fde6fd..05c1366909 100644 --- a/samples/widgets/static.cpp +++ b/samples/widgets/static.cpp @@ -210,10 +210,8 @@ IMPLEMENT_WIDGETS_PAGE(StaticWidgetsPage, _T("Static"), StaticWidgetsPage::StaticWidgetsPage(WidgetsBookCtrl *book, wxImageList *imaglist) - : WidgetsPage(book) + : WidgetsPage(book, imaglist, statbox_xpm) { - imaglist->Add(wxBitmap(statbox_xpm)); - // init everything m_chkVert = m_chkAutoResize = (wxCheckBox *)NULL; diff --git a/samples/widgets/textctrl.cpp b/samples/widgets/textctrl.cpp index 7728ba3cc9..87bf0c0cfa 100644 --- a/samples/widgets/textctrl.cpp +++ b/samples/widgets/textctrl.cpp @@ -346,10 +346,8 @@ IMPLEMENT_WIDGETS_PAGE(TextWidgetsPage, _T("Text"), // ---------------------------------------------------------------------------- TextWidgetsPage::TextWidgetsPage(WidgetsBookCtrl *book, wxImageList *imaglist) - : WidgetsPage(book) + : WidgetsPage(book, imaglist, text_xpm) { - imaglist->Add(wxBitmap(text_xpm)); - // init everything #ifdef __WXMSW__ m_radioKind = diff --git a/samples/widgets/toggle.cpp b/samples/widgets/toggle.cpp index 626bc0c2bb..214474f7ad 100644 --- a/samples/widgets/toggle.cpp +++ b/samples/widgets/toggle.cpp @@ -34,6 +34,7 @@ #ifndef WX_PRECOMP #include "wx/sizer.h" #include "wx/statbox.h" + #include "wx/textctrl.h" #endif #include "icons/toggle.xpm" @@ -114,10 +115,8 @@ IMPLEMENT_WIDGETS_PAGE(ToggleWidgetsPage, wxT("ToggleButton"), ToggleWidgetsPage::ToggleWidgetsPage(WidgetsBookCtrl *book, wxImageList *imaglist) - :WidgetsPage(book) + :WidgetsPage(book, imaglist, toggle_xpm) { - imaglist->Add(wxBitmap(toggle_xpm)); - wxSizer *sizerTop = new wxBoxSizer(wxHORIZONTAL); // left pane diff --git a/samples/widgets/widgets.cpp b/samples/widgets/widgets.cpp index 1a371f0bd9..533b35e819 100644 --- a/samples/widgets/widgets.cpp +++ b/samples/widgets/widgets.cpp @@ -47,6 +47,7 @@ #include "wx/colordlg.h" #include "wx/fontdlg.h" #include "wx/textdlg.h" +#include "wx/imaglist.h" #include "widgets.h" @@ -380,7 +381,7 @@ WidgetsFrame::WidgetsFrame(const wxString& title) // we have 2 panes: book with pages demonstrating the controls in the // upper one and the log window with some buttons in the lower - int style = wxNO_FULL_REPAINT_ON_RESIZE|wxCLIP_CHILDREN|wxBK_DEFAULT; + int style = wxNO_FULL_REPAINT_ON_RESIZE|wxCLIP_CHILDREN|WidgetBookStyle; // Uncomment to suppress page theme (draw in solid colour) //style |= wxNB_NOPAGETHEME; @@ -393,7 +394,7 @@ WidgetsFrame::WidgetsFrame(const wxString& title) style); InitBook(); -#ifndef __SMARTPHONE__ +#ifndef __WXHANDHELD__ // the lower one only has the log listbox and a button to clear it #if USE_LOG wxSizer *sizerDown = new wxStaticBoxSizer( @@ -423,11 +424,11 @@ WidgetsFrame::WidgetsFrame(const wxString& title) sizerTop->Add(0, 5, 0, wxGROW); // spacer in between sizerTop->Add(sizerDown, 0, wxGROW | (wxALL & ~wxTOP), 10); -#else // !__SMARTPHONE__/__SMARTPHONE__ +#else // !__WXHANDHELD__/__WXHANDHELD__ sizerTop->Add(m_book, 1, wxGROW | wxALL ); -#endif // __SMARTPHONE__ +#endif // __WXHANDHELD__ m_panel->SetSizer(sizerTop); @@ -445,9 +446,13 @@ WidgetsFrame::WidgetsFrame(const wxString& title) void WidgetsFrame::InitBook() { +#if USE_ICONS_IN_BOOK wxImageList *imageList = new wxImageList(32, 32); imageList->Add(wxBitmap(sample_xpm)); +#else + wxImageList *imageList = NULL; +#endif #if !USE_TREEBOOK WidgetsBookCtrl *books[MAX_PAGES]; @@ -469,7 +474,11 @@ void WidgetsFrame::InitBook() #if USE_TREEBOOK nPage++; // increase for parent page #else - books[cat] = new WidgetsBookCtrl( m_book, wxID_ANY ); + books[cat] = new WidgetsBookCtrl(m_book, + wxID_ANY, + wxDefaultPosition, + wxDefaultSize, + WidgetBookStyle); #endif for ( WidgetsPageInfo *info = WidgetsPage::ms_widgetPages; @@ -517,7 +526,9 @@ void WidgetsFrame::InitBook() GetMenuBar()->Append(menuPages, _T("&Page")); +#if USE_ICONS_IN_BOOK m_book->AssignImageList(imageList); +#endif for ( cat = 0; cat < MAX_PAGES; cat++ ) { @@ -525,7 +536,9 @@ void WidgetsFrame::InitBook() m_book->AddPage(NULL,WidgetsCategories[cat],false,0); #else m_book->AddPage(books[cat],WidgetsCategories[cat],false,0); +#if USE_ICONS_IN_BOOK books[cat]->SetImageList(imageList); +#endif #endif // now do add them @@ -816,13 +829,21 @@ WidgetsPageInfo::WidgetsPageInfo(Constructor ctor, const wxChar *label, int cate int WidgetsPage::ms_defaultFlags = wxBORDER_DEFAULT; WidgetsPageInfo *WidgetsPage::ms_widgetPages = NULL; -WidgetsPage::WidgetsPage(WidgetsBookCtrl *book) +WidgetsPage::WidgetsPage(WidgetsBookCtrl *book, + wxImageList *imaglist, + char* icon[]) : wxPanel(book, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxNO_FULL_REPAINT_ON_RESIZE | wxCLIP_CHILDREN | wxTAB_TRAVERSAL) { +#if USE_ICONS_IN_BOOK + imaglist->Add(wxBitmap(icon)); +#else + wxUnusedVar(imaglist); + wxUnusedVar(icon); +#endif } wxSizer *WidgetsPage::CreateSizerWithText(wxControl *control, diff --git a/samples/widgets/widgets.h b/samples/widgets/widgets.h index c1abc26796..ca2a8e7cca 100644 --- a/samples/widgets/widgets.h +++ b/samples/widgets/widgets.h @@ -18,22 +18,35 @@ #define WidgetsBookCtrl wxTreebook #define WidgetsBookCtrlEvent wxTreebookEvent #define EVT_WIDGETS_PAGE_CHANGED(id,func) EVT_TREEBOOK_PAGE_CHANGED(id,func) + #define WidgetBookStyle (wxBK_DEFAULT) #else #include "wx/bookctrl.h" #define USE_TREEBOOK 0 #define WidgetsBookCtrl wxBookCtrl #define WidgetsBookCtrlEvent wxBookCtrlEvent #define EVT_WIDGETS_PAGE_CHANGED(id,func) EVT_BOOKCTRL_PAGE_CHANGED(id,func) + #ifdef __POCKETPC__ + #define WidgetBookStyle (wxBK_BOTTOM|wxNB_FLAT) + #else + #define WidgetBookStyle (wxBK_DEFAULT) + #endif #endif -#if wxUSE_LOG && !defined(__SMARTPHONE__) +#if wxUSE_LOG && !defined(__WXHANDHELD__) #define USE_LOG 1 #else #define USE_LOG 0 #endif +#if defined(__WXHANDHELD__) + #define USE_ICONS_IN_BOOK 0 +#else + #define USE_ICONS_IN_BOOK 1 +#endif + class WXDLLEXPORT wxCheckBox; class WXDLLEXPORT wxSizer; +class WXDLLEXPORT wxImageList; class WXDLLEXPORT wxTextCtrl; class WXDLLEXPORT WidgetsBookCtrl; @@ -41,9 +54,6 @@ class WidgetsPageInfo; #include "wx/panel.h" -// all source files use wxImageList -#include "wx/imaglist.h" - // INTRODUCING NEW PAGES DON'T FORGET TO ADD ENTRIES TO 'WidgetsCategories' enum { @@ -81,7 +91,9 @@ enum class WidgetsPage : public wxPanel { public: - WidgetsPage(WidgetsBookCtrl *book); + WidgetsPage(WidgetsBookCtrl *book, + wxImageList *imaglist, + char* icon[]); // return the control shown by this page virtual wxControl *GetWidget() const = 0;