Reference Manual

Main Page | Namespace List | Class Hierarchy | Alphabetical List | Compound List | File List | Namespace Members | Compound Members | File Members

# Inti::Gdk::GC Class Reference

A GdkGC C++ wrapper class. More...

`#include <inti/gdk/gc.h>`

Inheritance diagram for Inti::Gdk::GC:

List of all members.

## Public Member Functions

Constructors

- GC (Drawable &drawable)
    Construct a new graphics context with default values.
- GC (Drawable &drawable, const GCValues &values)
    Construct a new graphics context with the given initial values.
- virtual ~GC ()
    Destructor.

Accessors

- GdkGC * gdk_gc () const
    Get a pointer to the GdkGC structure.
- GdkGCClass * gdk_gc_class () const
    Get a pointer to the GdkGCClass structure.
- operator GdkGC * () const
    Conversion operator; safely converts a GC to a GdkGC pointer.
- int ts_x_origin () const
    Returns the x origin of the tile or stipple.
- int ts_y_origin () const
    Returns the y origin of the tile or stipple.
- int clip_x_origin () const
    Returns the x origin of the clip mask.
- int clip_y_origin () const
    Returns the y origin of the clip mask.
- void get_values (GCValues &values) const
    Retrieves the current values from a graphics context.
- Colormap * get_colormap () const
    Retrieves the colormap for a given GC, if it exists.
- Screen * get_screen () const
    Gets the Screen for which the graphics context was created.

Methods

- void set_values (const GCValues &values)
    Sets attributes of a graphics context in bulk.
- void set_foreground (const Color &color)
    Sets the foreground color for the graphics context.
- void set_background (const Color &color)
    Sets the background color for the graphics context.
- void set_function (Function function)
    Determines how the current pixel values and the pixel values being drawn are combined to produce the final pixel values.
- void set_fill (Fill fill)
    Set the fill mode for the graphics context.
- void set_tile (Pixmap &tile)
    Set a tile pixmap for the graphics context.
- void set_stipple (Pixmap &stipple)
    Set the stipple bitmap for the graphics context.
- void set_ts_origin (int x, int y)
    Set the origin when using tiles or stipples with the graphics context.
- void set_ts_origin (const Point &point)
    Set the origin when using tiles or stipples with the graphics context.
- void set_clip_origin (int x, int y)
    Sets the origin of the clip mask.
- void set_clip_origin (const Point &point)
    Sets the origin of the clip mask.
- void set_clip_mask (Bitmap &mask)
    Sets the clip mask for a graphics context from a bitmap.
- void set_clip (int x, int y, int width, int height)
    Sets the clip mask for a graphics context from a rectangle.
- void set_clip (const Rectangle &rectangle)
    Sets the clip mask for a graphics context from a rectangle.
- void set_clip (const Region &region)
    Sets the clip mask for a graphics context from a region.
- void set_subwindow (SubwindowMode mode)
    Sets how drawing with this graphics context on a window will affect child windows of that window.
- void set_exposures (bool exposures)
    Sets whether copying non-visible portions of a drawable using a graphics context generates exposure events for the corresponding regions of the destination drawable (see Gdk::Drawable::draw_drawable()).
- void set_line_attributes (int line_width, LineStyle line_style, CapStyle cap_style, JoinStyle join_style)
    Sets various attributes of how lines are drawn.
- void set_line_width (int line_width)
    Sets the line width.
- void set_line_style (LineStyle line_style)
    Sets the way dashed lines are drawn.
- void set_cap_style (CapStyle cap_style)
    Sets the way the ends of lines are drawn.
- void set_join_style (JoinStyle join_style)
    Sets the way joins between lines are drawn.
- void set_dashes (int dash_offset, const std::vector< gint8 > &dash_list)
    Sets the way dashed-lines are drawn.
