class WXDLLIMPEXP_FWD_CORE wxPrinterDC;
class WXDLLIMPEXP_FWD_CORE wxPrintData;
-
-#if wxUSE_GRAPHICS_CONTEXT
-class WXDLLIMPEXP_FWD_CORE wxGraphicsContext;
-#endif
-
//-----------------------------------------------------------------------------
// wxDrawObject helper class
//-----------------------------------------------------------------------------
virtual bool CanDrawBitmap() const = 0;
virtual bool CanGetTextExtent() const = 0;
- // get graphics context from
-
-#if wxUSE_GRAPHICS_CONTEXT
- virtual wxGraphicsContext* CreateGraphicsContext()
+ // get Cairo context
+ virtual void* GetCairoContext() const
{
return NULL;
}
-#endif
// query dimension, colour deps, resolution
bool IsOk() const
{ return m_pimpl && m_pimpl->IsOk(); }
-#if wxUSE_GRAPHICS_CONTEXT
- wxGraphicsContext* CreateGraphicsContext()
- { return m_pimpl->CreateGraphicsContext(); }
-#endif
-
// query capabilities
bool CanDrawBitmap() const
class WXDLLIMPEXP_FWD_CORE wxWindowDC;
class WXDLLIMPEXP_FWD_CORE wxMemoryDC;
+class WXDLLIMPEXP_FWD_CORE wxPrinterDC;
class WXDLLIMPEXP_FWD_CORE wxGraphicsContext;
class WXDLLIMPEXP_FWD_CORE wxGraphicsPath;
class WXDLLIMPEXP_FWD_CORE wxGraphicsMatrix;
static wxGraphicsContext* Create( const wxWindowDC& dc) ;
static wxGraphicsContext * Create( const wxMemoryDC& dc) ;
+ static wxGraphicsContext * Create( const wxPrinterDC& dc) ;
static wxGraphicsContext* CreateFromNative( void * context ) ;
virtual wxGraphicsContext * CreateContext( const wxWindowDC& dc) = 0 ;
virtual wxGraphicsContext * CreateContext( const wxMemoryDC& dc) = 0 ;
+ virtual wxGraphicsContext * CreateContext( const wxPrinterDC& dc) = 0 ;
virtual wxGraphicsContext * CreateContextFromNativeContext( void * context ) = 0;
virtual ~wxWindowDCImpl();
-#if wxUSE_GRAPHICS_CONTEXT
- virtual wxGraphicsContext* CreateGraphicsContext();
-#endif
-
virtual bool CanDrawBitmap() const { return true; }
virtual bool CanGetTextExtent() const { return true; }
virtual ~wxMemoryDCImpl();
-#if wxUSE_GRAPHICS_CONTEXT
- virtual wxGraphicsContext* CreateGraphicsContext();
-#endif
-
// these get reimplemented for mono-bitmaps to behave
// more like their Win32 couterparts. They now interpret
// wxWHITE, wxWHITE_BRUSH and wxWHITE_PEN as drawing 0
bool Ok() const { return IsOk(); }
bool IsOk() const;
-#if wxUSE_GRAPHICS_CONTEXT
- virtual wxGraphicsContext* CreateGraphicsContext();
-#endif
+ virtual void* GetCairoContext() const;
bool CanDrawBitmap() const { return true; }
void Clear();
// Create a DC corresponding to the whole window
wxWindowDCImpl( wxDC *owner, wxWindow *win );
-#if wxUSE_GRAPHICS_CONTEXT
- virtual wxGraphicsContext* CreateGraphicsContext();
-#endif
-
virtual void DoGetSize(int *width, int *height) const;
protected:
wxMemoryDCImpl( wxMemoryDC *owner, wxBitmap& bitmap );
wxMemoryDCImpl( wxMemoryDC *owner, wxDC *dc ); // Create compatible DC
-#if wxUSE_GRAPHICS_CONTEXT
- virtual wxGraphicsContext* CreateGraphicsContext();
-#endif
-
// override some base class virtuals
virtual void DoDrawRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height);
virtual void DoGetSize(int* width, int* height) const;
@wxheader{graphics.h}
A wxGraphicsContext instance is the object that is drawn upon. It is created by
- a renderer using the CreateContext calls.., this can be either directly using a renderer
- instance, or indirectly using the static convenience CreateXXX functions of
- wxGraphicsContext that always delegate the task to the default renderer.
+ a renderer using wxGraphicsRenderer::CreateContext(). This can be either directly
+ using a renderer instance, or indirectly using the static convenience Create()
+ functions of wxGraphicsContext that always delegate the task to the default renderer.
@code
void MyCanvas::OnPaint(wxPaintEvent &event)
wxPaintDC dc(this);
// Create graphics context from it
- wxGraphicsContext *gc = dc.CreateGraphicsContext();
+ wxGraphicsContext *gc = wxGraphicsContext::CreateContext( dc );
if (gc)
{
- // make a path that contains a circle and some lines, centered at 100,100
+ // make a path that contains a circle and some lines
gc->SetPen( *wxRED_PEN );
wxGraphicsPath path = gc->CreatePath();
path.AddCircle( 50.0, 50.0, 50.0 );
class wxGraphicsContext : public wxGraphicsObject
{
public:
- //@{
/**
- Clips drawings to the rectangle.
+ Creates a wxGraphicsContext from a wxWindow.
+
+ @see wxGraphicsRenderer::CreateContext()
+ */
+ static wxGraphicsContext* Create( wxWindow* window ) ;
+
+ /**
+ Creates a wxGraphicsContext from a wxWindowDC
+
+ @see wxGraphicsRenderer::CreateContext()
+ */
+ static wxGraphicsContext* Create( const wxWindowDC& dc) ;
+
+ /**
+ Creates a wxGraphicsContext from a wxMemoryDC
+
+ @see wxGraphicsRenderer::CreateContext()
+ */
+ static wxGraphicsContext * Create( const wxMemoryDC& dc) ;
+
+ /**
+ Creates a wxGraphicsContext from a wxPrinterDC
+
+ @see wxGraphicsRenderer::CreateContext()
+ */
+ static wxGraphicsContext * Create( const wxPrinterDC& dc) ;
+
+ /**
+ Clips drawings to the region
*/
void Clip(const wxRegion& region);
+
+ /**
+ Clips drawings to the rectangle.
+ */
void Clip(wxDouble x, wxDouble y, wxDouble w, wxDouble h);
- //@}
/**
Concatenates the passed in transform with the current transform of this context
*/
void ConcatTransform(const wxGraphicsMatrix& matrix);
- //@{
- /**
- Creates a wxGraphicsContext from a wxWindow.
-
- @see wxGraphicsRenderer:: CreateContext
- */
- wxGraphicsContext* Create(const wxWindowDC& dc);
- wxGraphicsContext* Create(wxWindow* window);
- //@}
/**
Creates a native brush from a wxBrush.
dc.DrawBitmap( m_bitmap, 10, 10 );
#if wxUSE_GRAPHICS_CONTEXT
- wxGraphicsContext *gc = dc.CreateGraphicsContext();
+ wxGraphicsContext *gc = NULL;
+
+ wxPrinterDC *printer_dc = wxDynamicCast( &dc, wxPrinterDC );
+ if (printer_dc)
+ gc = wxGraphicsContext::Create( *printer_dc );
+
+ wxWindowDC *window_dc = wxDynamicCast( &dc, wxWindowDC );
+ if (window_dc)
+ gc = wxGraphicsContext::Create( *window_dc );
+
if (gc)
{
// make a path that contains a circle and some lines, centered at 100,100
#endif
}
-wxGraphicsContext* wxGraphicsContext::Create( const wxWindowDC& dc)
+/* static */ wxGraphicsContext* wxGraphicsContext::Create( const wxWindowDC& dc)
{
return wxGraphicsRenderer::GetDefaultRenderer()->CreateContext(dc);
}
-wxGraphicsContext* wxGraphicsContext::Create( const wxMemoryDC& dc)
+/* static */ wxGraphicsContext* wxGraphicsContext::Create( const wxMemoryDC& dc)
+{
+ return wxGraphicsRenderer::GetDefaultRenderer()->CreateContext(dc);
+}
+
+/* static */ wxGraphicsContext* wxGraphicsContext::Create( const wxPrinterDC& dc)
{
return wxGraphicsRenderer::GetDefaultRenderer()->CreateContext(dc);
}
virtual wxGraphicsContext * CreateContext( const wxWindowDC& dc);
virtual wxGraphicsContext * CreateContext( const wxMemoryDC& dc);
+ virtual wxGraphicsContext * CreateContext( const wxPrinterDC& dc);
virtual wxGraphicsContext * CreateContextFromNativeContext( void * context );
return new wxCairoContext(this,dc);
}
+wxGraphicsContext * wxCairoRenderer::CreateContext( const wxPrinterDC& dc)
+{
+ const wxDCImpl *impl = dc.GetImpl();
+ cairo_t* context = (cairo_t*) impl->GetCairoContext();
+ if (context)
+ return new wxCairoContext(this,context);
+ else
+ return NULL;
+}
+
wxGraphicsContext * wxCairoRenderer::CreateContextFromNativeContext( void * context )
{
return new wxCairoContext(this,(cairo_t*)context);
#include <gdk/gdkx.h>
-#if wxUSE_GRAPHICS_CONTEXT
-#include "wx/graphics.h"
-#endif
-
-
//-----------------------------------------------------------------------------
// local defines
//-----------------------------------------------------------------------------
pango_font_description_free( m_fontdesc );
}
-#if wxUSE_GRAPHICS_CONTEXT
-wxGraphicsContext* wxWindowDCImpl::CreateGraphicsContext()
-{
- wxWindowDC *windowdc = (wxWindowDC*) GetOwner();
- return wxGraphicsRenderer::GetDefaultRenderer()->CreateContext( *windowdc );
-}
-#endif
-
void wxWindowDCImpl::SetUpDC( bool isMemDC )
{
m_ok = true;
#include <gdk/gdk.h>
#include <gtk/gtk.h>
-#if wxUSE_GRAPHICS_CONTEXT
-#include "wx/graphics.h"
-#endif
-
//-----------------------------------------------------------------------------
// wxMemoryDCImpl
//-----------------------------------------------------------------------------
m_fontdesc = pango_font_description_copy( pango_context_get_font_description( m_context ) );
}
-#if wxUSE_GRAPHICS_CONTEXT
-wxGraphicsContext* wxMemoryDCImpl::CreateGraphicsContext()
-{
- wxMemoryDC *memdc = (wxMemoryDC*) GetOwner();
- return wxGraphicsRenderer::GetDefaultRenderer()->CreateContext( *memdc );
-}
-#endif
-
void wxMemoryDCImpl::DoSelect( const wxBitmap& bitmap )
{
Destroy();
return m_gpc != NULL;
}
-#if wxUSE_GRAPHICS_CONTEXT
-wxGraphicsContext* wxGtkPrinterDCImpl::CreateGraphicsContext()
+void* wxGtkPrinterDCImpl::GetCairoContext() const
{
- return wxGraphicsRenderer::GetDefaultRenderer()->CreateContextFromNativeContext( (void*) m_cairo );
+ return (void*) cairo_reference( m_cairo );
}
-#endif
bool wxGtkPrinterDCImpl::DoFloodFill(wxCoord WXUNUSED(x1),
wxCoord WXUNUSED(y1),
virtual wxGraphicsContext * CreateContext( const wxWindowDC& dc);
virtual wxGraphicsContext * CreateContext( const wxMemoryDC& dc);
+ virtual wxGraphicsContext * CreateContext( const wxPrinterDC& dc);
virtual wxGraphicsContext * CreateContextFromNativeContext( void * context );
return NULL;
}
+wxGraphicsContext * wxMacCoreGraphicsRenderer::CreateContext( const wxPrinterDC& dc )
+{
+#ifdef __WXMAC__
+ const wxDCImpl* impl = dc.GetImpl();
+
+ // TODO
+#endif
+ return NULL;
+}
+
wxGraphicsContext * wxMacCoreGraphicsRenderer::CreateContextFromNativeContext( void * context )
{
return new wxMacCoreGraphicsContext(this,(CGContextRef)context);
#include "wx/window.h"
#endif
-#if wxUSE_GRAPHICS_CONTEXT
-#include "wx/graphics.h"
-#endif
-
#include "wx/msw/private.h"
// ----------------------------------------------------------------------------
#endif
}
-#if wxUSE_GRAPHICS_CONTEXT
-wxGraphicsContext* wxWindowDCImpl::CreateGraphicsContext()
-{
- wxWindowDC *windowdc = (wxWindowDC*) GetOwner();
- return wxGraphicsRenderer::GetDefaultRenderer()->CreateContext( *windowdc );
-}
-#endif
-
void wxWindowDCImpl::DoGetSize(int *width, int *height) const
{
wxCHECK_RET( m_window, _T("wxWindowDCImpl without a window?") );
#include "wx/log.h"
#endif
-#if wxUSE_GRAPHICS_CONTEXT
-#include "wx/graphics.h"
-#endif
-
#include "wx/msw/private.h"
// ----------------------------------------------------------------------------
}
}
-#if wxUSE_GRAPHICS_CONTEXT
-wxGraphicsContext* wxMemoryDCImpl::CreateGraphicsContext()
-{
- wxMemoryDC *memdc = (wxMemoryDC*) GetOwner();
- return wxGraphicsRenderer::GetDefaultRenderer()->CreateContext( *memdc );
-}
-#endif
-
bool wxMemoryDCImpl::CreateCompatible(wxDC *dc)
{
wxDCImpl *impl = dc ? dc->GetImpl() : NULL ;
virtual wxGraphicsContext * CreateContext( const wxMemoryDC& dc);
+ virtual wxGraphicsContext * CreateContext( const wxPrinterDC& dc);
+
virtual wxGraphicsContext * CreateContextFromNativeContext( void * context );
virtual wxGraphicsContext * CreateContextFromNativeWindow( void * window );
return new wxGDIPlusContext(this,(HDC) msw->GetHDC());
}
+wxGraphicsContext * wxGDIPlusRenderer::CreateContext( const wxPrinterDC& dc)
+{
+ EnsureIsLoaded();
+ wxMSWDCImpl *msw = wxDynamicCast( dc.GetImpl() , wxMSWDCImpl );
+ return new wxGDIPlusContext(this,(HDC) msw->GetHDC());
+}
+
wxGraphicsContext * wxGDIPlusRenderer::CreateContext( const wxMemoryDC& dc)
{
EnsureIsLoaded();