Phoenix Logo

phoenix_title wx.GraphicsRenderer

A wx.GraphicsRenderer 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 ( wx.GraphicsContext, wx.GraphicsPath etc) and can be retrieved through their wx.GraphicsObject.GetRenderer method. Therefore you can create an additional instance of a path etc. by calling wx.GraphicsObject.GetRenderer and then using the appropriate CreateXXX() function of that renderer.

path = wx.GraphicsPath() # from somewhere
brush = path.GetRenderer().CreateBrush(wx.BLACK_BRUSH)

class_hierarchy Class Hierarchy

Inheritance diagram for class GraphicsRenderer:

method_summary Methods Summary

CreateBitmap Creates wx.GraphicsBitmap from an existing wx.Bitmap.
CreateBitmapFromImage Creates wx.GraphicsBitmap from an existing wx.Image.
CreateBitmapFromNativeBitmap Creates wx.GraphicsBitmap from a native bitmap handle.
CreateBrush Creates a native brush from a wx.Brush.
CreateContext Creates a wx.GraphicsContext from a wx.Window.
CreateContextFromImage Creates a wx.GraphicsContext associated with a wx.Image.
CreateContextFromNativeContext Creates a wx.GraphicsContext from a native context.
CreateContextFromNativeWindow Creates a wx.GraphicsContext from a native window.
CreateFont Creates a native graphics font from a wx.Font and a text colour.
CreateImageFromBitmap Creates a wx.Image from a wx.GraphicsBitmap.
CreateLinearGradientBrush Creates a native brush with a linear gradient.
CreateMatrix Creates a native affine transformation matrix from the passed in values.
CreateMeasuringContext Creates a wx.GraphicsContext that can be used for measuring texts only.
CreatePath Creates a native graphics path which is initially empty.
CreatePen Creates a native pen from a wx.Pen.
CreateRadialGradientBrush Creates a native brush with a radial gradient.
CreateSubBitmap Extracts a sub-bitmap from an existing bitmap.
GetCairoRenderer  
GetDefaultRenderer Returns the default renderer on this platform.

api Class API



class wx.GraphicsRenderer(Object)

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


Methods



CreateBitmap(self, bitmap)

Creates wx.GraphicsBitmap from an existing wx.Bitmap.

Returns an invalid NullGraphicsBitmap on failure.

Parameters:bitmap (wx.Bitmap) –
Return type: wx.GraphicsBitmap


CreateBitmapFromImage(self, image)

Creates wx.GraphicsBitmap from an existing wx.Image.

This method is more efficient than converting wx.Image to wx.Bitmap first and then calling CreateBitmap but otherwise has the same effect.

Returns an invalid NullGraphicsBitmap on failure.

Parameters:image (wx.Image) –
Return type: wx.GraphicsBitmap

New in version 2.9.3.



CreateBitmapFromNativeBitmap(self, bitmap)

Creates wx.GraphicsBitmap from a native bitmap handle.

bitmap meaning is platform-dependent. Currently it’s a GDI+ Bitmap pointer under MSW, CGImage pointer under OS X 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 wx.GraphicsBitmap is.

Parameters:bitmap
Return type: wx.GraphicsBitmap


CreateBrush(self, brush)

Creates a native brush from a wx.Brush.

Parameters:brush (wx.Brush) –
Return type: wx.GraphicsBrush


CreateContext(self, *args, **kw)

overload Overloaded Implementations:



CreateContext (self, window)

Creates a wx.GraphicsContext from a wx.Window.

Parameters:window (wx.Window) –
Return type: wx.GraphicsContext



CreateContext (self, windowDC)

Creates a wx.GraphicsContext from a wx.WindowDC.

Parameters:windowDC (wx.WindowDC) –
Return type: wx.GraphicsContext



CreateContext (self, memoryDC)

Creates a wx.GraphicsContext from a wx.MemoryDC.

Parameters:memoryDC (wx.MemoryDC) –
Return type: wx.GraphicsContext



CreateContext (self, printerDC)

