Merge branches 'statbmp-bundle', 'upscale-only-bitmap' and 'bitmap-from-icon'
Fixes for wxBitmapBundle behaviour and use it in wxStaticBitmap too now. See https://github.com/wxWidgets/wxWidgets/pull/2560, https://github.com/wxWidgets/wxWidgets/pull/2566, https://github.com/wxWidgets/wxWidgets/pull/2567
This commit is contained in:
@@ -223,7 +223,7 @@ public:
|
|||||||
#endif // wxUSE_PALETTE
|
#endif // wxUSE_PALETTE
|
||||||
|
|
||||||
// copies the contents and mask of the given (colour) icon to the bitmap
|
// copies the contents and mask of the given (colour) icon to the bitmap
|
||||||
virtual bool CopyFromIcon(const wxIcon& icon) = 0;
|
bool CopyFromIcon(const wxIcon& icon);
|
||||||
|
|
||||||
// implementation:
|
// implementation:
|
||||||
#if WXWIN_COMPATIBILITY_3_0
|
#if WXWIN_COMPATIBILITY_3_0
|
||||||
|
@@ -63,9 +63,6 @@ public:
|
|||||||
virtual void SetPalette(const wxPalette& palette);
|
virtual void SetPalette(const wxPalette& palette);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// copies the contents and mask of the given (colour) icon to the bitmap
|
|
||||||
virtual bool CopyFromIcon(const wxIcon& icon);
|
|
||||||
|
|
||||||
static void InitStandardHandlers();
|
static void InitStandardHandlers();
|
||||||
|
|
||||||
// raw bitmap access support functions
|
// raw bitmap access support functions
|
||||||
|
@@ -103,9 +103,6 @@ public:
|
|||||||
wxImage ConvertToImage() const wxOVERRIDE;
|
wxImage ConvertToImage() const wxOVERRIDE;
|
||||||
#endif // wxUSE_IMAGE
|
#endif // wxUSE_IMAGE
|
||||||
|
|
||||||
// copies the contents and mask of the given (colour) icon to the bitmap
|
|
||||||
virtual bool CopyFromIcon(const wxIcon& icon) wxOVERRIDE;
|
|
||||||
|
|
||||||
wxMask *GetMask() const wxOVERRIDE;
|
wxMask *GetMask() const wxOVERRIDE;
|
||||||
void SetMask( wxMask *mask ) wxOVERRIDE;
|
void SetMask( wxMask *mask ) wxOVERRIDE;
|
||||||
|
|
||||||
|
@@ -88,9 +88,6 @@ public:
|
|||||||
|
|
||||||
wxImage ConvertToImage() const;
|
wxImage ConvertToImage() const;
|
||||||
|
|
||||||
// copies the contents and mask of the given (colour) icon to the bitmap
|
|
||||||
virtual bool CopyFromIcon(const wxIcon& icon);
|
|
||||||
|
|
||||||
wxMask *GetMask() const;
|
wxMask *GetMask() const;
|
||||||
void SetMask( wxMask *mask );
|
void SetMask( wxMask *mask );
|
||||||
|
|
||||||
|
@@ -165,9 +165,6 @@ public:
|
|||||||
wxBitmapRefData *GetBitmapData()
|
wxBitmapRefData *GetBitmapData()
|
||||||
{ return (wxBitmapRefData *)m_refData; }
|
{ return (wxBitmapRefData *)m_refData; }
|
||||||
|
|
||||||
// copies the contents and mask of the given (colour) icon to the bitmap
|
|
||||||
virtual bool CopyFromIcon(const wxIcon& icon) wxOVERRIDE;
|
|
||||||
|
|
||||||
int GetWidth() const wxOVERRIDE;
|
int GetWidth() const wxOVERRIDE;
|
||||||
int GetHeight() const wxOVERRIDE;
|
int GetHeight() const wxOVERRIDE;
|
||||||
int GetDepth() const wxOVERRIDE;
|
int GetDepth() const wxOVERRIDE;
|
||||||
|
@@ -61,9 +61,6 @@ public:
|
|||||||
virtual void SetPalette(const wxPalette& palette) wxOVERRIDE;
|
virtual void SetPalette(const wxPalette& palette) wxOVERRIDE;
|
||||||
#endif // wxUSE_PALETTE
|
#endif // wxUSE_PALETTE
|
||||||
|
|
||||||
// copies the contents and mask of the given (colour) icon to the bitmap
|
|
||||||
virtual bool CopyFromIcon(const wxIcon& icon) wxOVERRIDE;
|
|
||||||
|
|
||||||
// implementation:
|
// implementation:
|
||||||
#if WXWIN_COMPATIBILITY_3_0
|
#if WXWIN_COMPATIBILITY_3_0
|
||||||
wxDEPRECATED(virtual void SetHeight(int height) wxOVERRIDE);
|
wxDEPRECATED(virtual void SetHeight(int height) wxOVERRIDE);
|
||||||
|
@@ -98,9 +98,6 @@ public:
|
|||||||
bool CreateFromImage(const wxImage& image, int depth = -1);
|
bool CreateFromImage(const wxImage& image, int depth = -1);
|
||||||
#endif // wxUSE_IMAGE
|
#endif // wxUSE_IMAGE
|
||||||
|
|
||||||
// copies the contents and mask of the given (colour) icon to the bitmap
|
|
||||||
virtual bool CopyFromIcon(const wxIcon& icon);
|
|
||||||
|
|
||||||
wxMask *GetMask() const;
|
wxMask *GetMask() const;
|
||||||
void SetMask( wxMask *mask );
|
void SetMask( wxMask *mask );
|
||||||
|
|
||||||
|
@@ -196,6 +196,12 @@ public:
|
|||||||
|
|
||||||
wxIMPLEMENT_DYNAMIC_CLASS(wxBitmapBaseModule, wxModule);
|
wxIMPLEMENT_DYNAMIC_CLASS(wxBitmapBaseModule, wxModule);
|
||||||
|
|
||||||
|
bool wxBitmapBase::CopyFromIcon(const wxIcon& icon)
|
||||||
|
{
|
||||||
|
*this = icon;
|
||||||
|
return IsOk();
|
||||||
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
// Trivial implementations of scale-factor related functions
|
// Trivial implementations of scale-factor related functions
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
@@ -205,7 +205,14 @@ wxSize wxBitmapBundleImplSet::GetPreferredSizeAtScale(double scale) const
|
|||||||
|
|
||||||
// We only get here if the target size is bigger than all the available
|
// We only get here if the target size is bigger than all the available
|
||||||
// sizes, in which case we have no choice but to use the biggest bitmap.
|
// sizes, in which case we have no choice but to use the biggest bitmap.
|
||||||
return m_entries.back().bitmap.GetSize();
|
const wxSize sizeMax = m_entries.back().bitmap.GetSize();
|
||||||
|
|
||||||
|
// But check how far is it from the requested scale: if it's more than 1.5
|
||||||
|
// times smaller, we should still scale it, notably to ensure that bitmaps
|
||||||
|
// of standard size are scaled when 2x DPI scaling is used.
|
||||||
|
return static_cast<double>(sizeTarget.y) / sizeMax.y >= 1.5
|
||||||
|
? sizeTarget
|
||||||
|
: sizeMax;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxBitmap wxBitmapBundleImplSet::GetBitmap(const wxSize& size)
|
wxBitmap wxBitmapBundleImplSet::GetBitmap(const wxSize& size)
|
||||||
|
@@ -603,12 +603,6 @@ void wxBitmap::SetMask(wxMask *mask)
|
|||||||
M_BITMAP->m_mask = mask;
|
M_BITMAP->m_mask = mask;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxBitmap::CopyFromIcon(const wxIcon& icon)
|
|
||||||
{
|
|
||||||
*this = *((wxBitmap*)(&icon));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
wxBitmap wxBitmap::GetSubBitmap(const wxRect& rect) const
|
wxBitmap wxBitmap::GetSubBitmap(const wxRect& rect) const
|
||||||
{
|
{
|
||||||
wxCHECK_MSG( IsOk() &&
|
wxCHECK_MSG( IsOk() &&
|
||||||
|
@@ -988,12 +988,6 @@ void wxBitmap::SetMask( wxMask *mask )
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxBitmap::CopyFromIcon(const wxIcon& icon)
|
|
||||||
{
|
|
||||||
*this = icon;
|
|
||||||
return IsOk();
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef __WXGTK3__
|
#ifdef __WXGTK3__
|
||||||
bool wxBitmap::CreateScaled(int w, int h, int depth, double scale)
|
bool wxBitmap::CreateScaled(int w, int h, int depth, double scale)
|
||||||
{
|
{
|
||||||
|
@@ -1192,12 +1192,6 @@ void wxBitmap::SetMask( wxMask *mask )
|
|||||||
M_BMPDATA->m_mask = mask;
|
M_BMPDATA->m_mask = mask;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxBitmap::CopyFromIcon(const wxIcon& icon)
|
|
||||||
{
|
|
||||||
*this = icon;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
wxBitmap wxBitmap::GetSubBitmap( const wxRect& rect) const
|
wxBitmap wxBitmap::GetSubBitmap( const wxRect& rect) const
|
||||||
{
|
{
|
||||||
wxCHECK_MSG( IsOk() &&
|
wxCHECK_MSG( IsOk() &&
|
||||||
|
@@ -782,11 +782,6 @@ wxBitmapRefData::~wxBitmapRefData()
|
|||||||
// wxBitmap
|
// wxBitmap
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
bool wxBitmap::CopyFromIcon(const wxIcon& icon)
|
|
||||||
{
|
|
||||||
return Create( icon.OSXGetImage() );
|
|
||||||
}
|
|
||||||
|
|
||||||
wxBitmap::wxBitmap(const char bits[], int the_width, int the_height, int no_bits)
|
wxBitmap::wxBitmap(const char bits[], int the_width, int the_height, int no_bits)
|
||||||
{
|
{
|
||||||
m_refData = new wxBitmapRefData( the_width , the_height , no_bits ) ;
|
m_refData = new wxBitmapRefData( the_width , the_height , no_bits ) ;
|
||||||
|
@@ -372,13 +372,6 @@ void wxBitmap::SetPalette(const wxPalette& WXUNUSED(palette))
|
|||||||
|
|
||||||
#endif // wxUSE_PALETTE
|
#endif // wxUSE_PALETTE
|
||||||
|
|
||||||
// copies the contents and mask of the given (colour) icon to the bitmap
|
|
||||||
bool wxBitmap::CopyFromIcon(const wxIcon& icon)
|
|
||||||
{
|
|
||||||
*this = icon;
|
|
||||||
return IsOk();
|
|
||||||
}
|
|
||||||
|
|
||||||
#if WXWIN_COMPATIBILITY_3_0
|
#if WXWIN_COMPATIBILITY_3_0
|
||||||
void wxBitmap::SetHeight(int height)
|
void wxBitmap::SetHeight(int height)
|
||||||
{
|
{
|
||||||
|
@@ -993,12 +993,6 @@ void wxBitmap::SetMask( wxMask *mask )
|
|||||||
M_BMPDATA->m_mask = mask;
|
M_BMPDATA->m_mask = mask;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxBitmap::CopyFromIcon(const wxIcon& icon)
|
|
||||||
{
|
|
||||||
*this = icon;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
wxBitmap wxBitmap::GetSubBitmap( const wxRect& rect) const
|
wxBitmap wxBitmap::GetSubBitmap( const wxRect& rect) const
|
||||||
{
|
{
|
||||||
wxCHECK_MSG( IsOk() &&
|
wxCHECK_MSG( IsOk() &&
|
||||||
|
@@ -57,6 +57,8 @@ TEST_CASE("BitmapBundle::GetPreferredSize", "[bmpbundle]")
|
|||||||
const wxBitmapBundle
|
const wxBitmapBundle
|
||||||
b = wxBitmapBundle::FromBitmaps(wxBitmap(normal), wxBitmap(bigger));
|
b = wxBitmapBundle::FromBitmaps(wxBitmap(normal), wxBitmap(bigger));
|
||||||
|
|
||||||
|
// Check that the existing bitmaps are used without scaling for most of the
|
||||||
|
// typical scaling values.
|
||||||
CHECK( b.GetPreferredSizeAtScale(0 ) == normal );
|
CHECK( b.GetPreferredSizeAtScale(0 ) == normal );
|
||||||
CHECK( b.GetPreferredSizeAtScale(1 ) == normal );
|
CHECK( b.GetPreferredSizeAtScale(1 ) == normal );
|
||||||
CHECK( b.GetPreferredSizeAtScale(1.25) == normal );
|
CHECK( b.GetPreferredSizeAtScale(1.25) == normal );
|
||||||
@@ -65,7 +67,10 @@ TEST_CASE("BitmapBundle::GetPreferredSize", "[bmpbundle]")
|
|||||||
CHECK( b.GetPreferredSizeAtScale(1.75) == bigger );
|
CHECK( b.GetPreferredSizeAtScale(1.75) == bigger );
|
||||||
CHECK( b.GetPreferredSizeAtScale(2 ) == bigger );
|
CHECK( b.GetPreferredSizeAtScale(2 ) == bigger );
|
||||||
CHECK( b.GetPreferredSizeAtScale(2.5 ) == bigger );
|
CHECK( b.GetPreferredSizeAtScale(2.5 ) == bigger );
|
||||||
CHECK( b.GetPreferredSizeAtScale(3 ) == bigger );
|
|
||||||
|
// This scale is too big to use any of the existing bitmaps, so they will
|
||||||
|
// be scaled.
|
||||||
|
CHECK( b.GetPreferredSizeAtScale(3 ) == 3*normal );
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef wxHAS_BITMAP_SCALE_FACTOR
|
#ifdef wxHAS_BITMAP_SCALE_FACTOR
|
||||||
|
Reference in New Issue
Block a user