Review feedback

This commit is contained in:
Adrien Tétar
2017-05-03 19:20:45 +02:00
committed by Vadim Zeitlin
parent 2305604565
commit 999c750ca7
14 changed files with 139 additions and 173 deletions

View File

@@ -22,6 +22,7 @@
#include "wx/font.h" #include "wx/font.h"
#include "wx/image.h" #include "wx/image.h"
#include "wx/vector.h" #include "wx/vector.h"
#include "wx/pen.h"
enum wxAntialiasMode enum wxAntialiasMode
{ {
@@ -136,43 +137,40 @@ protected:
// wxGraphicsPenInfo describes a wxGraphicsPen // wxGraphicsPenInfo describes a wxGraphicsPen
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
class wxGraphicsPenInfo : public wxPenInfo class wxGraphicsPenInfo : public wxPenInfoBase<wxGraphicsPenInfo>
{ {
public: public:
wxGraphicsPenInfo() explicit wxGraphicsPenInfo(const wxColour& colour = wxColour(), wxDouble width = 1.0, wxPenStyle style = wxPENSTYLE_SOLID)
: wxPenInfo() : wxPenInfoBase(colour, style)
{ {
m_widthF = -1.0; m_width = width;
} }
explicit wxGraphicsPenInfo(const wxColour& colour, double widthF = 1.0, wxPenStyle style = wxPENSTYLE_SOLID) static wxGraphicsPenInfo CreateFromPen(const wxPen& pen)
: wxPenInfo(colour, 0, style)
{ {
m_widthF = widthF; wxDash *dashes;
int nb_dashes = pen.GetDashes(&dashes);
return wxGraphicsPenInfo()
.Colour(pen.GetColour())
.Width(pen.GetWidth())
.Style(pen.GetStyle())
.Stipple(*pen.GetStipple())
.Dashes(nb_dashes, dashes)
.Join(pen.GetJoin())
.Cap(pen.GetCap());
} }
// Setters for the various attributes. All of them return the object itself // Setters
// so that the calls to them could be chained.
wxGraphicsPenInfo& Colour(const wxColour& colour); wxGraphicsPenInfo& Width(wxDouble width)
{ m_width = width; return *this; }
wxGraphicsPenInfo& Width(int width); // Accessors
wxGraphicsPenInfo& Style(wxPenStyle style); wxDouble GetWidth() const { return m_width; }
wxGraphicsPenInfo& Stipple(const wxBitmap& stipple);
wxGraphicsPenInfo& Dashes(int nb_dashes, const wxDash *dash);
wxGraphicsPenInfo& Join(wxPenJoin join);
wxGraphicsPenInfo& Cap(wxPenCap cap);
wxGraphicsPenInfo& WidthF(wxDouble widthF)
{ m_widthF = widthF; return *this; }
// Accessors are mostly meant to be used by wxGraphicsPen itself.
wxDouble GetWidthF() const { return m_widthF; }
private: private:
wxDouble m_widthF; wxDouble m_width;
}; };
class WXDLLIMPEXP_CORE wxGraphicsPen : public wxGraphicsObject class WXDLLIMPEXP_CORE wxGraphicsPen : public wxGraphicsObject
@@ -524,6 +522,8 @@ public:
virtual wxGraphicsPen CreatePen(const wxPen& pen) const; virtual wxGraphicsPen CreatePen(const wxPen& pen) const;
virtual wxGraphicsPen CreatePen(const wxGraphicsPenInfo& pen) const;
virtual wxGraphicsBrush CreateBrush(const wxBrush& brush ) const; virtual wxGraphicsBrush CreateBrush(const wxBrush& brush ) const;
// sets the brush to a linear gradient, starting at (x1,y1) and ending at // sets the brush to a linear gradient, starting at (x1,y1) and ending at
@@ -906,6 +906,8 @@ public:
virtual wxGraphicsPen CreatePen(const wxPen& pen) = 0; virtual wxGraphicsPen CreatePen(const wxPen& pen) = 0;
virtual wxGraphicsPen CreatePen(const wxGraphicsPenInfo& info) = 0;
virtual wxGraphicsBrush CreateBrush(const wxBrush& brush ) = 0; virtual wxGraphicsBrush CreateBrush(const wxBrush& brush ) = 0;
// Gradient brush creation functions may not honour all the stops specified // Gradient brush creation functions may not honour all the stops specified

View File

@@ -11,6 +11,7 @@
#ifndef _WX_PEN_H_BASE_ #ifndef _WX_PEN_H_BASE_
#define _WX_PEN_H_BASE_ #define _WX_PEN_H_BASE_
#include "wx/bitmap.h"
#include "wx/gdiobj.h" #include "wx/gdiobj.h"
#include "wx/gdicmn.h" #include "wx/gdicmn.h"
@@ -63,73 +64,56 @@ enum wxPenCap
// wxPenInfo describes a wxPen // wxPenInfo describes a wxPen
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
class wxPenInfo template <class T>
class wxPenInfoBase
{ {
public: public:
wxPenInfo() : wxPenInfoBase(const wxColour& colour, wxPenStyle style)
m_colour(wxNullColour)
{ {
Init(); m_nb_dashes = 0;
m_dash = NULL;
m_join = wxJOIN_ROUND;
m_cap = wxCAP_ROUND;
m_width = 1; m_colour = colour;
m_style = wxPENSTYLE_SOLID;
}
explicit wxPenInfo(const wxColour& colour, int width = 1, wxPenStyle style = wxPENSTYLE_SOLID) :
m_colour((wxColour&) colour)
{
Init();
m_width = width;
m_style = style; m_style = style;
} }
// Setters for the various attributes. All of them return the object itself // Setters for the various attributes. All of them return the object itself
// so that the calls to them could be chained. // so that the calls to them could be chained.
wxPenInfo& Colour(const wxColour& colour) T &Colour(const wxColour& colour)
{ m_colour = colour; return *this; } { m_colour = colour; return static_cast<T&>(*this); }
wxPenInfo& Width(int width) T &Style(wxPenStyle style)
{ m_width = width; return *this; } { m_style = style; return static_cast<T&>(*this); }
T &Stipple(const wxBitmap& stipple)
wxPenInfo& Style(wxPenStyle style) { m_stipple = stipple; m_style = wxPENSTYLE_STIPPLE; return static_cast<T&>(*this); }
{ m_style = style; return *this; } T &Dashes(int nb_dashes, const wxDash *dash)
wxPenInfo& Stipple(const wxBitmap& stipple) { m_nb_dashes = nb_dashes; m_dash = (wxDash *)dash; return static_cast<T&>(*this); }
{ m_stipple = stipple; m_style = wxPENSTYLE_STIPPLE; return *this; } T &Join(wxPenJoin join)
wxPenInfo& Dashes(int nb_dashes, const wxDash *dash) { m_join = join; return static_cast<T&>(*this); }
{ m_nb_dashes = nb_dashes; m_dash = (wxDash *)dash; return *this; } T &Cap(wxPenCap cap)
wxPenInfo& Join(wxPenJoin join) { m_cap = cap; return static_cast<T&>(*this); }
{ m_join = join; return *this; }
wxPenInfo& Cap(wxPenCap cap)
{ m_cap = cap; return *this; }
// Accessors are mostly meant to be used by wxPen itself. // Accessors are mostly meant to be used by wxPen itself.
wxColour GetColour() const { return m_colour; } wxColour GetColour() const { return m_colour; }
wxBitmap* GetStipple() { return &m_stipple; } wxBitmap GetStipple() const { return m_stipple; }
wxPenStyle GetStyle() const { return m_style; } wxPenStyle GetStyle() const { return m_style; }
wxPenJoin GetJoin() const { return m_join; } wxPenJoin GetJoin() const { return m_join; }
wxPenCap GetCap() const { return m_cap; } wxPenCap GetCap() const { return m_cap; }
int GetWidth() const { return m_width; }
int GetDashes(wxDash **ptr) const { *ptr = m_dash; return m_nb_dashes; } int GetDashes(wxDash **ptr) const { *ptr = m_dash; return m_nb_dashes; }
int GetDashCount() const { return m_nb_dashes; }
wxDash* GetDash() const { return m_dash; }
// Convenience // Convenience
bool IsTransparent() const { return m_style == wxPENSTYLE_TRANSPARENT; } bool IsTransparent() const { return m_style == wxPENSTYLE_TRANSPARENT; }
private: private:
void Init() wxColour m_colour;
{
m_stipple = wxNullBitmap;
m_nb_dashes = 0;
m_dash = NULL;
m_join = wxJOIN_ROUND;
m_cap = wxCAP_ROUND;
}
wxColour& m_colour;
int m_width;
wxBitmap m_stipple; wxBitmap m_stipple;
wxPenStyle m_style; wxPenStyle m_style;
wxPenJoin m_join; wxPenJoin m_join;
@@ -139,6 +123,28 @@ private:
wxDash* m_dash; wxDash* m_dash;
}; };
class wxPenInfo : public wxPenInfoBase<wxPenInfo>
{
public:
explicit wxPenInfo(const wxColour& colour = wxColour(), int width = 1, wxPenStyle style = wxPENSTYLE_SOLID)
: wxPenInfoBase(colour, style)
{
m_width = width;
}
// Setters
wxPenInfo& Width(int width)
{ m_width = width; return *this; }
// Accessors
int GetWidth() const { return m_width; }
private:
int m_width;
};
class WXDLLIMPEXP_CORE wxPenBase : public wxGDIObject class WXDLLIMPEXP_CORE wxPenBase : public wxGDIObject
{ {

View File

@@ -1532,6 +1532,7 @@ public:
}; };
/** /**
@class wxGraphicsPenInfo @class wxGraphicsPenInfo
@@ -1540,23 +1541,26 @@ public:
calls to its clearly named methods instead of passing them in the fixed calls to its clearly named methods instead of passing them in the fixed
order to wxGraphicsPen constructors. order to wxGraphicsPen constructors.
@since 3.1.0 Typically you would use wxGraphicsPenInfo with a wxGraphicsContext:
@code
wxGraphicsContext ctx = wxGraphicsContext::Create(dc);
ctx.SetPen(wxGraphicsPenInfo(*wxBLUE, 1.25));
@endcode
@since 3.1.1
*/ */
class wxGraphicsPenInfo : public wxPenInfo class wxGraphicsPenInfo : public wxPenInfoBase<wxGraphicsPenInfo>
{ {
public: public:
wxGraphicsPenInfo(); explicit wxGraphicsPenInfo(const wxColour& colour = wxColour(), wxDouble width = 1.0, wxPenStyle style = wxPENSTYLE_SOLID);
explicit wxGraphicsPenInfo(const wxColour& colour, double widthF = 1.0, wxPenStyle style = wxPENSTYLE_SOLID); static wxGraphicsPenInfo CreateFromPen(const wxPen& pen);
wxGraphicsPenInfo& ();
wxGraphicsPenInfo& Colour(const wxColour& col); wxGraphicsPenInfo& Colour(const wxColour& col);
wxGraphicsPenInfo& Width(int width); wxGraphicsPenInfo& Width(wxDouble width);
wxGraphicsPenInfo& WidthF(wxDouble widthF);
wxGraphicsPenInfo& Style(wxPenStyle style); wxGraphicsPenInfo& Style(wxPenStyle style);

View File

@@ -100,6 +100,7 @@ enum wxPenCap
}; };
/** /**
@class wxPenInfo @class wxPenInfo
@@ -108,17 +109,18 @@ enum wxPenCap
calls to its clearly named methods instead of passing them in the fixed calls to its clearly named methods instead of passing them in the fixed
order to wxPen constructors. order to wxPen constructors.
@since 3.1.0 For instance, to create a blue pen with a width of 0:
@code
wxPen pen(wxPenInfo(*wxBLUE, 0));
@endcode
@since 3.1.1
*/ */
class wxPenInfo class wxPenInfo : public wxPenInfoBase<wxPenInfo>
{ {
public: public:
wxPenInfo(); explicit wxPenInfo(const wxColour& colour = wxColour(), int width = 1, wxPenStyle style = wxPENSTYLE_SOLID);
explicit wxPenInfo(const wxColour& colour, int width = 1, wxPenStyle style = wxPENSTYLE_SOLID);
wxPenInfo& ();
wxPenInfo& Colour(const wxColour& col); wxPenInfo& Colour(const wxColour& col);
@@ -138,6 +140,7 @@ public:
}; };
/** /**
@class wxPen @class wxPen

View File

@@ -827,6 +827,11 @@ wxGraphicsPen wxGraphicsContext::CreatePen(const wxPen& pen) const
return GetRenderer()->CreatePen(pen); return GetRenderer()->CreatePen(pen);
} }
wxGraphicsPen wxGraphicsContext::CreatePen(const wxGraphicsPenInfo& info) const
{
return GetRenderer()->CreatePen(info);
}
wxGraphicsBrush wxGraphicsContext::CreateBrush(const wxBrush& brush ) const wxGraphicsBrush wxGraphicsContext::CreateBrush(const wxBrush& brush ) const
{ {
return GetRenderer()->CreateBrush(brush); return GetRenderer()->CreateBrush(brush);

View File

@@ -738,17 +738,7 @@ void wxCairoPenData::Init()
wxCairoPenData::wxCairoPenData( wxGraphicsRenderer* renderer, const wxPen &pen ) wxCairoPenData::wxCairoPenData( wxGraphicsRenderer* renderer, const wxPen &pen )
: wxCairoPenBrushBaseData(renderer, pen.GetColour(), pen.IsTransparent()) : wxCairoPenBrushBaseData(renderer, pen.GetColour(), pen.IsTransparent())
{ {
wxDash *dashes; InitFromPenInfo(wxGraphicsPenInfo::CreateFromPen(pen));
int nb_dashes = pen.GetDashes(&dashes);
InitFromPenInfo(wxGraphicsPenInfo()
.Colour(pen.GetColour())
.Width(pen.GetWidth())
.Style(pen.GetStyle())
.Stipple(*pen.GetStipple())
.Dashes(nb_dashes, dashes)
.Join(pen.GetJoin())
.Cap(pen.GetCap())
);
} }
wxCairoPenData::wxCairoPenData( wxGraphicsRenderer* renderer, const wxGraphicsPenInfo &info ) wxCairoPenData::wxCairoPenData( wxGraphicsRenderer* renderer, const wxGraphicsPenInfo &info )
@@ -760,8 +750,6 @@ wxCairoPenData::wxCairoPenData( wxGraphicsRenderer* renderer, const wxGraphicsPe
void wxCairoPenData::InitFromPenInfo( const wxGraphicsPenInfo &info ) void wxCairoPenData::InitFromPenInfo( const wxGraphicsPenInfo &info )
{ {
Init(); Init();
m_width = info.GetWidthF();
if (m_width < 0)
m_width = info.GetWidth(); m_width = info.GetWidth();
if (m_width <= 0.0) if (m_width <= 0.0)
m_width = 0.1; m_width = 0.1;
@@ -873,7 +861,10 @@ void wxCairoPenData::InitFromPenInfo( const wxGraphicsPenInfo &info )
case wxPENSTYLE_STIPPLE : case wxPENSTYLE_STIPPLE :
case wxPENSTYLE_STIPPLE_MASK : case wxPENSTYLE_STIPPLE_MASK :
case wxPENSTYLE_STIPPLE_MASK_OPAQUE : case wxPENSTYLE_STIPPLE_MASK_OPAQUE :
InitStipple(((wxGraphicsPenInfo&) info).GetStipple()); {
wxBitmap stipple = info.GetStipple();
InitStipple(&stipple);
}
break; break;
default : default :

View File

@@ -111,9 +111,7 @@ wxPen::wxPen(const wxPenInfo& info)
M_PENDATA->m_style = info.GetStyle(); M_PENDATA->m_style = info.GetStyle();
M_PENDATA->m_joinStyle = info.GetJoin(); M_PENDATA->m_joinStyle = info.GetJoin();
M_PENDATA->m_capStyle = info.GetCap(); M_PENDATA->m_capStyle = info.GetCap();
wxDash *dashes; M_PENDATA->m_countDashes = info.GetDashes(&M_PENDATA->m_dash);
M_PENDATA->m_countDashes = info.GetDashes(&dashes);
M_PENDATA->m_dash = dashes;
} }
wxPen::~wxPen() wxPen::~wxPen()

View File

@@ -112,9 +112,7 @@ wxPen::wxPen(const wxPenInfo& info)
M_PENDATA->m_style = info.GetStyle(); M_PENDATA->m_style = info.GetStyle();
M_PENDATA->m_joinStyle = info.GetJoin(); M_PENDATA->m_joinStyle = info.GetJoin();
M_PENDATA->m_capStyle = info.GetCap(); M_PENDATA->m_capStyle = info.GetCap();
wxDash *dashes; M_PENDATA->m_countDashes = info.GetDashes(&M_PENDATA->m_dash);
M_PENDATA->m_countDashes = info.GetDashes(&dashes);
M_PENDATA->m_dash = dashes;
} }
wxGDIRefData *wxPen::CreateGDIRefData() const wxGDIRefData *wxPen::CreateGDIRefData() const

View File

@@ -265,7 +265,7 @@ public:
~wxGDIPlusPenData(); ~wxGDIPlusPenData();
void Init(); void Init();
void InitFromPenInfo( wxGraphicsRenderer* renderer, const wxGraphicsPenInfo &info ); void InitFromPenInfo( const wxGraphicsPenInfo &info );
virtual wxDouble GetWidth() { return m_width; } virtual wxDouble GetWidth() { return m_width; }
virtual Pen* GetGDIPlusPen() { return m_pen; } virtual Pen* GetGDIPlusPen() { return m_pen; }
@@ -650,30 +650,18 @@ void wxGDIPlusPenData::Init()
wxGDIPlusPenData::wxGDIPlusPenData( wxGraphicsRenderer* renderer, const wxPen &pen ) wxGDIPlusPenData::wxGDIPlusPenData( wxGraphicsRenderer* renderer, const wxPen &pen )
: wxGraphicsObjectRefData(renderer) : wxGraphicsObjectRefData(renderer)
{ {
wxDash *dashes; InitFromPenInfo(wxGraphicsPenInfo::CreateFromPen(pen));
int nb_dashes = pen.GetDashes(&dashes);
InitFromPenInfo(renderer, wxGraphicsPenInfo()
.Colour(pen.GetColour())
.Width(pen.GetWidth())
.Style(pen.GetStyle())
.Stipple(*pen.GetStipple())
.Dashes(nb_dashes, dashes)
.Join(pen.GetJoin())
.Cap(pen.GetCap())
);
} }
wxGDIPlusPenData::wxGDIPlusPenData( wxGraphicsRenderer* renderer, const wxGraphicsPenInfo &info ) wxGDIPlusPenData::wxGDIPlusPenData( wxGraphicsRenderer* renderer, const wxGraphicsPenInfo &info )
: wxGraphicsObjectRefData(renderer) : wxGraphicsObjectRefData(renderer)
{ {
InitFromPenInfo(renderer, info); InitFromPenInfo(info);
} }
void wxGDIPlusPenData::InitFromPenInfo( wxGraphicsRenderer* renderer, const wxGraphicsPenInfo &info ) void wxGDIPlusPenData::InitFromPenInfo( const wxGraphicsPenInfo &info )
{ {
Init(); Init();
m_width = info.GetWidthF();
if (m_info < 0.0)
m_width = info.GetWidth(); m_width = info.GetWidth();
if (m_width <= 0.0) if (m_width <= 0.0)
m_width = 0.1; m_width = 0.1;
@@ -765,12 +753,12 @@ void wxGDIPlusPenData::InitFromPenInfo( wxGraphicsRenderer* renderer, const wxGr
break; break;
case wxPENSTYLE_STIPPLE : case wxPENSTYLE_STIPPLE :
{ {
wxBitmap* bmp = info.GetStipple(); wxBitmap bmp = info.GetStipple();
if ( bmp && bmp->IsOk() ) if ( bmp.IsOk() )
{ {
m_penImage = Bitmap::FromHBITMAP((HBITMAP)bmp->GetHBITMAP(), m_penImage = Bitmap::FromHBITMAP((HBITMAP)bmp.GetHBITMAP(),
#if wxUSE_PALETTE #if wxUSE_PALETTE
(HPALETTE)bmp->GetPalette()->GetHPALETTE() (HPALETTE)bmp.GetPalette()->GetHPALETTE()
#else #else
NULL NULL
#endif #endif
@@ -2491,7 +2479,7 @@ wxGraphicsPen wxGDIPlusRenderer::CreatePen(const wxPen& pen)
wxGraphicsPen wxGDIPlusRenderer::CreatePen(const wxGraphicsPenInfo& info) wxGraphicsPen wxGDIPlusRenderer::CreatePen(const wxGraphicsPenInfo& info)
{ {
ENSURE_LOADED_OR_RETURN(wxNullGraphicsPen); ENSURE_LOADED_OR_RETURN(wxNullGraphicsPen);
if ( !info.GetStyle() == wxPENSTYLE_TRANSPARENT ) if ( info.GetStyle() == wxPENSTYLE_TRANSPARENT )
return wxNullGraphicsPen; return wxNullGraphicsPen;
else else
{ {

View File

@@ -2462,7 +2462,7 @@ public:
wxD2DPenData(wxGraphicsRenderer* renderer, ID2D1Factory* direct2dFactory, const wxGraphicsPenInfo& info); wxD2DPenData(wxGraphicsRenderer* renderer, ID2D1Factory* direct2dFactory, const wxGraphicsPenInfo& info);
void InitFromPenInfo(wxGraphicsRenderer* renderer, ID2D1Factory* direct2dFactory); void Init(wxGraphicsRenderer* renderer, ID2D1Factory* direct2dFactory);
void CreateStrokeStyle(ID2D1Factory* const direct2dfactory); void CreateStrokeStyle(ID2D1Factory* const direct2dfactory);
@@ -2480,7 +2480,7 @@ public:
private: private:
// We store the source info for later when we need to recreate the // We store the source info for later when we need to recreate the
// device-dependent resources. // device-dependent resources.
const wxGraphicsPenInfo& m_sourceInfo; const wxGraphicsPenInfo m_sourceInfo;
// A stroke style is a device-independent resource. // A stroke style is a device-independent resource.
// Describes the caps, miter limit, line join, and dash information. // Describes the caps, miter limit, line join, and dash information.
@@ -2502,45 +2502,32 @@ wxD2DPenData::wxD2DPenData(
ID2D1Factory* direct2dFactory, ID2D1Factory* direct2dFactory,
const wxPen& pen) : const wxPen& pen) :
wxGraphicsObjectRefData(renderer), wxGraphicsObjectRefData(renderer),
m_sourceInfo(wxGraphicsPenInfo()) m_sourceInfo(wxGraphicsPenInfo::CreateFromPen(pen)),
m_width(pen.GetWidth()) m_width(pen.GetWidth())
{ {
wxDash* dashes; Init(renderer, direct2dFactory);
int nb_dashes = pen.GetDashes(&dashes);
m_sourceInfo
.Colour(pen.GetColour())
.Width(pen.GetWidth())
.Style(pen.GetStyle())
.Stipple(*pen.GetStipple())
.Dashes(nb_dashes, dashes)
.Join(pen.GetJoin())
.Cap(pen.GetCap())
InitFromPenInfo(renderer, direct2dFactory);
} }
wxD2DPenData::wxD2DPenData( wxD2DPenData::wxD2DPenData(
wxGraphicsRenderer* renderer, wxGraphicsRenderer* renderer,
ID2D1Factory* direct2dFactory, ID2D1Factory* direct2dFactory,
const wxGraphicsPenInfo& info) const wxGraphicsPenInfo& info)
: wxGraphicsObjectRefData(renderer), m_sourceInfo(Info), m_width(info.GetWidthF()) : wxGraphicsObjectRefData(renderer), m_sourceInfo(info), m_width(info.GetWidth())
{ {
if (m_width < 0.0) Init(renderer, direct2dFactory);
m_width = info.GetWidth();
InitFromPenInfo(renderer, direct2dFactory);
} }
void wxD2DPenData::InitFromPenInfo( void wxD2DPenData::Init(
wxGraphicsRenderer* renderer, wxGraphicsRenderer* renderer,
ID2D1Factory* direct2dFactory) ID2D1Factory* direct2dFactory)
{ {
CreateStrokeStyle(direct2dFactory, info); CreateStrokeStyle(direct2dFactory);
wxBrush strokeBrush; wxBrush strokeBrush;
if (m_sourceInfo.GetStyle() == wxPENSTYLE_STIPPLE) if (m_sourceInfo.GetStyle() == wxPENSTYLE_STIPPLE)
{ {
strokeBrush.SetStipple(*(m_sourceInfo.GetStipple())); strokeBrush.SetStipple(m_sourceInfo.GetStipple());
strokeBrush.SetStyle(wxBRUSHSTYLE_STIPPLE); strokeBrush.SetStyle(wxBRUSHSTYLE_STIPPLE);
} }
else if(wxIsHatchPenStyle(m_sourceInfo.GetStyle())) else if(wxIsHatchPenStyle(m_sourceInfo.GetStyle()))

View File

@@ -425,7 +425,7 @@ wxPen::wxPen(const wxPenInfo& info)
M_PENDATA->SetCap(info.GetCap()); M_PENDATA->SetCap(info.GetCap());
wxDash *dash; wxDash *dash;
int nb_dashes = info.GetDashes(&dash); int nb_dashes = info.GetDashes(&dash);
M_PENDATA->SetDashes(nb_dashes, dash) M_PENDATA->SetDashes(nb_dashes, dash);
} }
bool wxPen::operator==(const wxPen& pen) const bool wxPen::operator==(const wxPen& pen) const

View File

@@ -309,7 +309,7 @@ public:
~wxMacCoreGraphicsPenData(); ~wxMacCoreGraphicsPenData();
void Init(); void Init();
void InitFromPenInfo( wxGraphicsRenderer* renderer, const wxGraphicsPenInfo& info ); void InitFromPenInfo( const wxGraphicsPenInfo& info );
virtual void Apply( wxGraphicsContext* context ); virtual void Apply( wxGraphicsContext* context );
virtual wxDouble GetWidth() { return m_width; } virtual wxDouble GetWidth() { return m_width; }
@@ -334,34 +334,22 @@ protected :
wxMacCoreGraphicsPenData::wxMacCoreGraphicsPenData( wxGraphicsRenderer* renderer, const wxPen &pen ) : wxMacCoreGraphicsPenData::wxMacCoreGraphicsPenData( wxGraphicsRenderer* renderer, const wxPen &pen ) :
wxGraphicsObjectRefData( renderer ) wxGraphicsObjectRefData( renderer )
{ {
wxDash *dashes; InitFromPenInfo(wxGraphicsPenInfo::CreateFromPen(pen));
int nb_dashes = pen.GetDashes(&dashes);
InitFromPenInfo(renderer, wxGraphicsPenInfo()
.Colour(pen.GetColour())
.Width(pen.GetWidth())
.Style(pen.GetStyle())
.Stipple(*pen.GetStipple())
.Dashes(nb_dashes, dashes)
.Join(pen.GetJoin())
.Cap(pen.GetCap())
);
} }
wxMacCoreGraphicsPenData::wxMacCoreGraphicsPenData( wxGraphicsRenderer* renderer, const wxGraphicsPenInfo& info ) : wxMacCoreGraphicsPenData::wxMacCoreGraphicsPenData( wxGraphicsRenderer* renderer, const wxGraphicsPenInfo& info ) :
wxGraphicsObjectRefData( renderer ) wxGraphicsObjectRefData( renderer )
{ {
InitFromPenInfo(renderer, info); InitFromPenInfo(info);
} }
void wxMacCoreGraphicsPenData::InitFromPenInfo( wxGraphicsRenderer* renderer, const wxGraphicsPenInfo& info ) void wxMacCoreGraphicsPenData::InitFromPenInfo( const wxGraphicsPenInfo& info )
{ {
Init(); Init();
m_color.reset( wxMacCreateCGColor( info.GetColour() ) ) ; m_color.reset( wxMacCreateCGColor( info.GetColour() ) ) ;
// TODO: * m_dc->m_scaleX // TODO: * m_dc->m_scaleX
m_width = info.GetWidthF();
if (m_width < 0.0)
m_width = info.GetWidth(); m_width = info.GetWidth();
if (m_width <= 0.0) if (m_width <= 0.0)
m_width = (CGFloat) 0.1; m_width = (CGFloat) 0.1;
@@ -459,11 +447,11 @@ void wxMacCoreGraphicsPenData::InitFromPenInfo( wxGraphicsRenderer* renderer, co
case wxPENSTYLE_STIPPLE: case wxPENSTYLE_STIPPLE:
{ {
wxBitmap* bmp = info.GetStipple(); wxBitmap bmp = info.GetStipple();
if ( bmp && bmp->IsOk() ) if ( bmp.IsOk() )
{ {
m_colorSpace.reset( CGColorSpaceCreatePattern( NULL ) ); m_colorSpace.reset( CGColorSpaceCreatePattern( NULL ) );
m_pattern.reset( (CGPatternRef) *( new ImagePattern( bmp , CGAffineTransformMakeScale( 1,-1 ) ) ) ); m_pattern.reset( (CGPatternRef) *( new ImagePattern( &bmp , CGAffineTransformMakeScale( 1,-1 ) ) ) );
m_patternColorComponents = new CGFloat[1] ; m_patternColorComponents = new CGFloat[1] ;
m_patternColorComponents[0] = (CGFloat) 1.0; m_patternColorComponents[0] = (CGFloat) 1.0;
m_isPattern = true; m_isPattern = true;
@@ -2746,7 +2734,7 @@ wxGraphicsPen wxMacCoreGraphicsRenderer::CreatePen(const wxPen& pen)
wxGraphicsPen wxMacCoreGraphicsRenderer::CreatePen(const wxGraphicsPenInfo& info) wxGraphicsPen wxMacCoreGraphicsRenderer::CreatePen(const wxGraphicsPenInfo& info)
{ {
if ( info.GetStyle() == wxPENSTYLE_TRANSPARENT ) if ( info.IsTransparent() )
return wxNullGraphicsPen; return wxNullGraphicsPen;
else else
{ {

View File

@@ -150,9 +150,7 @@ wxPen::wxPen(const wxPenInfo& info)
M_PENDATA->m_style = info.GetStyle(); M_PENDATA->m_style = info.GetStyle();
M_PENDATA->m_join = info.GetJoin(); M_PENDATA->m_join = info.GetJoin();
M_PENDATA->m_cap = info.GetCap(); M_PENDATA->m_cap = info.GetCap();
wxDash *dashes; M_PENDATA->m_nbDash = info.GetDashes(&M_PENDATA->m_dash);
M_PENDATA->m_nbDash = info.GetDashes(&dashes);
M_PENDATA->m_dash = dashes;
RealizeResource(); RealizeResource();
} }

View File

@@ -102,9 +102,7 @@ wxPen::wxPen(const wxPenInfo& info)
M_PENDATA->m_capStyle = info.GetCap(); M_PENDATA->m_capStyle = info.GetCap();
M_PENDATA->m_joinStyle = info.GetJoin(); M_PENDATA->m_joinStyle = info.GetJoin();
M_PENDATA->m_stipple = info.GetStipple(); M_PENDATA->m_stipple = info.GetStipple();
wxDash *dashes; M_PENDATA->m_countDashes = info.GetDashes(&M_PENDATA->m_dash);
M_PENDATA->m_countDashes = info.GetDashes(&dashes);
M_PENDATA->m_dash = dashes;
} }
wxPen::~wxPen() wxPen::~wxPen()