Skip to content

Instantly share code, notes, and snippets.

@vadz
Created March 19, 2024 16:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vadz/ab3f683c4b396471b8c57f188e868b67 to your computer and use it in GitHub Desktop.
Save vadz/ab3f683c4b396471b8c57f188e868b67 to your computer and use it in GitHub Desktop.
Example of using `wxSplitterWindow`
#include <wx/app.h>
#include <wx/frame.h>
#include <wx/splitter.h>
#include <wx/textctrl.h>
class TextCtrlShowingSize : public wxTextCtrl {
public:
explicit TextCtrlShowingSize(wxWindow* parent) : wxTextCtrl(parent, wxID_ANY, {}) {
Bind(wxEVT_SIZE, [this](wxSizeEvent& event) {
auto size = event.GetSize();
SetValue(wxString::Format("Size: %d x %d", size.x, size.y));
event.Skip();
});
}
};
class TestApp : public wxApp {
public:
bool OnInit() override {
auto f = new wxFrame(nullptr, wxID_ANY, "Window with a splitter");
auto s = new wxSplitterWindow(f);
s->SplitVertically(new TextCtrlShowingSize(s), new TextCtrlShowingSize(s), f->FromDIP(200));
s->SetSashGravity(0.5);
s->SetMinimumPaneSize(4);
f->SetClientSize(f->FromDIP(wxSize(500, 300)));
f->Show();
return true;
}
};
wxIMPLEMENT_APP(TestApp);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment