| Version: 3.2.5

Public Member Functions | Static Public Member Functions | List of all members
wxGraphicsRenderer Class Referenceabstract
Class List by Category » Graphics Device Interface (GDI)

`#include <wx/graphics.h>`

Inheritance diagram for wxGraphicsRenderer:
[legend]

## Detailed Description

A wxGraphicsRenderer is the instance corresponding to the rendering engine used.

There may be multiple instances on a system, if there are different rendering engines present, but there is always only one instance per engine. This instance is pointed back to by all objects created by it (wxGraphicsContext, wxGraphicsPath etc.) and can be retrieved through their wxGraphicsObject::GetRenderer() method. Therefore you can create an additional instance of a path etc. by calling wxGraphicsObject::GetRenderer() and then using the appropriate CreateXXX() function of that renderer.

wxGraphicsPath *path = // from somewhere
wxGraphicsBrush *brush = path->GetRenderer()->CreateBrush( *wxBLACK_BRUSH );
wxBLACK_BRUSH
wxBrush * wxBLACK_BRUSH
Black brush.
Definition: brush.h:304
wxGraphicsBrush
A wxGraphicsBrush is a native representation of a brush.
Definition: graphics.h:1662
wxGraphicsObject::GetRenderer
wxGraphicsRenderer * GetRenderer() const
Returns the renderer that was used to create this instance, or NULL if it has not been initialized ye...
wxGraphicsPath
A wxGraphicsPath is a native representation of a geometric path.
Definition: graphics.h:21
wxGraphicsRenderer::CreateBrush
virtual wxGraphicsBrush CreateBrush(const wxBrush &brush)=0
Creates a native brush from a wxBrush.

##

Library: wxCore
Category: Graphics Device Interface (GDI)

## Public Member Functions

