No changes, just clean up duplicate colour functions in wxSearchCtrl.
Use wxColor::ChangeLightness() instead of private wxStepColour() that duplicates it. Close #12744. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@66310 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -50,55 +50,6 @@ static const wxCoord ICON_MARGIN = 0;
|
||||
static const wxCoord ICON_OFFSET = 0;
|
||||
#endif
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// TODO: These functions or something like them should probably be made
|
||||
// public. There are similar functions in src/aui/dockart.cpp...
|
||||
|
||||
static double wxBlendColour(double fg, double bg, double alpha)
|
||||
{
|
||||
double result = bg + (alpha * (fg - bg));
|
||||
if (result < 0.0)
|
||||
result = 0.0;
|
||||
if (result > 255)
|
||||
result = 255;
|
||||
return result;
|
||||
}
|
||||
|
||||
static wxColor wxStepColour(const wxColor& c, int ialpha)
|
||||
{
|
||||
if (ialpha == 100)
|
||||
return c;
|
||||
|
||||
double r = c.Red(), g = c.Green(), b = c.Blue();
|
||||
double bg;
|
||||
|
||||
// ialpha is 0..200 where 0 is completely black
|
||||
// and 200 is completely white and 100 is the same
|
||||
// convert that to normal alpha 0.0 - 1.0
|
||||
ialpha = wxMin(ialpha, 200);
|
||||
ialpha = wxMax(ialpha, 0);
|
||||
double alpha = ((double)(ialpha - 100.0))/100.0;
|
||||
|
||||
if (ialpha > 100)
|
||||
{
|
||||
// blend with white
|
||||
bg = 255.0;
|
||||
alpha = 1.0 - alpha; // 0 = transparent fg; 1 = opaque fg
|
||||
}
|
||||
else
|
||||
{
|
||||
// blend with black
|
||||
bg = 0.0;
|
||||
alpha = 1.0 + alpha; // 0 = transparent fg; 1 = opaque fg
|
||||
}
|
||||
|
||||
r = wxBlendColour(r, bg, alpha);
|
||||
g = wxBlendColour(g, bg, alpha);
|
||||
b = wxBlendColour(b, bg, alpha);
|
||||
|
||||
return wxColour((unsigned char)r, (unsigned char)g, (unsigned char)b);
|
||||
}
|
||||
|
||||
#define LIGHT_STEP 160
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
@@ -183,7 +134,7 @@ protected:
|
||||
{
|
||||
ChangeValue(m_descriptiveText);
|
||||
SetInsertionPoint(0);
|
||||
SetForegroundColour(wxStepColour(m_defaultFG, LIGHT_STEP));
|
||||
SetForegroundColour(m_defaultFG.ChangeLightness (LIGHT_STEP));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -967,7 +918,7 @@ static int GetMultiplier()
|
||||
wxBitmap wxSearchCtrl::RenderSearchBitmap( int x, int y, bool renderDrop )
|
||||
{
|
||||
wxColour bg = GetBackgroundColour();
|
||||
wxColour fg = wxStepColour(GetForegroundColour(), LIGHT_STEP-20);
|
||||
wxColour fg = GetForegroundColour().ChangeLightness(LIGHT_STEP-20);
|
||||
|
||||
//===============================================================================
|
||||
// begin drawing code
|
||||
@@ -1072,7 +1023,7 @@ wxBitmap wxSearchCtrl::RenderSearchBitmap( int x, int y, bool renderDrop )
|
||||
wxBitmap wxSearchCtrl::RenderCancelBitmap( int x, int y )
|
||||
{
|
||||
wxColour bg = GetBackgroundColour();
|
||||
wxColour fg = wxStepColour(GetForegroundColour(), LIGHT_STEP);
|
||||
wxColour fg = GetForegroundColour().ChangeLightness(LIGHT_STEP);
|
||||
|
||||
//===============================================================================
|
||||
// begin drawing code
|
||||
|
Reference in New Issue
Block a user