- void offset (int x_offset, int 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.
- void set_colormap (Colormap *colormap)
    Sets the colormap for the GC to the given colormap.
- void set_rgb_fg_color (const Color &color)
    Set the foreground color of a GC using an unallocated color.
- void set_rgb_bg_color (const Color &color)
    Set the background color of a GC using an unallocated color.

## Protected Member Functions

Constructors

- GC ()
    Construct a new graphics context.
- GC (GdkGC *gc, bool reference=true)
    Construct a new GC from an existing GdkGC.

## Detailed Description

A GdkGC C++ wrapper class.

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 a GCValues object, or can be set one-by-one using functions such as set_foreground(). A few of the values in the GC, such as the dash pattern, can only be set by the latter method.

Graphics contexts are created with the following default values:

- foreground = 0 (first entry in colormap - usually black)
- background = 1 (last entry in colormap - usually white)
- font = unused
- function = GC_COPY
- fill = SOLID
- tile = foreground fill pixmap
- stipple = Pixmap filled with 1s
- clip_mask = none
- subwindow_mode = CLIP_BY_CHILDREN
- ts_x_origin = 0
- ts_y_origin = 0
- clip_x_origin = 0
- clip_y_origin = 0
- graphics_exposure = true
- line_width = 0
- line_style = LINE_SOLID
- cap_style = CAP_BUTT
- join_style = JOIN_MITIR

As a rule it is not a good idea to modify the GC's retrieved from a widget style (see Gtk::Style). Widget's rely on these GC's and modifying them could modify the appearence of the widget. The best thing to do is the create your own and change one or more of the default values, either at construction time or later with one of the set_() methods.

GC's are not added to any other widget so you need to manage its memory allocation yourself. This means that you need to call unref() on the GC when you're finished with it. If you created the GC using a smart pointer, the smart pointer will call unref() for you when it goes out of scope.

The GCValues object allows you to set multiple values at once when constructing or modifying a graphics context. Just set the values you want and then pass your GCValues object to the Gdk::GC constructor or the Gdk::GC::set_values method if your modifying the graphics context later. You can retreive all the currently set values for a Gdk::GC by calling get_values.

## Constructor & Destructor Documentation

Inti::Gdk::GC::GC | ( | GdkGC * | gc,
|  | bool | reference = true
| ) | `[explicit, protected]`

Construct a new GC from an existing GdkGC.

Parameters:

  gc | A pointer to a GdkGC.
  reference | Set false if the initial reference count is floating, set true if it's not.

The gc can be a newly created GdkGC or an existing GdkGC. (see G::Object::Object).

Inti::Gdk::GC::GC | ( | Drawable & | drawable | ) | `[explicit]`

Construct a new graphics context with default values.

Parameters:

  drawable | A Drawable.

Note: The created GC must always be used with drawables of the same depth as drawable.

Inti::Gdk::GC::GC | ( | Drawable & | drawable,
|  | const GCValues & | values
| ) |

Construct a new graphics context with the given initial values.

Parameters:

  drawable | A Drawable.
  values | A GCValues object containing the initial values for the graphics context.

## Member Function Documentation

Colormap* Inti::Gdk::GC::get_colormap | ( |  | ) | const

Retrieves the colormap for a given GC, if it exists.

Returns:
  A Colormap.

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 set_colormap.

Screen* Inti::Gdk::GC::get_screen | ( |  | ) | const

Gets the Screen for which the graphics context was created.

Returns:
  The GdkScreen for the graphics context.

void Inti::Gdk::GC::get_values | ( | GCValues & | values | ) | const

Retrieves the current values from a graphics context.

Parameters:

  values | The GCValues object in which to store the results.

void Inti::Gdk::GC::offset | ( | int | x_offset,
|  | int | 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.

Parameters:

  x_offset | The amount by which to offset the GC in the X direction.
  y_offset | The amount by which to offset the GC in the Y direction.

void Inti::Gdk::GC::set_background | ( | const Color & | color | ) |

Sets the background color for the graphics context.

Parameters:

  color | The new background color.

void Inti::Gdk::GC::set_cap_style | ( | CapStyle | cap_style | ) |

Sets the way the ends of lines are drawn.

Parameters:

  cap_style | The manner in which the ends of lines are drawn.

void Inti::Gdk::GC::set_clip | ( | const Region & | region | ) |

Sets the clip mask for a graphics context from a region.

Parameters:

  region | The Region.

The clip mask is interpreted relative to the clip origin (see set_clip_origin()).

void Inti::Gdk::GC::set_clip | ( | const Rectangle & | rectangle | ) |

Sets the clip mask for a graphics context from a rectangle.

Parameters:

  rectangle | The rectangle to clip to.

The clip mask is interpreted relative to the clip origin (see set_clip_origin()).

void Inti::Gdk::GC::set_clip | ( | int | x,
|  | int | y,
|  | int | width,
|  | int | height
| ) |

Sets the clip mask for a graphics context from a rectangle.

Parameters:

  x | The X coordinate of the upper-left corner of the rectangle to clip to.
  y | The Y coordinate of the upper-left corner of the rectangle to clip to.
  width | The width of the rectangle to clip to.
  height | The height of the rectangle to clip to.

The clip mask is interpreted relative to the clip origin (see set_clip_origin()).

void Inti::Gdk::GC::set_clip_mask | ( | Bitmap & | mask | ) |

Sets the clip mask for a graphics context from a bitmap.

Parameters:

  mask | A bitmap.

The clip mask is interpreted relative to the clip origin (see set_clip_origin()).

void Inti::Gdk::GC::set_clip_origin | ( | const Point & | point | ) |

Sets the origin of the clip mask.

Parameters:

  point | A Point holding the x, y coordinates of the origin.

The coordinates are interpreted relative to the upper-left corner of the destination drawable of the current operation.

void Inti::Gdk::GC::set_clip_origin | ( | int | x,
|  | int | y
| ) |

Sets the origin of the clip mask.

Parameters:

  x | The X coordinate of the origin.
  y | The Y coordinate of the origin.

The coordinates are interpreted relative to the upper-left corner of the destination drawable of the current operation.

void Inti::Gdk::GC::set_colormap | ( | Colormap * | colormap | ) |

Sets the colormap for the GC to the given colormap.

Parameters:

  colormap | A Colormap.

The depth of the colormap's visual must match the depth of the drawable for which the GC was created.

void Inti::Gdk::GC::set_dashes | ( | int | dash_offset,
|  | const std::vector< gint8 > & | dash_list
| ) |

Sets the way dashed-lines are drawn.

Parameters:

  dash_offset | The dash offset.
  dash_list | A reference to a vector of gint8 that holds a sequence of dash lengths.

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 graphics context (This can be changed with set_line_attributes()).

void Inti::Gdk::GC::set_exposures | ( | bool | exposures | ) |

Sets whether copying non-visible portions of a drawable using a graphics context generates exposure events for the corresponding regions of the destination drawable (see Gdk::Drawable::draw_drawable()).

Parameters:

  exposures | If true, exposure events will be generated.

void Inti::Gdk::GC::set_fill | ( | Fill | fill | ) |

Set the fill mode for the graphics context.

Parameters:

  fill | The new fill mode.

void Inti::Gdk::GC::set_foreground | ( | const Color & | color | ) |

Sets the foreground color for the graphics context.

Parameters:

  color | The new foreground color.

void Inti::Gdk::GC::set_function | ( | Function | function | ) |

Determines how the current pixel values and the pixel values being drawn are combined to produce the final pixel values.

Parameters:

  function | The bitwise operation to use when drawing.

void Inti::Gdk::GC::set_join_style | ( | JoinStyle | join_style | ) |

Sets the way joins between lines are drawn.

Parameters:

  join_style | The manner in which lines are joined together.

void Inti::Gdk::GC::set_line_attributes | ( | int | line_width,
|  | LineStyle | line_style,
|  | CapStyle | cap_style,
|  | JoinStyle | join_style
| ) |

Sets various attributes of how lines are drawn.

Parameters:

  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 manner in which lines are joined together.

See the corresponding members of GCValues for full explanations of the arguments.

void Inti::Gdk::GC::set_line_style | ( | LineStyle | line_style | ) |

Sets the way dashed lines are drawn.

Parameters:

  line_style | The dash-style for lines.

void Inti::Gdk::GC::set_line_width | ( | int | line_width | ) |

Sets the line width.

Parameters:

  line_width | The width of lines.

void Inti::Gdk::GC::set_rgb_bg_color | ( | const Color & | color | ) |

Set the background color of a GC using an unallocated color.

Parameters:

  color | An unallocated GdkColor.

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.

Note: Calling this method for a GC without a colormap is an error.

void Inti::Gdk::GC::set_rgb_fg_color | ( | const Color & | color | ) |

Set the foreground color of a GC using an unallocated color.

Parameters:

  color | An unallocated GdkColor.

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.

Note: Calling this function for a GC without a colormap is an error.

void Inti::Gdk::GC::set_stipple | ( | Pixmap & | stipple | ) |

Set the stipple bitmap for the graphics context.

Parameters:

  stipple | The new stipple bitmap.

The stipple will only be used if the fill mode is Gdk::STIPPLED or Gdk::OPAQUE_STIPPLED.

void Inti::Gdk::GC::set_subwindow | ( | SubwindowMode | mode | ) |

Sets how drawing with this graphics context on a window will affect child windows of that window.

Parameters:

  mode | The subwindow mode.

void Inti::Gdk::GC::set_tile | ( | Pixmap & | tile | ) |

Set a tile pixmap for the graphics context.

Parameters:

  tile | The new tile pixmap.

This will only be used if the fill mode is GDK_TILED.

void Inti::Gdk::GC::set_ts_origin | ( | const Point & | point | ) |

Set the origin when using tiles or stipples with the graphics context.

Parameters:

  point | A Point holding the x, y coordinates of the origin.

The tile or stipple will be aligned such that the upper left corner of the tile or stipple will coincide with this point.

void Inti::Gdk::GC::set_ts_origin | ( | int | x,
|  | int | y
| ) |

Set the origin when using tiles or stipples with the graphics context.

Parameters:

  x | The X coordinate of the origin.
  y | The Y coordinate of the origin.

The tile or stipple will be aligned such that the upper left corner of the tile or stipple will coincide with this point.

void Inti::Gdk::GC::set_values | ( | const GCValues & | values | ) |

Sets attributes of a graphics context in bulk.

Parameters:

  values | A GCValues object containing the new values.

Only the values explicity set in values will be read and set as the new value for the graphics context. If you're only setting a few values on gc, calling individual "setter" methods is likely more convenient.

The documentation for this class was generated from the following file:

- gdk/gc.h

Main Page - Footer