Objects to encapsulate drawing properties
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.
<gdk-drawable>
) ⇒ (ret <gdk-gc>
)Create a new graphics context with default values.
- drawable
- a
<gdk-drawable>
. The created GC must always be used with drawables of the same depth as this one.- ret
- the new graphics context.
<gdk-gc>
) ⇒ (ret <gdk-screen>
)Gets the
<gdk-screen>
for which gc was created
- gc
- a
<gdk-gc>
.- ret
- the
<gdk-screen>
for gc.Since 2.2
<gdk-gc>
) (color <gdk-color>
)Sets the foreground color for a graphics context. Note that this function uses color->pixel, use
gdk-gc-set-rgb-fg-color
to specify the foreground color as red, green, blue components.
- gc
- a
<gdk-gc>
.- color
- the new foreground color.
<gdk-gc>
) (color <gdk-color>
)Sets the background color for a graphics context. Note that this function uses color->pixel, use
gdk-gc-set-rgb-bg-color
to specify the background color as red, green, blue components.
- gc
- a
<gdk-gc>
.- color
- the new background color.
<gdk-gc>
) (color <gdk-color>
)Set the foreground color of a GC using an unallocated color. The pixel value for the color will be determined using GdkRGB. If the colormap for the GC has not previously been initialized for GdkRGB, then for pseudo-color colormaps (colormaps with a small modifiable number of colors), a colorcube will be allocated in the colormap.
Calling this function for a GC without a colormap is an error.
- gc
- a
<gdk-gc>
- color
- an unallocated
<gdk-color>
.
<gdk-gc>
) (color <gdk-color>
)Set the background color of a GC using an unallocated color. The pixel value for the color will be determined using GdkRGB. If the colormap for the GC has not previously been initialized for GdkRGB, then for pseudo-color colormaps (colormaps with a small modifiable number of colors), a colorcube will be allocated in the colormap.
Calling this function for a GC without a colormap is an error.
- gc
- a
<gdk-gc>
- color
- an unallocated
<gdk-color>
.
<gdk-gc>
) (font <gdk-font>
)‘gdk_gc_set_font’ is deprecated and should not be used in newly-written code.
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 ‘
#f
’.)
- gc
- a
<gdk-gc>
.- font
- the new font.
<gdk-gc>
) (function <gdk-function>
)Determines how the current pixel values and the pixel values being drawn are combined to produce the final pixel values.
- gc
- a
<gdk-gc>
.- function
- the
<gdk-function>
to use
<gdk-gc>
) (fill <gdk-fill>
)Set the fill mode for a graphics context.
- gc
- a
<gdk-gc>
.- fill
- the new fill mode.
<gdk-gc>
) (tile <gdk-pixmap>
)Set a tile pixmap for a graphics context. This will only be used if the fill mode is ‘GDK_TILED’.
- gc
- a
<gdk-gc>
.- tile
- the new tile pixmap.
<gdk-gc>
) (stipple <gdk-pixmap>
)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’.
- gc
- a
<gdk-gc>
.- stipple
- the new stipple bitmap.
<gdk-gc>
) (x int
) (y int
)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.
- gc
- a
<gdk-gc>
.- x
- the x-coordinate of the origin.
- y
- the y-coordinate of the origin.
<gdk-gc>
) (x int
) (y int
)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.
- gc
- a
<gdk-gc>
.- x
- the x-coordinate of the origin.
- y
- the y-coordinate of the origin.
<gdk-gc>
) (mask <gdk-drawable>
)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
).
- gc
- the
<gdk-gc>
.- mask
- a bitmap.
<gdk-gc>
) (rectangle <gdk-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
).
- gc
- a
<gdk-gc>
.- rectangle
- the rectangle to clip to.
<gdk-gc>
) (region <gdk-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
).
- gc
- a
<gdk-gc>
.- region
- the
<gdk-region>
.
<gdk-gc>
) (mode <gdk-subwindow-mode>
)Sets how drawing with this GC on a window will affect child windows of that window.
- gc
- a
<gdk-gc>
.- mode
- the subwindow mode.
<gdk-gc>
) (exposures bool
)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-drawable
).
- gc
- a
<gdk-gc>
.- exposures
- if ‘
#t
’, exposure events will be generated.
<gdk-gc>
) (line_width int
) (line_style <gdk-line-style>
) (cap_style <gdk-cap-style>
) (join_style <gdk-join-style>
)Sets various attributes of how lines are drawn. See the corresponding members of
<gdk-gc-values>
for full explanations of the arguments.
- gc
- a
<gdk-gc>
.- line-width
- the width of lines.
- line-style
- the dash-style for lines.
- cap-style
- the manner in which the ends of lines are drawn.
- join-style
- the in which lines are joined together.
<gdk-gc>
) (src_gc <gdk-gc>
)Copy the set of values from one graphics context onto another graphics context.
- dst-gc
- the destination graphics context.
- src-gc
- the source graphics context.
<gdk-gc>
) (colormap <gdk-colormap>
)Sets the colormap for the GC to the given colormap. The depth of the colormap's visual must match the depth of the drawable for which the GC was created.
- gc
- a
<gdk-gc>
- colormap
- a
<gdk-colormap>
<gdk-gc>
) ⇒ (ret <gdk-colormap>
)Retrieves the colormap for a given GC, if it exists. A GC will have a colormap if the drawable for which it was created has a colormap, or if a colormap was set explicitely with gdk_gc_set_colormap.
- gc
- a
<gdk-gc>
- ret
- the colormap of gc, or ‘
#f
’ if gc doesn't have one.
<gdk-gc>
) (x_offset int
) (y_offset int
)Offset attributes such as the clip and tile-stipple origins of the GC so that drawing at x - x_offset, y - y_offset with the offset GC has the same effect as drawing at x, y with the original GC.
- gc
- a
<gdk-gc>
- x-offset
- amount by which to offset the GC in the X direction
- y-offset
- amount by which to offset the GC in the Y direction