gtkmm: Gdk::Cairo Namespace Reference

gtkmm 4.2.0

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes

- Namespace List
- Namespace Members

Functions
Gdk::Cairo Namespace Reference

## Functions
::Cairo::RefPtr< ::Cairo::Context > | wrap (cairo_t* cobject, bool has_reference=true)
| Creates a Cairo::RefPtr with a C++ wrapper for the C instance. More...
::Cairo::RefPtr< ::Cairo::Region > | wrap (cairo_region_t* cobject, bool has_reference=true)
| Creates a Cairo::RefPtr with a C++ wrapper for the C instance. More...
template<typename T = ::Cairo::Surface, typename = std::enable_if<std::is_base_of< ::Cairo::Surface, T>::value>>
::Cairo::RefPtr< T > | wrap (cairo_surface_t* cobject, bool has_reference=true)
| Creates a Cairo::RefPtr with a C++ wrapper for the C instance. More...
void | set_source_rgba (const ::Cairo::RefPtr< ::Cairo::Context >& context, const Gdk::RGBA& color)
| Sets the specified Gdk::RGBA as the source color of the Cairo context. More...
void | set_source_pixbuf (const ::Cairo::RefPtr< ::Cairo::Context >& context, const Glib::RefPtr< const Gdk::Pixbuf >& pixbuf, double pixbuf_x=0, double pixbuf_y=0)
| Sets the given pixbuf as the source pattern for the Cairo context. More...
void | add_rectangle_to_path (const ::Cairo::RefPtr< ::Cairo::Context >& context, const Gdk::Rectangle& rectangle)
| Adds the given rectangle to the current path of the context. More...
void | add_region_to_path (const ::Cairo::RefPtr< ::Cairo::Context >& context, const ::Cairo::RefPtr< ::Cairo::Region >& region)
| Adds the given region to the current path of the context. More...
::Cairo::RefPtr< ::Cairo::Region > | create_region_from_surface (const ::Cairo::RefPtr< ::Cairo::Surface >& surface)
| Creates a region that covers the area where the given surface is more than 50% opaque. More...
void | draw_from_gl (const ::Cairo::RefPtr< ::Cairo::Context >& context, const Glib::RefPtr< Gdk::Surface >& surface, int source, int source_type, int buffer_scale, int x, int y, int width, int height)
| This is the main way to draw GL content in gtkmm. More...

## Function Documentation

void Gdk::Cairo::add_rectangle_to_path | ( | const ::Cairo::RefPtr< ::Cairo::Context > & | context,
|  | const Gdk::Rectangle& | rectangle
| ) |  |

Adds the given rectangle to the current path of the context.

Parameters

  context | A cairo context.
  rectangle | A rectangle to add to the path of the context.

Since gtkmm 2.10:

void Gdk::Cairo::add_region_to_path | ( | const ::Cairo::RefPtr< ::Cairo::Context > & | context,
|  | const ::Cairo::RefPtr< ::Cairo::Region > & | region
| ) |  |

Adds the given region to the current path of the context.

Parameters

  context | A cairo context.
  region | A region to add to the path of the context.

Since gtkmm 2.10:

::Cairo::RefPtr< ::Cairo::Region> Gdk::Cairo::create_region_from_surface | ( | const ::Cairo::RefPtr< ::Cairo::Surface > & | surface | ) |

Creates a region that covers the area where the given surface is more than 50% opaque.

This function takes into account device offsets that might be set with Cairo::Surface::set_device_offset().

Parameters

  surface | A cairo surface.

Returns
  A cairo region.

Since gtkmm 3.24:

void Gdk::Cairo::draw_from_gl | ( | const ::Cairo::RefPtr< ::Cairo::Context > & | context,
|  | const Glib::RefPtr< Gdk::Surface >& | surface,
|  | int | source,
|  | int | source_type,
|  | int | buffer_scale,
|  | int | x,
|  | int | y,
|  | int | width,
|  | int | height
| ) |  |

This is the main way to draw GL content in gtkmm.

