Créer  Editer  FrontPage  Index  Chercher  Changements  History  RSS  Login

Gdk::GC

class Gdk::GC

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.

Class Methods

Gdk::GC.new(drawable)
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.
  • Returns: the new Gdk::GC

Instance Methods

screen
Gets the Gdk::Screen for which gc was created. Since 2.2
  • Returns: The Gdk::Screnn? for the Gdk::GC.
foreground
Gets the forground color for a graphics context.
foreground=(color)
Sets the foreground color for a graphics context. Note that this method uses color.pixel, use Gdk::GC#rgb_fg_color= to specify the foreground color as red, green, blue components.
set_foreground(color)
Same as Gdk::GC#foreground=.
background
Gets the background color for a graphic context.
  • Returns: self
background=(color)
Sets the background color for a graphics context. Note that this method uses color.pixel, use Gdk::GC#rgb_bg_color= to specify the background color as red, green, blue components.
set_background(color)
Same as Gdk::GC#background=.
rgb_fg_color=(color)
Set the foreground color of a GC using an unallocated color. The pixel value for the color will be determined using Gdk::RGB. If the colormap for the GC has not previously been initialized for Gdk::RGB, then for pseudo-color colormaps (colormaps with a small modifiable number of colors), a colorcube will be allocated in the colormap. Calling this method for a GC without a colormap is an error.
  • color: an unallocated Gdk::Color.
  • Returns: color
set_rgb_fg_color
Same as Gdk::GC#rgb_fg_color=.
rgb_bg_color=(color)
Set the background color of a GC using an unallocated color. The pixel value for the color will be determined using Gdk::RGB. If the colormap for the GC has not previously been initialized for Gdk::RGB, then for pseudo-color colormaps (colormaps with a small modifiable number of colors), a colorcube will be allocated in the colormap. Calling this method for a GC without a colormap is an error.
  • color: an unallocated Gdk::Color.
  • Returns: color
set_rgb_bg_color
Same as Gdk::GC#rgb_bg_color=.
function
Gets the function. See Gdk::GC#function=.
  • Returns: the function
function=(function)
Determines how the current pixel values and the pixel values being drawn are combined to produce the final pixel values.
set_function(function)
Same as Gdk::GC#function=.
fill
Gets the fill mode. See Gdk::GC#fill=.
  • Returns: the fill mode
fill=(fill)
Sets the fill mode for a graphics context.
  • fill: the new fill mode. (GdkFill).
  • Returns: fill
set_fill(fill)
Same as Gdk::GC#fill=.
  • fill: the new fill mode. (GdkFill).
  • Returns: self
tile
Gets a tile pixmap for a graphics context.
tile=(tile)
Sets a tile pixmap for a graphics context. This will only be used if the fill mode is Gdk::GC::TILED.
set_tile(tile)
Same as Gdk::GC#tile=.
stipple
Gets a stipple bitmap for a graphic context.
stipple=(stipple)
Set the stipple bitmap for a graphics context. The stipple will only be used if the fill mode is Gdk::GC::STIPPLED or Gdk::GC::OPAQUE_STIPPLED.
  • stipple: the new stipple bitmap (Gdk::Pixmap)
  • Returns: self
set_stipple(stipple)
Same as Gdk::GC#stipple=.
  • stipple: the new stipple bitmap (Gdk::Pixmap)
  • Returns: self
ts_origin
Gets the origin when using tile or stiples with the GC.
  • Returns: [x, y]
set_ts_origin(x, y)
Sets 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.
  • x: the x-coordinate of the origin. (Integer)
  • y: the y-coordinate of the origin. (Integer)
  • Returns: self
clip_origin
Gets the origin of the clip mask.
  • Returns: [x, y]
set_clip_origin(x, y)
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.
  • x: the x-coordinate of the origin. (Integer)
  • y: the y-coordinate of the origin. (Integer)
  • Returns: self
clip_mask
Gets the clip mask for a graphics context from a bitmap.
  • Returns: self
clip_mask=(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).
  • mask: a bitmap. (Gdk::Pixmap, dipth = 1)
  • Returns: mask
set_clip_mask(mask)
Same as Gdk::GC#clip_mask=.
  • mask: a bitmap. (Gdk::Pixmap, dipth = 1)
  • Returns: self
clip_rectangle=(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).
set_clip_rectangle(rectangle)
Same as Gdk::GC#clip_rectangle=.
clip_region=(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).
set_clip_region(region)
Same as Gdk::GC#clip_region=.
subwindow_mode
Gets the subwindow mode. See Gdk::GC#subwindow_mode=.
  • Returns: self
subwindow_mode=(mode)
Sets how drawing with this GC on a window will affect child windows of that window.
set_subwindow_mode(mode)
Same as Gdk::GC#subwindow_mode=.
exposures?
Gets the exposures. See Gdk::GC#exposures=.
  • Returns: if true, exposure events will be generated.
