Move duplicated code to rescale the bitmap to the shared function
This commit is contained in:
@@ -1235,6 +1235,9 @@ public:
|
|||||||
// Checks system screen design used for laying out various dialogs.
|
// Checks system screen design used for laying out various dialogs.
|
||||||
static bool IsSmallScreen();
|
static bool IsSmallScreen();
|
||||||
|
|
||||||
|
// Returns rescaled bitmap
|
||||||
|
static wxBitmap RescaleBitmap(const wxBitmap& srcBmp, double scaleX, double scaleY);
|
||||||
|
|
||||||
// Returns rectangle that fully contains properties between and including
|
// Returns rectangle that fully contains properties between and including
|
||||||
// p1 and p2. Rectangle is in virtual scrolled window coordinates.
|
// p1 and p2. Rectangle is in virtual scrolled window coordinates.
|
||||||
wxRect GetPropertyRect( const wxPGProperty* p1,
|
wxRect GetPropertyRect( const wxPGProperty* p1,
|
||||||
|
@@ -2160,25 +2160,7 @@ void wxPGMultiButton::Add( const wxBitmap& bitmap, int itemid )
|
|||||||
if ( bitmap.GetHeight() > hMax )
|
if ( bitmap.GetHeight() > hMax )
|
||||||
{
|
{
|
||||||
double scale = (double)hMax / bitmap.GetHeight();
|
double scale = (double)hMax / bitmap.GetHeight();
|
||||||
int w = wxRound(bitmap.GetWidth()*scale);
|
scaledBmp = wxPropertyGrid::RescaleBitmap(bitmap, scale, scale);
|
||||||
int h = wxRound(bitmap.GetHeight()*scale);
|
|
||||||
#if wxUSE_IMAGE
|
|
||||||
// Here we use high-quality wxImage scaling functions available
|
|
||||||
wxImage img = bitmap.ConvertToImage();
|
|
||||||
img.Rescale(w, h, wxIMAGE_QUALITY_HIGH);
|
|
||||||
scaledBmp = img;
|
|
||||||
#else // !wxUSE_IMAGE
|
|
||||||
scaledBmp.Create(w, h, bitmap.GetDepth());
|
|
||||||
#if defined(__WXMSW__) || defined(__WXOSX__)
|
|
||||||
// wxBitmap::UseAlpha() is used only on wxMSW and wxOSX.
|
|
||||||
scaledBmp.UseAlpha(bitmap.HasAlpha());
|
|
||||||
#endif // __WXMSW__ || __WXOSX__
|
|
||||||
{
|
|
||||||
wxMemoryDC dc(scaledBmp);
|
|
||||||
dc.SetUserScale(scale, scale);
|
|
||||||
dc.DrawBitmap(bitmap, 0, 0);
|
|
||||||
}
|
|
||||||
#endif // wxUSE_IMAGE/!wxUSE_IMAGE
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@@ -2162,30 +2162,8 @@ void wxPGProperty::SetValueImage( wxBitmap& bmp )
|
|||||||
|
|
||||||
if ( imSz.y != maxSz.y )
|
if ( imSz.y != maxSz.y )
|
||||||
{
|
{
|
||||||
#if wxUSE_IMAGE
|
|
||||||
// Here we use high-quality wxImage scaling functions available
|
|
||||||
wxImage img = bmp.ConvertToImage();
|
|
||||||
double scaleY = (double)maxSz.y / (double)imSz.y;
|
double scaleY = (double)maxSz.y / (double)imSz.y;
|
||||||
img.Rescale(wxRound(bmp.GetWidth()*scaleY),
|
m_valueBitmap = new wxBitmap(wxPropertyGrid::RescaleBitmap(bmp, scaleY, scaleY));
|
||||||
wxRound(bmp.GetHeight()*scaleY),
|
|
||||||
wxIMAGE_QUALITY_HIGH);
|
|
||||||
wxBitmap* bmpNew = new wxBitmap(img);
|
|
||||||
#else // !wxUSE_IMAGE
|
|
||||||
// This is the old, deprecated method of scaling the image
|
|
||||||
wxBitmap* bmpNew = new wxBitmap(maxSz.x,maxSz.y,bmp.GetDepth());
|
|
||||||
#if defined(__WXMSW__) || defined(__WXOSX__)
|
|
||||||
// wxBitmap::UseAlpha() is used only on wxMSW and wxOSX.
|
|
||||||
bmpNew->UseAlpha(bmp.HasAlpha());
|
|
||||||
#endif // __WXMSW__ || __WXOSX__
|
|
||||||
{
|
|
||||||
wxMemoryDC dc(*bmpNew);
|
|
||||||
double scaleY = (double)maxSz.y / (double)imSz.y;
|
|
||||||
dc.SetUserScale(scaleY, scaleY);
|
|
||||||
dc.DrawBitmap(bmp, 0, 0);
|
|
||||||
}
|
|
||||||
#endif // wxUSE_IMAGE/!wxUSE_IMAGE
|
|
||||||
|
|
||||||
m_valueBitmap = bmpNew;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@@ -1838,6 +1838,36 @@ bool wxPropertyGrid::IsSmallScreen()
|
|||||||
|
|
||||||
// -----------------------------------------------------------------------
|
// -----------------------------------------------------------------------
|
||||||
|
|
||||||
|
// static
|
||||||
|
wxBitmap wxPropertyGrid::RescaleBitmap(const wxBitmap& srcBmp,
|
||||||
|
double scaleX, double scaleY)
|
||||||
|
{
|
||||||
|
int w = wxRound(srcBmp.GetWidth()*scaleX);
|
||||||
|
int h = wxRound(srcBmp.GetHeight()*scaleY);
|
||||||
|
|
||||||
|
#if wxUSE_IMAGE
|
||||||
|
// Here we use high-quality wxImage scaling functions available
|
||||||
|
wxImage img = srcBmp.ConvertToImage();
|
||||||
|
img.Rescale(w, h, wxIMAGE_QUALITY_HIGH);
|
||||||
|
wxBitmap dstBmp(img);
|
||||||
|
#else // !wxUSE_IMAGE
|
||||||
|
wxBitmap dstBmp(w, h, srcBmp.GetDepth());
|
||||||
|
#if defined(__WXMSW__) || defined(__WXOSX__)
|
||||||
|
// wxBitmap::UseAlpha() is used only on wxMSW and wxOSX.
|
||||||
|
dstBmp.UseAlpha(srcBmp.HasAlpha());
|
||||||
|
#endif // __WXMSW__ || __WXOSX__
|
||||||
|
{
|
||||||
|
wxMemoryDC dc(dstBmp);
|
||||||
|
dc.SetUserScale(scaleX, scaleY);
|
||||||
|
dc.DrawBitmap(srcBmp, 0, 0);
|
||||||
|
}
|
||||||
|
#endif // wxUSE_IMAGE/!wxUSE_IMAGE
|
||||||
|
|
||||||
|
return dstBmp;
|
||||||
|
}
|
||||||
|
|
||||||
|
// -----------------------------------------------------------------------
|
||||||
|
|
||||||
wxPGProperty* wxPropertyGrid::DoGetItemAtY( int y ) const
|
wxPGProperty* wxPropertyGrid::DoGetItemAtY( int y ) const
|
||||||
{
|
{
|
||||||
// Outside?
|
// Outside?
|
||||||
|
Reference in New Issue
Block a user