virtual ~SpinBtnWidgetsPage(){};
virtual wxControl *GetWidget() const { return m_spinbtn; }
- virtual wxControl *GetWidget2() const { return m_spinctrl; }
- virtual wxControl *GetWidget3() const { return m_spinctrldbl; }
+ virtual Widgets GetWidgets() const
+ {
+ Widgets widgets(WidgetsPage::GetWidgets());
+ widgets.push_back(m_spinctrl);
+ widgets.push_back(m_spinctrldbl);
+ return widgets;
+ }
+
virtual void RecreateWidget() { CreateSpin(); }
// lazy creation of the content
WidgetsPage *page = CurrentPage();
- page->GetWidget()->SetToolTip(s_tip);
-
- wxControl *ctrl2 = page->GetWidget2();
- if ( ctrl2 )
- ctrl2->SetToolTip(s_tip);
+ const Widgets widgets = page->GetWidgets();
+ for ( Widgets::const_iterator it = widgets.begin();
+ it != widgets.end();
+ ++it )
+ {
+ (*it)->SetToolTip(s_tip);
+ }
}
#endif // wxUSE_TOOLTIPS
m_colFg = col;
- page->GetWidget()->SetForegroundColour(m_colFg);
- page->GetWidget()->Refresh();
-
- wxControl *ctrl2 = page->GetWidget2();
- if ( ctrl2 )
+ const Widgets widgets = page->GetWidgets();
+ for ( Widgets::const_iterator it = widgets.begin();
+ it != widgets.end();
+ ++it )
{
- ctrl2->SetForegroundColour(m_colFg);
- ctrl2->Refresh();
+ (*it)->SetForegroundColour(m_colFg);
+ (*it)->Refresh();
}
#else
wxLogMessage(wxT("Colour selection dialog not available in current build."));
m_colBg = col;
- page->GetWidget()->SetBackgroundColour(m_colBg);
- page->GetWidget()->Refresh();
-
- wxControl *ctrl2 = page->GetWidget2();
- if ( ctrl2 )
+ const Widgets widgets = page->GetWidgets();
+ for ( Widgets::const_iterator it = widgets.begin();
+ it != widgets.end();
+ ++it )
{
- ctrl2->SetBackgroundColour(m_colFg);
- ctrl2->Refresh();
+ (*it)->SetBackgroundColour(m_colBg);
+ (*it)->Refresh();
}
#else
wxLogMessage(wxT("Colour selection dialog not available in current build."));
m_font = font;
- page->GetWidget()->SetFont(m_font);
- page->GetWidget()->Refresh();
-
- wxControl *ctrl2 = page->GetWidget2();
- if ( ctrl2 )
+ const Widgets widgets = page->GetWidgets();
+ for ( Widgets::const_iterator it = widgets.begin();
+ it != widgets.end();
+ ++it )
{
- ctrl2->SetFont(m_font);
- ctrl2->Refresh();
+ (*it)->SetFont(m_font);
+ (*it)->Refresh();
}
#else
wxLogMessage(wxT("Font selection dialog not available in current build."));
void WidgetsFrame::OnEnable(wxCommandEvent& event)
{
- CurrentPage()->GetWidget()->Enable(event.IsChecked());
- if (CurrentPage()->GetWidget2())
- CurrentPage()->GetWidget2()->Enable(event.IsChecked());
+ const Widgets widgets = CurrentPage()->GetWidgets();
+ for ( Widgets::const_iterator it = widgets.begin();
+ it != widgets.end();
+ ++it )
+ {
+ (*it)->Enable(event.IsChecked());
+ }
}
void WidgetsFrame::OnSetBorder(wxCommandEvent& event)
void WidgetsFrame::OnToggleBusyCursor(wxCommandEvent& event)
{
- CurrentPage()->GetWidget()->SetCursor(*(event.IsChecked()
- ? wxHOURGLASS_CURSOR
- : wxSTANDARD_CURSOR));
+ wxCursor cursor(*(event.IsChecked() ? wxHOURGLASS_CURSOR
+ : wxSTANDARD_CURSOR));
+
+ const Widgets widgets = CurrentPage()->GetWidgets();
+ for ( Widgets::const_iterator it = widgets.begin();
+ it != widgets.end();
+ ++it )
+ {
+ (*it)->SetCursor(cursor);
+ }
}
void WidgetsFrame::OnDisableAutoComplete(wxCommandEvent& WXUNUSED(event))
class WidgetsPageInfo;
#include "wx/panel.h"
+#include "wx/vector.h"
// INTRODUCING NEW PAGES DON'T FORGET TO ADD ENTRIES TO 'WidgetsCategories'
enum
ALL_CTRLS = 1 << ALL_PAGE
};
+typedef wxVector<wxControl *> Widgets;
+
// ----------------------------------------------------------------------------
// WidgetsPage: a book page demonstrating some widget
// ----------------------------------------------------------------------------
// lazy creation of the content
virtual void CreateContent() = 0;
- // some pages show 2 controls, in this case override this one as well
- virtual wxControl *GetWidget2() const { return NULL; }
+ // some pages show additional controls, in this case override this one to
+ // return all of them (including the one returned by GetWidget())
+ virtual Widgets GetWidgets() const
+ {
+ Widgets widgets;
+ widgets.push_back(GetWidget());
+ return widgets;
+ }
// recreate the control shown by this page
//