我需要在一个框架中有3个panles,其中左侧面板和右侧面板应该由用户通过向左或向右拖动来重新连接。我使用AUI管理器完成了这个,但我想在不使用AUI的情况下做同样的事情(可能是sizer)。任何想法如何实现这一目标? 我已尝试如下所示,但我无法调整面板的大小。
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 );
}
答案 0 :(得分:2)
听起来你想要使用的是wxSplitterWindow。您可以在http://docs.wxwidgets.org/3.0/classwx_splitter_window.html找到此课程的文档。
答案 1 :(得分: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);
}