如何在wxwidgets中创建可调整大小的面板
How to create a resizable panels in wxwidgets?
我需要在一个框架中有3个面板,其中左面板和右面板应该由用户通过向左或向右拖动来调整。我已经使用AUI管理器完成了这一点,但我想在不使用AUI(可能是大小)的情况下做同样的事情。有什么办法做到这一点吗?我已经尝试了如下所示,但我无法调整面板的大小。
MyFrame1::MyFrame1(wxWindow* parent, wxwindowwid 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 );
}
听起来你想使用的是wxSplitterWindow。您可以在http://docs.wxwidgets.org/3.0/classwx_splitter_window.html找到该类的文档。
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);
}
相关文章:
- 如何创建可调整大小和固定大小的容器的变体
- 如何创建可重新创建的自定义要求
- 是否有提供可调整 dpi、可选文本和 CSS 支持的 HTML 到 PDF 渲染器?
- 将添加的列初始化为可调整大小的 2D 向量
- 可滚动的背景,上面有可调整大小的Qt小部件
- 用std::vector编写可调整大小的矢量时出现问题
- 使用固定的顶部坐标创建可调整大小的窗口
- 灵活的可调整大小的阵列C++
- 如何使Qt小部件可调整大小
- 带有指针的可调整大小数组
- 可调整大小的动态二维阵列的更好解决方案
- wxWidgets可调整大小的窗格
- 如何为Windows应用程序创建可移动/可调整大小/可配置的工具栏
- 在winforms中创建可移动和可调整大小的行
- WinAPI:创建可调整大小的窗口,没有标题栏,但有最小化/最大化/关闭按钮(如Firefox/Chrome/Opera
- 如何在Qt Creator中添加可调整大小的QVBoxLayout ?
- 可调整大小的窗口与可调整大小的圆圈
- 如何使Qt的边框布局项目可调整大小?
- 如何在wxwidgets中创建可调整大小的面板
- 如何创建一个可调整大小的Qt缩略图预览