.. wxPython Phoenix documentation
This file was generated by Phoenix's sphinx generator and associated
tools, do not edit by hand.
Copyright: (c) 2011-2017 by Total Control Software
License: wxWindows License
.. include:: headings.inc
.. _wx.GraphicsRenderer:
==========================================================================================================================================
|phoenix_title| **wx.GraphicsRenderer**
==========================================================================================================================================
A :ref:`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 (:ref:`wx.GraphicsContext`, :ref:`wx.GraphicsPath` etc) and can be retrieved through their :meth:`wx.GraphicsObject.GetRenderer` method. Therefore you can create an additional instance of a path etc. by calling :meth:`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
=================================
.. raw:: html
Inheritance diagram for class
GraphicsRenderer:
|
|method_summary| Methods Summary
================================
================================================================================ ================================================================================
:meth:`~wx.GraphicsRenderer.CreateBitmap` Creates :ref:`wx.GraphicsBitmap` from an existing :ref:`wx.Bitmap`.
:meth:`~wx.GraphicsRenderer.CreateBitmapFromImage` Creates :ref:`wx.GraphicsBitmap` from an existing :ref:`wx.Image`.
:meth:`~wx.GraphicsRenderer.CreateBitmapFromNativeBitmap` Creates :ref:`wx.GraphicsBitmap` from a native bitmap handle.
:meth:`~wx.GraphicsRenderer.CreateBrush` Creates a native brush from a :ref:`wx.Brush`.
:meth:`~wx.GraphicsRenderer.CreateContext` Creates a :ref:`wx.GraphicsContext` from a :ref:`wx.Window`.
:meth:`~wx.GraphicsRenderer.CreateContextFromImage` Creates a :ref:`wx.GraphicsContext` associated with a :ref:`wx.Image`.
:meth:`~wx.GraphicsRenderer.CreateContextFromNativeContext` Creates a :ref:`wx.GraphicsContext` from a native context.
:meth:`~wx.GraphicsRenderer.CreateContextFromNativeWindow` Creates a :ref:`wx.GraphicsContext` from a native window.
:meth:`~wx.GraphicsRenderer.CreateFont` Creates a native graphics font from a :ref:`wx.Font` and a text colour.
:meth:`~wx.GraphicsRenderer.CreateImageFromBitmap` Creates a :ref:`wx.Image` from a :ref:`wx.GraphicsBitmap`.
:meth:`~wx.GraphicsRenderer.CreateLinearGradientBrush` Creates a native brush with a linear gradient.
:meth:`~wx.GraphicsRenderer.CreateMatrix` Creates a native affine transformation matrix from the passed in values.
:meth:`~wx.GraphicsRenderer.CreateMeasuringContext` Creates a :ref:`wx.GraphicsContext` that can be used for measuring texts only.
:meth:`~wx.GraphicsRenderer.CreatePath` Creates a native graphics path which is initially empty.
:meth:`~wx.GraphicsRenderer.CreatePen` Creates a native pen from a :ref:`wx.Pen`.
:meth:`~wx.GraphicsRenderer.CreateRadialGradientBrush` Creates a native brush with a radial gradient.
:meth:`~wx.GraphicsRenderer.CreateSubBitmap` Extracts a sub-bitmap from an existing bitmap.
:meth:`~wx.GraphicsRenderer.GetCairoRenderer`
:meth:`~wx.GraphicsRenderer.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.
.. method:: CreateBitmap(self, bitmap)
Creates :ref:`wx.GraphicsBitmap` from an existing :ref:`wx.Bitmap`.
Returns an invalid NullGraphicsBitmap on failure.
:param `bitmap`:
:type `bitmap`: wx.Bitmap
:rtype: :ref:`wx.GraphicsBitmap`
.. method:: CreateBitmapFromImage(self, image)
Creates :ref:`wx.GraphicsBitmap` from an existing :ref:`wx.Image`.
This method is more efficient than converting :ref:`wx.Image` to :ref:`wx.Bitmap` first and then calling :meth:`CreateBitmap` but otherwise has the same effect.
Returns an invalid NullGraphicsBitmap on failure.
:param `image`:
:type `image`: wx.Image
:rtype: :ref:`wx.GraphicsBitmap`
.. versionadded:: 2.9.3
.. method:: CreateBitmapFromNativeBitmap(self, bitmap)
Creates :ref:`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 :ref:`wx.GraphicsBitmap` is.
:param `bitmap`:
:rtype: :ref:`wx.GraphicsBitmap`
.. method:: CreateBrush(self, brush)
Creates a native brush from a :ref:`wx.Brush`.
:param `brush`:
:type `brush`: wx.Brush
:rtype: :ref:`wx.GraphicsBrush`
.. method:: CreateContext(self, *args, **kw)
|overload| Overloaded Implementations:
**~~~**
**CreateContext** `(self, window)`
Creates a :ref:`wx.GraphicsContext` from a :ref:`wx.Window`.
:param `window`:
:type `window`: wx.Window
:rtype: :ref:`wx.GraphicsContext`
**~~~**
**CreateContext** `(self, windowDC)`
Creates a :ref:`wx.GraphicsContext` from a :ref:`wx.WindowDC`.
:param `windowDC`:
:type `windowDC`: wx.WindowDC
:rtype: :ref:`wx.GraphicsContext`
**~~~**
**CreateContext** `(self, memoryDC)`
Creates a :ref:`wx.GraphicsContext` from a :ref:`wx.MemoryDC`.
:param `memoryDC`:
:type `memoryDC`: wx.MemoryDC
:rtype: :ref:`wx.GraphicsContext`
**~~~**
**CreateContext** `(self, printerDC)`
Creates a :ref:`wx.GraphicsContext` from a :ref:`wx.PrinterDC`.
:param `printerDC`:
:type `printerDC`: wx.PrinterDC
:rtype: :ref:`wx.GraphicsContext`
**~~~**
.. method:: CreateContextFromImage(self, image)
Creates a :ref:`wx.GraphicsContext` associated with a :ref:`wx.Image`.
This function is used by `Context.CreateFromImage()` and is not normally called directly.
:param `image`:
:type `image`: wx.Image
:rtype: :ref:`wx.GraphicsContext`
.. versionadded:: 2.9.3
.. method:: CreateContextFromNativeContext(self, context)
Creates a :ref:`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.
:param `context`:
:rtype: :ref:`wx.GraphicsContext`
.. method:: CreateContextFromNativeWindow(self, window)
Creates a :ref:`wx.GraphicsContext` from a native window.
:param `window`:
:rtype: :ref:`wx.GraphicsContext`
.. method:: CreateFont(self, *args, **kw)
|overload| Overloaded Implementations:
**~~~**
**CreateFont** `(self, font, col=BLACK)`
Creates a native graphics font from a :ref:`wx.Font` and a text colour.
:param `font`:
:type `font`: wx.Font
:param `col`:
:type `col`: wx.Colour
:rtype: :ref:`wx.GraphicsFont`
**~~~**
**CreateFont** `(self, sizeInPixels, facename, flags=FONTFLAG_DEFAULT, col=BLACK)`
Creates a graphics font with the given characteristics.
If possible, the :meth:`CreateFont` overload taking :ref:`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.
:param `sizeInPixels`: Height of the font in user space units, i.e. normally pixels. Notice that this is different from the overload taking :ref:`wx.Font` as :ref:`wx.Font` size is specified in points.
:type `sizeInPixels`: float
:param `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.
:type `facename`: string
:param `flags`: Combination of FontFlag enum elements. Currently only ``FONTFLAG_ITALIC`` and ``FONTFLAG_BOLD`` are supported. By default the normal font version is used.
:type `flags`: int
:param `col`: The font colour, black by default.
:type `col`: wx.Colour
:rtype: :ref:`wx.GraphicsFont`
.. versionadded:: 2.9.3
**~~~**
.. method:: CreateImageFromBitmap(self, bmp)
Creates a :ref:`wx.Image` from a :ref:`wx.GraphicsBitmap`.
This method is used by the more convenient :meth:`wx.GraphicsBitmap.ConvertToImage` .
:param `bmp`:
:type `bmp`: wx.GraphicsBitmap
:rtype: :ref:`wx.Image`
.. method:: 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.
:param `x1`:
:type `x1`: wx.Double
:param `y1`:
:type `y1`: wx.Double
:param `x2`:
:type `x2`: wx.Double
:param `y2`:
:type `y2`: wx.Double
:param `stops`:
:type `stops`: wx.GraphicsGradientStops
:rtype: :ref:`wx.GraphicsBrush`
.. method:: 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.
:param `a`:
:type `a`: wx.Double
:param `b`:
:type `b`: wx.Double
:param `c`:
:type `c`: wx.Double
:param `d`:
:type `d`: wx.Double
:param `tx`:
:type `tx`: wx.Double
:param `ty`:
:type `ty`: wx.Double
:rtype: :ref:`wx.GraphicsMatrix`
.. method:: CreateMeasuringContext(self)
Creates a :ref:`wx.GraphicsContext` that can be used for measuring texts only.
No drawing commands are allowed.
:rtype: :ref:`wx.GraphicsContext`
.. method:: CreatePath(self)
Creates a native graphics path which is initially empty.
:rtype: :ref:`wx.GraphicsPath`
.. method:: CreatePen(self, pen)
Creates a native pen from a :ref:`wx.Pen`.
:param `pen`:
:type `pen`: wx.Pen
:rtype: :ref:`wx.GraphicsPen`
.. method:: 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.
:param `xo`:
:type `xo`: wx.Double
:param `yo`:
:type `yo`: wx.Double
:param `xc`:
:type `xc`: wx.Double
:param `yc`:
:type `yc`: wx.Double
:param `radius`:
:type `radius`: wx.Double
:param `stops`:
:type `stops`: wx.GraphicsGradientStops
:rtype: :ref:`wx.GraphicsBrush`
.. method:: 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.
:param `bitmap`:
:type `bitmap`: wx.GraphicsBitmap
:param `x`:
:type `x`: wx.Double
:param `y`:
:type `y`: wx.Double
:param `w`:
:type `w`: wx.Double
:param `h`:
:type `h`: wx.Double
:rtype: :ref:`wx.GraphicsBitmap`
.. staticmethod:: GetCairoRenderer()
:rtype: :ref:`wx.GraphicsRenderer`
.. staticmethod:: 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.
:rtype: :ref:`wx.GraphicsRenderer`