您需要将其视为多个嵌套块。
wxBoxSizer
水平方向。wxBoxSizer
垂直方向。proportion
参数。这是一个代码片段示例:
wxBoxSizer* rootsizer = new wxBoxSizer(wxHORIZONTAL);
//TODO: the right side control is whatever you need it to be
wxPanel* rightPanel = new wxPanel(parent, wxID_ANY, wxDefaultPosition, rightPanelSize);
//NOTE the use of 0 as the proportion; this means the right panel will NOT expand
//horizontally; it is fixed in size. The wxEXPAND flag means it will expand vertically
//to fill
rootsizer->Add(rightpanel, 0, wxEXPAND, 0);
//Our center sizer to contain our center controls
wxBoxSizer* centersizer = new wxBoxSizer(wxVERTICAL);
//NOTE the use of 1 as the proportion; this means the center panel will expand HORIZONTALLY to fill all available space
rootsizer->Add(centersizer, 1, wxEXPAND, 0);
//TODO: whatever control goes on the left
wxPanel* leftpanel = new wxPanel(parent, wxID_ANY, wxDefaultPosition, leftPanelSize);
//Proportion is again 0 to prevent expanding horizontally
rootsizer->Add(leftpanel, 0, wxEXPAND, 0);
//Now the second level
//TODO: whatever control goes on the top
wxPanel* toppanel = new wxPanel(parent, wxID_ANY, wxDefaultPosition, topPanelSize);
//Proportion is 0 to prevent expanding VERTICALLY (because we are now in the center sizer
//which is a vertical sizer
centersizer->Add(toppanel, 0, wxEXPAND, 0);
//Our final depth, the centermost control, is set to a proportion of 1 to fill the space
//vertically
//TODO: whatever is your center control
wxPanel* centerpanel = new wxPanel(parent, wxID_ANY, wxDefaultPosition, wxDefaultSize);
centersizer->Add(centerpanel, 1, wxEXPAND, 0);
//And then the bottom control at proportion 0
wxPanel* bottompanel= new wxPanel(parent, wxID_ANY, wxDefaultPosition, bottomPanelSize);
centersizer->Add(bottompanel, 0, wxEXPAND, 0);
通过组合多个级别的 sizerwxEXPAND
并正确分配proportion
,您可以获得适当的灵活性。您只需要学会从仅在一个方向上扩展和收缩的控件组来看待它。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句