0

我有 wxScrolledWindow 的问题。

我有一个 ScrolledWindow 持有一个 wxListBox。

有效的行为:

在将项目添加到列表框时,滚动条最终会出现。

失败的行为:

wxListBox 有一些项目。当我减小 ScrolledWindow 的大小以使某些项目被遮挡时,滚动条无法出现。

// split window into 2
wxBoxSizer *sizermain = new wxBoxSizer(wxVERTICAL);
wxSplitterWindow *splittermain = new wxSplitterWindow(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxSP_LIVE_UPDATE);
splittermain->SetSashGravity(0.5);
splittermain->SetMinimumPaneSize(20);
sizermain->Add(splittermain, 1,wxEXPAND,0);
this->SetSizer(sizermain);

// split left window into 2
wxSplitterWindow * splitterleft = new wxSplitterWindow(splittermain, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxSP_LIVE_UPDATE);
splitterleft->SetSashGravity(0.5);
splitterleft->SetMinimumPaneSize(20);
wxBoxSizer * sizerleft = new wxBoxSizer(wxHORIZONTAL);
sizerleft->Add(splitterleft, 1, wxEXPAND, 0);

// split right window into 2
wxSplitterWindow * splitteright = new wxSplitterWindow(splittermain, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxSP_LIVE_UPDATE);
splitteright->SetSashGravity(0.5);
splitteright->SetMinimumPaneSize(20);
wxBoxSizer * sizerright = new wxBoxSizer(wxHORIZONTAL);
sizerright->Add(splitteright, 1, wxEXPAND, 0);

wxScrolledWindow *tlpnl = new wxScrolledWindow(splitterleft, wxID_ANY);
wxListBox *tlcalls = new wxListBox(tlpnl, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0, nullptr, wxLB_EXTENDED);
wxBoxSizer *tlsizer = new wxBoxSizer(wxVERTICAL);
tlsizer->Add(tlcalls, 1,wxEXPAND,0);
tlpnl->SetSizer(tlsizer);

wxScrolledWindow *blpnl = new wxScrolledWindow(splitterleft, wxID_ANY);
wxListBox *blcontacts = new wxListBox(blpnl, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0, nullptr, wxLB_EXTENDED);
wxBoxSizer *blsizer = new wxBoxSizer(wxVERTICAL);
blsizer->Add(blcontacts, 1,wxEXPAND,0);
blpnl->SetSizer(blsizer);

wxScrolledWindow *trpnl = new wxScrolledWindow(splitteright, wxID_ANY);
inCall = new wxListBox(trpnl, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0, nullptr, wxLB_EXTENDED);
wxBoxSizer *trsizer = new wxBoxSizer(wxVERTICAL);
trsizer->Add(inCall, 1,wxEXPAND,0);
trpnl->SetSizer(trsizer);

wxScrolledWindow *brpnl = new wxScrolledWindow(splitteright, wxID_ANY);
wxTextCtrl *brtext = new wxTextCtrl(brpnl, wxID_ANY);
wxBoxSizer *brsizer = new wxBoxSizer(wxVERTICAL);
brsizer->Add(brtext, 1,wxEXPAND,0);
brpnl->SetSizer(brsizer);

splittermain->SplitVertically(splitterleft, splitteright);
splitterleft->SplitHorizontally(tlpnl, blpnl);
splitteright->SplitHorizontally(trpnl, brpnl);
4

1 回答 1

0

您的代码似乎没有显示问题(因为任何地方都没有项目),但它至少有一个问题:您创建sizerLeftsizerRightsizer 并向它们添加一些东西,但从不使用这些 sizer 本身。这可能解释了布局问题......但如果没有,你真的应该显示实际显示你所描述问题的代码(并且可能比你所拥有的更短,实际上需要两个拆分器吗?)。

于 2013-10-31T00:21:33.237 回答