1

我需要在一个框架中有 3 个面板,其中左面板和右面板应该由用户通过向左或向右拖动来调整。我已经使用 AUI 管理器完成了这项工作,但我想在不使用 AUI 的情况下做同样的事情(可能是 sizers)。任何想法如何实现这一目标?我已经尝试如下所示,但我无法调整面板的大小。

MyFrame1::MyFrame1( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style) : wxFrame( parent, id, title, pos, size, style) { this->SetSizeHints( wxDefaultSize, wxDefaultSize );

wxBoxSizer* bSizer6;
bSizer6 = new wxBoxSizer( wxHORIZONTAL );

wxBoxSizer* bSizer7;
bSizer7 = new wxBoxSizer( wxHORIZONTAL );

m_panel11 = new wxPanel( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL );
bSizer7->Add( m_panel11, 5, wxEXPAND | wxALL, 5 );


bSizer7->Add( 0, 0, 1, wxEXPAND, 5 );


bSizer6->Add( bSizer7, 1, wxEXPAND, 5 );

wxBoxSizer* bSizer9;
bSizer9 = new wxBoxSizer( wxHORIZONTAL );

m_panel12 = new wxPanel( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL );
bSizer9->Add( m_panel12, 1, wxEXPAND | wxALL, 5 );


bSizer6->Add( bSizer9, 1, wxEXPAND, 5 );

wxBoxSizer* bSizer10;
bSizer10 = new wxBoxSizer( wxHORIZONTAL );

m_panel13 = new wxPanel( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL );
bSizer10->Add( m_panel13, 1, wxEXPAND | wxALL, 5 );


bSizer6->Add( bSizer10, 1, wxEXPAND, 5 );


this->SetSizer( bSizer6 );
this->Layout();

this->Centre( wxBOTH );

}

4

2 回答 2

2

听起来您想要使用的是 wxSplitterWindow。您可以在http://docs.wxwidgets.org/3.0/classwx_splitter_window.html找到此类的文档。

于 2015-07-27T18:53:51.697 回答
0
MyFrame1::MyFrame1(wxWindow* parent, wxWindowID id, const wxString& title,
                     const wxPoint& pos, const wxSize& size, long style) :
        wxFrame(parent, id, title, pos, size, style)
{
    // use a base panel, so that you have the same background colour between controls
    // (panels in your case) too
    wxPanel* basePanel = new wxPanel(this);

    // create your controls; no need to add default values...
    m_panel11 = new wxPanel(basePanel);
    m_panel12 = new wxPanel(basePanel);
    m_panel13 = new wxPanel(basePanel);

    // create a sizer; one should be enough
    wxSizer* bSizer = new wxBoxSizer(wxHORIZONTAL);

    // add your controls to the sizer
    bSizer->Add(m_panel11, 1, wxEXPAND|wxALL, 5);
    bSizer->Add(m_panel12, 0, wxEXPAND|wxUP|wxDOWN|wxRIGHT, 5);
    bSizer->Add(m_panel13, 1, wxEXPAND|wxUP|wxDOWN|wxRIGHT, 5);
    // if you need different resizing proportion for each panel, read the description
    // of proportion parameter in wxSizer:Add() docs

    basePanel->SetSizer(bSizer);
}
于 2015-07-24T12:45:46.690 回答