wxCreateGreyedImage() deprecated, use wxImage::ConvertToGreyscale() directly instead
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@44604 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -14,6 +14,8 @@ Changes in behaviour which may result in compilation errors
|
|||||||
Deprecated methods and their replacements
|
Deprecated methods and their replacements
|
||||||
-----------------------------------------
|
-----------------------------------------
|
||||||
|
|
||||||
|
- wxCreateGreyedImage() deprecated, use wxImage::ConvertToGreyscale() instead
|
||||||
|
|
||||||
Major new features in this release
|
Major new features in this release
|
||||||
----------------------------------
|
----------------------------------
|
||||||
|
|
||||||
|
@@ -603,8 +603,14 @@ private:
|
|||||||
DECLARE_NO_COPY_CLASS(wxToolBarBase)
|
DECLARE_NO_COPY_CLASS(wxToolBarBase)
|
||||||
};
|
};
|
||||||
|
|
||||||
// Helper function for creating the image for disabled buttons
|
// deprecated function for creating the image for disabled buttons, use
|
||||||
bool wxCreateGreyedImage(const wxImage& in, wxImage& out) ;
|
// wxImage::ConvertToGreyscale() instead
|
||||||
|
#if WXWIN_COMPATIBILITY_2_8
|
||||||
|
|
||||||
|
wxDEPRECATED( bool wxCreateGreyedImage(const wxImage& in, wxImage& out) );
|
||||||
|
|
||||||
|
#endif // WXWIN_COMPATIBILITY_2_8
|
||||||
|
|
||||||
|
|
||||||
#endif // wxUSE_TOOLBAR
|
#endif // wxUSE_TOOLBAR
|
||||||
|
|
||||||
|
@@ -32,7 +32,9 @@
|
|||||||
#include "wx/control.h"
|
#include "wx/control.h"
|
||||||
#include "wx/frame.h"
|
#include "wx/frame.h"
|
||||||
#include "wx/settings.h"
|
#include "wx/settings.h"
|
||||||
#include "wx/image.h"
|
#if WXWIN_COMPATIBILITY_2_8
|
||||||
|
#include "wx/image.h"
|
||||||
|
#endif // WXWIN_COMPATIBILITY_2_8
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
@@ -674,73 +676,19 @@ void wxToolBarBase::UpdateWindowUI(long flags)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#if wxUSE_IMAGE
|
#if WXWIN_COMPATIBILITY_2_8
|
||||||
|
|
||||||
/*
|
bool wxCreateGreyedImage(const wxImage& in, wxImage& out)
|
||||||
* Make a greyed-out image suitable for disabled buttons.
|
|
||||||
* This code is adapted from wxNewBitmapButton in FL.
|
|
||||||
*/
|
|
||||||
|
|
||||||
bool wxCreateGreyedImage(const wxImage& src, wxImage& dst)
|
|
||||||
{
|
{
|
||||||
dst = src.Copy();
|
#if wxUSE_IMAGE
|
||||||
|
out = in.ConvertToGreyscale();
|
||||||
unsigned char rBg, gBg, bBg;
|
if ( out.Ok() )
|
||||||
if ( src.HasMask() )
|
return true;
|
||||||
{
|
|
||||||
src.GetOrFindMaskColour(&rBg, &gBg, &bBg);
|
|
||||||
dst.SetMaskColour(rBg, gBg, bBg);
|
|
||||||
}
|
|
||||||
else // assuming the pixels along the edges are of the background color
|
|
||||||
{
|
|
||||||
rBg = src.GetRed(0, 0);
|
|
||||||
gBg = src.GetGreen(0, 0);
|
|
||||||
bBg = src.GetBlue(0, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
const wxColour colBg(rBg, gBg, bBg);
|
|
||||||
|
|
||||||
const wxColour colDark = wxSystemSettings::GetColour(wxSYS_COLOUR_3DSHADOW);
|
|
||||||
const wxColour colLight = wxSystemSettings::GetColour(wxSYS_COLOUR_3DHIGHLIGHT);
|
|
||||||
|
|
||||||
// Second attempt, just making things monochrome
|
|
||||||
const int width = src.GetWidth();
|
|
||||||
const int height = src.GetHeight();
|
|
||||||
|
|
||||||
for ( int x = 0; x < width; x++ )
|
|
||||||
{
|
|
||||||
for ( int y = 0; y < height; y++ )
|
|
||||||
{
|
|
||||||
const int r = src.GetRed(x, y);
|
|
||||||
const int g = src.GetGreen(x, y);
|
|
||||||
const int b = src.GetBlue(x, y);
|
|
||||||
|
|
||||||
if ( r == rBg && g == gBg && b == bBg )
|
|
||||||
{
|
|
||||||
// Leave the background colour as-is
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Change light things to the background colour
|
|
||||||
wxColour col;
|
|
||||||
if ( r >= (colLight.Red() - 50) &&
|
|
||||||
g >= (colLight.Green() - 50) &&
|
|
||||||
b >= (colLight.Blue() - 50) )
|
|
||||||
{
|
|
||||||
col = colBg;
|
|
||||||
}
|
|
||||||
else // Change dark things to really dark
|
|
||||||
{
|
|
||||||
col = colDark;
|
|
||||||
}
|
|
||||||
|
|
||||||
dst.SetRGB(x, y, col.Red(), col.Green(), col.Blue());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif // wxUSE_IMAGE
|
#endif // wxUSE_IMAGE
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // WXWIN_COMPATIBILITY_2_8
|
||||||
|
|
||||||
#endif // wxUSE_TOOLBAR
|
#endif // wxUSE_TOOLBAR
|
||||||
|
@@ -680,8 +680,8 @@ bool wxToolBar::Realize()
|
|||||||
// no disabled bitmap specified but we still need to
|
// no disabled bitmap specified but we still need to
|
||||||
// fill the space in the image list with something, so
|
// fill the space in the image list with something, so
|
||||||
// we grey out the normal bitmap
|
// we grey out the normal bitmap
|
||||||
wxImage imgGreyed;
|
wxImage
|
||||||
wxCreateGreyedImage(bmp.ConvertToImage(), imgGreyed);
|
imgGreyed = bmp.ConvertToImage().ConvertToGreyscale();
|
||||||
|
|
||||||
#ifdef wxREMAP_BUTTON_COLOURS
|
#ifdef wxREMAP_BUTTON_COLOURS
|
||||||
if ( remapValue == Remap_Buttons )
|
if ( remapValue == Remap_Buttons )
|
||||||
|
Reference in New Issue
Block a user