---
name: "Gtk2::Gdk::GC"
section: "3pm"
platform: "linux"
package: "libgtk2-perl-doc"
version: "2:1.24992-1"
release: "Debian 10 (Buster)"
platforms: ["linux"]
url: "https://new.carta.tech/Gtk2::Gdk::GC"
---

# Gtk2::Gdk::GC(3pm)

wrapper for GdkGC

## NAME

Gtk2::Gdk::GC - wrapper for GdkGC

## HIERARCHY

```
  Glib::Object
  +----Gtk2::Gdk::GC
```

## METHODS

### gc = Gtk2::Gdk::GC-\>new ($drawable, $values=undef)

- •

  `$drawable` (Gtk2::Gdk::Drawable)

- •

  `$values` (scalar)

Create and return a new GC.

`$drawable` is used for the depth and the display (`"Gtk2::Gdk::Display"`) for the GC.  The GC can then be used with any drawable of the same depth on that display.

`$values` is a hashref containing some of the following keys,

```
    foreground          Gtk2::Gdk::Color
    background          Gtk2::Gdk::Color
    font                Gtk2::Gdk::Font
    function            Gtk2::Gdk::Function enum
    fill                Gtk2::Gdk::Fill enum
    tile                Gtk2::Gdk::Pixmap
    stipple             Gtk2::Gdk::Pixmap
    clip_mask           Gtk2::Gdk::Pixmap
    subwindow_mode      Gtk2::Gdk::SubwindowMode enum
    ts_x_origin         integer
    ts_y_origin         integer
    clip_x_origin       integer
    clip_y_origin       integer
    graphics_exposures  boolean integer 1 or 0
    line_width          integer
    line_style          Gtk2::Gdk::LineStyle enum
    cap_style           Gtk2::Gdk::CapStyle enum
    join_style          Gtk2::Gdk::JoinStyle enum
```

Keys not given get default values.  For the `"foreground"` and `"background"` colour objects only the `"pixel"` field is used; the red, green and blue are ignored.  For example

```
    my $pixel = 0x123456;
    my $color = Gtk2::Gdk::Color->new (0,0,0, $pixel);
    my $gc = Gtk2::Gdk::GC->new_with_values
      ($win, { foreground => $color,
               line_style => 'on_off_dash' });
```

### gc = Gtk2::Gdk::GC-\>new\_with\_values ($drawable, $values=undef)

- •

  `$drawable` (Gtk2::Gdk::Drawable)

- •

  `$values` (scalar)

### $gc-\>set\_background ($color)

- •

  `$color` (Gtk2::Gdk::Color)

### $gc-\>set\_clip\_mask ($mask)

- •

  `$mask` (scalar)

### $gc-\>set\_clip\_origin ($x, $y)

- •

  `$x` (integer)

- •

  `$y` (integer)

### $gc-\>set\_clip\_rectangle ($rectangle)

- •

  `$rectangle` (Gtk2::Gdk::Rectangle or undef)

### $gc-\>set\_clip\_region ($region)

- •

  `$region` (Gtk2::Gdk::Region or undef)

### colormap = $gc-\>get\_colormap

### $gc-\>set\_colormap ($colormap)

- •

  `$colormap` (Gtk2::Gdk::Colormap)

### $dst\_gc-\>copy ($src\_gc)

- •

  `$src_gc` (Gtk2::Gdk::GC)

### $gc-\>set\_dashes ($dash\_offset, ...)

- •

  `$dash_offset` (integer)

- •

  ... (list) of integers, the length of the dash segments

Sets the way dashed-lines are drawn. Lines will be drawn with alternating on and off segments of the lengths specified in list of dashes. The manner in which the on and off segments are drawn is determined by the line\_style value of the GC.

### $gc-\>set\_exposures ($exposures)

- •

  `$exposures` (boolean)

### $gc-\>set\_fill ($fill)

- •

  `$fill` (Gtk2::Gdk::Fill)

### $gc-\>set\_font ($font)

- •

  `$font` (Gtk2::Gdk::Font)

### $gc-\>set\_foreground ($color)

- •

  `$color` (Gtk2::Gdk::Color)

### $gc-\>set\_function ($function)

- •

  `$function` (Gtk2::Gdk::Function)

### $gc-\>set\_line\_attributes ($line\_width, $line\_style, $cap\_style, $join\_style)

- •

  `$line_width` (integer)

- •

  `$line_style` (Gtk2::Gdk::LineStyle)

- •

  `$cap_style` (Gtk2::Gdk::CapStyle)

- •

  `$join_style` (Gtk2::Gdk::JoinStyle)

