Review feedback
This commit is contained in:
committed by
Vadim Zeitlin
parent
2305604565
commit
999c750ca7
@@ -22,6 +22,7 @@
|
||||
#include "wx/font.h"
|
||||
#include "wx/image.h"
|
||||
#include "wx/vector.h"
|
||||
#include "wx/pen.h"
|
||||
|
||||
enum wxAntialiasMode
|
||||
{
|
||||
@@ -136,43 +137,40 @@ protected:
|
||||
// wxGraphicsPenInfo describes a wxGraphicsPen
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
class wxGraphicsPenInfo : public wxPenInfo
|
||||
class wxGraphicsPenInfo : public wxPenInfoBase<wxGraphicsPenInfo>
|
||||
{
|
||||
public:
|
||||
wxGraphicsPenInfo()
|
||||
: wxPenInfo()
|
||||
explicit wxGraphicsPenInfo(const wxColour& colour = wxColour(), wxDouble width = 1.0, wxPenStyle style = wxPENSTYLE_SOLID)
|
||||
: wxPenInfoBase(colour, style)
|
||||
{
|
||||
m_widthF = -1.0;
|
||||
m_width = width;
|
||||
}
|
||||
|
||||
explicit wxGraphicsPenInfo(const wxColour& colour, double widthF = 1.0, wxPenStyle style = wxPENSTYLE_SOLID)
|
||||
: wxPenInfo(colour, 0, style)
|
||||
static wxGraphicsPenInfo CreateFromPen(const wxPen& pen)
|
||||
{
|
||||
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
|
||||
// so that the calls to them could be chained.
|
||||
// Setters
|
||||
|
||||
wxGraphicsPenInfo& Colour(const wxColour& colour);
|
||||
wxGraphicsPenInfo& Width(wxDouble width)
|
||||
{ m_width = width; return *this; }
|
||||
|
||||
wxGraphicsPenInfo& Width(int width);
|
||||
// Accessors
|
||||
|
||||
wxGraphicsPenInfo& Style(wxPenStyle style);
|
||||
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; }
|
||||
wxDouble GetWidth() const { return m_width; }
|
||||
|
||||
private:
|
||||
wxDouble m_widthF;
|
||||
wxDouble m_width;
|
||||
};
|
||||
|
||||
class WXDLLIMPEXP_CORE wxGraphicsPen : public wxGraphicsObject
|
||||
@@ -524,6 +522,8 @@ public:
|
||||
|
||||
virtual wxGraphicsPen CreatePen(const wxPen& pen) const;
|
||||
|
||||
virtual wxGraphicsPen CreatePen(const wxGraphicsPenInfo& pen) const;
|
||||
|
||||
virtual wxGraphicsBrush CreateBrush(const wxBrush& brush ) const;
|
||||
|
||||
// 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 wxGraphicsPenInfo& info) = 0;
|
||||
|
||||
virtual wxGraphicsBrush CreateBrush(const wxBrush& brush ) = 0;
|
||||
|
||||
// Gradient brush creation functions may not honour all the stops specified
|
||||
|
@@ -11,6 +11,7 @@
|
||||
#ifndef _WX_PEN_H_BASE_
|
||||
#define _WX_PEN_H_BASE_
|
||||
|
||||
#include "wx/bitmap.h"
|
||||
#include "wx/gdiobj.h"
|
||||
#include "wx/gdicmn.h"
|
||||
|
||||
@@ -63,73 +64,56 @@ enum wxPenCap
|
||||
// wxPenInfo describes a wxPen
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
class wxPenInfo
|
||||
template <class T>
|
||||
class wxPenInfoBase
|
||||
{
|
||||
public:
|
||||
wxPenInfo() :
|
||||
m_colour(wxNullColour)
|
||||
wxPenInfoBase(const wxColour& colour, wxPenStyle style)
|
||||
{
|
||||
Init();
|
||||
m_nb_dashes = 0;
|
||||
m_dash = NULL;
|
||||
m_join = wxJOIN_ROUND;
|
||||
m_cap = wxCAP_ROUND;
|
||||
|
||||
m_width = 1;
|
||||
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_colour = colour;
|
||||
m_style = style;
|
||||
}
|
||||
|
||||
// Setters for the various attributes. All of them return the object itself
|
||||
// so that the calls to them could be chained.
|
||||
|
||||
wxPenInfo& Colour(const wxColour& colour)
|
||||
{ m_colour = colour; return *this; }
|
||||
T &Colour(const wxColour& colour)
|
||||
{ m_colour = colour; return static_cast<T&>(*this); }
|
||||
|
||||
wxPenInfo& Width(int width)
|
||||
{ m_width = width; return *this; }
|
||||
|
||||
wxPenInfo& Style(wxPenStyle style)
|
||||
{ m_style = style; return *this; }
|
||||
wxPenInfo& Stipple(const wxBitmap& stipple)
|
||||
{ m_stipple = stipple; m_style = wxPENSTYLE_STIPPLE; return *this; }
|
||||
wxPenInfo& Dashes(int nb_dashes, const wxDash *dash)
|
||||
{ m_nb_dashes = nb_dashes; m_dash = (wxDash *)dash; return *this; }
|
||||
wxPenInfo& Join(wxPenJoin join)
|
||||
{ m_join = join; return *this; }
|
||||
wxPenInfo& Cap(wxPenCap cap)
|
||||
{ m_cap = cap; return *this; }
|
||||
T &Style(wxPenStyle style)
|
||||
{ m_style = style; return static_cast<T&>(*this); }
|
||||
T &Stipple(const wxBitmap& stipple)
|
||||
{ m_stipple = stipple; m_style = wxPENSTYLE_STIPPLE; return static_cast<T&>(*this); }
|
||||
T &Dashes(int nb_dashes, const wxDash *dash)
|
||||
{ m_nb_dashes = nb_dashes; m_dash = (wxDash *)dash; return static_cast<T&>(*this); }
|
||||
T &Join(wxPenJoin join)
|
||||
{ m_join = join; return static_cast<T&>(*this); }
|
||||
T &Cap(wxPenCap cap)
|
||||
{ m_cap = cap; return static_cast<T&>(*this); }
|
||||
|
||||
// Accessors are mostly meant to be used by wxPen itself.
|
||||
|
||||
wxColour GetColour() const { return m_colour; }
|
||||
wxBitmap* GetStipple() { return &m_stipple; }
|
||||
wxBitmap GetStipple() const { return m_stipple; }
|
||||
wxPenStyle GetStyle() const { return m_style; }
|
||||
wxPenJoin GetJoin() const { return m_join; }
|
||||
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 GetDashCount() const { return m_nb_dashes; }
|
||||
wxDash* GetDash() const { return m_dash; }
|
||||
|
||||
// Convenience
|
||||
|
||||
bool IsTransparent() const { return m_style == wxPENSTYLE_TRANSPARENT; }
|
||||
|
||||
private:
|
||||
void Init()
|
||||
{
|
||||
m_stipple = wxNullBitmap;
|
||||
m_nb_dashes = 0;
|
||||
m_dash = NULL;
|
||||
m_join = wxJOIN_ROUND;
|
||||
m_cap = wxCAP_ROUND;
|
||||
}
|
||||
|
||||
wxColour& m_colour;
|
||||
int m_width;
|
||||
wxColour m_colour;
|
||||
wxBitmap m_stipple;
|
||||
wxPenStyle m_style;
|
||||
wxPenJoin m_join;
|
||||
@@ -139,6 +123,28 @@ private:
|
||||
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
|
||||
{
|
||||
|
@@ -1532,6 +1532,7 @@ public:
|
||||
};
|
||||
|
||||
|
||||
|
||||
/**
|
||||
@class wxGraphicsPenInfo
|
||||
|
||||
@@ -1540,23 +1541,26 @@ public:
|
||||
calls to its clearly named methods instead of passing them in the fixed
|
||||
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:
|
||||
|
||||
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);
|
||||
|
||||
wxGraphicsPenInfo& ();
|
||||
static wxGraphicsPenInfo CreateFromPen(const wxPen& pen);
|
||||
|
||||
wxGraphicsPenInfo& Colour(const wxColour& col);
|
||||
|
||||
wxGraphicsPenInfo& Width(int width);
|
||||
|
||||
wxGraphicsPenInfo& WidthF(wxDouble widthF);
|
||||
wxGraphicsPenInfo& Width(wxDouble width);
|
||||
|
||||
wxGraphicsPenInfo& Style(wxPenStyle style);
|
||||
|
||||
|
@@ -100,6 +100,7 @@ enum wxPenCap
|
||||
};
|
||||
|
||||
|
||||
|
||||
/**
|
||||
@class wxPenInfo
|
||||
|
||||
@@ -108,17 +109,18 @@ enum wxPenCap
|
||||
calls to its clearly named methods instead of passing them in the fixed
|
||||
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:
|
||||
|
||||
wxPenInfo();
|
||||
|
||||
explicit wxPenInfo(const wxColour& colour, int width = 1, wxPenStyle style = wxPENSTYLE_SOLID);
|
||||
|
||||
wxPenInfo& ();
|
||||
explicit wxPenInfo(const wxColour& colour = wxColour(), int width = 1, wxPenStyle style = wxPENSTYLE_SOLID);
|
||||
|
||||
wxPenInfo& Colour(const wxColour& col);
|
||||
|
||||
@@ -138,6 +140,7 @@ public:
|
||||
};
|
||||
|
||||
|
||||
|
||||
/**
|
||||
@class wxPen
|
||||
|
||||
|
@@ -827,6 +827,11 @@ wxGraphicsPen wxGraphicsContext::CreatePen(const wxPen& pen) const
|
||||
return GetRenderer()->CreatePen(pen);
|
||||
}
|
||||
|
||||
wxGraphicsPen wxGraphicsContext::CreatePen(const wxGraphicsPenInfo& info) const
|
||||
{
|
||||
return GetRenderer()->CreatePen(info);
|
||||
}
|
||||
|
||||
wxGraphicsBrush wxGraphicsContext::CreateBrush(const wxBrush& brush ) const
|
||||
{
|
||||
return GetRenderer()->CreateBrush(brush);
|
||||
|
@@ -738,17 +738,7 @@ void wxCairoPenData::Init()
|
||||
wxCairoPenData::wxCairoPenData( wxGraphicsRenderer* renderer, const wxPen &pen )
|
||||
: wxCairoPenBrushBaseData(renderer, pen.GetColour(), pen.IsTransparent())
|
||||
{
|
||||
wxDash *dashes;
|
||||
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())
|
||||
);
|
||||
InitFromPenInfo(wxGraphicsPenInfo::CreateFromPen(pen));
|
||||
}
|
||||
|
||||
wxCairoPenData::wxCairoPenData( wxGraphicsRenderer* renderer, const wxGraphicsPenInfo &info )
|
||||
@@ -760,8 +750,6 @@ wxCairoPenData::wxCairoPenData( wxGraphicsRenderer* renderer, const wxGraphicsPe
|
||||
void wxCairoPenData::InitFromPenInfo( const wxGraphicsPenInfo &info )
|
||||
{
|
||||
Init();
|
||||
m_width = info.GetWidthF();
|
||||
if (m_width < 0)
|
||||
m_width = info.GetWidth();
|
||||
if (m_width <= 0.0)
|
||||
m_width = 0.1;
|
||||
@@ -873,7 +861,10 @@ void wxCairoPenData::InitFromPenInfo( const wxGraphicsPenInfo &info )
|
||||
case wxPENSTYLE_STIPPLE :
|
||||
case wxPENSTYLE_STIPPLE_MASK :
|
||||
case wxPENSTYLE_STIPPLE_MASK_OPAQUE :
|
||||
InitStipple(((wxGraphicsPenInfo&) info).GetStipple());
|
||||
{
|
||||
wxBitmap stipple = info.GetStipple();
|
||||
InitStipple(&stipple);
|
||||
}
|
||||
break;
|
||||
|
||||
default :
|
||||
|
@@ -111,9 +111,7 @@ wxPen::wxPen(const wxPenInfo& info)
|
||||
M_PENDATA->m_style = info.GetStyle();
|
||||
M_PENDATA->m_joinStyle = info.GetJoin();
|
||||
M_PENDATA->m_capStyle = info.GetCap();
|
||||
wxDash *dashes;
|
||||
M_PENDATA->m_countDashes = info.GetDashes(&dashes);
|
||||
M_PENDATA->m_dash = dashes;
|
||||
M_PENDATA->m_countDashes = info.GetDashes(&M_PENDATA->m_dash);
|
||||
}
|
||||
|
||||
wxPen::~wxPen()
|
||||
|
@@ -112,9 +112,7 @@ wxPen::wxPen(const wxPenInfo& info)
|
||||
M_PENDATA->m_style = info.GetStyle();
|
||||
M_PENDATA->m_joinStyle = info.GetJoin();
|
||||
M_PENDATA->m_capStyle = info.GetCap();
|
||||
wxDash *dashes;
|
||||
M_PENDATA->m_countDashes = info.GetDashes(&dashes);
|
||||
M_PENDATA->m_dash = dashes;
|
||||
M_PENDATA->m_countDashes = info.GetDashes(&M_PENDATA->m_dash);
|
||||
}
|
||||
|
||||
wxGDIRefData *wxPen::CreateGDIRefData() const
|
||||
|
@@ -265,7 +265,7 @@ public:
|
||||
~wxGDIPlusPenData();
|
||||
|
||||
void Init();
|
||||
void InitFromPenInfo( wxGraphicsRenderer* renderer, const wxGraphicsPenInfo &info );
|
||||
void InitFromPenInfo( const wxGraphicsPenInfo &info );
|
||||
|
||||
virtual wxDouble GetWidth() { return m_width; }
|
||||
virtual Pen* GetGDIPlusPen() { return m_pen; }
|
||||
@@ -650,31 +650,19 @@ void wxGDIPlusPenData::Init()
|
||||
wxGDIPlusPenData::wxGDIPlusPenData( wxGraphicsRenderer* renderer, const wxPen &pen )
|
||||
: wxGraphicsObjectRefData(renderer)
|
||||
{
|
||||
wxDash *dashes;
|
||||
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())
|
||||
);
|
||||
InitFromPenInfo(wxGraphicsPenInfo::CreateFromPen(pen));
|
||||
}
|
||||
|
||||
wxGDIPlusPenData::wxGDIPlusPenData( wxGraphicsRenderer* renderer, const wxGraphicsPenInfo &info )
|
||||
: wxGraphicsObjectRefData(renderer)
|
||||
{
|
||||
InitFromPenInfo(renderer, info);
|
||||
InitFromPenInfo(info);
|
||||
}
|
||||
|
||||
void wxGDIPlusPenData::InitFromPenInfo( wxGraphicsRenderer* renderer, const wxGraphicsPenInfo &info )
|
||||
void wxGDIPlusPenData::InitFromPenInfo( const wxGraphicsPenInfo &info )
|
||||
{
|
||||
Init();
|
||||
m_width = info.GetWidthF();
|
||||
if (m_info < 0.0)
|
||||
m_width = info.GetWidth();
|
||||
m_width = info.GetWidth();
|
||||
if (m_width <= 0.0)
|
||||
m_width = 0.1;
|
||||
|
||||
@@ -765,12 +753,12 @@ void wxGDIPlusPenData::InitFromPenInfo( wxGraphicsRenderer* renderer, const wxGr
|
||||
break;
|
||||
case wxPENSTYLE_STIPPLE :
|
||||
{
|
||||
wxBitmap* bmp = info.GetStipple();
|
||||
if ( bmp && bmp->IsOk() )
|
||||
wxBitmap bmp = info.GetStipple();
|
||||
if ( bmp.IsOk() )
|
||||
{
|
||||
m_penImage = Bitmap::FromHBITMAP((HBITMAP)bmp->GetHBITMAP(),
|
||||
m_penImage = Bitmap::FromHBITMAP((HBITMAP)bmp.GetHBITMAP(),
|
||||
#if wxUSE_PALETTE
|
||||
(HPALETTE)bmp->GetPalette()->GetHPALETTE()
|
||||
(HPALETTE)bmp.GetPalette()->GetHPALETTE()
|
||||
#else
|
||||
NULL
|
||||
#endif
|
||||
@@ -2491,7 +2479,7 @@ wxGraphicsPen wxGDIPlusRenderer::CreatePen(const wxPen& pen)
|
||||
wxGraphicsPen wxGDIPlusRenderer::CreatePen(const wxGraphicsPenInfo& info)
|
||||
{
|
||||
ENSURE_LOADED_OR_RETURN(wxNullGraphicsPen);
|
||||
if ( !info.GetStyle() == wxPENSTYLE_TRANSPARENT )
|
||||
if ( info.GetStyle() == wxPENSTYLE_TRANSPARENT )
|
||||
return wxNullGraphicsPen;
|
||||
else
|
||||
{
|
||||
|
@@ -2462,7 +2462,7 @@ public:
|
||||
|
||||
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);
|
||||
|
||||
@@ -2480,7 +2480,7 @@ public:
|
||||
private:
|
||||
// We store the source info for later when we need to recreate the
|
||||
// device-dependent resources.
|
||||
const wxGraphicsPenInfo& m_sourceInfo;
|
||||
const wxGraphicsPenInfo m_sourceInfo;
|
||||
|
||||
// A stroke style is a device-independent resource.
|
||||
// Describes the caps, miter limit, line join, and dash information.
|
||||
@@ -2502,45 +2502,32 @@ wxD2DPenData::wxD2DPenData(
|
||||
ID2D1Factory* direct2dFactory,
|
||||
const wxPen& pen) :
|
||||
wxGraphicsObjectRefData(renderer),
|
||||
m_sourceInfo(wxGraphicsPenInfo())
|
||||
m_sourceInfo(wxGraphicsPenInfo::CreateFromPen(pen)),
|
||||
m_width(pen.GetWidth())
|
||||
{
|
||||
wxDash* dashes;
|
||||
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);
|
||||
Init(renderer, direct2dFactory);
|
||||
}
|
||||
|
||||
wxD2DPenData::wxD2DPenData(
|
||||
wxGraphicsRenderer* renderer,
|
||||
ID2D1Factory* direct2dFactory,
|
||||
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)
|
||||
m_width = info.GetWidth();
|
||||
|
||||
InitFromPenInfo(renderer, direct2dFactory);
|
||||
Init(renderer, direct2dFactory);
|
||||
}
|
||||
|
||||
void wxD2DPenData::InitFromPenInfo(
|
||||
void wxD2DPenData::Init(
|
||||
wxGraphicsRenderer* renderer,
|
||||
ID2D1Factory* direct2dFactory)
|
||||
{
|
||||
CreateStrokeStyle(direct2dFactory, info);
|
||||
CreateStrokeStyle(direct2dFactory);
|
||||
|
||||
wxBrush strokeBrush;
|
||||
|
||||
if (m_sourceInfo.GetStyle() == wxPENSTYLE_STIPPLE)
|
||||
{
|
||||
strokeBrush.SetStipple(*(m_sourceInfo.GetStipple()));
|
||||
strokeBrush.SetStipple(m_sourceInfo.GetStipple());
|
||||
strokeBrush.SetStyle(wxBRUSHSTYLE_STIPPLE);
|
||||
}
|
||||
else if(wxIsHatchPenStyle(m_sourceInfo.GetStyle()))
|
||||
|
@@ -425,7 +425,7 @@ wxPen::wxPen(const wxPenInfo& info)
|
||||
M_PENDATA->SetCap(info.GetCap());
|
||||
wxDash *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
|
||||
|
@@ -309,7 +309,7 @@ public:
|
||||
~wxMacCoreGraphicsPenData();
|
||||
|
||||
void Init();
|
||||
void InitFromPenInfo( wxGraphicsRenderer* renderer, const wxGraphicsPenInfo& info );
|
||||
void InitFromPenInfo( const wxGraphicsPenInfo& info );
|
||||
virtual void Apply( wxGraphicsContext* context );
|
||||
virtual wxDouble GetWidth() { return m_width; }
|
||||
|
||||
@@ -334,34 +334,22 @@ protected :
|
||||
wxMacCoreGraphicsPenData::wxMacCoreGraphicsPenData( wxGraphicsRenderer* renderer, const wxPen &pen ) :
|
||||
wxGraphicsObjectRefData( renderer )
|
||||
{
|
||||
wxDash *dashes;
|
||||
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())
|
||||
);
|
||||
InitFromPenInfo(wxGraphicsPenInfo::CreateFromPen(pen));
|
||||
}
|
||||
|
||||
wxMacCoreGraphicsPenData::wxMacCoreGraphicsPenData( wxGraphicsRenderer* renderer, const wxGraphicsPenInfo& info ) :
|
||||
wxGraphicsObjectRefData( renderer )
|
||||
{
|
||||
InitFromPenInfo(renderer, info);
|
||||
InitFromPenInfo(info);
|
||||
}
|
||||
|
||||
void wxMacCoreGraphicsPenData::InitFromPenInfo( wxGraphicsRenderer* renderer, const wxGraphicsPenInfo& info )
|
||||
void wxMacCoreGraphicsPenData::InitFromPenInfo( const wxGraphicsPenInfo& info )
|
||||
{
|
||||
Init();
|
||||
|
||||
m_color.reset( wxMacCreateCGColor( info.GetColour() ) ) ;
|
||||
|
||||
// TODO: * m_dc->m_scaleX
|
||||
m_width = info.GetWidthF();
|
||||
if (m_width < 0.0)
|
||||
m_width = info.GetWidth();
|
||||
if (m_width <= 0.0)
|
||||
m_width = (CGFloat) 0.1;
|
||||
@@ -459,11 +447,11 @@ void wxMacCoreGraphicsPenData::InitFromPenInfo( wxGraphicsRenderer* renderer, co
|
||||
|
||||
case wxPENSTYLE_STIPPLE:
|
||||
{
|
||||
wxBitmap* bmp = info.GetStipple();
|
||||
if ( bmp && bmp->IsOk() )
|
||||
wxBitmap bmp = info.GetStipple();
|
||||
if ( bmp.IsOk() )
|
||||
{
|
||||
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[0] = (CGFloat) 1.0;
|
||||
m_isPattern = true;
|
||||
@@ -2746,7 +2734,7 @@ wxGraphicsPen wxMacCoreGraphicsRenderer::CreatePen(const wxPen& pen)
|
||||
|
||||
wxGraphicsPen wxMacCoreGraphicsRenderer::CreatePen(const wxGraphicsPenInfo& info)
|
||||
{
|
||||
if ( info.GetStyle() == wxPENSTYLE_TRANSPARENT )
|
||||
if ( info.IsTransparent() )
|
||||
return wxNullGraphicsPen;
|
||||
else
|
||||
{
|
||||
|
@@ -150,9 +150,7 @@ wxPen::wxPen(const wxPenInfo& info)
|
||||
M_PENDATA->m_style = info.GetStyle();
|
||||
M_PENDATA->m_join = info.GetJoin();
|
||||
M_PENDATA->m_cap = info.GetCap();
|
||||
wxDash *dashes;
|
||||
M_PENDATA->m_nbDash = info.GetDashes(&dashes);
|
||||
M_PENDATA->m_dash = dashes;
|
||||
M_PENDATA->m_nbDash = info.GetDashes(&M_PENDATA->m_dash);
|
||||
|
||||
RealizeResource();
|
||||
}
|
||||
|
@@ -102,9 +102,7 @@ wxPen::wxPen(const wxPenInfo& info)
|
||||
M_PENDATA->m_capStyle = info.GetCap();
|
||||
M_PENDATA->m_joinStyle = info.GetJoin();
|
||||
M_PENDATA->m_stipple = info.GetStipple();
|
||||
wxDash *dashes;
|
||||
M_PENDATA->m_countDashes = info.GetDashes(&dashes);
|
||||
M_PENDATA->m_dash = dashes;
|
||||
M_PENDATA->m_countDashes = info.GetDashes(&M_PENDATA->m_dash);
|
||||
}
|
||||
|
||||
wxPen::~wxPen()
|
||||
|
Reference in New Issue
Block a user