gtkmm: Gdk::GC Class Reference

All drawing operations in GDK take a graphics context (GC) argument. More...

Inheritance diagram for Gdk::GC:
Collaboration diagram for Gdk::GC:

Public Member Functions

 GC (GC&& src) noexcept
 
GCoperator= (GC&& src) noexcept
 
 ~GC () noexceptoverride
 
GdkGC* gobj ()
 Provides access to the underlying C GObject. More...

 
const GdkGC* gobj () const
 Provides access to the underlying C GObject. More...

 
GdkGC* gobj_copy ()
 Provides access to the underlying C instance. The caller is responsible for unrefing it. Use when directly setting fields in structs. More...

 
void set_foreground (const Color& color)
 Sets the foreground color for a graphics context. More...

 
void set_background (const Color& color)
 Sets the background color for a graphics context. More...

 
void set_function (Function function)
 Determines how the current pixel values and the pixel values being drawn are combined to produce the final pixel values. More...

 
void set_fill (Fill fill)
 Set the fill mode for a graphics context. More...

 
void set_tile (const Glib::RefPtr< Pixmap >& tile)
 Set a tile pixmap for a graphics context. More...

 
void set_stipple (const Glib::RefPtr< Pixmap >& stipple)
 Set the stipple bitmap for a graphics context. More...

 
void set_ts_origin (int x, int y)
 Set the origin when using tiles or stipples with the GC. More...

 
void set_clip_origin (int x, int y)
 Sets the origin of the clip mask. More...

 
void set_clip_mask (const Glib::RefPtr< Bitmap >& mask)
 Sets the clip mask for a graphics context from a bitmap. More...

 
void set_clip_rectangle (Rectangle& rectangle)
 Sets the clip mask for a graphics context from a rectangle. More...

 
void set_clip_rectangle (const Rectangle& rectangle)
 Sets the clip mask for a graphics context from a rectangle. More...

 
void set_clip_region (const Region& region)
 Sets the clip mask for a graphics context from a region structure. More...

 
void set_subwindow (SubwindowMode mode)
 Sets how drawing with this GC on a window will affect child windows of that window. More...

 
void set_exposures (bool exposures)
 Sets whether copying non-visible portions of a drawable using this graphics context generate exposure events for the corresponding regions of the destination drawable. More...

 
void set_line_attributes (int line_width, LineStyle line_style, CapStyle cap_style, JoinStyle join_style)
 Sets various attributes of how lines are drawn. More...

 
void set_dashes (int dash_offset, gint8* dash_list, int n)
 Sets the way dashed-lines are drawn. More...

 
void offset (int x_offset, int y_offset)
 Offset attributes such as the clip and tile-stipple origins of the GC so that drawing at x - x_offset, y - y_offset with the offset GC has the same effect as drawing at x, y with the original GC. More...

 
void set_colormap (const Glib::RefPtr< Colormap >& colormap)
 Sets the colormap for the GC to the given colormap. More...

 
Glib::RefPtr< Colormapget_colormap ()
 Retrieves the colormap for a given GC, if it exists. More...

 
void set_rgb_fg_color (const Color& color)
 Set the foreground color of a GC using an unallocated color. More...

 
void set_rgb_bg_color (const Color& color)
 Set the background color of a GC using an unallocated color. More...

 
Glib::RefPtr< Screenget_screen ()
 Gets the Gdk::Screen for which gc was created. More...

 
Glib::RefPtr< const Screenget_screen () const
 Gets the Gdk::Screen for which gc was created. More...

 
- Public Member Functions inherited from Glib::Object
 Object (const Object &)=delete
 
Objectoperator= (const Object &)=delete
 
 Object (Object &&src) noexcept
 
Objectoperator= (Object &&src) noexcept
 
void * get_data (const QueryQuark &key)
 
void set_data (const Quark &key, void *data)
 
void set_data (const Quark &key, void *data, DestroyNotify notify)
 
void remove_data (const QueryQuark &quark)
 
void * steal_data (const QueryQuark &quark)
 
Glib::RefPtr< Glib::Objectwrap (GObject *object, bool take_copy=false)
 
- Public Member Functions inherited from Glib::ObjectBase
 ObjectBase (const ObjectBase &)=delete
 
ObjectBaseoperator= (const ObjectBase &)=delete
 
void set_property_value (const Glib::ustring &property_name, const Glib::ValueBase &value)
 
void get_property_value (const Glib::ustring &property_name, Glib::ValueBase &value) const
 
void set_property (const Glib::ustring &property_name, const PropertyType &value)
 
void get_property (const Glib::ustring &property_name, PropertyType &value) const
 
void connect_property_changed (const Glib::ustring &property_name, const sigc::slot< void > &slot)
 