exposures=(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::Drawable#draw_drawable).
  • exposures: if true, exposure events will be generated.
  • Returns: exposures
set_exposures(exposures)
Same as Gdk::GC#exposures=.
  • exposures: if true, exposure events will be generated.
  • Returns: self
line_attributes
Gets various attributes of how lines are drawn. See Gdk::GC#set_line_attributes.
  • Returns: [line_width, line_style, cap_style, join_style]
set_line_attributes(line_width, line_style, cap_style, join_style)
Sets various attributes of how lines are drawn.
  • line_width: the width of lines. (Integer)
  • line_style: the dash-style for lines. (GdkLineStyle)
  • cap_style: the manner in which the ends of lines are drawn. (GdkCapStyle)
  • join_style: the in which lines are joined together. (GdkJoinStyle)
  • Returns: self
set_dashes(dash_offset, 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.) The dash_offset defines the phase of the pattern, specifying how many pixels into the dash-list the pattern should actually begin.
  • dash_offset: the phase of the dash pattern. (Integer)
  • dashes: an Array of dash lengths(Integer).
  • Returns: self
copy(dest_gc)
copy(drawable)
Copy the set of values from one graphics context onto another graphics context.
  • dest_gc: the destination graphics context. (destructive!)
  • drawable: a Gdk::Drawable to create the destination graphics context.
  • Returns: a new graphics context.
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#colormap=.
  • Returns: the Gdk::Colormap of GC, or nil if GC doesn't have one.
  • Returns: self
colormap=(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.
set_colormap(colormap)
Same as Gdk::GC#colormap=.
offset(x_offset, y_offset)
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.
  • x_offset: amount by which to offset the GC in the X direction (Integer)
  • y_offset: amount by which to offset the GC in the Y direction (Integer)
  • Returns: self

Constants

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::GC::COPY, Gdk::GC::XOR and Gdk::GC::INVERT are generally useful. For bitmaps, Gdk::GC::AND and Gdk::GC::OR are also useful.

COPY
src
INVERT
NOT dst
XOR
src XOR dst
CLEAR
0
AND
src AND dst
AND_REVERSE
src AND (NOT dst)
AND_INVERT
(NOT src) AND dst
NOOP
dst
OR
src OR dst
EQUIV
(NOT src) XOR dst
OR_REVERSE
src OR (NOT dst)
COPY_INVERT
NOT src
OR_INVERT
(NOT src) AND dst
NAND
NOT (src AND dst)
NOR
NOT src AND NOT dst
SET
1

GdkFill

Determines how primitives are drawn.

SOLID
draw with the foreground color.
TILED
draw with a tiled pixmap.
STIPPLED
draw using the stipple bitmap. Pixels corresponding to bits in the stipple bitmap that are set will be drawn in the foreground color; pixels corresponding to bits that are not set will be left untouched.
OPAQUE_STIPPLED
draw using the stipple bitmap. Pixels corresponding to bits in the stipple bitmap that are set will be drawn in the foreground color; pixels corresponding to bits that are not set will be drawn with the background color.

GdkSubwindowMode

Determines how drawing onto a window will affect child windows of that window.

CLIP_BY_CHILDREN
= 0, only draw onto the window itself.
INCLUDE_INFERIORS
= 1, draw onto the window and child windows.

GdkLineStyle

Determines how lines are drawn.

LINE_SOLID
lines are drawn solid.
LINE_ON_OFF_DASH
even segments are drawn; odd segments are not drawn.
LINE_DOUBLE_DASH
even segments are normally. Odd segments are drawn in the background color if the fill style is Gdk::GC::SOLID, or in the background color masked by the stipple if the fill style is Gdk::GC::STIPPLED.

GdkCapStyle

Determines how the end of lines are drawn.

CAP_NOT_LAST
the same as Gdk::GC::CAP_BUTT for lines of non-zero width. for zero width lines, the final point on the line will not be drawn.
CAP_BUTT
the ends of the lines are drawn squared off and extending to the coordinates of the end point.
CAP_ROUND
the ends of the lines are drawn as semicircles with the diameter equal to the line width and centered at the end point.
CAP_PROJECTING
the ends of the lines are drawn squared off and extending half the width of the line beyond the end point.

GdkJoinStyle

Determines how the joins between segments of a polygon are drawn.

JOIN_MITER
the sides of each line are extended to meet at an angle.
JOIN_ROUND
the sides of the two lines are joined by a circular arc.
JOIN_BEVEL
the sides of the two lines are joined by a straight line which makes an equal angle with each line.

ChangeLog

  • 2005-05-07 Added. - Masao?
Dernière modification:2011/06/22 19:21:30
Mots clef:
Références:[Gdk::Drawable] [Gdk::GC] [Gdk::RGB] [Gdk::Region] [Gtk::Style]