X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/7b1a66bb689ec080da5b95e9b2ae991af063d31d..8ef9a526cea6ecc3853f327a76da14561b36f82a:/src/common/dcgraph.cpp diff --git a/src/common/dcgraph.cpp b/src/common/dcgraph.cpp index 923bbe2793..6c4e534530 100644 --- a/src/common/dcgraph.cpp +++ b/src/common/dcgraph.cpp @@ -28,9 +28,12 @@ #include "wx/region.h" #endif -#ifdef __WXMAC__ -#include "wx/mac/private.h" +#include "wx/dcclient.h" + +#ifdef __WXOSX__ + #include "ApplicationServices/ApplicationServices.h" #endif + //----------------------------------------------------------------------------- // constants //----------------------------------------------------------------------------- @@ -67,6 +70,10 @@ wxGCDC::wxGCDC() : { } +wxGCDC::~wxGCDC() +{ +} + wxGraphicsContext* wxGCDC::GetGraphicsContext() { if (!m_pimpl) return NULL; @@ -110,6 +117,7 @@ wxGCDCImpl::wxGCDCImpl( wxDC *owner, const wxWindowDC& dc ) : { Init(); SetGraphicsContext( wxGraphicsContext::Create(dc) ); + m_window = dc.GetWindow(); } wxGCDCImpl::wxGCDCImpl( wxDC *owner, const wxMemoryDC& dc ) : @@ -149,7 +157,7 @@ void wxGCDCImpl::DoDrawBitmap( const wxBitmap &bmp, wxCoord x, wxCoord y, bool W { m_graphicContext->SetPen(*wxTRANSPARENT_PEN); m_graphicContext->SetBrush( wxBrush( m_textBackgroundColour , wxSOLID ) ); - m_graphicContext->DrawRectangle( x , y , bmp.GetWidth() , bmp.GetHeight() ); + m_graphicContext->DrawRectangle( x , y , bmp.GetWidth() , bmp.GetHeight() ); m_graphicContext->SetBrush( wxBrush( m_textForegroundColour , wxSOLID ) ); m_graphicContext->DrawBitmap( bmp, x , y , bmp.GetWidth() , bmp.GetHeight() ); m_graphicContext->SetBrush( m_graphicContext->CreateBrush(m_brush)); @@ -170,12 +178,12 @@ void wxGCDCImpl::DoDrawIcon( const wxIcon &icon, wxCoord x, wxCoord y ) m_graphicContext->DrawIcon( icon , x, y, w, h ); } -bool wxGCDCImpl::StartDoc( const wxString& WXUNUSED(message) ) +bool wxGCDCImpl::StartDoc( const wxString& WXUNUSED(message) ) { - return false; + return true; } -void wxGCDCImpl::EndDoc() +void wxGCDCImpl::EndDoc() { } @@ -183,13 +191,13 @@ void wxGCDCImpl::StartPage() { } -void wxGCDCImpl::EndPage() +void wxGCDCImpl::EndPage() { } - + void wxGCDCImpl::Flush() { -#ifdef __WXMAC__ +#ifdef __WXOSX__ CGContextFlush( (CGContextRef) m_graphicContext->GetNativeContext() ); #endif } @@ -261,7 +269,7 @@ void wxGCDCImpl::DestroyClippingRegion() int width, height ; GetOwner()->GetSize( &width , &height ) ; m_graphicContext->Clip( DeviceToLogicalX(0) , DeviceToLogicalY(0) , DeviceToLogicalXRel(width), DeviceToLogicalYRel(height) ); - + m_graphicContext->SetPen( m_pen ); m_graphicContext->SetBrush( m_brush ); @@ -337,7 +345,7 @@ int wxGCDCImpl::GetDepth() const } void wxGCDCImpl::ComputeScaleAndOrigin() -{ +{ wxDCImpl::ComputeScaleAndOrigin(); if ( m_graphicContext ) @@ -398,7 +406,7 @@ void wxGCDCImpl::SetBrush( const wxBrush &brush ) m_graphicContext->SetBrush( m_brush ); } } - + void wxGCDCImpl::SetBackground( const wxBrush &brush ) { if (m_backgroundBrush == brush) @@ -782,7 +790,7 @@ bool wxGCDCImpl::DoStretchBlit( if ( logical_func == wxNO_OP ) return true; else if ( !m_graphicContext->SetLogicalFunction( logical_func ) ) - + { wxFAIL_MSG( wxT("Blitting is only supported with wxCOPY logical operation.") ); return false; @@ -944,8 +952,13 @@ void wxGCDCImpl::Clear(void) void wxGCDCImpl::DoGetSize(int *width, int *height) const { - *width = 10000; - *height = 10000; + wxCHECK_RET( IsOk(), wxT("wxGCDC(cg)::DoGetSize - invalid DC") ); + wxDouble w,h; + m_graphicContext->GetSize( &w, &h ); + if ( height ) + *height = (int) (h+0.5); + if ( width ) + *width = (int) (w+0.5); } void wxGCDCImpl::DoGradientFillLinear(const wxRect& rect,