Introduce wxGraphicsPenInfo class
This commit is contained in:
committed by
Vadim Zeitlin
parent
bc562289c6
commit
2305604565
@@ -261,9 +261,11 @@ class wxGDIPlusPenData : public wxGraphicsObjectRefData
|
||||
{
|
||||
public:
|
||||
wxGDIPlusPenData( wxGraphicsRenderer* renderer, const wxPen &pen );
|
||||
wxGDIPlusPenData( wxGraphicsRenderer* renderer, const wxGraphicsPenInfo &info );
|
||||
~wxGDIPlusPenData();
|
||||
|
||||
void Init();
|
||||
void InitFromPenInfo( wxGraphicsRenderer* renderer, const wxGraphicsPenInfo &info );
|
||||
|
||||
virtual wxDouble GetWidth() { return m_width; }
|
||||
virtual Pen* GetGDIPlusPen() { return m_pen; }
|
||||
@@ -400,7 +402,7 @@ public:
|
||||
virtual bool SetAntialiasMode(wxAntialiasMode antialias) wxOVERRIDE;
|
||||
|
||||
virtual bool SetInterpolationQuality(wxInterpolationQuality interpolation) wxOVERRIDE;
|
||||
|
||||
|
||||
virtual bool SetCompositionMode(wxCompositionMode op) wxOVERRIDE;
|
||||
|
||||
virtual void BeginLayer(wxDouble opacity) wxOVERRIDE;
|
||||
@@ -575,6 +577,8 @@ public :
|
||||
|
||||
virtual wxGraphicsPen CreatePen(const wxPen& pen) wxOVERRIDE;
|
||||
|
||||
virtual wxGraphicsPen CreatePen(const wxGraphicsPenInfo& pen) wxOVERRIDE;
|
||||
|
||||
virtual wxGraphicsBrush CreateBrush(const wxBrush& brush ) wxOVERRIDE;
|
||||
|
||||
virtual wxGraphicsBrush
|
||||
@@ -645,16 +649,39 @@ 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())
|
||||
);
|
||||
}
|
||||
|
||||
wxGDIPlusPenData::wxGDIPlusPenData( wxGraphicsRenderer* renderer, const wxGraphicsPenInfo &info )
|
||||
: wxGraphicsObjectRefData(renderer)
|
||||
{
|
||||
InitFromPenInfo(renderer, info);
|
||||
}
|
||||
|
||||
void wxGDIPlusPenData::InitFromPenInfo( wxGraphicsRenderer* renderer, const wxGraphicsPenInfo &info )
|
||||
{
|
||||
Init();
|
||||
m_width = pen.GetWidth();
|
||||
m_width = info.GetWidthF();
|
||||
if (m_info < 0.0)
|
||||
m_width = info.GetWidth();
|
||||
if (m_width <= 0.0)
|
||||
m_width = 0.1;
|
||||
|
||||
m_pen = new Pen(wxColourToColor(pen.GetColour()), m_width );
|
||||
m_pen = new Pen(wxColourToColor(info.GetColour()), m_width );
|
||||
|
||||
LineCap cap;
|
||||
switch ( pen.GetCap() )
|
||||
switch ( info.GetCap() )
|
||||
{
|
||||
case wxCAP_ROUND :
|
||||
cap = LineCapRound;
|
||||
@@ -675,7 +702,7 @@ wxGDIPlusPenData::wxGDIPlusPenData( wxGraphicsRenderer* renderer, const wxPen &p
|
||||
m_pen->SetLineCap(cap,cap, DashCapFlat);
|
||||
|
||||
LineJoin join;
|
||||
switch ( pen.GetJoin() )
|
||||
switch ( info.GetJoin() )
|
||||
{
|
||||
case wxJOIN_BEVEL :
|
||||
join = LineJoinBevel;
|
||||
@@ -699,7 +726,7 @@ wxGDIPlusPenData::wxGDIPlusPenData( wxGraphicsRenderer* renderer, const wxPen &p
|
||||
m_pen->SetDashStyle(DashStyleSolid);
|
||||
|
||||
DashStyle dashStyle = DashStyleSolid;
|
||||
switch ( pen.GetStyle() )
|
||||
switch ( info.GetStyle() )
|
||||
{
|
||||
case wxPENSTYLE_SOLID :
|
||||
break;
|
||||
@@ -723,7 +750,7 @@ wxGDIPlusPenData::wxGDIPlusPenData( wxGraphicsRenderer* renderer, const wxPen &p
|
||||
{
|
||||
dashStyle = DashStyleCustom;
|
||||
wxDash *dashes;
|
||||
int count = pen.GetDashes( &dashes );
|
||||
int count = info.GetDashes( &dashes );
|
||||
if ((dashes != NULL) && (count > 0))
|
||||
{
|
||||
REAL *userLengths = new REAL[count];
|
||||
@@ -738,7 +765,7 @@ wxGDIPlusPenData::wxGDIPlusPenData( wxGraphicsRenderer* renderer, const wxPen &p
|
||||
break;
|
||||
case wxPENSTYLE_STIPPLE :
|
||||
{
|
||||
wxBitmap* bmp = pen.GetStipple();
|
||||
wxBitmap* bmp = info.GetStipple();
|
||||
if ( bmp && bmp->IsOk() )
|
||||
{
|
||||
m_penImage = Bitmap::FromHBITMAP((HBITMAP)bmp->GetHBITMAP(),
|
||||
@@ -755,11 +782,11 @@ wxGDIPlusPenData::wxGDIPlusPenData( wxGraphicsRenderer* renderer, const wxPen &p
|
||||
}
|
||||
break;
|
||||
default :
|
||||
if ( pen.GetStyle() >= wxPENSTYLE_FIRST_HATCH &&
|
||||
pen.GetStyle() <= wxPENSTYLE_LAST_HATCH )
|
||||
if ( info.GetStyle() >= wxPENSTYLE_FIRST_HATCH &&
|
||||
info.GetStyle() <= wxPENSTYLE_LAST_HATCH )
|
||||
{
|
||||
HatchStyle style;
|
||||
switch( pen.GetStyle() )
|
||||
switch( info.GetStyle() )
|
||||
{
|
||||
case wxPENSTYLE_BDIAGONAL_HATCH :
|
||||
style = HatchStyleBackwardDiagonal;
|
||||
@@ -785,7 +812,7 @@ wxGDIPlusPenData::wxGDIPlusPenData( wxGraphicsRenderer* renderer, const wxPen &p
|
||||
m_penBrush = new HatchBrush
|
||||
(
|
||||
style,
|
||||
wxColourToColor(pen.GetColour()),
|
||||
wxColourToColor(info.GetColour()),
|
||||
Color::Transparent
|
||||
);
|
||||
m_pen->SetBrush( m_penBrush );
|
||||
@@ -2047,7 +2074,7 @@ void wxGDIPlusContext::DoDrawText(const wxString& str,
|
||||
|
||||
wxGDIPlusFontData * const
|
||||
fontData = (wxGDIPlusFontData *)m_font.GetRefData();
|
||||
|
||||
|
||||
m_context->DrawString
|
||||
(
|
||||
str.wc_str(*wxConvUI), // string to draw, always Unicode
|
||||
@@ -2160,7 +2187,7 @@ bool wxGDIPlusContext::ShouldOffset() const
|
||||
{
|
||||
if ( !m_enableOffset )
|
||||
return false;
|
||||
|
||||
|
||||
int penwidth = 0 ;
|
||||
if ( !m_pen.IsNull() )
|
||||
{
|
||||
@@ -2461,6 +2488,19 @@ wxGraphicsPen wxGDIPlusRenderer::CreatePen(const wxPen& pen)
|
||||
}
|
||||
}
|
||||
|
||||
wxGraphicsPen wxGDIPlusRenderer::CreatePen(const wxGraphicsPenInfo& info)
|
||||
{
|
||||
ENSURE_LOADED_OR_RETURN(wxNullGraphicsPen);
|
||||
if ( !info.GetStyle() == wxPENSTYLE_TRANSPARENT )
|
||||
return wxNullGraphicsPen;
|
||||
else
|
||||
{
|
||||
wxGraphicsPen p;
|
||||
p.SetRefData(new wxGDIPlusPenData( this, info ));
|
||||
return p;
|
||||
}
|
||||
}
|
||||
|
||||
wxGraphicsBrush wxGDIPlusRenderer::CreateBrush(const wxBrush& brush )
|
||||
{
|
||||
ENSURE_LOADED_OR_RETURN(wxNullGraphicsBrush);
|
||||
|
Reference in New Issue
Block a user