+ // helper to determine if a 0.5 offset should be applied for the drawing operation
+ virtual bool ShouldOffset() const { return false; }
+
+ // indicates whether the context should try to offset for pixel boundaries, this only makes sense on
+ // bitmap devices like screen, by default this is turned off
+ virtual void EnableOffset(bool enable = true);
+
+ void DisableOffset() { EnableOffset(false); }
+ bool OffsetEnabled() { return m_enableOffset; }
+
+protected:
+ // These fields must be initialized in the derived class ctors.
+ wxDouble m_width,
+ m_height;
+
+ wxGraphicsPen m_pen;
+ wxGraphicsBrush m_brush;
+ wxGraphicsFont m_font;
+ wxAntialiasMode m_antialias;
+ wxCompositionMode m_composition;
+ bool m_enableOffset;
+
+protected:
+ // implementations of overloaded public functions: we use different names
+ // for them to avoid the virtual function hiding problems in the derived
+ // classes
+ virtual void DoDrawText(const wxString& str, wxDouble x, wxDouble y) = 0;
+ virtual void DoDrawRotatedText(const wxString& str, wxDouble x, wxDouble y,
+ wxDouble angle);
+ virtual void DoDrawFilledText(const wxString& str, wxDouble x, wxDouble y,
+ const wxGraphicsBrush& backgroundBrush);
+ virtual void DoDrawRotatedFilledText(const wxString& str,
+ wxDouble x, wxDouble y,
+ wxDouble angle,
+ const wxGraphicsBrush& backgroundBrush);
+
+ wxDECLARE_NO_COPY_CLASS(wxGraphicsContext);
+ DECLARE_ABSTRACT_CLASS(wxGraphicsContext)
+};
+
+#if 0
+
+//
+// A graphics figure allows to cache path, pen etc creations, also will be a basis for layering/grouping elements
+//
+
+class WXDLLIMPEXP_CORE wxGraphicsFigure : public wxGraphicsObject
+{
+public:
+ wxGraphicsFigure(wxGraphicsRenderer* renderer);
+
+ virtual ~wxGraphicsFigure();
+
+ void SetPath( wxGraphicsMatrix* matrix );
+
+ void SetMatrix( wxGraphicsPath* path);
+
+ // draws this object on the context
+ virtual void Draw( wxGraphicsContext* cg );
+
+ // returns the path of this object
+ wxGraphicsPath* GetPath() { return m_path; }
+
+ // returns the transformation matrix of this object, may be null if there is no transformation necessary
+ wxGraphicsMatrix* GetMatrix() { return m_matrix; }
+
+private:
+ wxGraphicsMatrix* m_matrix;
+ wxGraphicsPath* m_path;
+
+ DECLARE_DYNAMIC_CLASS(wxGraphicsFigure)
+};
+
+#endif
+
+//
+// The graphics renderer is the instance corresponding to the rendering engine used, eg there is ONE core graphics renderer
+// instance on OSX. This instance is pointed back to by all objects created by it. Therefore you can create eg additional
+// paths at any point from a given matrix etc.
+//
+
+class WXDLLIMPEXP_CORE wxGraphicsRenderer : public wxObject
+{
+public:
+ wxGraphicsRenderer() {}
+
+ virtual ~wxGraphicsRenderer() {}
+
+ static wxGraphicsRenderer* GetDefaultRenderer();
+
+ static wxGraphicsRenderer* GetCairoRenderer();
+ // Context
+
+ virtual wxGraphicsContext * CreateContext( const wxWindowDC& dc) = 0;
+ virtual wxGraphicsContext * CreateContext( const wxMemoryDC& dc) = 0;
+#if wxUSE_PRINTING_ARCHITECTURE
+ virtual wxGraphicsContext * CreateContext( const wxPrinterDC& dc) = 0;
+#endif
+#ifdef __WXMSW__
+#if wxUSE_ENH_METAFILE
+ virtual wxGraphicsContext * CreateContext( const wxEnhMetaFileDC& dc) = 0;
+#endif
+#endif
+
+ virtual wxGraphicsContext * CreateContextFromNativeContext( void * context ) = 0;
+
+ virtual wxGraphicsContext * CreateContextFromNativeWindow( void * window ) = 0;
+
+ virtual wxGraphicsContext * CreateContext( wxWindow* window ) = 0;
+
+ // create a context that can be used for measuring texts only, no drawing allowed
+ virtual wxGraphicsContext * CreateMeasuringContext() = 0;
+
+ // Path
+
+ virtual wxGraphicsPath CreatePath() = 0;
+
+ // Matrix
+
+ virtual wxGraphicsMatrix CreateMatrix( wxDouble a=1.0, wxDouble b=0.0, wxDouble c=0.0, wxDouble d=1.0,
+ wxDouble tx=0.0, wxDouble ty=0.0) = 0;
+
+ // Paints
+
+ virtual wxGraphicsPen CreatePen(const wxPen& pen) = 0;
+
+ virtual wxGraphicsBrush CreateBrush(const wxBrush& brush ) = 0;
+
+ // Gradient brush creation functions may not honour all the stops specified
+ // stops and use just its boundary colours (this is currently the case
+ // under OS X)
+ virtual wxGraphicsBrush
+ CreateLinearGradientBrush(wxDouble x1, wxDouble y1,
+ wxDouble x2, wxDouble y2,
+ const wxGraphicsGradientStops& stops) = 0;
+
+ virtual wxGraphicsBrush
+ CreateRadialGradientBrush(wxDouble xo, wxDouble yo,
+ wxDouble xc, wxDouble yc,
+ wxDouble radius,
+ const wxGraphicsGradientStops& stops) = 0;
+
+ // sets the font
+ virtual wxGraphicsFont CreateFont( const wxFont &font , const wxColour &col = *wxBLACK ) = 0;
+
+ // create a native bitmap representation
+ virtual wxGraphicsBitmap CreateBitmap( const wxBitmap &bitmap ) = 0;
+
+ // create a graphics bitmap from a native bitmap
+ virtual wxGraphicsBitmap CreateBitmapFromNativeBitmap( void* bitmap ) = 0;
+
+ // create a subimage from a native image representation
+ virtual wxGraphicsBitmap CreateSubBitmap( const wxGraphicsBitmap &bitmap, wxDouble x, wxDouble y, wxDouble w, wxDouble h ) = 0;
+
+private:
+ wxDECLARE_NO_COPY_CLASS(wxGraphicsRenderer);
+ DECLARE_ABSTRACT_CLASS(wxGraphicsRenderer)