X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/c929ad91417a4ee797652d79300c0c23219a46fd..87f0b1323b7ac77f02133b836c8dfee63b0fd387:/src/common/graphcmn.cpp diff --git a/src/common/graphcmn.cpp b/src/common/graphcmn.cpp index 99a42c8a95..9a75c2bf71 100644 --- a/src/common/graphcmn.cpp +++ b/src/common/graphcmn.cpp @@ -524,6 +524,11 @@ void wxGraphicsGradientStops::Add(const wxGraphicsGradientStop& stop) } } +void * wxGraphicsBitmap::GetNativeBitmap() const +{ + return GetBitmapData()->GetNativeBitmap(); +} + //----------------------------------------------------------------------------- // wxGraphicsContext Convenience Methods //----------------------------------------------------------------------------- @@ -534,7 +539,8 @@ IMPLEMENT_ABSTRACT_CLASS(wxGraphicsContext, wxObject) wxGraphicsContext::wxGraphicsContext(wxGraphicsRenderer* renderer) : wxGraphicsObject(renderer), m_antialias(wxANTIALIAS_DEFAULT), - m_composition(wxCOMPOSITION_OVER) + m_composition(wxCOMPOSITION_OVER), + m_enableOffset(false) { } @@ -564,6 +570,11 @@ void wxGraphicsContext::Flush() { } +void wxGraphicsContext::EnableOffset(bool enable) +{ + m_enableOffset = enable; +} + #if 0 void wxGraphicsContext::SetAlpha( wxDouble WXUNUSED(alpha) ) { @@ -575,12 +586,6 @@ wxDouble wxGraphicsContext::GetAlpha() const } #endif -void wxGraphicsContext::GetSize( wxDouble* width, wxDouble* height) -{ - *width = 10000.0; - *height = 10000.0; -} - void wxGraphicsContext::GetDPI( wxDouble* dpiX, wxDouble* dpiY) { *dpiX = 72.0; @@ -595,7 +600,7 @@ void wxGraphicsContext::SetPen( const wxGraphicsPen& pen ) void wxGraphicsContext::SetPen( const wxPen& pen ) { - if ( !pen.Ok() || pen.GetStyle() == wxPENSTYLE_TRANSPARENT ) + if ( !pen.IsOk() || pen.GetStyle() == wxPENSTYLE_TRANSPARENT ) SetPen( wxNullGraphicsPen ); else SetPen( CreatePen( pen ) ); @@ -609,7 +614,7 @@ void wxGraphicsContext::SetBrush( const wxGraphicsBrush& brush ) void wxGraphicsContext::SetBrush( const wxBrush& brush ) { - if ( !brush.Ok() || brush.GetStyle() == wxBRUSHSTYLE_TRANSPARENT ) + if ( !brush.IsOk() || brush.GetStyle() == wxBRUSHSTYLE_TRANSPARENT ) SetBrush( wxNullGraphicsBrush ); else SetBrush( CreateBrush( brush ) ); @@ -623,7 +628,7 @@ void wxGraphicsContext::SetFont( const wxGraphicsFont& font ) void wxGraphicsContext::SetFont( const wxFont& font, const wxColour& colour ) { - if ( font.Ok() ) + if ( font.IsOk() ) SetFont( CreateFont( font, colour ) ); else SetFont( wxNullGraphicsFont ); @@ -665,9 +670,7 @@ wxGraphicsContext::DoDrawFilledText(const wxString &str, // to make sure our 'OffsetToPixelBoundaries' doesn't move the fill shape SetPen( wxNullGraphicsPen ); - wxGraphicsPath path = CreatePath(); - path.AddRectangle( x , y, width, height ); - FillPath( path ); + DrawRectangle(x , y, width, height); DrawText( str, x ,y); SetBrush( formerBrush ); @@ -839,17 +842,32 @@ wxGraphicsContext::CreateRadialGradientBrush( ); } -// sets the font wxGraphicsFont wxGraphicsContext::CreateFont( const wxFont &font , const wxColour &col ) const { return GetRenderer()->CreateFont(font,col); } +wxGraphicsFont +wxGraphicsContext::CreateFont(double size, + const wxString& facename, + int flags, + const wxColour& col) const +{ + return GetRenderer()->CreateFont(size, facename, flags, col); +} + wxGraphicsBitmap wxGraphicsContext::CreateBitmap( const wxBitmap& bmp ) const { return GetRenderer()->CreateBitmap(bmp); } +#if wxUSE_IMAGE +wxGraphicsBitmap wxGraphicsContext::CreateBitmapFromImage(const wxImage& image) const +{ + return GetRenderer()->CreateBitmapFromImage(image); +} +#endif // wxUSE_IMAGE + wxGraphicsBitmap wxGraphicsContext::CreateSubBitmap( const wxGraphicsBitmap &bmp, wxDouble x, wxDouble y, wxDouble w, wxDouble h ) const { return GetRenderer()->CreateSubBitmap(bmp,x,y,w,h); @@ -872,12 +890,14 @@ wxGraphicsBitmap wxGraphicsContext::CreateSubBitmap( const wxGraphicsBitmap &bmp } #endif +#ifdef __WXMSW__ #if wxUSE_ENH_METAFILE /* static */ wxGraphicsContext* wxGraphicsContext::Create( const wxEnhMetaFileDC& dc) { return wxGraphicsRenderer::GetDefaultRenderer()->CreateContext(dc); } #endif +#endif wxGraphicsContext* wxGraphicsContext::CreateFromNative( void * context ) { @@ -894,6 +914,13 @@ wxGraphicsContext* wxGraphicsContext::Create( wxWindow* window ) return wxGraphicsRenderer::GetDefaultRenderer()->CreateContext(window); } +#if wxUSE_IMAGE +/* static */ wxGraphicsContext* wxGraphicsContext::Create(wxImage& image) +{ + return wxGraphicsRenderer::GetDefaultRenderer()->CreateContextFromImage(image); +} +#endif // wxUSE_IMAGE + wxGraphicsContext* wxGraphicsContext::Create() { return wxGraphicsRenderer::GetDefaultRenderer()->CreateMeasuringContext();