X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/13a3888794c97e06686a9f40189d63f708e891ba..3c01c5951189e13b8b4a5d7b288b54d4a57a30f8:/samples/wrapsizer/wrapsizer.cpp?ds=sidebyside diff --git a/samples/wrapsizer/wrapsizer.cpp b/samples/wrapsizer/wrapsizer.cpp index 19a66de76e..b65694e3b9 100644 --- a/samples/wrapsizer/wrapsizer.cpp +++ b/samples/wrapsizer/wrapsizer.cpp @@ -3,7 +3,7 @@ // Purpose: wxWidgets sample demonstrating wxWrapSizer use // Author: Arne Steinarson // Created: 21.01.2008 -// RCS-ID: $Id:$ +// RCS-ID: $Id$ // Copyright: (c) Arne Steinarson // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -21,70 +21,19 @@ #include "wx/wrapsizer.h" #include "wx/artprov.h" +#ifndef __WXMSW__ + #include "../sample.xpm" +#endif + + +// ---------------------------------------------------------------------------- +// definitions +// ---------------------------------------------------------------------------- + class WrapSizerFrame : public wxFrame { public: - WrapSizerFrame() - : wxFrame(NULL, wxID_ANY, "wxWrapSizer Sample") - { - // Root sizer, vertical - wxSizer * const sizerRoot = new wxBoxSizer(wxVERTICAL); - - // Some toolbars in a wrap sizer - wxSizer * const sizerTop = new wxWrapSizer( wxHORIZONTAL ); - sizerTop->Add(MakeToolBar()); - sizerTop->Add(20, 1); - sizerTop->Add(MakeToolBar()); - sizerTop->Add(20, 1); - sizerTop->Add(MakeToolBar()); - sizerRoot->Add(sizerTop, wxSizerFlags().Expand().Border()); - - // A number of checkboxes inside a wrap sizer - wxSizer *sizerMid = new wxStaticBoxSizer(wxVERTICAL, this, - "With check-boxes"); - wxSizer * const sizerMidWrap = new wxWrapSizer(wxHORIZONTAL); - for ( int nCheck = 0; nCheck < 6; nCheck++ ) - { - wxCheckBox *chk = new wxCheckBox - ( - this, - wxID_ANY, - wxString::Format("Option %d", nCheck) - ); - - sizerMidWrap->Add(chk, wxSizerFlags().Centre().Border()); - } - - sizerMid->Add(sizerMidWrap, wxSizerFlags(100).Expand()); - sizerRoot->Add(sizerMid, wxSizerFlags(100).Expand().Border()); - - - // A shaped item inside a box sizer - wxSizer *sizerBottom = new wxStaticBoxSizer(wxVERTICAL, this, - "With wxSHAPED item"); - wxSizer *sizerBottomBox = new wxBoxSizer(wxHORIZONTAL); - sizerBottom->Add(sizerBottomBox, wxSizerFlags(100).Expand()); - - sizerBottomBox->Add(new wxListBox(this, wxID_ANY, - wxPoint(0, 0), wxSize(70, 70)), - wxSizerFlags().Expand().Shaped()); - sizerBottomBox->AddSpacer(10); - sizerBottomBox->Add(new wxCheckBox(this, wxID_ANY, - "A much longer option..."), - wxSizerFlags(100).Border()); - sizerRoot->Add(sizerBottom, wxSizerFlags(100).Expand().Border()); - - // OK Button - sizerRoot->Add(new wxButton(this, wxID_OK), - wxSizerFlags().Centre().DoubleBorder()); - Connect(wxID_OK, wxEVT_COMMAND_BUTTON_CLICKED, - wxCommandEventHandler(WrapSizerFrame::OnButton)); - - // Set sizer for window - SetSizerAndFit(sizerRoot); - - Show(); - } + WrapSizerFrame(); private: void OnButton(wxCommandEvent& WXUNUSED(event)) @@ -116,10 +65,8 @@ private: tb->Realize( ); return tb; } - }; - class WrapSizerApp : public wxApp { public: @@ -133,3 +80,73 @@ public: }; IMPLEMENT_APP(WrapSizerApp); + + +// ---------------------------------------------------------------------------- +// WrapSizerFrame +// ---------------------------------------------------------------------------- + +WrapSizerFrame::WrapSizerFrame() + : wxFrame(NULL, wxID_ANY, "wxWrapSizer Sample") +{ + SetIcon(wxICON(sample)); + + // Root sizer, vertical + wxSizer * const sizerRoot = new wxBoxSizer(wxVERTICAL); + + // Some toolbars in a wrap sizer + wxSizer * const sizerTop = new wxWrapSizer( wxHORIZONTAL ); + sizerTop->Add(MakeToolBar()); + sizerTop->Add(20, 1); + sizerTop->Add(MakeToolBar()); + sizerTop->Add(20, 1); + sizerTop->Add(MakeToolBar()); + sizerRoot->Add(sizerTop, wxSizerFlags().Expand().Border()); + + // A number of checkboxes inside a wrap sizer + wxSizer *sizerMid = new wxStaticBoxSizer(wxVERTICAL, this, + "With check-boxes"); + wxSizer * const sizerMidWrap = new wxWrapSizer(wxHORIZONTAL); + for ( int nCheck = 0; nCheck < 6; nCheck++ ) + { + wxCheckBox *chk = new wxCheckBox + ( + this, + wxID_ANY, + wxString::Format("Option %d", nCheck) + ); + + sizerMidWrap->Add(chk, wxSizerFlags().Centre().Border()); + } + + sizerMid->Add(sizerMidWrap, wxSizerFlags(100).Expand()); + sizerRoot->Add(sizerMid, wxSizerFlags(100).Expand().Border()); + + + // A shaped item inside a box sizer + wxSizer *sizerBottom = new wxStaticBoxSizer(wxVERTICAL, this, + "With wxSHAPED item"); + wxSizer *sizerBottomBox = new wxBoxSizer(wxHORIZONTAL); + sizerBottom->Add(sizerBottomBox, wxSizerFlags(100).Expand()); + + sizerBottomBox->Add(new wxListBox(this, wxID_ANY, + wxPoint(0, 0), wxSize(70, 70)), + wxSizerFlags().Expand().Shaped()); + sizerBottomBox->AddSpacer(10); + sizerBottomBox->Add(new wxCheckBox(this, wxID_ANY, + "A much longer option..."), + wxSizerFlags(100).Border()); + sizerRoot->Add(sizerBottom, wxSizerFlags(100).Expand().Border()); + + // OK Button + sizerRoot->Add(new wxButton(this, wxID_OK), + wxSizerFlags().Centre().DoubleBorder()); + Connect(wxID_OK, wxEVT_COMMAND_BUTTON_CLICKED, + wxCommandEventHandler(WrapSizerFrame::OnButton)); + + // Set sizer for window + SetSizerAndFit(sizerRoot); + + Show(); +} +