void connect_property_changed (const Glib::ustring &property_name, sigc::slot< void > &&slot)
 
sigc::connection connect_property_changed_with_return (const Glib::ustring &property_name, const sigc::slot< void > &slot)
 
sigc::connection connect_property_changed_with_return (const Glib::ustring &property_name, sigc::slot< void > &&slot)
 
void freeze_notify ()
 
void thaw_notify ()
 
virtual void reference () const
 
virtual void unreference () const
 
GObject * gobj ()
 
const GObject * gobj () const
 
GObject * gobj_copy () const
 
- Public Member Functions inherited from sigc::trackable
 trackable () noexcept
 
 trackable (const trackable &src) noexcept
 
 trackable (trackable &&src)
 
 ~trackable ()
 
void add_destroy_notify_callback (void *data, func_destroy_notify func) const
 
void notify_callbacks ()
 
trackableoperator= (const trackable &src)
 
trackableoperator= (trackable &&src)
 
void remove_destroy_notify_callback (void *data) const
 

Static Public Member Functions

static GType get_type ()
 Get the GType for this class, for use with the underlying GObject type system. More...

 
static Glib::RefPtr< GCcreate ()
 
static Glib::RefPtr< GCcreate (const Glib::RefPtr< Drawable >& drawable)
 

Protected Member Functions

 GC ()
 
 GC (const Glib::RefPtr< Drawable >& drawable)
 
- Protected Member Functions inherited from Glib::Object
 Object ()
 
 Object (const Glib::ConstructParams &construct_params)
 
 Object (GObject *castitem)
 
 ~Object () noexceptoverride
 
- Protected Member Functions inherited from Glib::ObjectBase
 ObjectBase ()
 
 ObjectBase (const char *custom_type_name)
 
 ObjectBase (const std::type_info &custom_type_info)
 
 ObjectBase (ObjectBase &&src) noexcept
 
ObjectBaseoperator= (ObjectBase &&src) noexcept
 
virtual ~ObjectBase () noexcept=0
 
void initialize (GObject *castitem)
 
void initialize_move (GObject *castitem, Glib::ObjectBase *previous_wrapper)
 

Related Functions

(Note that these are not member functions.)

Glib::RefPtr< Gdk::GCwrap (GdkGC* object, bool take_copy=false)
 A Glib::wrap() method for this object. More...

 

Additional Inherited Members

- Public Types inherited from Glib::Object
typedef void(*)(gpointer data DestroyNotify)
 
- Public Types inherited from sigc::trackable
typedef internal::func_destroy_notify func_destroy_notify
 

Detailed Description

All drawing operations in GDK take a graphics context (GC) argument.

A graphics context encapsulates information about the way things are drawn, such as the foreground color or line width. By using graphics contexts, the number of arguments to each drawing call is greatly reduced, and communication overhead is minimized, since identical arguments do not need to be passed repeatedly.

Constructor & Destructor Documentation

Gdk::GC::GC ( GC&&  src)
noexcept
Gdk::GC::~GC ( )
overridenoexcept
Gdk::GC::GC ( )
protected
Gdk::GC::GC ( const Glib::RefPtr< Drawable >&  drawable)
explicitprotected

Member Function Documentation

static Glib::RefPtr<GC> Gdk::GC::create ( )
static
static Glib::RefPtr<GC> Gdk::GC::create ( const Glib::RefPtr< Drawable >&  drawable)
static
Glib::RefPtr<Colormap> Gdk::GC::get_colormap ( )

Retrieves the colormap for a given GC, if it exists.

A GC will have a colormap if the drawable for which it was created has a colormap, or if a colormap was set explicitely with gdk_gc_set_colormap.

Deprecated: 2.22: There is no replacement. Cairo handles colormaps automatically, so there is no need to care about them.

Returns
The colormap of gc, or nullptr if gc doesn't have one.
Glib::RefPtr<Screen> Gdk::GC::get_screen ( )

Gets the Gdk::Screen for which gc was created.

Since gtkmm 2.2:
Returns
The Gdk::Screen for gc.
Glib::RefPtr<const Screen> Gdk::GC::get_screen ( ) const

Gets the Gdk::Screen for which gc was created.

Since gtkmm 2.2:
Returns
The Gdk::Screen for gc.
static GType Gdk::GC::get_type ( )
static

Get the GType for this class, for use with the underlying GObject type system.

GdkGC* Gdk::GC::gobj ( )
inline

Provides access to the underlying C GObject.

const GdkGC* Gdk::GC::gobj ( ) const
inline

Provides access to the underlying C GObject.

GdkGC* Gdk::GC::gobj_copy ( )

Provides access to the underlying C instance. The caller is responsible for unrefing it. Use when directly setting fields in structs.

