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 GdkGCClass ##### -->
53 <!-- ##### STRUCT GdkGCValues ##### -->
55 The #GdkGCValues structure holds a set of values used
56 to create or modify a graphics context.
58 <informaltable pgwide=1 frame="none" role="struct">
59 <tgroup cols="2"><colspec colwidth="2*"><colspec colwidth="8*">
63 <entry>#GdkColor foreground;</entry>
64 <entry>the foreground color.</entry>
68 <entry>#GdkColor background;</entry>
69 <entry>the background color.</entry>
73 <entry>#GdkFont *font;</entry>
74 <entry>the default font..</entry>
78 <entry>#GdkFunction function;</entry>
79 <entry>the bitwise operation used when drawing.</entry>
83 <entry>#GdkFill fill;</entry>
84 <entry>the fill style.</entry>
88 <entry>#GdkPixmap *tile;</entry>
89 <entry>the tile pixmap.</entry>
93 <entry>#GdkPixmap *stipple;</entry>
94 <entry>the stipple bitmap.</entry>
98 <entry>#GdkPixmap *clip_mask;</entry>
99 <entry>the clip mask bitmap.</entry>
103 <entry>#GdkSubwindowMode subwindow_mode;</entry>
104 <entry>the subwindow mode.</entry>
108 <entry>#gint ts_x_origin;</entry>
109 <entry>the x origin of the tile or stipple.</entry>
113 <entry>#gint ts_y_origin;</entry>
114 <entry>the y origin of the tile or stipple.</entry>
118 <entry>#gint clip_x_origin;</entry>
119 <entry>the x origin of the clip mask.</entry>
123 <entry>#gint clip_y_origin;</entry>
124 <entry>the y origin of the clip mask.</entry>
128 <entry>#gint graphics_exposures;</entry>
129 <entry>whether graphics exposures are enabled.</entry>
133 <entry>#gint line_width;</entry>
134 <entry>the line width</entry>
138 <entry>#GdkLineStyle line_style;</entry>
139 <entry>the way dashed lines are drawn</entry>
143 <entry>#GdkCapStyle cap_style;</entry>
144 <entry>the way the ends of lines are drawn</entry>
148 <entry>#GdkJoinStyle join_style;</entry>
149 <entry>the way joins between lines are drawn</entry>
152 </tbody></tgroup></informaltable>
174 <!-- ##### ENUM GdkGCValuesMask ##### -->
176 A set of bit flags used to indicate which fields
177 #GdkGCValues structure are set.
191 @GDK_GC_CLIP_X_ORIGIN:
192 @GDK_GC_CLIP_Y_ORIGIN:
199 <!-- ##### ENUM GdkFunction ##### -->
201 Determines how the bit values for the source pixels are combined with
202 the bit values for destination pixels to produce the final result. The
203 sixteen values here correspond to the 16 different possible 2x2 truth
204 tables. Only a couple of these values are usually useful; for colored
205 images, only %GDK_COPY, %GDK_XOR and %GDK_INVERT are generally
206 useful. For bitmaps, %GDK_AND and %GDK_OR are also useful.
226 <!-- ##### FUNCTION gdk_gc_new ##### -->
228 Create a new graphics context with default values.
232 @Returns: the new graphics context.
233 <!-- # Unused Parameters # -->
234 @window: a #GdkDrawable. The created GC must always be used
235 with drawables of the same depth as this one.
238 <!-- ##### FUNCTION gdk_gc_new_with_values ##### -->
240 Create a new GC with the given initial values.
244 @values: a structure containing initial values for the GC.
245 @values_mask: a bit mask indicating which fields in @values
247 @Returns: the new graphics context.
248 <!-- # Unused Parameters # -->
249 @window: a #GdkDrawable. The created GC must always be used
250 with drawables of the same depth as this one.
253 <!-- ##### FUNCTION gdk_gc_ref ##### -->
255 Increase the reference count on a graphics context.
262 <!-- ##### FUNCTION gdk_gc_unref ##### -->
264 Decrease the reference count on a graphics context. If
265 the resulting reference count is zero, the graphics
266 context will be destroyed.
272 <!-- ##### MACRO gdk_gc_destroy ##### -->
274 Identical to gdk_gc_unref(). This function is obsolete
275 and should not be used.
278 <!-- # Unused Parameters # -->
282 <!-- ##### FUNCTION gdk_gc_set_values ##### -->
292 <!-- ##### FUNCTION gdk_gc_get_values ##### -->
294 Retrieves the current values from a graphics context.
298 @values: the #GdkGCValues structure in which to store the results.
301 <!-- ##### FUNCTION gdk_gc_set_foreground ##### -->
303 Sets the foreground color for a graphics context.
307 @color: the new foreground color.
310 <!-- ##### FUNCTION gdk_gc_set_background ##### -->
312 Sets the background color for a graphics context.
316 @color: the new background color.
319 <!-- ##### FUNCTION gdk_gc_set_rgb_fg_color ##### -->
328 <!-- ##### FUNCTION gdk_gc_set_rgb_bg_color ##### -->
337 <!-- ##### FUNCTION gdk_gc_set_font ##### -->
339 Sets the font for a graphics context. (Note that
340 all text-drawing functions in GDK take a @font
341 argument; the value set here is used when that
349 <!-- ##### FUNCTION gdk_gc_set_function ##### -->
351 Determines how the current pixel values and the
352 pixel values being drawn are combined to produce
353 the final pixel values.
360 <!-- ##### FUNCTION gdk_gc_set_fill ##### -->
362 Set the fill mode for a graphics context.
366 @fill: the new fill mode.
369 <!-- ##### ENUM GdkFill ##### -->
371 Determines how primitives are drawn.
373 <informaltable pgwide=1 frame="none" role="enum">
374 <tgroup cols="2"><colspec colwidth="2*"><colspec colwidth="8*">
378 <entry>GDK_SOLID</entry>
379 <entry>draw with the foreground color.</entry>
383 <entry>GDK_TILED</entry>
384 <entry>draw with a tiled pixmap.</entry>
388 <entry>GDK_STIPPLED</entry>
389 <entry>draw using the stipple bitmap. Pixels corresponding
390 to bits in the stipple bitmap that are set will be drawn in the
391 foreground color; pixels corresponding to bits that are
392 not set will be left untouched.</entry>
396 <entry>GDK_OPAQUE_STIPPLED</entry>
397 <entry>draw using the stipple bitmap. Pixels corresponding
398 to bits in the stipple bitmap that are set will be drawn in the
399 foreground color; pixels corresponding to bits that are
400 not set will be drawn with the background color.</entry>
403 </tbody></tgroup></informaltable>
409 @GDK_OPAQUE_STIPPLED:
411 <!-- ##### FUNCTION gdk_gc_set_tile ##### -->
413 Set a tile pixmap for a graphics context.
414 This will only be used if the fill mode
419 @tile: the new tile pixmap.
422 <!-- ##### FUNCTION gdk_gc_set_stipple ##### -->
424 Set the stipple bitmap for a graphics context. The
425 stipple will only be used if the fill mode is
426 %GDK_STIPPLED or %GDK_OPAQUE_STIPPLED.
430 @stipple: the new stipple bitmap.
433 <!-- ##### FUNCTION gdk_gc_set_ts_origin ##### -->
435 Set the origin when using tiles or stipples with
436 the GC. The tile or stipple will be aligned such
437 that the upper left corner of the tile or stipple
438 will coincide with this point.
442 @x: the x-coordinate of the origin.
443 @y: the y-coordinate of the origin.
446 <!-- ##### FUNCTION gdk_gc_set_clip_origin ##### -->
448 Sets the origin of the clip mask. The coordinates are
449 interpreted relative to the upper-left corner of
450 the destination drawable of the current operation.
454 @x: the x-coordinate of the origin.
455 @y: the y-coordinate of the origin.
458 <!-- ##### FUNCTION gdk_gc_set_clip_mask ##### -->
460 Sets the clip mask for a graphics context from a bitmap.
461 The clip mask is interpreted relative to the clip
462 origin. (See gdk_gc_set_clip_origin()).
469 <!-- ##### FUNCTION gdk_gc_set_clip_rectangle ##### -->
471 Sets the clip mask for a graphics context from a
472 rectangle. The clip mask is interpreted relative to the clip
473 origin. (See gdk_gc_set_clip_origin()).
478 @rectangle: the rectangle to clip to.
481 <!-- ##### FUNCTION gdk_gc_set_clip_region ##### -->
483 Sets the clip mask for a graphics context from a region structure.
484 The clip mask is interpreted relative to the clip origin. (See
485 gdk_gc_set_clip_origin()).
489 @region: the #GdkRegion.
492 <!-- ##### FUNCTION gdk_gc_set_subwindow ##### -->
494 Sets how drawing with this GC on a window will affect child
495 windows of that window.
499 @mode: the subwindow mode.
502 <!-- ##### ENUM GdkSubwindowMode ##### -->
505 Determines how drawing onto a window will affect child
506 windows of that window.
508 <informaltable pgwide=1 frame="none" role="enum">
509 <tgroup cols="2"><colspec colwidth="3*"><colspec colwidth="7*">
513 <entry>GDK_CLIP_BY_CHILDREN</entry>
514 <entry>only draw onto the window itself.</entry>
518 <entry>GDK_INCLUDE_INFERIORS</entry>
519 <entry>Draw onto the window and child windows.</entry>
522 </tbody></tgroup></informaltable>
525 @GDK_CLIP_BY_CHILDREN:
526 @GDK_INCLUDE_INFERIORS:
528 <!-- ##### FUNCTION gdk_gc_set_exposures ##### -->
530 Sets whether copying non-visible portions of a drawable
531 using this graphics context generate exposure events
532 for the corresponding regions of the destination
533 drawable. (See gdk_draw_pixmap()).
537 @exposures: if %TRUE, exposure events will be generated.
540 <!-- ##### FUNCTION gdk_gc_set_line_attributes ##### -->
542 Sets various attributes of how lines are drawn. See
543 the corresponding members of GdkGCValues for full
544 explanations of the arguments.
548 @line_width: the width of lines.
549 @line_style: the dash-style for lines.
550 @cap_style: the manner in which the ends of lines are drawn.
551 @join_style: the in which lines are joined together.
554 <!-- ##### ENUM GdkLineStyle ##### -->
556 Determines how lines are drawn.
558 <informaltable pgwide=1 frame="none" role="enum">
559 <tgroup cols="2"><colspec colwidth="2*"><colspec colwidth="8*">
563 <entry>GDK_LINE_SOLID</entry>
564 <entry>lines are drawn solid.</entry>
568 <entry>GDK_LINE_ON_OFF_DASH</entry>
569 <entry>even segments are drawn; odd segments are not drawn.</entry>
573 <entry>GDK_LINE_DOUBLE_DASH</entry>
574 <entry>even segments are normally. Odd segments are drawn
575 in the background color if the fill style is %GDK_SOLID,
576 or in the background color masked by the stipple if the
577 fill style is %GDK_STIPPLED.</entry>
580 </tbody></tgroup></informaltable>
584 @GDK_LINE_ON_OFF_DASH:
585 @GDK_LINE_DOUBLE_DASH:
587 <!-- ##### ENUM GdkCapStyle ##### -->
589 Determines how the end of lines are drawn.
591 <informaltable pgwide=1 frame="none" role="struct">
592 <tgroup cols="2"><colspec colwidth="2*"><colspec colwidth="8*">
596 <entry>GDK_CAP_NOT_LAST</entry>
597 <entry>the same as %GDK_CAP_BUTT for lines of non-zero width.
598 for zero width lines, the final point on the line
599 will not be drawn.</entry>
603 <entry>GDK_CAP_BUTT</entry>
604 <entry>the ends of the lines are drawn squared off and extending
605 to the coordinates of the end point.</entry>
609 <entry>GDK_CAP_ROUND</entry>
610 <entry>the ends of the lines are drawn as semicircles with the
611 diameter equal to the line width and centered at the
616 <entry>GDK_CAP_PROJECTING</entry>
617 <entry>the ends of the lines are drawn squared off and extending
618 half the width of the line beyond the end point.</entry>
620 </tbody></tgroup></informaltable>
628 <!-- ##### ENUM GdkJoinStyle ##### -->
630 Determines how the joins between segments of a polygon are drawn.
632 <informaltable pgwide=1 frame="none" role="struct">
633 <tgroup cols="2"><colspec colwidth="2*"><colspec colwidth="8*">
637 <entry>GDK_JOIN_MITER</entry>
638 <entry>the sides of each line are extended to meet at an angle.</entry>
642 <entry>GDK_JOIN_ROUND</entry>
643 <entry>the sides of the two lines are joined by a circular arc.</entry>
647 <entry>GDK_JOIN_BEVEL</entry>
648 <entry>the sides of the two lines are joined by a straight line which
649 makes an equal angle with each line.</entry>
652 </tbody></tgroup></informaltable>
659 <!-- ##### FUNCTION gdk_gc_set_dashes ##### -->
661 Sets the way dashed-lines are drawn. Lines will be
662 drawn with alternating on and off segments of the
663 lengths specified in @dash_list. The manner in
664 which the on and off segments are drawn is determined
665 by the @line_style value of the GC. (This can
666 be changed with gdk_gc_set_line_attributes)
671 @dash_list: an array of dash lengths.
672 @n: the number of elements in @dash_list.
675 <!-- ##### FUNCTION gdk_gc_copy ##### -->
677 Copy the set of values from one graphics context
678 onto another graphics context.
681 @dst_gc: the destination graphics context.
682 @src_gc: the source graphics context.
685 <!-- ##### FUNCTION gdk_gc_set_colormap ##### -->
694 <!-- ##### FUNCTION gdk_gc_get_colormap ##### -->