virtual wxControl *GetWidget() const { return m_button; }
virtual void RecreateWidget() { CreateButton(); }
+ // lazy creation of the content
+ virtual void CreateContent();
+
protected:
// event handlers
void OnCheckOrRadioBox(wxCommandEvent& event);
m_button = (wxButton *)NULL;
m_sizerButton = (wxSizer *)NULL;
+}
+void ButtonWidgetsPage::CreateContent()
+{
wxSizer *sizerTop = new wxBoxSizer(wxHORIZONTAL);
// left pane
virtual wxControl *GetWidget() const { return m_checkbox; }
virtual void RecreateWidget() { CreateCheckbox(); }
+ // lazy creation of the content
+ virtual void CreateContent();
+
protected:
// event handlers
void OnCheckBox(wxCommandEvent& event);
CheckBoxWidgetsPage::CheckBoxWidgetsPage(WidgetsBookCtrl *book,
wxImageList *imaglist)
: WidgetsPage(book, imaglist, checkbox_xpm)
+{
+}
+
+void CheckBoxWidgetsPage::CreateContent()
{
wxSizer *sizerTop = new wxBoxSizer(wxHORIZONTAL);
virtual wxControl *GetWidget() const { return m_combobox; }
virtual void RecreateWidget() { CreateCombo(); }
+ // lazy creation of the content
+ virtual void CreateContent();
+
protected:
// event handlers
void OnButtonReset(wxCommandEvent& event);
m_combobox = (wxComboBox *)NULL;
m_sizerCombo = (wxSizer *)NULL;
+}
+void ComboboxWidgetsPage::CreateContent()
+{
/*
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
void ComboboxWidgetsPage::OnButtonChange(wxCommandEvent& WXUNUSED(event))
{
int sel = m_combobox->GetSelection();
- if ( sel != -1 )
+ if ( sel != wxNOT_FOUND )
{
#ifndef __WXGTK__
m_combobox->SetString(sel, m_textChange->GetValue());
void ComboboxWidgetsPage::OnUpdateUIDeleteSelButton(wxUpdateUIEvent& event)
{
if (m_combobox)
- event.Enable(m_combobox->GetSelection() != -1);
+ event.Enable(m_combobox->GetSelection() != wxNOT_FOUND);
}
void ComboboxWidgetsPage::OnUpdateUIClearButton(wxUpdateUIEvent& event)
virtual wxControl *GetWidget() const { return m_datePicker; }
virtual void RecreateWidget() { CreateDatePicker(); }
+ // lazy creation of the content
+ virtual void CreateContent();
+
protected:
// event handlers
void OnButtonSet(wxCommandEvent& event);
DatePickerWidgetsPage::DatePickerWidgetsPage(WidgetsBookCtrl *book,
wxImageList *imaglist)
:WidgetsPage(book, imaglist, datepick_xpm)
+{
+}
+
+void DatePickerWidgetsPage::CreateContent()
{
wxSizer *sizerTop = new wxBoxSizer(wxHORIZONTAL);
virtual wxControl *GetWidget() const { return m_gauge; }
virtual void RecreateWidget() { CreateGauge(); }
+ // lazy creation of the content
+ virtual void CreateContent();
+
protected:
// event handlers
void OnButtonReset(wxCommandEvent& event);
m_gauge = (wxGauge *)NULL;
m_sizerGauge = (wxSizer *)NULL;
+}
+void GaugeWidgetsPage::CreateContent()
+{
wxSizer *sizerTop = new wxBoxSizer(wxHORIZONTAL);
// left pane
{
public:
HyperlinkWidgetsPage(WidgetsBookCtrl *book, wxImageList *imaglist);
- virtual ~HyperlinkWidgetsPage(){};
+ virtual ~HyperlinkWidgetsPage() {}
virtual wxControl *GetWidget() const { return m_hyperlink; }
virtual void RecreateWidget() { CreateHyperlink(); }
+ // lazy creation of the content
+ virtual void CreateContent();
+
protected:
// event handlers
void OnButtonSetLabel(wxCommandEvent& event);
HyperlinkWidgetsPage::HyperlinkWidgetsPage(WidgetsBookCtrl *book,
wxImageList *imaglist)
- :WidgetsPage(book, imaglist, hyperlnk_xpm)
+ :WidgetsPage(book, imaglist, hyperlnk_xpm)
+{
+}
+
+void HyperlinkWidgetsPage::CreateContent()
{
wxSizer *sizerTop = new wxBoxSizer(wxHORIZONTAL);
virtual wxControl *GetWidget() const { return m_lbox; }
virtual void RecreateWidget() { CreateLbox(); }
+ // lazy creation of the content
+ virtual void CreateContent();
+
protected:
// event handlers
void OnButtonReset(wxCommandEvent& event);
#ifdef __WXWINCE__
wxListBoxBase
#else
- wxListBox
+ wxListBox
#endif
*m_lbox;
m_lbox = NULL;
m_sizerLbox = (wxSizer *)NULL;
+}
+
+void ListboxWidgetsPage::CreateContent()
+{
/*
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
virtual wxControl *GetWidget() const { return m_book; }
virtual void RecreateWidget() { RecreateBook(); }
+ // lazy creation of the content
+ virtual void CreateContent();
+
protected:
// event handlers
void OnButtonReset(wxCommandEvent& event);
#endif // USE_ICONS_IN_BOOK
m_book = NULL;
+ m_radioOrient = NULL;
m_sizerBook = (wxSizer *)NULL;
+}
+void BookWidgetsPage::CreateContent()
+{
wxSizer *sizerTop = new wxBoxSizer(wxHORIZONTAL);
// left pane
void BookWidgetsPage::RecreateBook()
{
+ // do not recreate anything in case page content was not prepared yet
+ if(!m_radioOrient)
+ return;
+
int flags = ms_defaultFlags;
+
switch ( m_radioOrient->GetSelection() )
{
default:
int BookWidgetsPage::GetTextValue(wxTextCtrl *text) const
{
- long pos;
- if ( !text->GetValue().ToLong(&pos) )
+ long pos = -1;
+
+ if ( !text || !text->GetValue().ToLong(&pos) )
pos = -1;
return (int)pos;
void BookWidgetsPage::OnUpdateUIResetButton(wxUpdateUIEvent& event)
{
- event.Enable( !m_chkImages->GetValue() ||
- m_radioOrient->GetSelection() != wxBK_TOP );
+ if(m_chkImages && m_radioOrient)
+ event.Enable( !m_chkImages->GetValue() ||
+ m_radioOrient->GetSelection() != wxBK_TOP );
}
void BookWidgetsPage::OnUpdateUINumPagesText(wxUpdateUIEvent& event)
{
- event.SetText( wxString::Format(_T("%d"), m_book->GetPageCount()) );
+ if(m_book)
+ event.SetText( wxString::Format(_T("%d"), m_book->GetPageCount()) );
}
void BookWidgetsPage::OnUpdateUICurSelectText(wxUpdateUIEvent& event)
{
- event.SetText( wxString::Format(_T("%d"), m_book->GetSelection()) );
+ if(m_book)
+ event.SetText( wxString::Format(_T("%d"), m_book->GetSelection()) );
}
void BookWidgetsPage::OnCheckOrRadioBox(wxCommandEvent& WXUNUSED(event))
virtual wxControl *GetWidget() const { return m_filePicker; }
virtual void RecreateWidget() { RecreateAllPickers(); }
+ // lazy creation of the content
+ virtual void CreateContent();
+
protected:
enum PickerKind
{
PickerWidgetsPage::PickerWidgetsPage(WidgetsBookCtrl *book,
wxImageList *imaglist)
: WidgetsPage(book, imaglist, picker_xpm)
+{
+}
+
+void PickerWidgetsPage::CreateContent()
{
// left pane
wxSizer *boxleft = new wxBoxSizer(wxVERTICAL);
virtual wxControl *GetWidget() const { return m_radio; }
virtual void RecreateWidget() { CreateRadio(); }
+ // lazy creation of the content
+ virtual void CreateContent();
+
protected:
// event handlers
void OnCheckOrRadioBox(wxCommandEvent& event);
m_radio =
m_radioDir = (wxRadioBox *)NULL;
m_sizerRadio = (wxSizer *)NULL;
+}
+void RadioWidgetsPage::CreateContent()
+{
wxSizer *sizerTop = new wxBoxSizer(wxHORIZONTAL);
// left pane
virtual wxControl *GetWidget() const { return m_slider; }
virtual void RecreateWidget() { CreateSlider(); }
+ // lazy creation of the content
+ virtual void CreateContent();
+
protected:
// event handlers
void OnButtonReset(wxCommandEvent& event);
m_slider = (wxSlider *)NULL;
m_sizerSlider = (wxSizer *)NULL;
+}
+void SliderWidgetsPage::CreateContent()
+{
wxSizer *sizerTop = new wxBoxSizer(wxHORIZONTAL);
// left pane
virtual wxControl *GetWidget2() const { return m_spinctrl; }
virtual void RecreateWidget() { CreateSpin(); }
+ // lazy creation of the content
+ virtual void CreateContent();
+
protected:
// event handlers
void OnButtonReset(wxCommandEvent& event);
m_spinbtn = (wxSpinButton *)NULL;
m_sizerSpin = (wxSizer *)NULL;
+}
+void SpinBtnWidgetsPage::CreateContent()
+{
wxSizer *sizerTop = new wxBoxSizer(wxHORIZONTAL);
// left pane
virtual wxControl *GetWidget() const { return m_statText; }
virtual void RecreateWidget() { CreateStatic(); }
+ // lazy creation of the content
+ virtual void CreateContent();
+
protected:
// event handlers
void OnCheckOrRadioBox(wxCommandEvent& event);
m_staticBox = (wxStaticBox *)NULL;
m_sizerStatBox = (wxStaticBoxSizer *)NULL;
m_sizerStatic = (wxSizer *)NULL;
+}
+void StaticWidgetsPage::CreateContent()
+{
wxSizer *sizerTop = new wxBoxSizer(wxHORIZONTAL);
// left pane
virtual wxControl *GetWidget() const { return m_text; }
virtual void RecreateWidget() { CreateText(); }
+ // lazy creation of the content
+ virtual void CreateContent();
+
protected:
// create an info text contorl
wxTextCtrl *CreateInfoText();
m_posLast =
m_selFrom =
m_selTo = -2; // not -1 which means "no selection"
+}
+void TextWidgetsPage::CreateContent()
+{
// left pane
static const wxString modes[] =
{
virtual wxControl *GetWidget() const { return m_toggle; }
virtual void RecreateWidget() { CreateToggle(); }
+ // lazy creation of the content
+ virtual void CreateContent();
+
protected:
// event handlers
void OnButtonReset(wxCommandEvent& event);
ToggleWidgetsPage::ToggleWidgetsPage(WidgetsBookCtrl *book,
wxImageList *imaglist)
:WidgetsPage(book, imaglist, toggle_xpm)
+{
+}
+
+void ToggleWidgetsPage::CreateContent()
{
wxSizer *sizerTop = new wxBoxSizer(wxHORIZONTAL);
#include "wx/fontdlg.h"
#include "wx/textdlg.h"
#include "wx/imaglist.h"
+#include "wx/wupdlock.h"
#include "widgets.h"
WidgetsPage *WidgetsFrame::CurrentPage()
{
+ wxWindow *page = m_book->GetCurrentPage();
+ if(!page) return NULL;
+
#if USE_TREEBOOK
- return wxStaticCast(m_book->GetCurrentPage(), WidgetsPage);
+ return wxStaticCast(page, WidgetsPage);
#else
- WidgetsBookCtrl *book = wxStaticCast(m_book->GetCurrentPage(), WidgetsBookCtrl);
- if (!book) return NULL;
- return wxStaticCast(book->GetCurrentPage(), WidgetsPage);
+ WidgetsBookCtrl *subBook = wxStaticCast(page, WidgetsBookCtrl);
+ if (!subBook) return NULL;
+ page = subBook->GetCurrentPage();
+ if(!page) return NULL;
+ return wxStaticCast(page, WidgetsPage);
#endif
}
void WidgetsFrame::OnPageChanged(WidgetsBookCtrlEvent& event)
{
+ // adjust "Page" menu selection
wxMenuItem *item = GetMenuBar()->FindItem(Widgets_GoToPage + event.GetSelection());
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();
}
// return the control shown by this page
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
virtual wxControl *GetWidget2() const { return NULL; }