Drawing Primitives

Drawing Primitives — Functions for drawing points, lines, arcs, and text

Synopsis

#include <gdk/gdk.h>

                    GdkDrawable;
GdkDisplay*         gdk_drawable_get_display            (GdkDrawable *drawable);
GdkScreen*          gdk_drawable_get_screen             (GdkDrawable *drawable);
GdkVisual*          gdk_drawable_get_visual             (GdkDrawable *drawable);
void                gdk_drawable_set_colormap           (GdkDrawable *drawable,
                                                         GdkColormap *colormap);
GdkColormap*        gdk_drawable_get_colormap           (GdkDrawable *drawable);
gint                gdk_drawable_get_depth              (GdkDrawable *drawable);
void                gdk_drawable_get_size               (GdkDrawable *drawable,
                                                         gint *width,
                                                         gint *height);
cairo_region_t *    gdk_drawable_get_clip_region        (GdkDrawable *drawable);
cairo_region_t *    gdk_drawable_get_visible_region     (GdkDrawable *drawable);

Object Hierarchy

  GObject
   +----GdkDrawable
         +----GdkWindow
         +----GdkPixmap

Description

These functions provide support for drawing points, lines, arcs and text onto what are called 'drawables'. Drawables, as the name suggests, are things which support drawing onto them, and are either GdkWindow or GdkPixmap objects.

Many of the drawing operations take a GdkGC argument, which represents a graphics context. This GdkGC contains a number of drawing attributes such as foreground color, background color and line width, and is used to reduce the number of arguments needed for each drawing operation. See the Graphics Contexts section for more information.

Some of the drawing operations take Pango data structures like PangoContext, PangoLayout or PangoLayoutLine as arguments. If you're using GTK+, the ususal way to obtain these structures is via gtk_widget_create_pango_context() or gtk_widget_create_pango_layout().

Details

GdkDrawable

typedef struct _GdkDrawable GdkDrawable;

An opaque structure representing an object that can be drawn onto. This can be a GdkPixmap, a GdkBitmap, or a GdkWindow.


gdk_drawable_get_display ()

GdkDisplay*         gdk_drawable_get_display            (GdkDrawable *drawable);

Gets the GdkDisplay associated with a GdkDrawable.

drawable :

a GdkDrawable

Returns :

the GdkDisplay associated with drawable

Since 2.2


gdk_drawable_get_screen ()

GdkScreen*          gdk_drawable_get_screen             (GdkDrawable *drawable);

Gets the GdkScreen associated with a GdkDrawable.

drawable :

a GdkDrawable

Returns :

the GdkScreen associated with drawable

Since 2.2


gdk_drawable_get_visual ()

GdkVisual*          gdk_drawable_get_visual             (GdkDrawable *drawable);

Gets the GdkVisual describing the pixel format of drawable.

drawable :

a GdkDrawable

Returns :

a GdkVisual

gdk_drawable_set_colormap ()

void                gdk_drawable_set_colormap           (GdkDrawable *drawable,
                                                         GdkColormap *colormap);

Sets the colormap associated with drawable. Normally this will happen automatically when the drawable is created; you only need to use this function if the drawable-creating function did not have a way to determine the colormap, and you then use drawable operations that require a colormap. The colormap for all drawables and graphics contexts you intend to use together should match.

drawable :

a GdkDrawable

colormap :

a GdkColormap

gdk_drawable_get_colormap ()

GdkColormap*        gdk_drawable_get_colormap           (GdkDrawable *drawable);

Gets the colormap for drawable, if one is set; returns NULL otherwise.

drawable :

a GdkDrawable

Returns :

the colormap, or NULL

gdk_drawable_get_depth ()

gint                gdk_drawable_get_depth              (GdkDrawable *drawable);

Obtains the bit depth of the drawable, that is, the number of bits that make up a pixel in the drawable's visual. Examples are 8 bits per pixel, 24 bits per pixel, etc.

drawable :

a GdkDrawable

Returns :

number of bits per pixel

gdk_drawable_get_size ()

void                gdk_drawable_get_size               (GdkDrawable *drawable,
                                                         gint *width,
                                                         gint *height);

Fills *width and *height with the size of drawable. width or height can be NULL if you only want the other one.

On the X11 platform, if drawable is a GdkWindow, the returned size is the size reported in the most-recently-processed configure event, rather than the current size on the X server.

drawable :

a GdkDrawable

width :

location to store drawable's width, or NULL. [out][allow-none]

height :

location to store drawable's height, or NULL. [out][allow-none]

gdk_drawable_get_clip_region ()

cairo_region_t *    gdk_drawable_get_clip_region        (GdkDrawable *drawable);

Computes the region of a drawable that potentially can be written to by drawing primitives. This region will not take into account the clip region for the GC, and may also not take into account other factors such as if the window is obscured by other windows, but no area outside of this region will be affected by drawing primitives.

drawable :

a GdkDrawable

Returns :

a cairo_region_t. This must be freed with cairo_region_destroy() when you are done.

gdk_drawable_get_visible_region ()

cairo_region_t *    gdk_drawable_get_visible_region     (GdkDrawable *drawable);

Computes the region of a drawable that is potentially visible. This does not necessarily take into account if the window is obscured by other windows, but no area outside of this region is visible.

drawable :

a GdkDrawable

Returns :

a cairo_region_t. This must be freed with cairo_region_destroy() when you are done.