virtual wxGraphicsBitmap | CreateBitmap (const wxBitmap &bitmap)=0
| Creates wxGraphicsBitmap from an existing wxBitmap. More...
virtual wxGraphicsBitmap | CreateBitmapFromImage (const wxImage &image)=0
| Creates wxGraphicsBitmap from an existing wxImage. More...
virtual wxImage | CreateImageFromBitmap (const wxGraphicsBitmap &bmp)=0
| Creates a wxImage from a wxGraphicsBitmap. More...
virtual wxGraphicsBitmap | CreateBitmapFromNativeBitmap (void *bitmap)=0
| Creates wxGraphicsBitmap from a native bitmap handle. More...
virtual wxGraphicsContext * | CreateContext (wxWindow *window)=0
| Creates a wxGraphicsContext from a wxWindow. More...
virtual wxGraphicsContext * | CreateContext (const wxWindowDC &windowDC)=0
| Creates a wxGraphicsContext from a wxWindowDC. More...
virtual wxGraphicsContext * | CreateContext (const wxMemoryDC &memoryDC)=0
| Creates a wxGraphicsContext from a wxMemoryDC. More...
virtual wxGraphicsContext * | CreateContext (const wxPrinterDC &printerDC)=0
| Creates a wxGraphicsContext from a wxPrinterDC. More...
virtual wxGraphicsContext * | CreateContext (const wxEnhMetaFileDC &metaFileDC)=0
| Creates a wxGraphicsContext from a wxEnhMetaFileDC. More...
wxGraphicsContext * | CreateContextFromUnknownDC (wxDC &dc)
| Creates a wxGraphicsContext from a DC of unknown specific type. More...
wxGraphicsContext * | CreateContextFromImage (wxImage &image)
| Creates a wxGraphicsContext associated with a wxImage. More...
virtual wxGraphicsBrush | CreateBrush (const wxBrush &brush)=0
| Creates a native brush from a wxBrush. More...
virtual wxGraphicsContext * | CreateContextFromNativeContext (void *context)=0
| Creates a wxGraphicsContext from a native context. More...
virtual wxGraphicsContext * | CreateContextFromNativeWindow (void *window)=0
| Creates a wxGraphicsContext from a native window. More...
virtual wxGraphicsContext * | CreateMeasuringContext ()=0
| Creates a wxGraphicsContext that can be used for measuring texts only. More...
virtual wxGraphicsFont | CreateFont (const wxFont &font, const wxColour &col= *wxBLACK)=0
| Creates a native graphics font from a wxFont and a text colour. More...
virtual wxGraphicsFont | CreateFont (double sizeInPixels, const wxString &facename, int flags=wxFONTFLAG_DEFAULT, const wxColour &col= *wxBLACK)=0
| Creates a graphics font with the given characteristics. More...
virtual wxGraphicsFont | CreateFontAtDPI (const wxFont &font, const wxRealPoint &dpi, const wxColour &col= *wxBLACK)=0
| Creates a native graphics font from a wxFont and a text colour. More...
virtual wxGraphicsBrush | CreateLinearGradientBrush (wxDouble x1, wxDouble y1, wxDouble x2, wxDouble y2, const wxGraphicsGradientStops &stops, const wxGraphicsMatrix &matrix=wxNullGraphicsMatrix)=0
| Creates a native brush with a linear gradient. More...
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
| Creates a native affine transformation matrix from the passed in values. More...
virtual wxGraphicsPath | CreatePath ()=0
| Creates a native graphics path which is initially empty. More...
virtual wxGraphicsPen | CreatePen (const wxGraphicsPenInfo &info)=0
| Creates a native pen from its description. More...
virtual wxGraphicsBrush | CreateRadialGradientBrush (wxDouble startX, wxDouble startY, wxDouble endX, wxDouble endY, wxDouble radius, const wxGraphicsGradientStops &stops, const wxGraphicsMatrix &matrix=wxNullGraphicsMatrix)=0
| Creates a native brush with a radial gradient. More...
virtual wxGraphicsBitmap | CreateSubBitmap (const wxGraphicsBitmap &bitmap, wxDouble x, wxDouble y, wxDouble w, wxDouble h)=0
| Extracts a sub-bitmap from an existing bitmap. More...
virtual wxString | GetName () const =0
| Returns the name of the technology used by the renderer. More...
virtual void | GetVersion (int *major, int *minor=NULL, int *micro=NULL) const =0
| Returns the version major, minor and micro/build of the technology used by the renderer. More...
Public Member Functions inherited from wxObject
| wxObject ()
| Default ctor; initializes to NULL the internal reference data. More...
| wxObject (const wxObject &other)
| Copy ctor. More...
virtual | ~wxObject ()
| Destructor. More...
virtual wxClassInfo * | GetClassInfo () const
| This virtual function is redefined for every class that requires run-time type information, when using the wxDECLARE_CLASS macro (or similar). More...
wxObjectRefData * | GetRefData () const
| Returns the wxObject::m_refData pointer, i.e. the data referenced by this object. More...
bool | IsKindOf (const wxClassInfo *info) const
| Determines whether this class is a subclass of (or the same class as) the given class. More...
bool | IsSameAs (const wxObject &obj) const
| Returns true if this object has the same data pointer as obj. More...
void | Ref (const wxObject &clone)
| Makes this object refer to the data in clone. More...
void | SetRefData (wxObjectRefData *data)
| Sets the wxObject::m_refData pointer. More...
void | UnRef ()
| Decrements the reference count in the associated data, and if it is zero, deletes the data. More...
void | UnShare ()
| This is the same of AllocExclusive() but this method is public. More...
void | operator delete (void *buf)
| The delete operator is defined for debugging versions of the library only, when the identifier `__WXDEBUG__` is defined. More...
void * | operator new (size_t size, const wxString &filename=NULL, int lineNum=0)
| The new operator is defined for debugging versions of the library only, when the identifier `__WXDEBUG__` is defined. More...

## Static Public Member Functions

static wxGraphicsContext * | CreateContextFromNativeHDC (WXHDC dc)
| Creates a wxGraphicsContext from a native DC handle. More...
static wxGraphicsRenderer * | GetDefaultRenderer ()
| Returns the default renderer on this platform. More...
static wxGraphicsRenderer * | GetCairoRenderer ()
| Returns Cairo renderer. More...
static wxGraphicsRenderer * | GetGDIPlusRenderer ()
| Returns GDI+ renderer (MSW only). More...
static wxGraphicsRenderer * | GetDirect2DRenderer ()
| Returns Direct2D renderer (MSW only). More...

