Created
March 19, 2024 16:46
-
-
Save vadz/ab3f683c4b396471b8c57f188e868b67 to your computer and use it in GitHub Desktop.
Example of using `wxSplitterWindow`
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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