gpt4 book ai didi

c++ - wxSizer 和 wxStaticBitmap 忽略最小尺寸

转载 作者:行者123 更新时间:2023-11-28 08:01:10 28 4
gpt4 key购买 nike

Wizard::Wizard( wxWindow* parent, const wxString& archive )
: wxWizard(parent, wxID_ANY, _("Wizard"))
{
this->SetSizeHints( wxSize( -1,-1 ), wxDefaultSize );

wxWizardPageSimple* rcModWizPageSelect = new wxWizardPageSimple( this );
m_pages.Add( rcModWizPageSelect );

wxBoxSizer* bSizer1;
bSizer1 = new wxBoxSizer( wxVERTICAL );

m_bitmap2 = new wxStaticBitmap( rcModWizPageSelect, wxID_ANY, wxBitmap( wxT("data/img.jpg"), wxBITMAP_TYPE_ANY ), wxDefaultPosition, wxDefaultSize, 0 );
m_bitmap2->SetMinSize( wxSize( 586,192 ) );

bSizer1->Add( m_bitmap2, 0, wxALL|wxEXPAND|wxFIXED_MINSIZE, 5 );

wxStaticBoxSizer* sbSizer1;
sbSizer1 = new wxStaticBoxSizer( new wxStaticBox( rcModWizPageSelect, wxID_ANY, _("Select Archive") ), wxVERTICAL );

rcModArchivePicker = new wxFilePickerCtrl( rcModWizPageSelect, wxID_ANY, wxEmptyString, _("Select a file"), wxT("*.zip"), wxDefaultPosition, wxDefaultSize, wxFLP_DEFAULT_STYLE|wxFLP_FILE_MUST_EXIST|wxFLP_OPEN );
sbSizer1->Add( rcModArchivePicker, 0, wxALL|wxEXPAND, 5 );

bSizer1->Add( sbSizer1, 1, wxALL|wxEXPAND, 5 );

rcModWizPageSelect->SetSizer( bSizer1 );
rcModWizPageSelect->Layout();
bSizer1->Fit( rcModWizPageSelect );
wxWizardPageSimple* rcModWizPageProgress = new wxWizardPageSimple( this );
m_pages.Add( rcModWizPageProgress );

wxBoxSizer* bSizer2;
bSizer2 = new wxBoxSizer( wxVERTICAL );

m_bitmap1 = new wxStaticBitmap( rcModWizPageProgress, wxID_ANY, wxBitmap( wxT("data/img.jpg"), wxBITMAP_TYPE_ANY ), wxDefaultPosition, wxDefaultSize, 0 );
m_bitmap1->SetMinSize( wxSize( 586,192 ) );

bSizer2->Add( m_bitmap1, 0, wxALL|wxEXPAND|wxFIXED_MINSIZE, 5 );

wxStaticBoxSizer* sbSizer2;
sbSizer2 = new wxStaticBoxSizer( new wxStaticBox( rcModWizPageProgress, wxID_ANY, _("Please Wait") ), wxVERTICAL );

rcModInstallProgress = new wxGauge( rcModWizPageProgress, wxID_ANY, 100, wxDefaultPosition, wxDefaultSize, wxGA_HORIZONTAL|wxGA_SMOOTH );
rcModInstallProgress->SetValue( 0 );
sbSizer2->Add( rcModInstallProgress, 0, wxALL|wxEXPAND, 5 );

bSizer2->Add( sbSizer2, 1, wxALL|wxEXPAND, 5 );

rcModWizPageProgress->SetSizer( bSizer2 );
rcModWizPageProgress->Layout();
bSizer2->Fit( rcModWizPageProgress );

this->Centre( wxBOTH );

for ( unsigned int i = 1; i < m_pages.GetCount(); i++ )
{
m_pages.Item( i )->SetPrev( m_pages.Item( i - 1 ) );
m_pages.Item( i - 1 )->SetNext( m_pages.Item( i ) );
}
}

我尝试创建一个漂亮的向导对话框,但最小尺寸被忽略,整个框架比我的图像小得多。图片大小为 586x192。

wxFormBuilder 中的预览看起来不错,但生成的代码看起来完全不同。这里有2张图片: http://i.stack.imgur.com/tbOzP.png http://i.stack.imgur.com/B3vVf.png

谁能帮我解决这个问题?

最佳答案

我遇到了同样的问题,并且能够通过调用 sizer 上的 SetItemMinSize() 来解决它,如下所示:

sizer->Add(control, 0, 0, 0);
sizer->SetItemMinSize(control, 150, -1);

关于c++ - wxSizer 和 wxStaticBitmap 忽略最小尺寸,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11443676/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com