Skip to content

Instantly share code, notes, and snippets.

@vadz
Last active December 21, 2015 22:59
Show Gist options
  • Save vadz/6378729 to your computer and use it in GitHub Desktop.
Save vadz/6378729 to your computer and use it in GitHub Desktop.
A simple wxWidgets example converted to C++11
#include <wx/wx.h>
class MyFrame : public wxFrame
{
public:
MyFrame() : wxFrame(nullptr, wxID_ANY, "Test")
{
auto sizer = new wxBoxSizer(wxHORIZONTAL);
sizer->Add(new wxStaticText(this, wxID_ANY, "Press to enlarge"), wxSizerFlags().Border().Centre());
auto btn = new wxButton(this, wxID_OK);
btn->Bind(wxEVT_BUTTON, [=](wxCommandEvent&) {
for ( auto& w: GetChildren() )
w->SetFont(w->GetFont().Larger());
Fit();
});
sizer->Add(btn, wxSizerFlags().Border().Centre());
SetSizerAndFit(sizer);
Show(true);
}
};
class MyApp : public wxApp
{
public:
virtual bool OnInit() override { new MyFrame; return true; }
};
wxIMPLEMENT_APP(MyApp);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment