virtual void StrokePath( const wxGraphicsPath& p );
virtual void FillPath( const wxGraphicsPath& p , wxPolygonFillMode fillStyle = wxODDEVEN_RULE );
+ virtual void DrawRectangle( wxDouble x, wxDouble y, wxDouble w, wxDouble h );
+
// stroke lines connecting each of the points
virtual void StrokeLines( size_t n, const wxPoint2DDouble *points);
GraphicsState m_state1;
GraphicsState m_state2;
- wxDouble m_width;
- wxDouble m_height;
-
DECLARE_DYNAMIC_CLASS_NO_COPY(wxGDIPlusContext)
};
DashStyle dashStyle = DashStyleSolid;
switch ( pen.GetStyle() )
{
- case wxSOLID :
+ case wxPENSTYLE_SOLID :
break;
- case wxDOT :
+ case wxPENSTYLE_DOT :
dashStyle = DashStyleDot;
break;
- case wxLONG_DASH :
+ case wxPENSTYLE_LONG_DASH :
dashStyle = DashStyleDash; // TODO verify
break;
- case wxSHORT_DASH :
+ case wxPENSTYLE_SHORT_DASH :
dashStyle = DashStyleDash;
break;
- case wxDOT_DASH :
+ case wxPENSTYLE_DOT_DASH :
dashStyle = DashStyleDashDot;
break;
- case wxUSER_DASH :
+ case wxPENSTYLE_USER_DASH :
{
dashStyle = DashStyleCustom;
wxDash *dashes;
}
}
break;
- case wxSTIPPLE :
+ case wxPENSTYLE_STIPPLE :
{
wxBitmap* bmp = pen.GetStipple();
if ( bmp && bmp->Ok() )
}
break;
default :
- if ( pen.GetStyle() >= wxFIRST_HATCH && pen.GetStyle() <= wxLAST_HATCH )
+ if ( pen.GetStyle() >= wxPENSTYLE_FIRST_HATCH &&
+ pen.GetStyle() <= wxPENSTYLE_LAST_HATCH )
{
- HatchStyle style = HatchStyleHorizontal;
+ HatchStyle style;
switch( pen.GetStyle() )
{
- case wxBDIAGONAL_HATCH :
+ case wxPENSTYLE_BDIAGONAL_HATCH :
style = HatchStyleBackwardDiagonal;
break ;
- case wxCROSSDIAG_HATCH :
+ case wxPENSTYLE_CROSSDIAG_HATCH :
style = HatchStyleDiagonalCross;
break ;
- case wxFDIAGONAL_HATCH :
+ case wxPENSTYLE_FDIAGONAL_HATCH :
style = HatchStyleForwardDiagonal;
break ;
- case wxCROSS_HATCH :
+ case wxPENSTYLE_CROSS_HATCH :
style = HatchStyleCross;
break ;
- case wxHORIZONTAL_HATCH :
+ case wxPENSTYLE_HORIZONTAL_HATCH :
style = HatchStyleHorizontal;
break ;
- case wxVERTICAL_HATCH :
+ case wxPENSTYLE_VERTICAL_HATCH :
style = HatchStyleVertical;
break ;
-
+ default:
+ style = HatchStyleHorizontal;
}
m_penBrush = new HatchBrush
(
}
else if ( brush.IsHatch() )
{
- HatchStyle style = HatchStyleHorizontal;
+ HatchStyle style;
switch( brush.GetStyle() )
{
- case wxBDIAGONAL_HATCH :
+ case wxBRUSHSTYLE_BDIAGONAL_HATCH :
style = HatchStyleBackwardDiagonal;
break ;
- case wxCROSSDIAG_HATCH :
+ case wxBRUSHSTYLE_CROSSDIAG_HATCH :
style = HatchStyleDiagonalCross;
break ;
- case wxFDIAGONAL_HATCH :
+ case wxBRUSHSTYLE_FDIAGONAL_HATCH :
style = HatchStyleForwardDiagonal;
break ;
- case wxCROSS_HATCH :
+ case wxBRUSHSTYLE_CROSS_HATCH :
style = HatchStyleCross;
break ;
- case wxHORIZONTAL_HATCH :
+ case wxBRUSHSTYLE_HORIZONTAL_HATCH :
style = HatchStyleHorizontal;
break ;
- case wxVERTICAL_HATCH :
+ case wxBRUSHSTYLE_VERTICAL_HATCH :
style = HatchStyleVertical;
break ;
-
+ default:
+ style = HatchStyleHorizontal;
}
m_brush = new HatchBrush
(
: wxGraphicsContext(renderer)
{
Init();
+ m_enableOffset = true;
m_context = new Graphics( hwnd);
RECT rect = wxGetWindowRect(hwnd);
m_width = rect.right - rect.left;
m_context->ResetClip();
}
+void wxGDIPlusContext::DrawRectangle( wxDouble x, wxDouble y, wxDouble w, wxDouble h )
+{
+ if (m_composition == wxCOMPOSITION_DEST)
+ return;
+
+ wxGDIPlusOffsetHelper helper( m_context , ShouldOffset() );
+ Brush *brush = m_brush.IsNull() ? NULL : ((wxGDIPlusBrushData*)m_brush.GetRefData())->GetGDIPlusBrush();
+ Pen *pen = m_pen.IsNull() ? NULL : ((wxGDIPlusPenData*)m_pen.GetGraphicsData())->GetGDIPlusPen();
+
+ if ( brush )
+ {
+ // the offset is used to fill only the inside of the rectangle and not paint underneath
+ // its border which may influence a transparent Pen
+ REAL offset = 0;
+ if ( pen )
+ offset = pen->GetWidth();
+ m_context->FillRectangle( brush, (REAL)x + offset/2, (REAL)y + offset/2, (REAL)w - offset, (REAL)h - offset);
+ }
+
+ if ( pen )
+ {
+ m_context->DrawRectangle( pen, (REAL)x, (REAL)y, (REAL)w, (REAL)h );
+ }
+}
+
void wxGDIPlusContext::StrokeLines( size_t n, const wxPoint2DDouble *points)
{
if (m_composition == wxCOMPOSITION_DEST)
{
Rect drawRect((REAL) x, (REAL)y, (REAL)w, (REAL)h);
m_context->SetPixelOffsetMode( PixelOffsetModeNone );
- m_context->DrawImage(image, drawRect, 0 , 0 , image->GetWidth()-1, image->GetHeight()-1, UnitPixel ) ;
+ m_context->DrawImage(image, drawRect, 0 , 0 , image->GetWidth(), image->GetHeight(), UnitPixel ) ;
m_context->SetPixelOffsetMode( PixelOffsetModeHalf );
}
else
bool wxGDIPlusContext::ShouldOffset() const
{
+ if ( !m_enableOffset )
+ return false;
+
int penwidth = 0 ;
if ( !m_pen.IsNull() )
{
wxGraphicsContext * wxGDIPlusRenderer::CreateContext( const wxWindowDC& dc)
{
ENSURE_LOADED_OR_RETURN(NULL);
- return new wxGDIPlusContext(this, dc);
+ wxGDIPlusContext* context = new wxGDIPlusContext(this, dc);
+ context->EnableOffset(true);
+ return context;
}
#if wxUSE_PRINTING_ARCHITECTURE
wxGraphicsContext * wxGDIPlusRenderer::CreateContext( const wxMemoryDC& dc)
{
ENSURE_LOADED_OR_RETURN(NULL);
- return new wxGDIPlusContext(this, dc);
+ wxGDIPlusContext* context = new wxGDIPlusContext(this, dc);
+ context->EnableOffset(true);
+ return context;
}
wxGraphicsContext * wxGDIPlusRenderer::CreateMeasuringContext()