On-demand creation of the pages for speedup of sample launch.
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@39593 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -85,6 +85,9 @@ public:
|
|||||||
virtual wxControl *GetWidget() const { return m_button; }
|
virtual wxControl *GetWidget() const { return m_button; }
|
||||||
virtual void RecreateWidget() { CreateButton(); }
|
virtual void RecreateWidget() { CreateButton(); }
|
||||||
|
|
||||||
|
// lazy creation of the content
|
||||||
|
virtual void CreateContent();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// event handlers
|
// event handlers
|
||||||
void OnCheckOrRadioBox(wxCommandEvent& event);
|
void OnCheckOrRadioBox(wxCommandEvent& event);
|
||||||
@@ -183,7 +186,10 @@ ButtonWidgetsPage::ButtonWidgetsPage(WidgetsBookCtrl *book,
|
|||||||
|
|
||||||
m_button = (wxButton *)NULL;
|
m_button = (wxButton *)NULL;
|
||||||
m_sizerButton = (wxSizer *)NULL;
|
m_sizerButton = (wxSizer *)NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ButtonWidgetsPage::CreateContent()
|
||||||
|
{
|
||||||
wxSizer *sizerTop = new wxBoxSizer(wxHORIZONTAL);
|
wxSizer *sizerTop = new wxBoxSizer(wxHORIZONTAL);
|
||||||
|
|
||||||
// left pane
|
// left pane
|
||||||
|
@@ -79,6 +79,9 @@ public:
|
|||||||
virtual wxControl *GetWidget() const { return m_checkbox; }
|
virtual wxControl *GetWidget() const { return m_checkbox; }
|
||||||
virtual void RecreateWidget() { CreateCheckbox(); }
|
virtual void RecreateWidget() { CreateCheckbox(); }
|
||||||
|
|
||||||
|
// lazy creation of the content
|
||||||
|
virtual void CreateContent();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// event handlers
|
// event handlers
|
||||||
void OnCheckBox(wxCommandEvent& event);
|
void OnCheckBox(wxCommandEvent& event);
|
||||||
@@ -159,6 +162,10 @@ IMPLEMENT_WIDGETS_PAGE(CheckBoxWidgetsPage, wxT("CheckBox"), FAMILY_CTRLS );
|
|||||||
CheckBoxWidgetsPage::CheckBoxWidgetsPage(WidgetsBookCtrl *book,
|
CheckBoxWidgetsPage::CheckBoxWidgetsPage(WidgetsBookCtrl *book,
|
||||||
wxImageList *imaglist)
|
wxImageList *imaglist)
|
||||||
: WidgetsPage(book, imaglist, checkbox_xpm)
|
: WidgetsPage(book, imaglist, checkbox_xpm)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void CheckBoxWidgetsPage::CreateContent()
|
||||||
{
|
{
|
||||||
wxSizer *sizerTop = new wxBoxSizer(wxHORIZONTAL);
|
wxSizer *sizerTop = new wxBoxSizer(wxHORIZONTAL);
|
||||||
|
|
||||||
|
@@ -90,6 +90,9 @@ public:
|
|||||||
virtual wxControl *GetWidget() const { return m_combobox; }
|
virtual wxControl *GetWidget() const { return m_combobox; }
|
||||||
virtual void RecreateWidget() { CreateCombo(); }
|
virtual void RecreateWidget() { CreateCombo(); }
|
||||||
|
|
||||||
|
// lazy creation of the content
|
||||||
|
virtual void CreateContent();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// event handlers
|
// event handlers
|
||||||
void OnButtonReset(wxCommandEvent& event);
|
void OnButtonReset(wxCommandEvent& event);
|
||||||
@@ -212,7 +215,10 @@ ComboboxWidgetsPage::ComboboxWidgetsPage(WidgetsBookCtrl *book,
|
|||||||
|
|
||||||
m_combobox = (wxComboBox *)NULL;
|
m_combobox = (wxComboBox *)NULL;
|
||||||
m_sizerCombo = (wxSizer *)NULL;
|
m_sizerCombo = (wxSizer *)NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ComboboxWidgetsPage::CreateContent()
|
||||||
|
{
|
||||||
/*
|
/*
|
||||||
What we create here is a frame having 3 panes: style pane is the
|
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
|
leftmost one, in the middle the pane with buttons allowing to perform
|
||||||
@@ -408,7 +414,7 @@ void ComboboxWidgetsPage::OnButtonReset(wxCommandEvent& WXUNUSED(event))
|
|||||||
void ComboboxWidgetsPage::OnButtonChange(wxCommandEvent& WXUNUSED(event))
|
void ComboboxWidgetsPage::OnButtonChange(wxCommandEvent& WXUNUSED(event))
|
||||||
{
|
{
|
||||||
int sel = m_combobox->GetSelection();
|
int sel = m_combobox->GetSelection();
|
||||||
if ( sel != -1 )
|
if ( sel != wxNOT_FOUND )
|
||||||
{
|
{
|
||||||
#ifndef __WXGTK__
|
#ifndef __WXGTK__
|
||||||
m_combobox->SetString(sel, m_textChange->GetValue());
|
m_combobox->SetString(sel, m_textChange->GetValue());
|
||||||
@@ -531,7 +537,7 @@ void ComboboxWidgetsPage::OnUpdateUIDeleteButton(wxUpdateUIEvent& event)
|
|||||||
void ComboboxWidgetsPage::OnUpdateUIDeleteSelButton(wxUpdateUIEvent& event)
|
void ComboboxWidgetsPage::OnUpdateUIDeleteSelButton(wxUpdateUIEvent& event)
|
||||||
{
|
{
|
||||||
if (m_combobox)
|
if (m_combobox)
|
||||||
event.Enable(m_combobox->GetSelection() != -1);
|
event.Enable(m_combobox->GetSelection() != wxNOT_FOUND);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ComboboxWidgetsPage::OnUpdateUIClearButton(wxUpdateUIEvent& event)
|
void ComboboxWidgetsPage::OnUpdateUIClearButton(wxUpdateUIEvent& event)
|
||||||
|
@@ -75,6 +75,9 @@ public:
|
|||||||
virtual wxControl *GetWidget() const { return m_datePicker; }
|
virtual wxControl *GetWidget() const { return m_datePicker; }
|
||||||
virtual void RecreateWidget() { CreateDatePicker(); }
|
virtual void RecreateWidget() { CreateDatePicker(); }
|
||||||
|
|
||||||
|
// lazy creation of the content
|
||||||
|
virtual void CreateContent();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// event handlers
|
// event handlers
|
||||||
void OnButtonSet(wxCommandEvent& event);
|
void OnButtonSet(wxCommandEvent& event);
|
||||||
@@ -132,6 +135,10 @@ IMPLEMENT_WIDGETS_PAGE(DatePickerWidgetsPage, wxT("DatePicker"),
|
|||||||
DatePickerWidgetsPage::DatePickerWidgetsPage(WidgetsBookCtrl *book,
|
DatePickerWidgetsPage::DatePickerWidgetsPage(WidgetsBookCtrl *book,
|
||||||
wxImageList *imaglist)
|
wxImageList *imaglist)
|
||||||
:WidgetsPage(book, imaglist, datepick_xpm)
|
:WidgetsPage(book, imaglist, datepick_xpm)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void DatePickerWidgetsPage::CreateContent()
|
||||||
{
|
{
|
||||||
wxSizer *sizerTop = new wxBoxSizer(wxHORIZONTAL);
|
wxSizer *sizerTop = new wxBoxSizer(wxHORIZONTAL);
|
||||||
|
|
||||||
|
@@ -77,6 +77,9 @@ public:
|
|||||||
virtual wxControl *GetWidget() const { return m_gauge; }
|
virtual wxControl *GetWidget() const { return m_gauge; }
|
||||||
virtual void RecreateWidget() { CreateGauge(); }
|
virtual void RecreateWidget() { CreateGauge(); }
|
||||||
|
|
||||||
|
// lazy creation of the content
|
||||||
|
virtual void CreateContent();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// event handlers
|
// event handlers
|
||||||
void OnButtonReset(wxCommandEvent& event);
|
void OnButtonReset(wxCommandEvent& event);
|
||||||
@@ -179,7 +182,10 @@ GaugeWidgetsPage::GaugeWidgetsPage(WidgetsBookCtrl *book,
|
|||||||
|
|
||||||
m_gauge = (wxGauge *)NULL;
|
m_gauge = (wxGauge *)NULL;
|
||||||
m_sizerGauge = (wxSizer *)NULL;
|
m_sizerGauge = (wxSizer *)NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
void GaugeWidgetsPage::CreateContent()
|
||||||
|
{
|
||||||
wxSizer *sizerTop = new wxBoxSizer(wxHORIZONTAL);
|
wxSizer *sizerTop = new wxBoxSizer(wxHORIZONTAL);
|
||||||
|
|
||||||
// left pane
|
// left pane
|
||||||
|
@@ -69,11 +69,14 @@ class HyperlinkWidgetsPage : public WidgetsPage
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
HyperlinkWidgetsPage(WidgetsBookCtrl *book, wxImageList *imaglist);
|
HyperlinkWidgetsPage(WidgetsBookCtrl *book, wxImageList *imaglist);
|
||||||
virtual ~HyperlinkWidgetsPage(){};
|
virtual ~HyperlinkWidgetsPage() {}
|
||||||
|
|
||||||
virtual wxControl *GetWidget() const { return m_hyperlink; }
|
virtual wxControl *GetWidget() const { return m_hyperlink; }
|
||||||
virtual void RecreateWidget() { CreateHyperlink(); }
|
virtual void RecreateWidget() { CreateHyperlink(); }
|
||||||
|
|
||||||
|
// lazy creation of the content
|
||||||
|
virtual void CreateContent();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// event handlers
|
// event handlers
|
||||||
void OnButtonSetLabel(wxCommandEvent& event);
|
void OnButtonSetLabel(wxCommandEvent& event);
|
||||||
@@ -129,6 +132,10 @@ IMPLEMENT_WIDGETS_PAGE(HyperlinkWidgetsPage, wxT("Hyperlink"),
|
|||||||
HyperlinkWidgetsPage::HyperlinkWidgetsPage(WidgetsBookCtrl *book,
|
HyperlinkWidgetsPage::HyperlinkWidgetsPage(WidgetsBookCtrl *book,
|
||||||
wxImageList *imaglist)
|
wxImageList *imaglist)
|
||||||
:WidgetsPage(book, imaglist, hyperlnk_xpm)
|
:WidgetsPage(book, imaglist, hyperlnk_xpm)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void HyperlinkWidgetsPage::CreateContent()
|
||||||
{
|
{
|
||||||
wxSizer *sizerTop = new wxBoxSizer(wxHORIZONTAL);
|
wxSizer *sizerTop = new wxBoxSizer(wxHORIZONTAL);
|
||||||
|
|
||||||
|
@@ -81,6 +81,9 @@ public:
|
|||||||
virtual wxControl *GetWidget() const { return m_lbox; }
|
virtual wxControl *GetWidget() const { return m_lbox; }
|
||||||
virtual void RecreateWidget() { CreateLbox(); }
|
virtual void RecreateWidget() { CreateLbox(); }
|
||||||
|
|
||||||
|
// lazy creation of the content
|
||||||
|
virtual void CreateContent();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// event handlers
|
// event handlers
|
||||||
void OnButtonReset(wxCommandEvent& event);
|
void OnButtonReset(wxCommandEvent& event);
|
||||||
@@ -225,6 +228,10 @@ ListboxWidgetsPage::ListboxWidgetsPage(WidgetsBookCtrl *book,
|
|||||||
m_lbox = NULL;
|
m_lbox = NULL;
|
||||||
m_sizerLbox = (wxSizer *)NULL;
|
m_sizerLbox = (wxSizer *)NULL;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void ListboxWidgetsPage::CreateContent()
|
||||||
|
{
|
||||||
/*
|
/*
|
||||||
What we create here is a frame having 3 panes: style pane is the
|
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
|
leftmost one, in the middle the pane with buttons allowing to perform
|
||||||
|
@@ -92,6 +92,9 @@ public:
|
|||||||
virtual wxControl *GetWidget() const { return m_book; }
|
virtual wxControl *GetWidget() const { return m_book; }
|
||||||
virtual void RecreateWidget() { RecreateBook(); }
|
virtual void RecreateWidget() { RecreateBook(); }
|
||||||
|
|
||||||
|
// lazy creation of the content
|
||||||
|
virtual void CreateContent();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// event handlers
|
// event handlers
|
||||||
void OnButtonReset(wxCommandEvent& event);
|
void OnButtonReset(wxCommandEvent& event);
|
||||||
@@ -199,8 +202,12 @@ BookWidgetsPage::BookWidgetsPage(WidgetsBookCtrl *book, wxImageList *imaglist, c
|
|||||||
#endif // USE_ICONS_IN_BOOK
|
#endif // USE_ICONS_IN_BOOK
|
||||||
|
|
||||||
m_book = NULL;
|
m_book = NULL;
|
||||||
|
m_radioOrient = NULL;
|
||||||
m_sizerBook = (wxSizer *)NULL;
|
m_sizerBook = (wxSizer *)NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
void BookWidgetsPage::CreateContent()
|
||||||
|
{
|
||||||
wxSizer *sizerTop = new wxBoxSizer(wxHORIZONTAL);
|
wxSizer *sizerTop = new wxBoxSizer(wxHORIZONTAL);
|
||||||
|
|
||||||
// left pane
|
// left pane
|
||||||
@@ -343,7 +350,12 @@ void BookWidgetsPage::CreateImageList()
|
|||||||
|
|
||||||
void BookWidgetsPage::RecreateBook()
|
void BookWidgetsPage::RecreateBook()
|
||||||
{
|
{
|
||||||
|
// do not recreate anything in case page content was not prepared yet
|
||||||
|
if(!m_radioOrient)
|
||||||
|
return;
|
||||||
|
|
||||||
int flags = ms_defaultFlags;
|
int flags = ms_defaultFlags;
|
||||||
|
|
||||||
switch ( m_radioOrient->GetSelection() )
|
switch ( m_radioOrient->GetSelection() )
|
||||||
{
|
{
|
||||||
default:
|
default:
|
||||||
@@ -412,8 +424,9 @@ void BookWidgetsPage::RecreateBook()
|
|||||||
|
|
||||||
int BookWidgetsPage::GetTextValue(wxTextCtrl *text) const
|
int BookWidgetsPage::GetTextValue(wxTextCtrl *text) const
|
||||||
{
|
{
|
||||||
long pos;
|
long pos = -1;
|
||||||
if ( !text->GetValue().ToLong(&pos) )
|
|
||||||
|
if ( !text || !text->GetValue().ToLong(&pos) )
|
||||||
pos = -1;
|
pos = -1;
|
||||||
|
|
||||||
return (int)pos;
|
return (int)pos;
|
||||||
@@ -504,17 +517,20 @@ void BookWidgetsPage::OnUpdateUIRemoveButton(wxUpdateUIEvent& event)
|
|||||||
|
|
||||||
void BookWidgetsPage::OnUpdateUIResetButton(wxUpdateUIEvent& event)
|
void BookWidgetsPage::OnUpdateUIResetButton(wxUpdateUIEvent& event)
|
||||||
{
|
{
|
||||||
|
if(m_chkImages && m_radioOrient)
|
||||||
event.Enable( !m_chkImages->GetValue() ||
|
event.Enable( !m_chkImages->GetValue() ||
|
||||||
m_radioOrient->GetSelection() != wxBK_TOP );
|
m_radioOrient->GetSelection() != wxBK_TOP );
|
||||||
}
|
}
|
||||||
|
|
||||||
void BookWidgetsPage::OnUpdateUINumPagesText(wxUpdateUIEvent& event)
|
void BookWidgetsPage::OnUpdateUINumPagesText(wxUpdateUIEvent& event)
|
||||||
{
|
{
|
||||||
|
if(m_book)
|
||||||
event.SetText( wxString::Format(_T("%d"), m_book->GetPageCount()) );
|
event.SetText( wxString::Format(_T("%d"), m_book->GetPageCount()) );
|
||||||
}
|
}
|
||||||
|
|
||||||
void BookWidgetsPage::OnUpdateUICurSelectText(wxUpdateUIEvent& event)
|
void BookWidgetsPage::OnUpdateUICurSelectText(wxUpdateUIEvent& event)
|
||||||
{
|
{
|
||||||
|
if(m_book)
|
||||||
event.SetText( wxString::Format(_T("%d"), m_book->GetSelection()) );
|
event.SetText( wxString::Format(_T("%d"), m_book->GetSelection()) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -90,6 +90,9 @@ public:
|
|||||||
virtual wxControl *GetWidget() const { return m_filePicker; }
|
virtual wxControl *GetWidget() const { return m_filePicker; }
|
||||||
virtual void RecreateWidget() { RecreateAllPickers(); }
|
virtual void RecreateWidget() { RecreateAllPickers(); }
|
||||||
|
|
||||||
|
// lazy creation of the content
|
||||||
|
virtual void CreateContent();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
enum PickerKind
|
enum PickerKind
|
||||||
{
|
{
|
||||||
@@ -206,6 +209,10 @@ IMPLEMENT_WIDGETS_PAGE(PickerWidgetsPage, _T("Pickers"),
|
|||||||
PickerWidgetsPage::PickerWidgetsPage(WidgetsBookCtrl *book,
|
PickerWidgetsPage::PickerWidgetsPage(WidgetsBookCtrl *book,
|
||||||
wxImageList *imaglist)
|
wxImageList *imaglist)
|
||||||
: WidgetsPage(book, imaglist, picker_xpm)
|
: WidgetsPage(book, imaglist, picker_xpm)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void PickerWidgetsPage::CreateContent()
|
||||||
{
|
{
|
||||||
// left pane
|
// left pane
|
||||||
wxSizer *boxleft = new wxBoxSizer(wxVERTICAL);
|
wxSizer *boxleft = new wxBoxSizer(wxVERTICAL);
|
||||||
|
@@ -89,6 +89,9 @@ public:
|
|||||||
virtual wxControl *GetWidget() const { return m_radio; }
|
virtual wxControl *GetWidget() const { return m_radio; }
|
||||||
virtual void RecreateWidget() { CreateRadio(); }
|
virtual void RecreateWidget() { CreateRadio(); }
|
||||||
|
|
||||||
|
// lazy creation of the content
|
||||||
|
virtual void CreateContent();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// event handlers
|
// event handlers
|
||||||
void OnCheckOrRadioBox(wxCommandEvent& event);
|
void OnCheckOrRadioBox(wxCommandEvent& event);
|
||||||
@@ -199,7 +202,10 @@ RadioWidgetsPage::RadioWidgetsPage(WidgetsBookCtrl *book,
|
|||||||
m_radio =
|
m_radio =
|
||||||
m_radioDir = (wxRadioBox *)NULL;
|
m_radioDir = (wxRadioBox *)NULL;
|
||||||
m_sizerRadio = (wxSizer *)NULL;
|
m_sizerRadio = (wxSizer *)NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
void RadioWidgetsPage::CreateContent()
|
||||||
|
{
|
||||||
wxSizer *sizerTop = new wxBoxSizer(wxHORIZONTAL);
|
wxSizer *sizerTop = new wxBoxSizer(wxHORIZONTAL);
|
||||||
|
|
||||||
// left pane
|
// left pane
|
||||||
|
@@ -95,6 +95,9 @@ public:
|
|||||||
virtual wxControl *GetWidget() const { return m_slider; }
|
virtual wxControl *GetWidget() const { return m_slider; }
|
||||||
virtual void RecreateWidget() { CreateSlider(); }
|
virtual void RecreateWidget() { CreateSlider(); }
|
||||||
|
|
||||||
|
// lazy creation of the content
|
||||||
|
virtual void CreateContent();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// event handlers
|
// event handlers
|
||||||
void OnButtonReset(wxCommandEvent& event);
|
void OnButtonReset(wxCommandEvent& event);
|
||||||
@@ -223,7 +226,10 @@ SliderWidgetsPage::SliderWidgetsPage(WidgetsBookCtrl *book,
|
|||||||
|
|
||||||
m_slider = (wxSlider *)NULL;
|
m_slider = (wxSlider *)NULL;
|
||||||
m_sizerSlider = (wxSizer *)NULL;
|
m_sizerSlider = (wxSizer *)NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
void SliderWidgetsPage::CreateContent()
|
||||||
|
{
|
||||||
wxSizer *sizerTop = new wxBoxSizer(wxHORIZONTAL);
|
wxSizer *sizerTop = new wxBoxSizer(wxHORIZONTAL);
|
||||||
|
|
||||||
// left pane
|
// left pane
|
||||||
|
@@ -80,6 +80,9 @@ public:
|
|||||||
virtual wxControl *GetWidget2() const { return m_spinctrl; }
|
virtual wxControl *GetWidget2() const { return m_spinctrl; }
|
||||||
virtual void RecreateWidget() { CreateSpin(); }
|
virtual void RecreateWidget() { CreateSpin(); }
|
||||||
|
|
||||||
|
// lazy creation of the content
|
||||||
|
virtual void CreateContent();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// event handlers
|
// event handlers
|
||||||
void OnButtonReset(wxCommandEvent& event);
|
void OnButtonReset(wxCommandEvent& event);
|
||||||
@@ -197,7 +200,10 @@ SpinBtnWidgetsPage::SpinBtnWidgetsPage(WidgetsBookCtrl *book,
|
|||||||
|
|
||||||
m_spinbtn = (wxSpinButton *)NULL;
|
m_spinbtn = (wxSpinButton *)NULL;
|
||||||
m_sizerSpin = (wxSizer *)NULL;
|
m_sizerSpin = (wxSizer *)NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
void SpinBtnWidgetsPage::CreateContent()
|
||||||
|
{
|
||||||
wxSizer *sizerTop = new wxBoxSizer(wxHORIZONTAL);
|
wxSizer *sizerTop = new wxBoxSizer(wxHORIZONTAL);
|
||||||
|
|
||||||
// left pane
|
// left pane
|
||||||
|
@@ -145,6 +145,9 @@ public:
|
|||||||
virtual wxControl *GetWidget() const { return m_statText; }
|
virtual wxControl *GetWidget() const { return m_statText; }
|
||||||
virtual void RecreateWidget() { CreateStatic(); }
|
virtual void RecreateWidget() { CreateStatic(); }
|
||||||
|
|
||||||
|
// lazy creation of the content
|
||||||
|
virtual void CreateContent();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// event handlers
|
// event handlers
|
||||||
void OnCheckOrRadioBox(wxCommandEvent& event);
|
void OnCheckOrRadioBox(wxCommandEvent& event);
|
||||||
@@ -227,7 +230,10 @@ StaticWidgetsPage::StaticWidgetsPage(WidgetsBookCtrl *book,
|
|||||||
m_staticBox = (wxStaticBox *)NULL;
|
m_staticBox = (wxStaticBox *)NULL;
|
||||||
m_sizerStatBox = (wxStaticBoxSizer *)NULL;
|
m_sizerStatBox = (wxStaticBoxSizer *)NULL;
|
||||||
m_sizerStatic = (wxSizer *)NULL;
|
m_sizerStatic = (wxSizer *)NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
void StaticWidgetsPage::CreateContent()
|
||||||
|
{
|
||||||
wxSizer *sizerTop = new wxBoxSizer(wxHORIZONTAL);
|
wxSizer *sizerTop = new wxBoxSizer(wxHORIZONTAL);
|
||||||
|
|
||||||
// left pane
|
// left pane
|
||||||
|
@@ -138,6 +138,9 @@ public:
|
|||||||
virtual wxControl *GetWidget() const { return m_text; }
|
virtual wxControl *GetWidget() const { return m_text; }
|
||||||
virtual void RecreateWidget() { CreateText(); }
|
virtual void RecreateWidget() { CreateText(); }
|
||||||
|
|
||||||
|
// lazy creation of the content
|
||||||
|
virtual void CreateContent();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// create an info text contorl
|
// create an info text contorl
|
||||||
wxTextCtrl *CreateInfoText();
|
wxTextCtrl *CreateInfoText();
|
||||||
@@ -374,7 +377,10 @@ TextWidgetsPage::TextWidgetsPage(WidgetsBookCtrl *book, wxImageList *imaglist)
|
|||||||
m_posLast =
|
m_posLast =
|
||||||
m_selFrom =
|
m_selFrom =
|
||||||
m_selTo = -2; // not -1 which means "no selection"
|
m_selTo = -2; // not -1 which means "no selection"
|
||||||
|
}
|
||||||
|
|
||||||
|
void TextWidgetsPage::CreateContent()
|
||||||
|
{
|
||||||
// left pane
|
// left pane
|
||||||
static const wxString modes[] =
|
static const wxString modes[] =
|
||||||
{
|
{
|
||||||
|
@@ -64,6 +64,9 @@ public:
|
|||||||
virtual wxControl *GetWidget() const { return m_toggle; }
|
virtual wxControl *GetWidget() const { return m_toggle; }
|
||||||
virtual void RecreateWidget() { CreateToggle(); }
|
virtual void RecreateWidget() { CreateToggle(); }
|
||||||
|
|
||||||
|
// lazy creation of the content
|
||||||
|
virtual void CreateContent();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// event handlers
|
// event handlers
|
||||||
void OnButtonReset(wxCommandEvent& event);
|
void OnButtonReset(wxCommandEvent& event);
|
||||||
@@ -116,6 +119,10 @@ IMPLEMENT_WIDGETS_PAGE(ToggleWidgetsPage, wxT("ToggleButton"),
|
|||||||
ToggleWidgetsPage::ToggleWidgetsPage(WidgetsBookCtrl *book,
|
ToggleWidgetsPage::ToggleWidgetsPage(WidgetsBookCtrl *book,
|
||||||
wxImageList *imaglist)
|
wxImageList *imaglist)
|
||||||
:WidgetsPage(book, imaglist, toggle_xpm)
|
:WidgetsPage(book, imaglist, toggle_xpm)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void ToggleWidgetsPage::CreateContent()
|
||||||
{
|
{
|
||||||
wxSizer *sizerTop = new wxBoxSizer(wxHORIZONTAL);
|
wxSizer *sizerTop = new wxBoxSizer(wxHORIZONTAL);
|
||||||
|
|
||||||
|
@@ -48,6 +48,7 @@
|
|||||||
#include "wx/fontdlg.h"
|
#include "wx/fontdlg.h"
|
||||||
#include "wx/textdlg.h"
|
#include "wx/textdlg.h"
|
||||||
#include "wx/imaglist.h"
|
#include "wx/imaglist.h"
|
||||||
|
#include "wx/wupdlock.h"
|
||||||
|
|
||||||
#include "widgets.h"
|
#include "widgets.h"
|
||||||
|
|
||||||
@@ -567,12 +568,17 @@ void WidgetsFrame::InitBook()
|
|||||||
|
|
||||||
WidgetsPage *WidgetsFrame::CurrentPage()
|
WidgetsPage *WidgetsFrame::CurrentPage()
|
||||||
{
|
{
|
||||||
|
wxWindow *page = m_book->GetCurrentPage();
|
||||||
|
if(!page) return NULL;
|
||||||
|
|
||||||
#if USE_TREEBOOK
|
#if USE_TREEBOOK
|
||||||
return wxStaticCast(m_book->GetCurrentPage(), WidgetsPage);
|
return wxStaticCast(page, WidgetsPage);
|
||||||
#else
|
#else
|
||||||
WidgetsBookCtrl *book = wxStaticCast(m_book->GetCurrentPage(), WidgetsBookCtrl);
|
WidgetsBookCtrl *subBook = wxStaticCast(page, WidgetsBookCtrl);
|
||||||
if (!book) return NULL;
|
if (!subBook) return NULL;
|
||||||
return wxStaticCast(book->GetCurrentPage(), WidgetsPage);
|
page = subBook->GetCurrentPage();
|
||||||
|
if(!page) return NULL;
|
||||||
|
return wxStaticCast(page, WidgetsPage);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -603,8 +609,29 @@ void WidgetsFrame::OnButtonClearLog(wxCommandEvent& WXUNUSED(event))
|
|||||||
|
|
||||||
void WidgetsFrame::OnPageChanged(WidgetsBookCtrlEvent& event)
|
void WidgetsFrame::OnPageChanged(WidgetsBookCtrlEvent& event)
|
||||||
{
|
{
|
||||||
|
// adjust "Page" menu selection
|
||||||
wxMenuItem *item = GetMenuBar()->FindItem(Widgets_GoToPage + event.GetSelection());
|
wxMenuItem *item = GetMenuBar()->FindItem(Widgets_GoToPage + event.GetSelection());
|
||||||
if (item) item->Check();
|
if (item) item->Check();
|
||||||
|
|
||||||
|
// lazy creation of the pages
|
||||||
|
WidgetsPage* page = CurrentPage();
|
||||||
|
if (page && (page->GetChildren().GetCount()==0))
|
||||||
|
{
|
||||||
|
wxWindowUpdateLocker noUpdates(page);
|
||||||
|
page->CreateContent();
|
||||||
|
WidgetsBookCtrl *book = wxStaticCast(page->GetParent(), WidgetsBookCtrl);
|
||||||
|
wxSize size;
|
||||||
|
for ( size_t i = 0; i < book->GetPageCount(); ++i )
|
||||||
|
{
|
||||||
|
wxWindow *page = book->GetPage(i);
|
||||||
|
if (page)
|
||||||
|
{
|
||||||
|
size.IncTo(page->GetSize());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
page->SetSize(size);
|
||||||
|
}
|
||||||
|
|
||||||
event.Skip();
|
event.Skip();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -98,6 +98,9 @@ public:
|
|||||||
// return the control shown by this page
|
// return the control shown by this page
|
||||||
virtual wxControl *GetWidget() const = 0;
|
virtual wxControl *GetWidget() const = 0;
|
||||||
|
|
||||||
|
// lazy creation of the content
|
||||||
|
virtual void CreateContent() = 0;
|
||||||
|
|
||||||
// some pages show 2 controls, in this case override this one as well
|
// some pages show 2 controls, in this case override this one as well
|
||||||
virtual wxControl *GetWidget2() const { return NULL; }
|
virtual wxControl *GetWidget2() const { return NULL; }
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user