void Gdk::GC::offset ( int  x_offset,
int  y_offset 
)

Offset attributes such as the clip and tile-stipple origins of the GC so that drawing at x - x_offset, y - y_offset with the offset GC has the same effect as drawing at x, y with the original GC.

Deprecated: 2.22: There is no direct replacement, as this is just a convenience function for gdk_gc_set_ts_origin and set_clip_origin().

Parameters
x_offsetAmount by which to offset the GC in the X direction.
y_offsetAmount by which to offset the GC in the Y direction.
GC& Gdk::GC::operator= ( GC&&  src)
noexcept
void Gdk::GC::set_background ( const Color color)

Sets the background color for a graphics context.

Note that this function uses color->pixel, use set_rgb_bg_color() to specify the background color as red, green, blue components.

Deprecated: 2.22: Use gdk_cairo_set_source_color() to use a Gdk::Color as the source in Cairo. Note that if you want to draw a background and a foreground in Cairo, you need to call drawing functions (like cairo_fill()) twice.

Parameters
colorThe new background color.
void Gdk::GC::set_clip_mask ( const Glib::RefPtr< Bitmap >&  mask)

Sets the clip mask for a graphics context from a bitmap.

The clip mask is interpreted relative to the clip origin. (See set_clip_origin()).

Deprecated: 2.22: Use cairo_mask() instead.

Parameters
maskA bitmap.
void Gdk::GC::set_clip_origin ( int  x,
int  y 
)

Sets the origin of the clip mask.

The coordinates are interpreted relative to the upper-left corner of the destination drawable of the current operation.

Deprecated: 2.22: Use cairo_translate() before applying the clip path in Cairo.

Parameters
xThe x-coordinate of the origin.
yThe y-coordinate of the origin.
void Gdk::GC::set_clip_rectangle ( Rectangle rectangle)

Sets the clip mask for a graphics context from a rectangle.

The clip mask is interpreted relative to the clip origin. (See set_clip_origin()).

Deprecated: 2.22: Use cairo_rectangle() and cairo_clip() in Cairo.

Deprecated:
Use set_clip_rectangle(const Rectangle& rectangle) instead.
Parameters
rectangleThe rectangle to clip to.
void Gdk::GC::set_clip_rectangle ( const Rectangle rectangle)

Sets the clip mask for a graphics context from a rectangle.

The clip mask is interpreted relative to the clip origin. (See set_clip_origin()).

Deprecated: 2.22: Use cairo_rectangle() and cairo_clip() in Cairo.

Parameters
rectangleThe rectangle to clip to.
void Gdk::GC::set_clip_region ( const Region region)

Sets the clip mask for a graphics context from a region structure.

The clip mask is interpreted relative to the clip origin. (See set_clip_origin()).

Deprecated: 2.22: Use gdk_cairo_region() and cairo_clip() in Cairo.

Parameters
regionThe Gdk::Region.
void Gdk::GC::set_colormap ( const Glib::RefPtr< Colormap >&  colormap)

Sets the colormap for the GC to the given colormap.

The depth of the colormap's visual must match the depth of the drawable for which the GC was created.

Deprecated: 2.22: There is no replacement. Cairo handles colormaps automatically, so there is no need to care about them.

Parameters
colormapA Gdk::Colormap.
void Gdk::GC::set_dashes ( int  dash_offset,
gint8 *  dash_list,
int  n 
)

Sets the way dashed-lines are drawn.

Lines will be drawn with alternating on and off segments of the lengths specified in dash_list. The manner in which the on and off segments are drawn is determined by the line_style value of the GC. (This can be changed with set_line_attributes().)

The dash_offset defines the phase of the pattern, specifying how many pixels into the dash-list the pattern should actually begin.

Deprecated: 2.22: Use cairo_set_dash() to set the dash in Cairo.

Parameters
dash_offsetThe phase of the dash pattern.
dash_listAn array of dash lengths.
nThe number of elements in dash_list.
void Gdk::GC::set_exposures ( bool  exposures)

Sets whether copying non-visible portions of a drawable using this graphics context generate exposure events for the corresponding regions of the destination drawable.

(See gdk_draw_drawable()).

Deprecated: 2.22: There is no replacement. If you need to control exposures, you must use drawing operations of the underlying window system or use Gdk::Window::invalidate_rect(). Cairo will never generate exposures.

Parameters
exposuresIf true, exposure events will be generated.
void Gdk::GC::set_fill ( Fill  fill)

Set the fill mode for a graphics context.

Deprecated: 2.22: You can achieve tiling in Cairo by using cairo_pattern_set_extend() on the source. For stippling, see the deprecation comments on set_stipple().

Parameters
fillThe new fill mode.
void Gdk::GC::set_foreground ( const Color color)

