Xfce Foundation Classes
Main Page  | IndexNamespace List  |  Alphabetical List  |  Class List  |  File List


Xfc::Gdk::GC Class Reference

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

#include <xfc/gdk/gc.hh>

Inheritance diagram for Xfc::Gdk::GC:

Xfc::G::Object Xfc::G::TypeInstance Xfc::Trackable Xfc::Gtk::GC List of all members.

Public Member Functions

Constructors
Accessors
Methods

Protected Member Functions

Constructors

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:

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

Xfc::Gdk::GC::GC GdkGC *  gc,
bool  owns_reference = true
[explicit, protected]
 

Construct a new GC from an existing GdkGC.

Parameters:
gc A pointer to a GdkGC.
owns_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).

Xfc::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. GC is created with a reference count of 1 that the caller owns.

Xfc::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.
GC is created with a reference count of 1 that the caller owns.


Member Function Documentation

Colormap* Xfc::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* Xfc::Gdk::GC::get_screen  )  const
 

Gets the Screen for which the graphics context was created.

Returns:
The GdkScreen for the graphics context.

void Xfc::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 Xfc::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 Xfc::Gdk::GC::set_background const Color color  ) 
 

Sets the background color for the graphics context.

Parameters:
color The new background color.

void Xfc::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 Xfc::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 Xfc::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 Xfc::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 Xfc::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 Xfc::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 Xfc::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 Xfc::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 Xfc::Gdk::GC::set_dashes int  dash_offset,
gint8 *  dash_list,
int  n
 

Sets the way dashed-lines are drawn.

Parameters:
dash_offset The dash offset.
dash_list An array of dash lengths.
n The number of elements in dash_list.
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 Xfc::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 Xfc::Gdk::GC::set_fill Fill  fill  ) 
 

Set the fill mode for the graphics context.

Parameters:
fill The new fill mode.

void Xfc::Gdk::GC::set_foreground const Color color  ) 
 

Sets the foreground color for the graphics context.

Parameters:
color The new foreground color.

void Xfc::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 Xfc::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 Xfc::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 Xfc::Gdk::GC::set_line_style LineStyle  line_style  ) 
 

Sets the way dashed lines are drawn.

Parameters:
line_style The dash-style for lines.

void Xfc::Gdk::GC::set_line_width int  line_width  ) 
 

Sets the line width.

Parameters:
line_width The width of lines.

void Xfc::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 Xfc::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 Xfc::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 Xfc::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 Xfc::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 Xfc::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 Xfc::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 Xfc::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: Xfce Foundation Classes
Copyright © 2004-2005 The XFC Development Team XFC 4.3