1 <!-- ##### SECTION Title ##### -->
4 <!-- ##### SECTION Short_Description ##### -->
5 objects to encapsulate drawing properties.
7 <!-- ##### SECTION Long_Description ##### -->
9 All drawing operations in GDK take a
10 <firstterm>graphics context</firstterm> (GC) argument.
11 A graphics context encapsulates information about
12 the way things are drawn, such as the foreground
13 color or line width. By using graphics contexts,
14 the number of arguments to each drawing call is
15 greatly reduced, and communication overhead is
16 minimized, since identical arguments do not need
17 to be passed repeatedly.
20 Most values of a graphics context can be set at
21 creation time by using gdk_gc_new_with_values(),
22 or can be set one-by-one using functions such
23 as gdk_gc_set_foreground(). A few of the values
24 in the GC, such as the dash pattern, can only
25 be set by the latter method.
28 <!-- ##### SECTION See_Also ##### -->
33 <!-- ##### STRUCT GdkGC ##### -->
35 The #GdkGC structure represents a graphics context.
36 It is an opaque structure with no user-visible
47 <!-- ##### STRUCT GdkGCValues ##### -->
49 The #GdkGCValues structure holds a set of values used
50 to create or modify a graphics context.
53 @foreground: the foreground color.
54 @background: the background color.
55 @font: the default font.
56 @function: the bitwise operation used when drawing.
57 @fill: the fill style.
58 @tile: the tile pixmap.
59 @stipple: the stipple bitmap.
60 @clip_mask: the clip mask bitmap.
61 @subwindow_mode: the subwindow mode.
62 @ts_x_origin: the x origin of the tile or stipple.
63 @ts_y_origin: the y origin of the tile or stipple.
64 @clip_x_origin: the x origin of the clip mask.
65 @clip_y_origin: the y origin of the clip mask.
66 @graphics_exposures: whether graphics exposures are enabled.
67 @line_width: the line width.
68 @line_style: the way dashed lines are drawn.
69 @cap_style: the way the ends of lines are drawn.
70 @join_style: the way joins between lines are drawn.
72 <!-- ##### ENUM GdkGCValuesMask ##### -->
74 A set of bit flags used to indicate which fields
75 #GdkGCValues structure are set.
78 @GDK_GC_FOREGROUND: the @foreground is set.
79 @GDK_GC_BACKGROUND: the @background is set.
80 @GDK_GC_FONT: the @font is set.
81 @GDK_GC_FUNCTION: the @function is set.
82 @GDK_GC_FILL: the @fill is set.
83 @GDK_GC_TILE: the @tile is set.
84 @GDK_GC_STIPPLE: the @stipple is set.
85 @GDK_GC_CLIP_MASK: the @clip_mask is set.
86 @GDK_GC_SUBWINDOW: the @subwindow_mode is set.
87 @GDK_GC_TS_X_ORIGIN: the @ts_x_origin is set.
88 @GDK_GC_TS_Y_ORIGIN: the @ts_y_origin is set.
89 @GDK_GC_CLIP_X_ORIGIN: the @clip_x_origin is set.
90 @GDK_GC_CLIP_Y_ORIGIN: the @clip_y_origin is set.
91 @GDK_GC_EXPOSURES: the @graphics_exposures is set.
92 @GDK_GC_LINE_WIDTH: the @line_width is set.
93 @GDK_GC_LINE_STYLE: the @line_style is set.
94 @GDK_GC_CAP_STYLE: the @cap_style is set.
95 @GDK_GC_JOIN_STYLE: the @join_style is set.
97 <!-- ##### ENUM GdkFunction ##### -->
99 Determines how the bit values for the source pixels are combined with
100 the bit values for destination pixels to produce the final result. The
101 sixteen values here correspond to the 16 different possible 2x2 truth
102 tables. Only a couple of these values are usually useful; for colored
103 images, only %GDK_COPY, %GDK_XOR and %GDK_INVERT are generally
104 useful. For bitmaps, %GDK_AND and %GDK_OR are also useful.
124 <!-- ##### FUNCTION gdk_gc_new ##### -->
126 Create a new graphics context with default values.
129 @drawable: a #GdkDrawable. The created GC must always be used
130 with drawables of the same depth as this one.
131 @Returns: the new graphics context.
134 <!-- ##### FUNCTION gdk_gc_new_with_values ##### -->
136 Create a new GC with the given initial values.
139 @drawable: a #GdkDrawable. The created GC must always be used
140 with drawables of the same depth as this one.
141 @values: a structure containing initial values for the GC.
142 @values_mask: a bit mask indicating which fields in @values
144 @Returns: the new graphics context.
147 <!-- ##### FUNCTION gdk_gc_ref ##### -->
156 <!-- ##### FUNCTION gdk_gc_unref ##### -->
164 <!-- ##### MACRO gdk_gc_destroy ##### -->
166 Identical to gdk_gc_unref(). This function is obsolete
167 and should not be used.
170 <!-- # Unused Parameters # -->
174 <!-- ##### FUNCTION gdk_gc_set_values ##### -->
184 <!-- ##### FUNCTION gdk_gc_get_values ##### -->
186 Retrieves the current values from a graphics context.
190 @values: the #GdkGCValues structure in which to store the results.
193 <!-- ##### FUNCTION gdk_gc_set_foreground ##### -->
195 Sets the foreground color for a graphics context.
199 @color: the new foreground color.
202 <!-- ##### FUNCTION gdk_gc_set_background ##### -->
204 Sets the background color for a graphics context.
208 @color: the new background color.
211 <!-- ##### FUNCTION gdk_gc_set_rgb_fg_color ##### -->
220 <!-- ##### FUNCTION gdk_gc_set_rgb_bg_color ##### -->
229 <!-- ##### FUNCTION gdk_gc_set_font ##### -->
231 Sets the font for a graphics context. (Note that
232 all text-drawing functions in GDK take a @font
233 argument; the value set here is used when that
241 <!-- ##### FUNCTION gdk_gc_set_function ##### -->
243 Determines how the current pixel values and the
244 pixel values being drawn are combined to produce
245 the final pixel values.
252 <!-- ##### FUNCTION gdk_gc_set_fill ##### -->
254 Set the fill mode for a graphics context.
258 @fill: the new fill mode.
261 <!-- ##### ENUM GdkFill ##### -->
263 Determines how primitives are drawn.
266 @GDK_SOLID: draw with the foreground color.
267 @GDK_TILED: draw with a tiled pixmap.
268 @GDK_STIPPLED: draw using the stipple bitmap. Pixels corresponding
269 to bits in the stipple bitmap that are set will be drawn in the
270 foreground color; pixels corresponding to bits that are
271 not set will be left untouched.
272 @GDK_OPAQUE_STIPPLED: draw using the stipple bitmap. Pixels corresponding
273 to bits in the stipple bitmap that are set will be drawn in the
274 foreground color; pixels corresponding to bits that are
275 not set will be drawn with the background color.
277 <!-- ##### FUNCTION gdk_gc_set_tile ##### -->
279 Set a tile pixmap for a graphics context.
280 This will only be used if the fill mode
285 @tile: the new tile pixmap.
288 <!-- ##### FUNCTION gdk_gc_set_stipple ##### -->
290 Set the stipple bitmap for a graphics context. The
291 stipple will only be used if the fill mode is
292 %GDK_STIPPLED or %GDK_OPAQUE_STIPPLED.
296 @stipple: the new stipple bitmap.
299 <!-- ##### FUNCTION gdk_gc_set_ts_origin ##### -->
301 Set the origin when using tiles or stipples with
302 the GC. The tile or stipple will be aligned such
303 that the upper left corner of the tile or stipple
304 will coincide with this point.
308 @x: the x-coordinate of the origin.
309 @y: the y-coordinate of the origin.
312 <!-- ##### FUNCTION gdk_gc_set_clip_origin ##### -->
314 Sets the origin of the clip mask. The coordinates are
315 interpreted relative to the upper-left corner of
316 the destination drawable of the current operation.
320 @x: the x-coordinate of the origin.
321 @y: the y-coordinate of the origin.
324 <!-- ##### FUNCTION gdk_gc_set_clip_mask ##### -->
326 Sets the clip mask for a graphics context from a bitmap.
327 The clip mask is interpreted relative to the clip
328 origin. (See gdk_gc_set_clip_origin()).
335 <!-- ##### FUNCTION gdk_gc_set_clip_rectangle ##### -->
337 Sets the clip mask for a graphics context from a
338 rectangle. The clip mask is interpreted relative to the clip
339 origin. (See gdk_gc_set_clip_origin()).
344 @rectangle: the rectangle to clip to.
347 <!-- ##### FUNCTION gdk_gc_set_clip_region ##### -->
349 Sets the clip mask for a graphics context from a region structure.
350 The clip mask is interpreted relative to the clip origin. (See
351 gdk_gc_set_clip_origin()).
355 @region: the #GdkRegion.
358 <!-- ##### FUNCTION gdk_gc_set_subwindow ##### -->
360 Sets how drawing with this GC on a window will affect child
361 windows of that window.
365 @mode: the subwindow mode.
368 <!-- ##### ENUM GdkSubwindowMode ##### -->
370 Determines how drawing onto a window will affect child
371 windows of that window.
374 @GDK_CLIP_BY_CHILDREN: only draw onto the window itself.
375 @GDK_INCLUDE_INFERIORS: draw onto the window and child windows.
377 <!-- ##### FUNCTION gdk_gc_set_exposures ##### -->
379 Sets whether copying non-visible portions of a drawable
380 using this graphics context generate exposure events
381 for the corresponding regions of the destination
382 drawable. (See gdk_draw_drawable()).
386 @exposures: if %TRUE, exposure events will be generated.
389 <!-- ##### FUNCTION gdk_gc_set_line_attributes ##### -->
391 Sets various attributes of how lines are drawn. See
392 the corresponding members of #GdkGCValues for full
393 explanations of the arguments.
397 @line_width: the width of lines.
398 @line_style: the dash-style for lines.
399 @cap_style: the manner in which the ends of lines are drawn.
400 @join_style: the in which lines are joined together.
403 <!-- ##### ENUM GdkLineStyle ##### -->
405 Determines how lines are drawn.
408 @GDK_LINE_SOLID: lines are drawn solid.
409 @GDK_LINE_ON_OFF_DASH: even segments are drawn; odd segments are not drawn.
410 @GDK_LINE_DOUBLE_DASH: even segments are normally. Odd segments are drawn
411 in the background color if the fill style is %GDK_SOLID, or in the background
412 color masked by the stipple if the fill style is %GDK_STIPPLED.
414 <!-- ##### ENUM GdkCapStyle ##### -->
416 Determines how the end of lines are drawn.
419 @GDK_CAP_NOT_LAST: the same as %GDK_CAP_BUTT for lines of non-zero width.
420 for zero width lines, the final point on the line will not be drawn.
421 @GDK_CAP_BUTT: the ends of the lines are drawn squared off and extending
422 to the coordinates of the end point.
423 @GDK_CAP_ROUND: the ends of the lines are drawn as semicircles with the
424 diameter equal to the line width and centered at the end point.
425 @GDK_CAP_PROJECTING: the ends of the lines are drawn squared off and extending
426 half the width of the line beyond the end point.
428 <!-- ##### ENUM GdkJoinStyle ##### -->
430 Determines how the joins between segments of a polygon are drawn.
433 @GDK_JOIN_MITER: the sides of each line are extended to meet at an angle.
434 @GDK_JOIN_ROUND: the sides of the two lines are joined by a circular arc.
435 @GDK_JOIN_BEVEL: the sides of the two lines are joined by a straight line which
436 makes an equal angle with each line.
438 <!-- ##### FUNCTION gdk_gc_set_dashes ##### -->
440 Sets the way dashed-lines are drawn. Lines will be
441 drawn with alternating on and off segments of the
442 lengths specified in @dash_list. The manner in
443 which the on and off segments are drawn is determined
444 by the @line_style value of the GC. (This can
445 be changed with gdk_gc_set_line_attributes())
450 @dash_list: an array of dash lengths.
451 @n: the number of elements in @dash_list.
454 <!-- ##### FUNCTION gdk_gc_copy ##### -->
456 Copy the set of values from one graphics context
457 onto another graphics context.
460 @dst_gc: the destination graphics context.
461 @src_gc: the source graphics context.
464 <!-- ##### FUNCTION gdk_gc_set_colormap ##### -->
473 <!-- ##### FUNCTION gdk_gc_get_colormap ##### -->
482 <!-- ##### FUNCTION gdk_gc_offset ##### -->