Sets the foreground color for a graphics context.

Note that this function uses color->pixel, use set_rgb_fg_color() to specify the foreground color as red, green, blue components.

Deprecated: 2.22: Use gdk_cairo_set_source_color() to use a Gdk::Color as the source in Cairo.

Parameters
colorThe new foreground color.
void Gdk::GC::set_function ( Function  function)

Determines how the current pixel values and the pixel values being drawn are combined to produce the final pixel values.

Deprecated: 2.22: Use cairo_set_operator() with Cairo.

Parameters
functionThe Gdk::Function to use.
void Gdk::GC::set_line_attributes ( int  line_width,
LineStyle  line_style,
CapStyle  cap_style,
JoinStyle  join_style 
)

Sets various attributes of how lines are drawn.

See the corresponding members of Gdk::GCValues for full explanations of the arguments.

Deprecated: 2.22: Use the Cairo functions cairo_set_line_width(), cairo_set_line_join(), cairo_set_line_cap() and cairo_set_dash() to affect the stroking behavior in Cairo. Keep in mind that the default attributes of a #cairo_t are different from the default attributes of a Gdk::GC.

Parameters
line_widthThe width of lines.
line_styleThe dash-style for lines.
cap_styleThe manner in which the ends of lines are drawn.
join_styleThe in which lines are joined together.
void Gdk::GC::set_rgb_bg_color ( const Color color)

Set the background color of a GC using an unallocated color.

The pixel value for the color will be determined using GdkRGB. If the colormap for the GC has not previously been initialized for GdkRGB, then for pseudo-color colormaps (colormaps with a small modifiable number of colors), a colorcube will be allocated in the colormap.

Calling this function for a GC without a colormap is an error.

Deprecated: 2.22: Use gdk_cairo_set_source_color() instead.

Parameters
colorAn unallocated Gdk::Color.
void Gdk::GC::set_rgb_fg_color ( const Color color)

Set the foreground color of a GC using an unallocated color.

The pixel value for the color will be determined using GdkRGB. If the colormap for the GC has not previously been initialized for GdkRGB, then for pseudo-color colormaps (colormaps with a small modifiable number of colors), a colorcube will be allocated in the colormap.

Calling this function for a GC without a colormap is an error.

Deprecated: 2.22: Use gdk_cairo_set_source_color() instead.

Parameters
colorAn unallocated Gdk::Color.
void Gdk::GC::set_stipple ( const Glib::RefPtr< Pixmap >&  stipple)

Set the stipple bitmap for a graphics context.

The stipple will only be used if the fill mode is Gdk::STIPPLED or Gdk::OPAQUE_STIPPLED.

Deprecated: 2.22: Stippling has no direct replacement in Cairo. If you want to achieve an identical look, you can use the stipple bitmap as a mask. Most likely, this involves rendering the source to an intermediate surface using cairo_push_group() first, so that you can then use cairo_mask() to achieve the stippled look.

Parameters
stippleThe new stipple bitmap.
void Gdk::GC::set_subwindow ( SubwindowMode  mode)

Sets how drawing with this GC on a window will affect child windows of that window.

Deprecated: 2.22: There is no replacement. If you need to control subwindows, you must use drawing operations of the underlying window system manually. Cairo will always use Gdk::INCLUDE_INFERIORS on sources and masks and Gdk::CLIP_BY_CHILDREN on targets.

Parameters
modeThe subwindow mode.
void Gdk::GC::set_tile ( const Glib::RefPtr< Pixmap >&  tile)

Set a tile pixmap for a graphics context.

This will only be used if the fill mode is Gdk::TILED.

Deprecated: 2.22: The following code snippet sets a tiling Gdk::Pixmap as the source in Cairo:

[C example ellipted]

Parameters
tileThe new tile pixmap.
void Gdk::GC::set_ts_origin ( int  x,
int  y 
)

Set the origin when using tiles or stipples with the GC.

The tile or stipple will be aligned such that the upper left corner of the tile or stipple will coincide with this point.

Deprecated: 2.22: You can set the origin for tiles and stipples in Cairo by changing the source's matrix using cairo_pattern_set_matrix(). Or you can specify it with gdk_cairo_set_source_pixmap() as shown in the example for set_tile().

Parameters
xThe x-coordinate of the origin.
yThe y-coordinate of the origin.

Friends And Related Function Documentation

Glib::RefPtr< Gdk::GC > wrap ( GdkGC *  object,
bool  take_copy = false 
)
related

A Glib::wrap() method for this object.

Parameters
objectThe C instance.
take_copyFalse if the result should take ownership of the C instance. True if it should take a new copy or ref.
Returns
A C++ instance that wraps this C instance.

The documentation for this class was generated from the following file:
  • gdkmm/gc.h