Creates a wx.GraphicsContext from a wx.PrinterDC.

Parameters:printerDC (wx.PrinterDC) –
Return type: wx.GraphicsContext





CreateContextFromImage(self, image)

Creates a wx.GraphicsContext associated with a wx.Image.

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

Parameters:image (wx.Image) –
Return type: wx.GraphicsContext

New in version 2.9.3.



CreateContextFromNativeContext(self, context)

Creates a wx.GraphicsContext from a native context.

This native context must be a CGContextRef for Core Graphics, a Graphics pointer for GDIPlus, or a cairo_t pointer for cairo.

Parameters:context
Return type: wx.GraphicsContext


CreateContextFromNativeWindow(self, window)

Creates a wx.GraphicsContext from a native window.

Parameters:window
Return type: wx.GraphicsContext


CreateFont(self, *args, **kw)

overload Overloaded Implementations:



CreateFont (self, font, col=BLACK)

Creates a native graphics font from a wx.Font and a text colour.

Parameters:
Return type:

wx.GraphicsFont



CreateFont (self, sizeInPixels, facename, flags=FONTFLAG_DEFAULT, col=BLACK)

Creates a graphics font with the given characteristics.

If possible, the CreateFont overload taking wx.Font 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 (float) – Height of the font in user space units, i.e. normally pixels. Notice that this is different from the overload taking wx.Font as wx.Font size is specified in points.
  • facename (string) – 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 (int) – Combination of FontFlag enum elements. Currently only FONTFLAG_ITALIC and FONTFLAG_BOLD are supported. By default the normal font version is used.
  • col (wx.Colour) – The font colour, black by default.
Return type:

wx.GraphicsFont

New in version 2.9.3.





CreateImageFromBitmap(self, bmp)

Creates a wx.Image from a wx.GraphicsBitmap.

This method is used by the more convenient wx.GraphicsBitmap.ConvertToImage .

Parameters:bmp (wx.GraphicsBitmap) –
Return type: wx.Image


CreateLinearGradientBrush(self, x1, y1, x2, y2, stops)

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.

Parameters:
Return type:

wx.GraphicsBrush



CreateMatrix(self, a=1.0, b=0.0, c=0.0, d=1.0, tx=0.0, ty=0.0)

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

The defaults result in an identity matrix.

Parameters:
  • a (wx.Double) –
  • b (wx.Double) –
  • c (wx.Double) –
  • d (wx.Double) –
  • tx (wx.Double) –
  • ty (wx.Double) –
Return type:

wx.GraphicsMatrix



CreateMeasuringContext(self)

Creates a wx.GraphicsContext that can be used for measuring texts only.

No drawing commands are allowed.

Return type: wx.GraphicsContext


CreatePath(self)

Creates a native graphics path which is initially empty.

Return type: wx.GraphicsPath


CreatePen(self, pen)

Creates a native pen from a wx.Pen.

Parameters:pen (wx.Pen) –
Return type: wx.GraphicsPen


CreateRadialGradientBrush(self, xo, yo, xc, yc, radius, stops)

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.

Parameters:
  • xo (wx.Double) –
  • yo (wx.Double) –
  • xc (wx.Double) –
  • yc (wx.Double) –
  • radius (wx.Double) –
  • stops (wx.GraphicsGradientStops) –
Return type:

wx.GraphicsBrush



CreateSubBitmap(self, bitmap, x, y, w, h)

Extracts a sub-bitmap from an existing bitmap.

Currently this function is implemented in the native MSW and OS X versions but not when using Cairo.

Parameters:
  • bitmap (wx.GraphicsBitmap) –
  • x (wx.Double) –
  • y (wx.Double) –
  • w (wx.Double) –
  • h (wx.Double) –
Return type:

wx.GraphicsBitmap



static GetCairoRenderer()
Return type: wx.GraphicsRenderer


static GetDefaultRenderer()

Returns the default renderer on this platform.

On OS X 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.

Return type: wx.GraphicsRenderer