#include "wx/region.h"
#endif
-#ifdef __WXMAC__
-#include "wx/mac/private.h"
+#include "wx/dcclient.h"
+
+#ifdef __WXOSX__
+ #include "ApplicationServices/ApplicationServices.h"
#endif
+
//-----------------------------------------------------------------------------
// constants
//-----------------------------------------------------------------------------
IMPLEMENT_DYNAMIC_CLASS(wxGCDC, wxDC)
-wxGCDC::wxGCDC(const wxWindowDC& dc)
+wxGCDC::wxGCDC(const wxWindowDC& dc) :
+ wxDC( new wxGCDCImpl( this, dc ) )
{
- m_pimpl = new wxGCDCImpl( this, dc );
}
-wxGCDC::wxGCDC( const wxMemoryDC& dc)
+wxGCDC::wxGCDC( const wxMemoryDC& dc) :
+ wxDC( new wxGCDCImpl( this, dc ) )
{
- m_pimpl = new wxGCDCImpl( this, dc );
}
-wxGCDC::wxGCDC()
+wxGCDC::wxGCDC() :
+ wxDC( new wxGCDCImpl( this ) )
+{
+}
+
+wxGCDC::~wxGCDC()
{
- m_pimpl = new wxGCDCImpl( this );
}
wxGraphicsContext* wxGCDC::GetGraphicsContext()
{
Init();
SetGraphicsContext( wxGraphicsContext::Create(dc) );
+ m_window = dc.GetWindow();
}
wxGCDCImpl::wxGCDCImpl( wxDC *owner, const wxMemoryDC& dc ) :
{
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));
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()
{
}
{
}
-void wxGCDCImpl::EndPage()
+void wxGCDCImpl::EndPage()
{
}
-
+
void wxGCDCImpl::Flush()
{
-#ifdef __WXMAC__
+#ifdef __WXOSX__
CGContextFlush( (CGContextRef) m_graphicContext->GetNativeContext() );
#endif
}
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 );
}
void wxGCDCImpl::ComputeScaleAndOrigin()
-{
+{
wxDCImpl::ComputeScaleAndOrigin();
if ( m_graphicContext )
m_graphicContext->SetBrush( m_brush );
}
}
-
+
void wxGCDCImpl::SetBackground( const wxBrush &brush )
{
if (m_backgroundBrush == brush)
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;
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,