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.
Most values of a graphics context can be set at
creation time by using gdk_gc_new_with_values(),
or can be set one-by-one using functions such
as gdk_gc_set_foreground(). A few of the values
in the GC, such as the dash pattern, can only
be set by the latter method.
Details
struct GdkGC
struct GdkGC
{
gint dummy_var;
}; |
The GdkGC structure represents a graphics context.
It is an opaque structure with no user-visible
elements.
struct GdkGCValues
struct GdkGCValues
{
GdkColor foreground;
GdkColor background;
GdkFont *font;
GdkFunction function;
GdkFill fill;
GdkPixmap *tile;
GdkPixmap *stipple;
GdkPixmap *clip_mask;
GdkSubwindowMode subwindow_mode;
gint ts_x_origin;
gint ts_y_origin;
gint clip_x_origin;
gint clip_y_origin;
gint graphics_exposures;
gint line_width;
GdkLineStyle line_style;
GdkCapStyle cap_style;
GdkJoinStyle join_style;
}; |
The GdkGCValues structure holds a set of values used
to create or modify a graphics context.
enum GdkGCValuesMask
typedef enum
{
GDK_GC_FOREGROUND = 1 << 0,
GDK_GC_BACKGROUND = 1 << 1,
GDK_GC_FONT = 1 << 2,
GDK_GC_FUNCTION = 1 << 3,
GDK_GC_FILL = 1 << 4,
GDK_GC_TILE = 1 << 5,
GDK_GC_STIPPLE = 1 << 6,
GDK_GC_CLIP_MASK = 1 << 7,
GDK_GC_SUBWINDOW = 1 << 8,
GDK_GC_TS_X_ORIGIN = 1 << 9,
GDK_GC_TS_Y_ORIGIN = 1 << 10,
GDK_GC_CLIP_X_ORIGIN = 1 << 11,
GDK_GC_CLIP_Y_ORIGIN = 1 << 12,
GDK_GC_EXPOSURES = 1 << 13,
GDK_GC_LINE_WIDTH = 1 << 14,
GDK_GC_LINE_STYLE = 1 << 15,
GDK_GC_CAP_STYLE = 1 << 16,
GDK_GC_JOIN_STYLE = 1 << 17
} GdkGCValuesMask; |
A set of bit flags used to indicate which fields
GdkGCValues structure are set.
enum GdkFunction
typedef enum
{
GDK_COPY,
GDK_INVERT,
GDK_XOR,
GDK_CLEAR,
GDK_AND,
GDK_AND_REVERSE,
GDK_AND_INVERT,
GDK_NOOP,
GDK_OR,
GDK_EQUIV,
GDK_OR_REVERSE,
GDK_COPY_INVERT,
GDK_OR_INVERT,
GDK_NAND,
GDK_SET
} GdkFunction; |
Determines how the bit values for the source pixels are combined with
the bit values for destination pixels to produce the final result. The
sixteen values here correspond to the 16 different possible 2x2 truth
tables. Only a couple of these values are usually useful; for colored
images, only GDK_COPY, GDK_XOR and GDK_INVERT are generally
useful. For bitmaps, GDK_AND and GDK_OR are also useful.
gdk_gc_new ()
Create a new graphics context with default values.
gdk_gc_new_with_values ()
Create a new GC with the given initial values.
gdk_gc_ref ()
Increase the reference count on a graphics context.
gdk_gc_unref ()
void gdk_gc_unref (GdkGC *gc); |
Decrease the reference count on a graphics context. If
the resulting reference count is zero, the graphics
context will be destroyed.
gdk_gc_destroy ()
void gdk_gc_destroy (GdkGC *gc); |
Identical to gdk_gc_unref(). This function is obsolete
and should not be used.
gdk_gc_get_values ()
Retrieves the current values from a graphics context.
gdk_gc_set_foreground ()
Sets the foreground color for a graphics context.
gdk_gc_set_background ()
Sets the background color for a graphics context.
gdk_gc_set_font ()
Sets the font for a graphics context. (Note that
all text-drawing functions in GDK take a font
argument; the value set here is used when that
argument is NULL.)
gdk_gc_set_function ()
Determines how the current pixel values and the
pixel values being drawn are combined to produce
the final pixel values.
gdk_gc_set_fill ()
Set the fill mode for a graphics context.
enum GdkFill
typedef enum
{
GDK_SOLID,
GDK_TILED,
GDK_STIPPLED,
GDK_OPAQUE_STIPPLED
} GdkFill; |
Determines how primitives are drawn.
gdk_gc_set_tile ()
Set a tile pixmap for a graphics context.
This will only be used if the fill mode
is GDK_TILED.
gdk_gc_set_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.
gdk_gc_set_ts_origin ()
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.
gdk_gc_set_clip_origin ()
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.
gdk_gc_set_clip_mask ()
Sets the clip mask for a graphics context from a bitmap.
The clip mask is interpreted relative to the clip
origin. (See gdk_gc_set_clip_origin()).
gdk_gc_set_clip_rectangle ()
Sets the clip mask for a graphics context from a
rectangle. The clip mask is interpreted relative to the clip
origin. (See gdk_gc_set_clip_origin()).
gdk_gc_set_clip_region ()
Sets the clip mask for a graphics context from a region structure.
The clip mask is interpreted relative to the clip origin. (See
gdk_gc_set_clip_origin()).
gdk_gc_set_subwindow ()
Sets how drawing with this GC on a window will affect child
windows of that window.
enum GdkSubwindowMode
typedef enum
{
GDK_CLIP_BY_CHILDREN = 0,
GDK_INCLUDE_INFERIORS = 1
} GdkSubwindowMode; |
Determines how drawing onto a window will affect child
windows of that window.
gdk_gc_set_exposures ()
void gdk_gc_set_exposures (GdkGC *gc,
gint 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_pixmap()).
gdk_gc_set_line_attributes ()
Sets various attributes of how lines are drawn. See
the corresponding members of GdkGCValues for full
explanations of the arguments.
enum GdkLineStyle
typedef enum
{
GDK_LINE_SOLID,
GDK_LINE_ON_OFF_DASH,
GDK_LINE_DOUBLE_DASH
} GdkLineStyle; |
Determines how lines are drawn.
enum GdkCapStyle
typedef enum
{
GDK_CAP_NOT_LAST,
GDK_CAP_BUTT,
GDK_CAP_ROUND,
GDK_CAP_PROJECTING
} GdkCapStyle; |
Determines how the end of lines are drawn.
enum GdkJoinStyle
typedef enum
{
GDK_JOIN_MITER,
GDK_JOIN_ROUND,
GDK_JOIN_BEVEL
} GdkJoinStyle; |
Determines how the joins between segments of a polygon are drawn.
gdk_gc_set_dashes ()
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 gdk_gc_set_line_attributes)
gdk_gc_copy ()
Copy the set of values from one graphics context
onto another graphics context.