Created
March 16, 2024 17:18
-
-
Save vadz/6fc7c93d5a5d98726151303d12599558 to your computer and use it in GitHub Desktop.
Example of defining a custom dock art provider
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/dc.h> | |
#include <wx/frame.h> | |
#include <wx/panel.h> | |
#include <wx/sizer.h> | |
#include <wx/textctrl.h> | |
#include <wx/aui/aui.h> | |
class TestDockArt : public wxAuiDefaultDockArt { | |
public: | |
void DrawCaption(wxDC& dc, | |
wxWindow* window, | |
const wxString& text, | |
const wxRect& rect, | |
wxAuiPaneInfo& pane) | |
{ | |
dc.SetBrush(*wxBLUE); | |
dc.DrawRectangle(rect); | |
dc.SetTextForeground(*wxYELLOW); | |
dc.DrawText(text, rect.x + window->FromDIP(5), rect.y); | |
} | |
}; | |
class TestPanel : public wxPanel { | |
public: | |
explicit TestPanel(wxWindow* parent) : wxPanel(parent, wxID_ANY) { | |
m_manager.SetManagedWindow(this); | |
m_manager.SetArtProvider(new TestDockArt); | |
m_manager.AddPane(new wxTextCtrl(this, wxID_ANY, "Central pane"), wxAuiPaneInfo().CenterPane()); | |
m_manager.AddPane(new wxTextCtrl(this, wxID_ANY, "Left pane"), wxAuiPaneInfo().Left().Layer(1).MinSize(FromDIP(wxSize(200, 100))).Caption("Left pane").CloseButton()); | |
m_manager.AddPane(new wxTextCtrl(this, wxID_ANY, "Bottom pane"), wxAuiPaneInfo().Bottom().Layer(2).MinSize(FromDIP(wxSize(200, 100))).Caption("Bottom pane").MaximizeButton()); | |
m_manager.Update(); | |
} | |
private: | |
wxAuiManager m_manager; | |
}; | |
class TestApp : public wxApp { | |
public: | |
bool OnInit() override { | |
auto f = new wxFrame(nullptr, wxID_ANY, "Window containing AUI panel"); | |
auto t = new wxTextCtrl(f, wxID_ANY, "Just a text", wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE); | |
auto p = new TestPanel(f); | |
auto s = new wxBoxSizer(wxHORIZONTAL); | |
s->Add(t, wxSizerFlags().Expand()); | |
s->Add(p, wxSizerFlags(1).Expand()); | |
f->SetSizer(s); | |
f->SetClientSize(f->FromDIP(wxSize(800, 600))); | |
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