Use helper wxColourToColor function in wxMSW wxGraphicsContext code.

Don't repeat Color ctor from wxColour all the time.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@63855 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2010-04-05 11:44:28 +00:00
parent cffda6922a
commit f49c80c105

View File

@@ -42,10 +42,19 @@
#include "wx/msw/dc.h" #include "wx/msw/dc.h"
#include "wx/dcgraph.h" #include "wx/dcgraph.h"
#include "wx/msw/private.h" // needs to be before #include <commdlg.h>
#if wxUSE_COMMON_DIALOGS && !defined(__WXMICROWIN__)
#include <commdlg.h>
#endif
#include "wx/stack.h" #include "wx/stack.h"
WX_DECLARE_STACK(GraphicsState, GraphicsStates); WX_DECLARE_STACK(GraphicsState, GraphicsStates);
namespace
{
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// constants // constants
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
@@ -56,11 +65,19 @@ const double RAD2DEG = 180.0 / M_PI;
// Local functions // Local functions
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
static inline double dmin(double a, double b) { return a < b ? a : b; } inline double dmin(double a, double b) { return a < b ? a : b; }
static inline double dmax(double a, double b) { return a > b ? a : b; } inline double dmax(double a, double b) { return a > b ? a : b; }
static inline double DegToRad(double deg) { return (deg * M_PI) / 180.0; } inline double DegToRad(double deg) { return (deg * M_PI) / 180.0; }
static inline double RadToDeg(double deg) { return (deg * 180.0) / M_PI; } inline double RadToDeg(double deg) { return (deg * 180.0) / M_PI; }
// translate a wxColour to a Color
inline Color wxColourToColor(const wxColour& col)
{
return Color(col.Alpha(), col.Red(), col.Green(), col.Blue());
}
} // anonymous namespace
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// device context implementation // device context implementation
@@ -78,12 +95,6 @@ static inline double RadToDeg(double deg) { return (deg * 180.0) / M_PI; }
// wxGraphicsPath implementation // wxGraphicsPath implementation
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
#include "wx/msw/private.h" // needs to be before #include <commdlg.h>
#if wxUSE_COMMON_DIALOGS && !defined(__WXMICROWIN__)
#include <commdlg.h>
#endif
class wxGDIPlusPathData : public wxGraphicsPathData class wxGDIPlusPathData : public wxGraphicsPathData
{ {
public : public :
@@ -404,8 +415,7 @@ wxGDIPlusPenData::wxGDIPlusPenData( wxGraphicsRenderer* renderer, const wxPen &p
if (m_width <= 0.0) if (m_width <= 0.0)
m_width = 0.1; m_width = 0.1;
m_pen = new Pen(Color( pen.GetColour().Alpha() , pen.GetColour().Red() , m_pen = new Pen(wxColourToColor(pen.GetColour()), m_width );
pen.GetColour().Green() , pen.GetColour().Blue() ), m_width );
LineCap cap; LineCap cap;
switch ( pen.GetCap() ) switch ( pen.GetCap() )
@@ -528,8 +538,12 @@ wxGDIPlusPenData::wxGDIPlusPenData( wxGraphicsRenderer* renderer, const wxPen &p
break ; break ;
} }
m_penBrush = new HatchBrush(style,Color( pen.GetColour().Alpha() , pen.GetColour().Red() , m_penBrush = new HatchBrush
pen.GetColour().Green() , pen.GetColour().Blue() ), Color::Transparent ); (
style,
wxColourToColor(pen.GetColour()),
Color::Transparent
);
m_pen->SetBrush( m_penBrush ); m_pen->SetBrush( m_penBrush );
} }
break; break;
@@ -554,8 +568,7 @@ wxGDIPlusBrushData::wxGDIPlusBrushData( wxGraphicsRenderer* renderer , const wxB
Init(); Init();
if ( brush.GetStyle() == wxSOLID) if ( brush.GetStyle() == wxSOLID)
{ {
m_brush = new SolidBrush( Color( brush.GetColour().Alpha() , brush.GetColour().Red() , m_brush = new SolidBrush(wxColourToColor( brush.GetColour()));
brush.GetColour().Green() , brush.GetColour().Blue() ) );
} }
else if ( brush.IsHatch() ) else if ( brush.IsHatch() )
{ {
@@ -582,8 +595,12 @@ wxGDIPlusBrushData::wxGDIPlusBrushData( wxGraphicsRenderer* renderer , const wxB
break ; break ;
} }
m_brush = new HatchBrush(style,Color( brush.GetColour().Alpha() , brush.GetColour().Red() , m_brush = new HatchBrush
brush.GetColour().Green() , brush.GetColour().Blue() ), Color::Transparent ); (
style,
wxColourToColor(brush.GetColour()),
Color::Transparent
);
} }
else else
{ {
@@ -655,8 +672,7 @@ wxGDIPlusFontData::wxGDIPlusFontData( wxGraphicsRenderer* renderer, const wxFont
if ( font.GetWeight() == wxFONTWEIGHT_BOLD ) if ( font.GetWeight() == wxFONTWEIGHT_BOLD )
style |= FontStyleBold; style |= FontStyleBold;
m_font = new Font( s , size , style ); m_font = new Font( s , size , style );
m_textBrush = new SolidBrush( Color( col.Alpha() , col.Red() , m_textBrush = new SolidBrush(wxColourToColor(col));
col.Green() , col.Blue() ));
} }
wxGDIPlusFontData::~wxGDIPlusFontData() wxGDIPlusFontData::~wxGDIPlusFontData()