## Additional Inherited Members

Protected Member Functions inherited from wxObject
void | AllocExclusive ()
| Ensure that this object's data is not shared with any other object. More...
virtual wxObjectRefData * | CreateRefData () const
| Creates a new instance of the wxObjectRefData-derived class specific to this object and returns it. More...
virtual wxObjectRefData * | CloneRefData (const wxObjectRefData *data) const
| Creates a new instance of the wxObjectRefData-derived class specific to this object and initializes it copying data. More...
Protected Attributes inherited from wxObject
wxObjectRefData * | m_refData
| Pointer to an object which is the object's reference-counted data. More...

## Member Function Documentation

## ◆ CreateBitmap()

virtual wxGraphicsBitmap wxGraphicsRenderer::CreateBitmap | ( | const wxBitmap & | bitmap | ) |

pure virtual

Creates wxGraphicsBitmap from an existing wxBitmap.

Returns an invalid wxNullGraphicsBitmap on failure.

## ◆ CreateBitmapFromImage()

virtual wxGraphicsBitmap wxGraphicsRenderer::CreateBitmapFromImage | ( | const wxImage & | image | ) |

pure virtual

Creates wxGraphicsBitmap from an existing wxImage.

This method is more efficient than converting wxImage to wxBitmap first and then calling CreateBitmap() but otherwise has the same effect.

Returns an invalid wxNullGraphicsBitmap on failure.

Since
  2.9.3

## ◆ CreateBitmapFromNativeBitmap()

virtual wxGraphicsBitmap wxGraphicsRenderer::CreateBitmapFromNativeBitmap | ( | void * | bitmap | ) |

pure virtual

Creates wxGraphicsBitmap from a native bitmap handle.

bitmap meaning is platform-dependent. Currently it's a GDI+ `Bitmap` pointer under MSW, `CGImage` pointer under macOS or a `cairo_surface_t` pointer when using Cairo under any platform.

Notice that this method takes ownership of bitmap, i.e. it will be destroyed when the returned wxGraphicsBitmap is.

## ◆ CreateBrush()

virtual wxGraphicsBrush wxGraphicsRenderer::CreateBrush | ( | const wxBrush & | brush | ) |

pure virtual

Creates a native brush from a wxBrush.

## ◆ CreateContext() [1/5]

virtual wxGraphicsContext* wxGraphicsRenderer::CreateContext | ( | const wxEnhMetaFileDC & | metaFileDC | ) |

pure virtual

Creates a wxGraphicsContext from a wxEnhMetaFileDC.

This function, as wxEnhMetaFileDC class itself, is only available only under MSW (but not for Direct2D renderer).

## ◆ CreateContext() [2/5]

virtual wxGraphicsContext* wxGraphicsRenderer::CreateContext | ( | const wxMemoryDC & | memoryDC | ) |

pure virtual

Creates a wxGraphicsContext from a wxMemoryDC.

## ◆ CreateContext() [3/5]

virtual wxGraphicsContext* wxGraphicsRenderer::CreateContext | ( | const wxPrinterDC & | printerDC | ) |

pure virtual

Creates a wxGraphicsContext from a wxPrinterDC.

Remarks
  Not implemented for Direct2D renderer (on MSW).

## ◆ CreateContext() [4/5]

virtual wxGraphicsContext* wxGraphicsRenderer::CreateContext | ( | const wxWindowDC & | windowDC | ) |

pure virtual

Creates a wxGraphicsContext from a wxWindowDC.

## ◆ CreateContext() [5/5]

virtual wxGraphicsContext* wxGraphicsRenderer::CreateContext | ( | wxWindow * | window | ) |

pure virtual

Creates a wxGraphicsContext from a wxWindow.

## ◆ CreateContextFromImage()

wxGraphicsContext* wxGraphicsRenderer::CreateContextFromImage | ( | wxImage & | image | ) |

Creates a wxGraphicsContext associated with a wxImage.

This function is used by wxContext::CreateFromImage() and is not normally called directly.

Since
  2.9.3

## ◆ CreateContextFromNativeContext()

virtual wxGraphicsContext* wxGraphicsRenderer::CreateContextFromNativeContext | ( | void * | context | ) |

