diff --git a/samples/propgrid/propgrid.cpp b/samples/propgrid/propgrid.cpp index fae9cda7e4..75375dce3d 100644 --- a/samples/propgrid/propgrid.cpp +++ b/samples/propgrid/propgrid.cpp @@ -1149,8 +1149,7 @@ void FormMain::PopulateWithStandardItems () // Set test information for cells in columns 3 and 4 // (reserve column 2 for displaying units) wxPropertyGridIterator it; - int bmpH = pg->GetGrid()->GetRowHeight() - 2; - wxBitmap bmp = wxArtProvider::GetBitmap(wxART_FOLDER, wxART_OTHER, wxSize(bmpH, bmpH)); + wxBitmap bmp = wxArtProvider::GetBitmap(wxART_FOLDER); for ( it = pg->GetGrid()->GetIterator(); !it.AtEnd(); diff --git a/src/propgrid/property.cpp b/src/propgrid/property.cpp index 556080c7ad..facf98e1b0 100644 --- a/src/propgrid/property.cpp +++ b/src/propgrid/property.cpp @@ -150,16 +150,28 @@ int wxPGCellRenderer::PreDrawCell( wxDC& dc, const wxRect& rect, const wxPGCell& dc.SetFont(font); const wxBitmap& bmp = cell.GetBitmap(); - if ( bmp.IsOk() && - // Do not draw oversized bitmap outside choice popup - ((flags & ChoicePopup) || bmp.GetHeight() < rect.height ) - ) + if ( bmp.IsOk() ) { - dc.DrawBitmap( bmp, + int hMax = rect.height - wxPG_CUSTOM_IMAGE_SPACINGY; + wxBitmap scaledBmp; + int yOfs; + if ( bmp.GetHeight() <= hMax ) + { + scaledBmp = bmp; + yOfs = (hMax - bmp.GetHeight()) / 2; + } + else + { + double scale = (double)hMax / bmp.GetHeight(); + scaledBmp = wxPropertyGrid::RescaleBitmap(bmp, scale, scale); + yOfs = 0; + } + + dc.DrawBitmap( scaledBmp, rect.x + wxPG_CONTROL_MARGIN + wxCC_CUSTOM_IMAGE_MARGIN1, - rect.y + wxPG_CUSTOM_IMAGE_SPACINGY, + rect.y + wxPG_CUSTOM_IMAGE_SPACINGY + yOfs, true ); - imageWidth = bmp.GetWidth(); + imageWidth = scaledBmp.GetWidth(); } return imageWidth;