背景をパネル名panel_top_rightに追加する
//////Class
Class {
private:
//背景用
void OnImagePanelPaint(wxPaintEvent&);
wxPanel* panel_top_right;
wxBitmap m_scaledBg;
wxImage m_image;
void CreateScaledBg();
}
//////記述
panel_top_right = new wxPanel(this, wxID_ANY, wxDefaultPosition, wxSize(300, 200));
m_image = wxImage("BG.bmp", wxBITMAP_TYPE_ANY);
if (!m_image.IsOk())
{
return;
}
//////Bind
panel_top_right->Bind(wxEVT_PAINT, &MyFrame::OnImagePanelPaint, this);
//////Class Function
//パネルサイズと画像サイズを、パネル更新の度に確認する、
void MyFrame::OnImagePanelPaint(wxPaintEvent&)
{
if (panel_top_right->GetSize() != m_scaledBg.GetSize())
{
CreateScaledBg();
}
wxPaintDC dc(panel_top_right);
dc.DrawBitmap(m_scaledBg, 0, 0);
}
//画像サイズをpanel_top_rightに合わせる
void MyFrame::CreateScaledBg()
{
wxSize sz = panel_top_right->GetSize();
m_scaledBg = wxBitmap(m_image.Scale(sz.GetWidth(), sz.GetHeight(),
wxIMAGE_QUALITY_NORMAL));
}
Comments