I think I misunderstand or misuse the proportion parameter in the wxBoxSizer, from my understanding, if two panels are added into a horizontal sizer with proportion argument 2 and 3, their width should be fixed at 2:3 when resizing the window. But in fact, I see the first panel size is fixed regardless of the whole size. I'm not sure whether I need to add some flags to achieve this function like wxEXPAND or wxGROW, etc.
Besides, a more strange behavior is when Grid is added into the sizer. e.g. I want to create a ui like this: So I write my code like this:
Code: Select all
#include <wx/wx.h>
#include <wx/grid.h>
#include <wx/srchctrl.h>
class MyFrame : public wxFrame
{
public:
MyFrame(wxWindow* parent = nullptr) : wxFrame(parent, wxID_ANY, "Test", wxDefaultPosition, wxSize(1200, 900))
{
wxPanel* search_panel = new wxPanel(this);
wxBoxSizer* col_sizer = new wxBoxSizer(wxVERTICAL);
wxSearchCtrl* search_ctrl = new wxSearchCtrl(search_panel, wxID_ANY, "Search");
col_sizer->Add(search_ctrl, 0, wxEXPAND | wxALL, 4);
wxGrid* product_grid = new wxGrid(search_panel, wxID_ANY);
product_grid->CreateGrid(100, 5);
col_sizer->Add(product_grid, 0);
search_panel->SetSizer(col_sizer);
col_sizer->SetSizeHints(search_panel);
wxPanel* blank_panel = new wxPanel(this);
wxBoxSizer* row_sizer = new wxBoxSizer(wxHORIZONTAL);
row_sizer->Add(search_panel, 2, wxALL, 1);
row_sizer->Add(blank_panel, 3, wxALL, 1);
wxGrid* bottom_grid = new wxGrid(this, wxID_ANY);
bottom_grid->CreateGrid(100, 100);
wxBoxSizer* top_col_sizer = new wxBoxSizer(wxVERTICAL);
top_col_sizer->Add(row_sizer, 2, wxALL, 1);
top_col_sizer->Add(bottom_grid, 3, wxALL, 1);
SetSizerAndFit(top_col_sizer);
Centre();
}
private:
wxGrid* grid_;
};
class MyApp : public wxApp
{
public:
bool OnInit() override
{
(new MyFrame())->Show();
return true;
}
}; wxIMPLEMENT_APP(MyApp);
Thanks in advance.
Besides, I also find the auimanager seemingly powerful and enable the pane inside it to be resized, is there any examples beside the auidemo in samples?