+// ----------------------------------------------------------------------------
+// MyProportionsFrame
+// ----------------------------------------------------------------------------
+
+MyProportionsFrame::MyProportionsFrame(wxFrame *parent)
+ : wxFrame(parent, wxID_ANY, _T("Box Sizer Proportions Demo"))
+{
+ size_t n;
+
+ // create the controls
+ wxPanel *panel = new wxPanel(this, wxID_ANY);
+ for ( n = 0; n < WXSIZEOF(m_spins); n++ )
+ {
+ m_spins[n] = new wxSpinCtrl(panel);
+ m_spins[n]->SetValue(n);
+ }
+
+ // lay them out
+ m_sizer = new wxStaticBoxSizer(wxHORIZONTAL, panel,
+ _T("Try changing elements proportions and resizing the window"));
+ for ( n = 0; n < WXSIZEOF(m_spins); n++ )
+ m_sizer->Add(m_spins[n], wxSizerFlags().Border());
+
+ // put everything together
+ panel->SetSizer(m_sizer);
+ wxSizer *sizerTop = new wxBoxSizer(wxVERTICAL);
+ sizerTop->Add(panel, wxSizerFlags(1).Expand().Border());
+ UpdateProportions();
+ SetSizerAndFit(sizerTop);
+
+ // and connect the events
+ Connect(wxEVT_COMMAND_TEXT_UPDATED,
+ wxCommandEventHandler(MyProportionsFrame::OnProportionUpdated));
+ Connect(wxEVT_COMMAND_SPINCTRL_UPDATED,
+ wxSpinEventHandler(MyProportionsFrame::OnProportionChanged));
+}
+
+void MyProportionsFrame::UpdateProportions()
+{
+ for ( size_t n = 0; n < WXSIZEOF(m_spins); n++ )
+ {
+ m_sizer->GetItem(n)->SetProportion(m_spins[n]->GetValue());
+ }
+
+ m_sizer->Layout();
+}
+
+void MyProportionsFrame::OnProportionUpdated(wxCommandEvent& WXUNUSED(event))
+{
+ UpdateProportions();
+}
+
+void MyProportionsFrame::OnProportionChanged(wxSpinEvent& WXUNUSED(event))
+{
+ UpdateProportions();
+}