### $gc-\>offset ($x\_offset, $y\_offset)

- •

  `$x_offset` (integer)

- •

  `$y_offset` (integer)

### $gc-\>set\_rgb\_background ($rgb)

- •

  `$rgb` (unsigned)

### $gc-\>set\_rgb\_bg\_color ($color)

- •

  `$color` (Gtk2::Gdk::Color)

### $gc-\>set\_rgb\_fg\_color ($color)

- •

  `$color` (Gtk2::Gdk::Color)

### $gc-\>set\_rgb\_foreground ($rgb)

- •

  `$rgb` (unsigned)

### $gc-\>rgb\_gc\_set\_background ($rgb)

- •

  `$rgb` (unsigned)

### $gc-\>rgb\_gc\_set\_foreground ($rgb)

- •

  `$rgb` (unsigned)

### screen = $gc-\>get\_screen

Since: gtk+ 2.2

### $gc-\>set\_stipple ($stipple)

- •

  `$stipple` (Gtk2::Gdk::Pixmap)

### $gc-\>set\_subwindow ($mode)

- •

  `$mode` (Gtk2::Gdk::SubwindowMode)

### $gc-\>set\_tile ($tile)

- •

  `$tile` (Gtk2::Gdk::Pixmap)

### $gc-\>set\_ts\_origin ($x, $y)

- •

  `$x` (integer)

- •

  `$y` (integer)

### scalar = $gc-\>get\_values

Return the attributes of `$gc` in the form of a hashref with keys and values as described with `"new"` above.

In the `"foreground"` and `"background"` colour objects returned only the `"pixel"` fields are set; the red, green and blue fields are garbage.

### $gc-\>set\_values ($values)

- •

  `$values` (scalar)

Set some of the attributes of `$gc`.  `$values` is a hashref of keys and values as described for `"new"` and `"new_with_values"` above. Fields not present in `$values` are left unchanged.

## ENUMS AND FLAGS

### enum Gtk2::Gdk::CapStyle

- •

  'not-last' / 'GDK\_CAP\_NOT\_LAST'

- •

  'butt' / 'GDK\_CAP\_BUTT'

- •

  'round' / 'GDK\_CAP\_ROUND'

- •

  'projecting' / 'GDK\_CAP\_PROJECTING'

### enum Gtk2::Gdk::Fill

- •

  'solid' / 'GDK\_SOLID'

- •

  'tiled' / 'GDK\_TILED'

- •

  'stippled' / 'GDK\_STIPPLED'

- •

  'opaque-stippled' / 'GDK\_OPAQUE\_STIPPLED'

### enum Gtk2::Gdk::Function

- •

  'copy' / 'GDK\_COPY'

- •

  'invert' / 'GDK\_INVERT'

- •

  'xor' / 'GDK\_XOR'

- •

  'clear' / 'GDK\_CLEAR'

- •

  'and' / 'GDK\_AND'

- •

  'and-reverse' / 'GDK\_AND\_REVERSE'

- •

  'and-invert' / 'GDK\_AND\_INVERT'

- •

  'noop' / 'GDK\_NOOP'

- •

  'or' / 'GDK\_OR'

- •

  'equiv' / 'GDK\_EQUIV'

- •

  'or-reverse' / 'GDK\_OR\_REVERSE'

- •

  'copy-invert' / 'GDK\_COPY\_INVERT'

- •

  'or-invert' / 'GDK\_OR\_INVERT'

- •

  'nand' / 'GDK\_NAND'

- •

  'nor' / 'GDK\_NOR'

- •

  'set' / 'GDK\_SET'

### enum Gtk2::Gdk::JoinStyle

- •

  'miter' / 'GDK\_JOIN\_MITER'

- •

  'round' / 'GDK\_JOIN\_ROUND'

- •

  'bevel' / 'GDK\_JOIN\_BEVEL'

### enum Gtk2::Gdk::LineStyle

- •

  'solid' / 'GDK\_LINE\_SOLID'

- •

  'on-off-dash' / 'GDK\_LINE\_ON\_OFF\_DASH'

- •

  'double-dash' / 'GDK\_LINE\_DOUBLE\_DASH'

### enum Gtk2::Gdk::SubwindowMode

- •

  'clip-by-children' / 'GDK\_CLIP\_BY\_CHILDREN'

- •

  'include-inferiors' / 'GDK\_INCLUDE\_INFERIORS'

## SEE ALSO

Gtk2, Glib::Object

## COPYRIGHT

Copyright (C) 2003-2011 by the gtk2-perl team.

This software is licensed under the LGPL.  See Gtk2 for a full notice.