pure virtual

Creates a wxGraphicsContext from a native context.

This native context must be a CGContextRef for Core Graphics, a Graphics pointer for GDIPlus, an ID2D1RenderTarget pointer for Direct2D, a cairo_t pointer or HDC for Cairo on MSW, or a cairo_t pointer for Cairo on any other platform.

## ◆ CreateContextFromNativeHDC()

static wxGraphicsContext* wxGraphicsRenderer::CreateContextFromNativeHDC | ( | WXHDC | dc | ) |

static

Creates a wxGraphicsContext from a native DC handle.

Windows only.

Since
  3.1.1

## ◆ CreateContextFromNativeWindow()

virtual wxGraphicsContext* wxGraphicsRenderer::CreateContextFromNativeWindow | ( | void * | window | ) |

pure virtual

Creates a wxGraphicsContext from a native window.

## ◆ CreateContextFromUnknownDC()

wxGraphicsContext* wxGraphicsRenderer::CreateContextFromUnknownDC | ( | wxDC & | dc | ) |

Creates a wxGraphicsContext from a DC of unknown specific type.

Creates a wxGraphicsContext if dc is a supported type (i.e. has a corresponding CreateContext() method, e.g. wxWindowDC or wxMemoryDC). Returns NULL if the DC is unsupported.

This method is only useful as a helper in generic code that operates with wxDC and doesn't known its exact type. Use the appropriate CreateContext() overload instead if you know that the DC is e.g. wxWindowDC.

See also
  wxGraphicsContext::CreateFromUnknownDC()

Since
  3.1.3

## ◆ CreateFont() [1/2]

virtual wxGraphicsFont wxGraphicsRenderer::CreateFont | ( | const wxFont & | font,
|  | const wxColour & | col = `*wxBLACK`
| ) |  |

pure virtual

Creates a native graphics font from a wxFont and a text colour.

## ◆ CreateFont() [2/2]

virtual wxGraphicsFont wxGraphicsRenderer::CreateFont | ( | double | sizeInPixels,
|  | const wxString & | facename,
|  | int | flags = `wxFONTFLAG_DEFAULT`,
|  | const wxColour & | col = `*wxBLACK`
| ) |  |

pure virtual

Creates a graphics font with the given characteristics.

If possible, the CreateFont() overload taking wxFont should be used instead. The main advantage of this overload is that it can be used without X server connection under Unix when using Cairo.

Parameters

  sizeInPixels | Height of the font in user space units, i.e. normally pixels. Notice that this is different from the overload taking wxFont as wxFont size is specified in points.
  facename | The name of the font. The same font name might not be available under all platforms so the font name can also be empty to use the default platform font.
  flags | Combination of wxFontFlag enum elements. Currently only `wxFONTFLAG_ITALIC` and `wxFONTFLAG_BOLD` are supported. By default the normal font version is used.
  col | The font colour, black by default.

Since
  2.9.3

## ◆ CreateFontAtDPI()

virtual wxGraphicsFont wxGraphicsRenderer::CreateFontAtDPI | ( | const wxFont & | font,
|  | const wxRealPoint & | dpi,
|  | const wxColour & | col = `*wxBLACK`
| ) |  |

pure virtual

Creates a native graphics font from a wxFont and a text colour.

The specified DPI is used to convert the (fractional) wxFont point-size to a fractional pixel-size.

Since
  3.1.3

## ◆ CreateImageFromBitmap()

virtual wxImage wxGraphicsRenderer::CreateImageFromBitmap | ( | const wxGraphicsBitmap & | bmp | ) |

pure virtual

Creates a wxImage from a wxGraphicsBitmap.

This method is used by the more convenient wxGraphicsBitmap::ConvertToImage.

## ◆ CreateLinearGradientBrush()

virtual wxGraphicsBrush wxGraphicsRenderer::CreateLinearGradientBrush | ( | wxDouble | x1,
|  | wxDouble | y1,
|  | wxDouble | x2,
|  | wxDouble | y2,
|  | const wxGraphicsGradientStops & | stops,
|  | const wxGraphicsMatrix & | matrix = `wxNullGraphicsMatrix`
| ) |  |

pure virtual

