]> Pileus Git - ~andy/gtk/blob - docs/reference/gdk/tmpl/gcs.sgml
Use the new snazzy mother-of-all-gtk-doc-makefiles.
[~andy/gtk] / docs / reference / gdk / tmpl / gcs.sgml
1 <!-- ##### SECTION Title ##### -->
2 Graphics Contexts
3
4 <!-- ##### SECTION Short_Description ##### -->
5 objects to encapsulate drawing properties.
6
7 <!-- ##### SECTION Long_Description ##### -->
8 <para>
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.
18 </para>
19 <para>
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.
26 </para>
27
28 <!-- ##### SECTION See_Also ##### -->
29 <para>
30
31 </para>
32
33 <!-- ##### STRUCT GdkGC ##### -->
34 <para>
35 The #GdkGC structure represents a graphics context.
36 It is an opaque structure with no user-visible
37 elements.
38 </para>
39
40 @parent_instance: 
41 @clip_x_origin: 
42 @clip_y_origin: 
43 @ts_x_origin: 
44 @ts_y_origin: 
45 @colormap: 
46
47 <!-- ##### STRUCT GdkGCClass ##### -->
48 <para>
49
50 </para>
51
52
53 <!-- ##### STRUCT GdkGCValues ##### -->
54 <para>
55 The #GdkGCValues structure holds a set of values used
56 to create or modify a graphics context.
57
58 <informaltable pgwide=1 frame="none" role="struct">
59 <tgroup cols="2"><colspec colwidth="2*"><colspec colwidth="8*">
60 <tbody>
61
62 <row>
63 <entry>#GdkColor        foreground;</entry>
64 <entry>the foreground color.</entry>
65 </row>
66
67 <row>
68 <entry>#GdkColor        background;</entry>
69 <entry>the background color.</entry>
70 </row>
71
72 <row>
73 <entry>#GdkFont *font;</entry>
74 <entry>the default font..</entry>
75 </row>
76
77 <row>
78 <entry>#GdkFunction function;</entry>
79 <entry>the bitwise operation used when drawing.</entry>
80 </row>
81
82 <row>
83 <entry>#GdkFill fill;</entry>
84 <entry>the fill style.</entry>
85 </row>
86
87 <row>
88 <entry>#GdkPixmap *tile;</entry>
89 <entry>the tile pixmap.</entry>
90 </row>
91
92 <row>
93 <entry>#GdkPixmap *stipple;</entry>
94 <entry>the stipple bitmap.</entry>
95 </row>
96
97 <row>
98 <entry>#GdkPixmap *clip_mask;</entry>
99 <entry>the clip mask bitmap.</entry>
100 </row>
101
102 <row>
103 <entry>#GdkSubwindowMode subwindow_mode;</entry>
104 <entry>the subwindow mode.</entry>
105 </row>
106
107 <row>
108 <entry>#gint ts_x_origin;</entry>
109 <entry>the x origin of the tile or stipple.</entry>
110 </row>
111
112 <row>
113 <entry>#gint ts_y_origin;</entry>
114 <entry>the y origin of the tile or stipple.</entry>
115 </row>
116
117 <row>
118 <entry>#gint clip_x_origin;</entry>
119 <entry>the x origin of the clip mask.</entry>
120 </row>
121
122 <row>
123 <entry>#gint clip_y_origin;</entry>
124 <entry>the y origin of the clip mask.</entry>
125 </row>
126
127 <row>
128 <entry>#gint graphics_exposures;</entry>
129 <entry>whether graphics exposures are enabled.</entry>
130 </row>
131
132 <row>
133 <entry>#gint line_width;</entry>
134 <entry>the line width</entry>
135 </row>
136
137 <row>
138 <entry>#GdkLineStyle line_style;</entry>
139 <entry>the way dashed lines are drawn</entry>
140 </row>
141
142 <row>
143 <entry>#GdkCapStyle cap_style;</entry>
144 <entry>the way the ends of lines are drawn</entry>
145 </row>
146
147 <row>
148 <entry>#GdkJoinStyle join_style;</entry>
149 <entry>the way joins between lines are drawn</entry>
150 </row>
151
152 </tbody></tgroup></informaltable>
153 </para>
154
155 @foreground: 
156 @background: 
157 @font: 
158 @function: 
159 @fill: 
160 @tile: 
161 @stipple: 
162 @clip_mask: 
163 @subwindow_mode: 
164 @ts_x_origin: 
165 @ts_y_origin: 
166 @clip_x_origin: 
167 @clip_y_origin: 
168 @graphics_exposures: 
169 @line_width: 
170 @line_style: 
171 @cap_style: 
172 @join_style: 
173
174 <!-- ##### ENUM GdkGCValuesMask ##### -->
175 <para>
176 A set of bit flags used to indicate which fields
177 #GdkGCValues structure are set.
178 </para>
179
180 @GDK_GC_FOREGROUND: 
181 @GDK_GC_BACKGROUND: 
182 @GDK_GC_FONT: 
183 @GDK_GC_FUNCTION: 
184 @GDK_GC_FILL: 
185 @GDK_GC_TILE: 
186 @GDK_GC_STIPPLE: 
187 @GDK_GC_CLIP_MASK: 
188 @GDK_GC_SUBWINDOW: 
189 @GDK_GC_TS_X_ORIGIN: 
190 @GDK_GC_TS_Y_ORIGIN: 
191 @GDK_GC_CLIP_X_ORIGIN: 
192 @GDK_GC_CLIP_Y_ORIGIN: 
193 @GDK_GC_EXPOSURES: 
194 @GDK_GC_LINE_WIDTH: 
195 @GDK_GC_LINE_STYLE: 
196 @GDK_GC_CAP_STYLE: 
197 @GDK_GC_JOIN_STYLE: 
198
199 <!-- ##### ENUM GdkFunction ##### -->
200 <para>
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.
207 </para>
208
209 @GDK_COPY: 
210 @GDK_INVERT: 
211 @GDK_XOR: 
212 @GDK_CLEAR: 
213 @GDK_AND: 
214 @GDK_AND_REVERSE: 
215 @GDK_AND_INVERT: 
216 @GDK_NOOP: 
217 @GDK_OR: 
218 @GDK_EQUIV: 
219 @GDK_OR_REVERSE: 
220 @GDK_COPY_INVERT: 
221 @GDK_OR_INVERT: 
222 @GDK_NAND: 
223 @GDK_NOR: 
224 @GDK_SET: 
225
226 <!-- ##### FUNCTION gdk_gc_new ##### -->
227 <para>
228 Create a new graphics context with default values. 
229 </para>
230
231 @drawable: 
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.
236
237
238 <!-- ##### FUNCTION gdk_gc_new_with_values ##### -->
239 <para>
240 Create a new GC with the given initial values.
241 </para>
242
243 @drawable: 
244 @values: a structure containing initial values for the GC.
245 @values_mask: a bit mask indicating which fields in @values
246    are set.
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.
251
252
253 <!-- ##### FUNCTION gdk_gc_ref ##### -->
254 <para>
255 Increase the reference count on a graphics context.
256 </para>
257
258 @gc: a #GdkGC.
259 @Returns: @gc.
260
261
262 <!-- ##### FUNCTION gdk_gc_unref ##### -->
263 <para>
264 Decrease the reference count on a graphics context. If
265 the resulting reference count is zero, the graphics
266 context will be destroyed.
267 </para>
268
269 @gc: a #GdkGC.
270
271
272 <!-- ##### MACRO gdk_gc_destroy ##### -->
273 <para>
274 Identical to gdk_gc_unref(). This function is obsolete
275 and should not be used.
276 </para>
277
278 <!-- # Unused Parameters # -->
279 @gc: a #GdkGC.
280
281
282 <!-- ##### FUNCTION gdk_gc_set_values ##### -->
283 <para>
284
285 </para>
286
287 @gc: 
288 @values: 
289 @values_mask: 
290
291
292 <!-- ##### FUNCTION gdk_gc_get_values ##### -->
293 <para>
294 Retrieves the current values from a graphics context.
295 </para>
296
297 @gc: a #GdkGC.
298 @values: the #GdkGCValues structure in which to store the results.
299
300
301 <!-- ##### FUNCTION gdk_gc_set_foreground ##### -->
302 <para>
303 Sets the foreground color for a graphics context.
304 </para>
305
306 @gc: a #GdkGC.
307 @color: the new foreground color.
308
309
310 <!-- ##### FUNCTION gdk_gc_set_background ##### -->
311 <para>
312 Sets the background color for a graphics context.
313 </para>
314
315 @gc: a #GdkGC.
316 @color: the new background color.
317
318
319 <!-- ##### FUNCTION gdk_gc_set_rgb_fg_color ##### -->
320 <para>
321
322 </para>
323
324 @gc: 
325 @color: 
326
327
328 <!-- ##### FUNCTION gdk_gc_set_rgb_bg_color ##### -->
329 <para>
330
331 </para>
332
333 @gc: 
334 @color: 
335
336
337 <!-- ##### FUNCTION gdk_gc_set_font ##### -->
338 <para>
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
342 argument is %NULL.)
343 </para>
344
345 @gc: a #GdkGC.
346 @font: the new font.
347
348
349 <!-- ##### FUNCTION gdk_gc_set_function ##### -->
350 <para>
351 Determines how the current pixel values and the
352 pixel values being drawn are combined to produce
353 the final pixel values.
354 </para>
355
356 @gc: a #GdkGC.
357 @function: 
358
359
360 <!-- ##### FUNCTION gdk_gc_set_fill ##### -->
361 <para>
362 Set the fill mode for a graphics context.
363 </para>
364
365 @gc: a #GdkGC.
366 @fill: the new fill mode.
367
368
369 <!-- ##### ENUM GdkFill ##### -->
370 <para>
371 Determines how primitives are drawn.
372
373 <informaltable pgwide=1 frame="none" role="enum">
374 <tgroup cols="2"><colspec colwidth="2*"><colspec colwidth="8*">
375 <tbody>
376
377 <row>
378 <entry>GDK_SOLID</entry>
379 <entry>draw with the foreground color.</entry>
380 </row>
381
382 <row>
383 <entry>GDK_TILED</entry>
384 <entry>draw with a tiled pixmap.</entry>
385 </row>
386
387 <row>
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>
393 </row>
394
395 <row>
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>
401 </row>
402
403 </tbody></tgroup></informaltable>
404 </para>
405
406 @GDK_SOLID: 
407 @GDK_TILED: 
408 @GDK_STIPPLED: 
409 @GDK_OPAQUE_STIPPLED: 
410
411 <!-- ##### FUNCTION gdk_gc_set_tile ##### -->
412 <para>
413 Set a tile pixmap for a graphics context.
414 This will only be used if the fill mode
415 is %GDK_TILED.
416 </para>
417
418 @gc: a #GdkGC.
419 @tile: the new tile pixmap.
420
421
422 <!-- ##### FUNCTION gdk_gc_set_stipple ##### -->
423 <para>
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.
427 </para>
428
429 @gc: a #GdkGC.
430 @stipple: the new stipple bitmap.
431
432
433 <!-- ##### FUNCTION gdk_gc_set_ts_origin ##### -->
434 <para>
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.
439 </para>
440
441 @gc: a #GdkGC.
442 @x: the x-coordinate of the origin.
443 @y: the y-coordinate of the origin.
444
445
446 <!-- ##### FUNCTION gdk_gc_set_clip_origin ##### -->
447 <para>
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.
451 </para>
452
453 @gc: a #GdkGC.
454 @x: the x-coordinate of the origin.
455 @y: the y-coordinate of the origin.
456
457
458 <!-- ##### FUNCTION gdk_gc_set_clip_mask ##### -->
459 <para>
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()).
463 </para>
464
465 @gc: the #GdkGC.
466 @mask: a bitmap.
467
468
469 <!-- ##### FUNCTION gdk_gc_set_clip_rectangle ##### -->
470 <para>
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()).
474
475 </para>
476
477 @gc: a #GdkGC.
478 @rectangle: the rectangle to clip to.
479
480
481 <!-- ##### FUNCTION gdk_gc_set_clip_region ##### -->
482 <para>
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()).
486 </para>
487
488 @gc: a #GdkGC.
489 @region: the #GdkRegion.
490
491
492 <!-- ##### FUNCTION gdk_gc_set_subwindow ##### -->
493 <para>
494 Sets how drawing with this GC on a window will affect child
495 windows of that window. 
496 </para>
497
498 @gc: a #GdkGC.
499 @mode: the subwindow mode.
500
501
502 <!-- ##### ENUM GdkSubwindowMode ##### -->
503 <para>
504
505 Determines how drawing onto a window will affect child
506 windows of that window. 
507
508 <informaltable pgwide=1 frame="none" role="enum">
509 <tgroup cols="2"><colspec colwidth="3*"><colspec colwidth="7*">
510 <tbody>
511
512 <row>
513 <entry>GDK_CLIP_BY_CHILDREN</entry>
514 <entry>only draw onto the window itself.</entry>
515 </row>
516
517 <row>
518 <entry>GDK_INCLUDE_INFERIORS</entry>
519 <entry>Draw onto the window and child windows.</entry>
520 </row>
521
522 </tbody></tgroup></informaltable>
523 </para>
524
525 @GDK_CLIP_BY_CHILDREN: 
526 @GDK_INCLUDE_INFERIORS: 
527
528 <!-- ##### FUNCTION gdk_gc_set_exposures ##### -->
529 <para>
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()).
534 </para>
535
536 @gc: a #GdkGC.
537 @exposures: if %TRUE, exposure events will be generated.
538
539
540 <!-- ##### FUNCTION gdk_gc_set_line_attributes ##### -->
541 <para>
542 Sets various attributes of how lines are drawn. See
543 the corresponding members of GdkGCValues for full
544 explanations of the arguments.
545 </para>
546
547 @gc: a #GdkGC.
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.
552
553
554 <!-- ##### ENUM GdkLineStyle ##### -->
555 <para>
556 Determines how lines are drawn.
557
558 <informaltable pgwide=1 frame="none" role="enum">
559 <tgroup cols="2"><colspec colwidth="2*"><colspec colwidth="8*">
560 <tbody>
561
562 <row>
563 <entry>GDK_LINE_SOLID</entry>
564 <entry>lines are drawn solid.</entry>
565 </row>
566
567 <row>
568 <entry>GDK_LINE_ON_OFF_DASH</entry>
569 <entry>even segments are drawn; odd segments are not drawn.</entry>
570 </row>
571
572 <row>
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>
578 </row>
579
580 </tbody></tgroup></informaltable>
581 </para>
582
583 @GDK_LINE_SOLID: 
584 @GDK_LINE_ON_OFF_DASH: 
585 @GDK_LINE_DOUBLE_DASH: 
586
587 <!-- ##### ENUM GdkCapStyle ##### -->
588 <para>
589 Determines how the end of lines are drawn.
590
591 <informaltable pgwide=1 frame="none" role="struct">
592 <tgroup cols="2"><colspec colwidth="2*"><colspec colwidth="8*">
593 <tbody>
594
595 <row>
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>
600 </row>
601
602 <row>
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>
606 </row>
607
608 <row>
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
612        end point.</entry>
613 </row>
614
615 <row>
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>
619 </row>
620 </tbody></tgroup></informaltable>
621 </para>
622
623 @GDK_CAP_NOT_LAST: 
624 @GDK_CAP_BUTT: 
625 @GDK_CAP_ROUND: 
626 @GDK_CAP_PROJECTING: 
627
628 <!-- ##### ENUM GdkJoinStyle ##### -->
629 <para>
630 Determines how the joins between segments of a polygon are drawn.
631
632 <informaltable pgwide=1 frame="none" role="struct">
633 <tgroup cols="2"><colspec colwidth="2*"><colspec colwidth="8*">
634 <tbody>
635
636 <row>
637 <entry>GDK_JOIN_MITER</entry>
638 <entry>the sides of each line are extended to meet at an angle.</entry>
639 </row>
640
641 <row>
642 <entry>GDK_JOIN_ROUND</entry>
643 <entry>the sides of the two lines are joined by a circular arc.</entry>
644 </row>
645
646 <row>
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>
650 </row>
651
652 </tbody></tgroup></informaltable>
653 </para>
654
655 @GDK_JOIN_MITER: 
656 @GDK_JOIN_ROUND: 
657 @GDK_JOIN_BEVEL: 
658
659 <!-- ##### FUNCTION gdk_gc_set_dashes ##### -->
660 <para>
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)
667 </para>
668
669 @gc: a #GdkGC.
670 @dash_offset: the
671 @dash_list: an array of dash lengths.
672 @n: the number of elements in @dash_list.
673
674
675 <!-- ##### FUNCTION gdk_gc_copy ##### -->
676 <para>
677 Copy the set of values from one graphics context
678 onto another graphics context.
679 </para>
680
681 @dst_gc: the destination graphics context.
682 @src_gc: the source graphics context.
683
684
685 <!-- ##### FUNCTION gdk_gc_set_colormap ##### -->
686 <para>
687
688 </para>
689
690 @gc: 
691 @colormap: 
692
693
694 <!-- ##### FUNCTION gdk_gc_get_colormap ##### -->
695 <para>
696
697 </para>
698
699 @gc: 
700 @Returns: 
701
702