Improved retrieving bitmaps from wxArtProvider in propgrid sample.
Retrieve from wxArtProvider bitmaps of required size instead of rescaling them in the application.
This commit is contained in:
@@ -1175,35 +1175,6 @@ void FormMain::PopulateWithStandardItems ()
|
|||||||
|
|
||||||
// -----------------------------------------------------------------------
|
// -----------------------------------------------------------------------
|
||||||
|
|
||||||
// Helper procedure to rescale bitmaps
|
|
||||||
static void RescaleBitmap(const wxBitmap& srcBmp, wxBitmap& dstBmp)
|
|
||||||
{
|
|
||||||
// Source bitmap should rescaled to the size of target bitmap.
|
|
||||||
if ( srcBmp.GetSize() != dstBmp.GetSize() )
|
|
||||||
{
|
|
||||||
#if wxUSE_IMAGE
|
|
||||||
// Use high-quality wxImage scaling functions
|
|
||||||
wxImage img = srcBmp.ConvertToImage();
|
|
||||||
img.Rescale(dstBmp.GetWidth(), dstBmp.GetHeight(), wxIMAGE_QUALITY_HIGH);
|
|
||||||
dstBmp = wxBitmap(img);
|
|
||||||
#else
|
|
||||||
// Old method of scaling the image
|
|
||||||
double scaleX = (double)dstBmp.GetWidth() / (double)srcBmp.GetWidth();
|
|
||||||
double scaleY = (double)dstBmp.GetHeight() / (double)srcBmp.GetHeight();
|
|
||||||
dstBmp.UseAlpha(srcBmp.HasAlpha());
|
|
||||||
{
|
|
||||||
wxMemoryDC dc(dstBmp);
|
|
||||||
dc.SetUserScale(scaleX, scaleY);
|
|
||||||
dc.DrawBitmap(srcBmp, 0, 0);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
dstBmp = srcBmp;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void FormMain::PopulateWithExamples ()
|
void FormMain::PopulateWithExamples ()
|
||||||
{
|
{
|
||||||
wxPropertyGridManager* pgman = m_pPropGridManager;
|
wxPropertyGridManager* pgman = m_pPropGridManager;
|
||||||
@@ -1587,21 +1558,12 @@ void FormMain::PopulateWithExamples ()
|
|||||||
//
|
//
|
||||||
// Test adding variable height bitmaps in wxPGChoices
|
// Test adding variable height bitmaps in wxPGChoices
|
||||||
wxPGChoices bc;
|
wxPGChoices bc;
|
||||||
wxBitmap smallBmp(16, 16);
|
bc.Add(wxT("Wee"),
|
||||||
wxBitmap bmp = wxArtProvider::GetBitmap(wxART_CDROM);
|
wxArtProvider::GetBitmap(wxART_CDROM, wxART_OTHER, wxSize(16, 16)));
|
||||||
RescaleBitmap(bmp, smallBmp);
|
bc.Add(wxT("Not so wee"),
|
||||||
|
wxArtProvider::GetBitmap(wxART_FLOPPY, wxART_OTHER, wxSize(32, 32)));
|
||||||
wxBitmap mediumBmp(32, 32);
|
bc.Add(wxT("Friggin' huge"),
|
||||||
bmp = wxArtProvider::GetBitmap(wxART_FLOPPY);
|
wxArtProvider::GetBitmap(wxART_HARDDISK, wxART_OTHER, wxSize(64, 64)));
|
||||||
RescaleBitmap(bmp, mediumBmp);
|
|
||||||
|
|
||||||
wxBitmap largeBmp(64, 64);
|
|
||||||
bmp = wxArtProvider::GetBitmap(wxART_HARDDISK);
|
|
||||||
RescaleBitmap(bmp, largeBmp);
|
|
||||||
|
|
||||||
bc.Add(wxT("Wee"), smallBmp);
|
|
||||||
bc.Add(wxT("Not so wee"), mediumBmp);
|
|
||||||
bc.Add(wxT("Friggin' huge"), largeBmp);
|
|
||||||
|
|
||||||
pg->Append( new wxEnumProperty(wxT("Variable Height Bitmaps"),
|
pg->Append( new wxEnumProperty(wxT("Variable Height Bitmaps"),
|
||||||
wxPG_LABEL,
|
wxPG_LABEL,
|
||||||
|
Reference in New Issue
Block a user