Creates a native brush with a linear gradient.

Stops support is new since wxWidgets 2.9.1, previously only the start and end colours could be specified.

The ability to apply a transformation matrix to the gradient was added in 3.1.3

## ◆ CreateMatrix()

virtual wxGraphicsMatrix wxGraphicsRenderer::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`
| ) |  |

pure virtual

Creates a native affine transformation matrix from the passed in values.

The defaults result in an identity matrix.

## ◆ CreateMeasuringContext()

virtual wxGraphicsContext* wxGraphicsRenderer::CreateMeasuringContext | ( |  | ) |

pure virtual

Creates a wxGraphicsContext that can be used for measuring texts only.

No drawing commands are allowed.

## ◆ CreatePath()

virtual wxGraphicsPath wxGraphicsRenderer::CreatePath | ( |  | ) |

pure virtual

Creates a native graphics path which is initially empty.

## ◆ CreatePen()

virtual wxGraphicsPen wxGraphicsRenderer::CreatePen | ( | const wxGraphicsPenInfo & | info | ) |

pure virtual

Creates a native pen from its description.

Since
  3.1.1

## ◆ CreateRadialGradientBrush()

virtual wxGraphicsBrush wxGraphicsRenderer::CreateRadialGradientBrush | ( | wxDouble | startX,
|  | wxDouble | startY,
|  | wxDouble | endX,
|  | wxDouble | endY,
|  | wxDouble | radius,
|  | const wxGraphicsGradientStops & | stops,
|  | const wxGraphicsMatrix & | matrix = `wxNullGraphicsMatrix`
| ) |  |

pure virtual

Creates a native brush with a radial gradient.

Stops support is new since wxWidgets 2.9.1, previously only the start and end colours could be specified.

The ability to apply a transformation matrix to the gradient was added in 3.1.3

## ◆ CreateSubBitmap()

virtual wxGraphicsBitmap wxGraphicsRenderer::CreateSubBitmap | ( | const wxGraphicsBitmap & | bitmap,
|  | wxDouble | x,
|  | wxDouble | y,
|  | wxDouble | w,
|  | wxDouble | h
| ) |  |

pure virtual

Extracts a sub-bitmap from an existing bitmap.

## ◆ GetCairoRenderer()

static wxGraphicsRenderer* wxGraphicsRenderer::GetCairoRenderer | ( |  | ) |

static

Returns Cairo renderer.

## ◆ GetDefaultRenderer()

static wxGraphicsRenderer* wxGraphicsRenderer::GetDefaultRenderer | ( |  | ) |

static

Returns the default renderer on this platform.

On macOS this is the Core Graphics (a.k.a. Quartz 2D) renderer, on MSW the GDIPlus renderer, and on GTK we currently default to the Cairo renderer.

## ◆ GetDirect2DRenderer()

static wxGraphicsRenderer* wxGraphicsRenderer::GetDirect2DRenderer | ( |  | ) |

static

Returns Direct2D renderer (MSW only).

## ◆ GetGDIPlusRenderer()

static wxGraphicsRenderer* wxGraphicsRenderer::GetGDIPlusRenderer | ( |  | ) |

static

Returns GDI+ renderer (MSW only).

## ◆ GetName()

virtual wxString wxGraphicsRenderer::GetName | ( |  | ) | const

pure virtual

Returns the name of the technology used by the renderer.

Currently this function returns "gdiplus" for Windows GDI+ implementation, "direct2d" for Windows Direct2D implementation, "cairo" for Cairo implementation and "cg" for macOS CoreGraphics implementation.

Remarks
  The string returned by this method is not user-readable and is expected to be used internally by the program only.

Since
  3.1.0

## ◆ GetVersion()

virtual void wxGraphicsRenderer::GetVersion | ( | int * | major,
|  | int * | minor = `NULL`,
|  | int * | micro = `NULL`
| ) |  | const

pure virtual

Returns the version major, minor and micro/build of the technology used by the renderer.

Currently this function returns the OS major and minor versions in the parameters with the matching names and sets micro to 0 for the GDI+ and CoreGraphics engines which are considered to be parts of their respective OS.

For Cairo, this is the major,minor,micro version of the Cairo library which is returned.