2009年6月30日星期二

转贴一个利用sizer的参考代码

原帖地址:http://wxforum.shadonet.com/viewtopic.php?t=24064



实现如图的layout :

//create sizer
wxBoxSizer *sizer = new wxBoxSizer(wxVERTICAL);

// top
pPanelTop = new wxPanel(this, wxID_ANY, wxDefaultPosition, wxSize(320, 60) );
wxColour color(_T("#FDFDFD"));
pPanelTop->SetBackgroundColour(color);

sizer->Add(pPanelTop, 0, wxALIGN_TOP wxEXPAND, 0);

// center
pPanelCenter = new wxPanel(this, wxID_ANY, wxDefaultPosition, wxSize(300, 400) );
wxColour black_color(_T("BLACK"));
pPanelCenter->SetBackgroundColour(black_color);

pPanelLeft = new wxPanel(this, wxID_ANY, wxDefaultPosition, wxSize(10, 100) );
pPanelRight = new wxPanel(this, wxID_ANY, wxDefaultPosition, wxSize(10, 100) );
pPanelLeft->SetBackgroundColour(color);
pPanelRight->SetBackgroundColour(color);

wxBoxSizer *center_sizer = new wxBoxSizer(wxHORIZONTAL);
center_sizer->Add(pPanelLeft, 0, wxEXPAND, 0);
center_sizer->Add(pPanelCenter, 1, wxEXPAND, 0);
center_sizer->Add(pPanelRight, 0, wxEXPAND, 0);

// bottom
pPanelBottom = new wxPanel(this, wxID_ANY, wxDefaultPosition, wxSize(100, 10) );
pPanelBottom->SetBackgroundColour(color);

sizer->Add(center_sizer, 1, wxEXPAND, 0);
sizer->Add(pPanelBottom, 0, wxALIGN_BOTTOM wxEXPAND, 0);

sizer->SetSizeHints(this);
SetSizer(sizer);

没有评论:

发表评论