It takes a render buffer ID (source_type == GL_RENDERBUFFER) or a texture id (source_type == GL_TEXTURE) and draws it onto context with an OVER operation, respecting the current clip. The top left corner of the rectangle specified by x, y, width and height will be drawn at the current (0,0) position of the cairo context.

This will work for all cairo contexts, as long as surface is realized, but the fallback implementation that reads back the pixels from the buffer may be used in the general case. In the case of direct drawing to a surface with no special effects applied to context it will however use a more efficient approach.

For GL_RENDERBUFFER the code will always fall back to software for buffers with alpha components, so make sure you use GL_TEXTURE if using alpha.

Calling this may change the current GL context.

Parameters

  context | A cairo context.
  surface | The surface we're rendering for (not necessarily into).
  source | The GL ID of the source buffer.
  source_type | The type of the source.
  buffer_scale | The scale-factor that the source buffer is allocated for.
  x | The source x position in source to start copying from in GL coordinates.
  y | The source y position in source to start copying from in GL coordinates.
  width | The width of the region to draw.
  height | The height of the region to draw.

Since gtkmm 3.24:

void Gdk::Cairo::set_source_pixbuf | ( | const ::Cairo::RefPtr< ::Cairo::Context > & | context,
|  | const Glib::RefPtr< const Gdk::Pixbuf >& | pixbuf,
|  | double | pixbuf_x = `0`,
|  | double | pixbuf_y = `0`
| ) |  |

Sets the given pixbuf as the source pattern for the Cairo context.

The pattern has an extend mode of Cairo::Pattern::Extend::NONE and is aligned so that the origin of pixbuf is pixbuf_x, pixbuf_y.

Parameters

  context | The cairo context.
  pixbuf | A Gdk::Pixbuf
  pixbuf_x | X coordinate of location to place upper left corner of pixbuf.
  pixbuf_y | Y coordinate of location to place upper left corner of pixbuf.

Since gtkmm 2.10:

void Gdk::Cairo::set_source_rgba | ( | const ::Cairo::RefPtr< ::Cairo::Context > & | context,
|  | const Gdk::RGBA& | color
| ) |  |

Sets the specified Gdk::RGBA as the source color of the Cairo context.

Parameters

  context | The cairo context.
  color | The color to use as the source color.

Since gtkmm 3.0:

::Cairo::RefPtr< ::Cairo::Context> Gdk::Cairo::wrap | ( | cairo_t * | cobject,
|  | bool | has_reference = `true`
| ) |  |

Creates a Cairo::RefPtr with a C++ wrapper for the C instance.

Parameters

  cobject | The C instance.
  has_reference | Whether we already have a reference. Otherwise, the function will take an extra reference.

Returns
  A C++ instance that wraps this C instance. If cobject is a nullptr, returns an empty Cairo::RefPtr.

Since gtkmm 3.92:

::Cairo::RefPtr< ::Cairo::Region> Gdk::Cairo::wrap | ( | cairo_region_t * | cobject,
|  | bool | has_reference = `true`
| ) |  |

Creates a Cairo::RefPtr with a C++ wrapper for the C instance.

Parameters

  cobject | The C instance.
  has_reference | Whether we already have a reference. Otherwise, the function will take an extra reference.

Returns
  A C++ instance that wraps this C instance. If cobject is a nullptr, returns an empty Cairo::RefPtr.

Since gtkmm 3.92:

template <typename T = ::Cairo::Surface, typename = std::enable_if<std::is_base_of< ::Cairo::Surface, T>::value>>

::Cairo::RefPtr<T> Gdk::Cairo::wrap | ( | cairo_surface_t * | cobject,
|  | bool | has_reference = `true`
| ) |  |

Creates a Cairo::RefPtr with a C++ wrapper for the C instance.

Template Parameters

  T | Cairo::Surface or a subclass of Cairo::Surface.

Parameters

  cobject | The C instance.
  has_reference | Whether we already have a reference. Otherwise, the function will take an extra reference.

Returns
  A C++ instance that wraps this C instance. If cobject is a nullptr, returns an empty Cairo::RefPtr.

Since gtkmm 3.92: