Class Index Cross Index Namespace Index

Class Gdk_GC

Gdk GC (Graphics Context) Handle
Contained in: global
Derived from: Gdk_Handle
Derived by: none

#include <gtk--/gc.h>


public function member index:

Gdk_GC();
Gdk_GC(GdkGC* gc);
Gdk_GC(const Gdk_GC& gc);
Gdk_GC(Gdk_Drawable& drawable);
void copy(Gdk_GC& src);
void create(Gdk_Drawable const& drawable);
Gdk_Font get_font();
void get_values(GdkGCValues& values);
Gdk_GC& operator = (const Gdk_GC&);
void release();
void set_background(const Gdk_Color& c);
void set_cap_style(GdkCapStyle cap_style);
void set_clip_mask(Gdk_Bitmap& mask);
void set_clip_mask();
void set_clip_origin(gint x, gint y);
void set_clip_rectangle(const Gdk_Rectangle& rect);
void set_clip_rectangle(gint x, gint y, gint w, gint h);
void set_clip_region(Gdk_Region& region);
void set_dashes(gint size);
void set_dashes(gint on, gint off);
void set_dashes(gint dash_offset, gint8 dash_list[], gint dash_list_length);
void set_exposures(bool exp);
void set_fill(GdkFill fill);
void set_font(const Gdk_Font& font);
void set_foreground(const Gdk_Color& c);
void set_function(GdkFunction func);
void set_join_style(GdkJoinStyle join_style);
void set_line_attributes(gint line_width, GdkLineStyle line_style=GDK_LINE_SOLID, GdkCapStyle cap_style=GDK_CAP_BUTT, GdkJoinStyle join_style=GDK_JOIN_MITER);
void set_line_style(GdkLineStyle line_style);
void set_line_width(gint line_width);
void set_noclip();
void set_stipple(Gdk_Pixmap& stip);
void set_subwindow(GdkSubwindowMode mode);
void set_tile(Gdk_Pixmap& tile);
void set_ts_origin(gint x, gint y);
~Gdk_GC();
 

protected function member index:

void ref();
void unref();
 

private function member index:

void destroy();
 

Description:

The Graphics Context specifies a number of server side resources that are used by several drawing commands.

For understanding Graphics Contexts you should read chapter 10 of Gtk+/Gnome Application Development (>500K) by Havoc Pennington or chapter 7 of "Xlib -- C Language X Interface" from the X Consortium.


Function Member Descriptions:

Gdk_GC::Gdk_GC - Create an unconnect GC Handle.

Gdk_GC();

Gdk_GC::Gdk_GC - Wrap an existing GdkGC.

Gdk_GC(GdkGC* gc);

Gdk_GC::Gdk_GC - Initialize a GC reference from a existing one.

Gdk_GC(const Gdk_GC& gc);
The new GC refers to the same Graphics Context on the server side.


Gdk_GC::Gdk_GC - Create a new GC for this drawable.

Gdk_GC(Gdk_Drawable& drawable);
Allocate a remote gc object based on this drawable.


Gdk_GC::copy - Copy server GC.

void copy(Gdk_GC& src);
This copies all properties of one remote GC to another GC on the server.

Both, source handle and destination (this) handle, have to be connected to remote Graphics Contexts when calling this method.



Gdk_GC::create - Create a GC on server

void create(Gdk_Drawable const& drawable);
Allocate a remote gc object based on this drawable.

If the GC Handle is already connected to a remote Graphics Context, then this connection will be released.

If the drawable handle is not connected to a remote drawable, then the GC handle is unconnected after this call.



Gdk_GC::destroy - Destroy a remote gc.

void destroy();
This is very dangerous and should probably be removed. Nuke the GC and make this copy invalid.


Gdk_GC::get_font - Return the current font.

Gdk_Font get_font();
Font will not be initialized if there is no current font.


Gdk_GC::get_values - Get GC properites.

void get_values(GdkGCValues& values);
GdkGCValues is defined as struct _GdkGCValues in gdk/gdktypes.h


Gdk_GC::ref - (internal function) increment gdk reference counter

void ref();

Gdk_GC::set_background - Set background color.

void set_background(const Gdk_Color& c);

Gdk_GC::set_cap_style - Set the cap style.

void set_cap_style(GdkCapStyle cap_style);
Caps are the ends of lines. GdkCapStyle is an enum.

Valid values for cap_style are: GDK_CAP_NOT_LAST, GDK_CAP_BUTT, GDK_CAP_ROUND, GDK_CAP_PROJECTING.

GDK_CAP_NOT_LAST is equal to GDK_CAP_BUTT, except for lines with width 0, in which case the Pixel at the end point given is not drawn.

GDK_CAP_BUTT is for lines with suare ends.

GDK_CAP_ROUND causes lines to have filled half circles attached to their end points.

Lines drawn with GDK_CAP_PROJECTING continue beyond their end points for a distance equal to their half width. Line ends are square.



Gdk_GC::set_clip_mask - Set the clipping mask.

void set_clip_mask(Gdk_Bitmap& mask);
Only bits set to 1 in this mask will be drawn.


Gdk_GC::set_clip_mask - Deactive the clipping mask.

void set_clip_mask();

Gdk_GC::set_clip_origin - Set the origin of the clipping mask.

void set_clip_origin(gint x, gint y);

Gdk_GC::set_clip_rectangle - Set the clipping rectangle.

void set_clip_rectangle(const Gdk_Rectangle& rect);
This method sets the clipping mask and the clipping origin for you so that only pixels inside this rectangle are drawn.


Gdk_GC::set_clip_rectangle - Set the clipping rectangle.

void set_clip_rectangle(gint x, gint y, gint w, gint h);
This method calls the rectangle constructor for you before calling void set_clip_rectangle (const Gdk_Rectangle &rect).


Gdk_GC::set_clip_region - Set the clip region. (needs work)

void set_clip_region(Gdk_Region& region);

Gdk_GC::set_dashes - Set the length of dashes.

void set_dashes(gint size);
On and off will have the same size. size is given in Pixels.


Gdk_GC::set_dashes - Set the length of dashes.

void set_dashes(gint on, gint off);
Use this method if you want dotted lines (choose a smaller value for an than for off). on and off are given in Pixels.


Gdk_GC::set_dashes - Set the length of dashes.

void set_dashes(gint dash_offset, gint8 dash_list[], gint dash_list_length);
The ons and offs of a dashed line do not have to be the same all the time. With this method you can produce dash-dot lines (or dash-dot-dot or dash-dash-dot-longdash-dash-dot or whatever you like).

The dash_list is a vector of length dash_list_length. The elements of dash_list specify the length of the on/off dashes in pixels. dash_list[0], dash_list[2] ... specify the on dashes, the other values are for the off dashes. After dash_list[dash_list_length-1], dash_list[0] is again used.

dash_offset sets the pixel number with which lines are supposed to start. Usually you will set this to 0.

Constraints: dash_list_length>0, dash_list[i]>0 for all i.



Gdk_GC::set_exposures - Determines wether Gdk_Window::copy_area can generate expose events.

void set_exposures(bool exp);
exp is a boolean value.

If it is set to true, and copy_area is told to copy an area from a window that is currently obscured, then the XServer sends expose events to the obscured window so that the obscured contents is redrawn by the application. This contents is then used in the copy.



Gdk_GC::set_fill - Set the fill style.

void set_fill(GdkFill fill);
GdkFill is an enum defined in gdk/gdktypes.h.

The default fill style is GDK_SOLID. When it is set, the drawing commands do what you expect.

If you want to learn about the other fill styles (GDK_SOLID, GDK_TILED, GDK_STIPPLED, GDK_OPAQUE_STIPPLED), you should read chapter 10 of Gtk+/Gnome Application Development (>500K) by Havoc Pennington or chapter 7 of "Xlib -- C Language X Interface" from the X Consortium.



Gdk_GC::set_font - Set the font associated with this GC.

void set_font(const Gdk_Font& font);

Gdk_GC::set_foreground - Set foreground color.

void set_foreground(const Gdk_Color& c);

Gdk_GC::set_function - Set the drawing function.

void set_function(GdkFunction func);
GdkFunction is an enum defined in gdk/gdktypes.h. It specifies how Pixels are set in a drawable.

Common values: GDK_COPY, GDK_INVERT, GDK_XOR.



Gdk_GC::set_join_style - Set the joint style.

void set_join_style(GdkJoinStyle join_style);
Join styles describe how lines sharing a common end point and drawn in the same drawing request connect with each other.

GdkJoinStyle is an enum. valid values for join_style are: GDK_JOIN_MITER, GDK_JOIN_ROUND, GDK_JOIN_BEVEL.

GDK_JOIN_MITER: Lines which form an angle of more than 11 degrees are continued beyond the endpoint until their outer edges meet. Only the intersection set of the two continued lines is drawn. Lines with a smaller angle are joint as with GDK_JOIN_BEVEL.

GDK_JOIN_ROUND: The lines join in a circle with diameter line_width.

GDK_JOIN_BEVEL: The lines end as with CapButt and then the triangle left on the outer edge is filled.



Gdk_GC::set_line_attributes - Set the line attributes

void set_line_attributes(gint line_width, GdkLineStyle line_style=GDK_LINE_SOLID, GdkCapStyle cap_style=GDK_CAP_BUTT, GdkJoinStyle join_style=GDK_JOIN_MITER);
See set_line_width, set_line_style, set_cap_style, set_join_style for an explanation of the arguments.


Gdk_GC::set_line_style - Set the line style.

void set_line_style(GdkLineStyle line_style);
Lines can be drawn in a number of diffent fashions.

GdkLineStyle is an enum. Valid values for line_style are: GDK_LINE_SOLID, GDK_LINE_ON_OFF_DASH, GDK_LINE_DOUBLE_DASH.

Lines with line_style GDK_LINE_SOLID are just a plain lines.

GDK_LINE_ON_OFF_DASH produces dashed lines. The Pixels inside the dashes are drawn in the foreground color, while the Pixels between the dashes are left untouched. The cap style applies to all ends of all dashes.

GDK_LINE_DOUBLE_DASH produces dashed lines where the Pixels inside the dashes are drawn in the foreground color while the Pixels between the dashes are drawn in the background color.



Gdk_GC::set_line_width - Set the line width.

void set_line_width(gint line_width);
line_width is given in Pixels.

0 is a special value for a line width of one Pixel. Lines with line_width set to 0 are usually drawn with hardware acceleration, and the exact pixels set can be different depending on the hardware in use and the direction in that the line is drawn.

This cannot happen for lines with line_width>0. For further info, see chapter 7 of "Xlib -- C Language X Interface" from the X Consortium.



Gdk_GC::set_noclip - Deactive the clipping mask (non-standard)

void set_noclip();

Gdk_GC::set_stipple - Set the fill stipple.

void set_stipple(Gdk_Pixmap& stip);
This has an effect only for the GDK_STIPPLED and GDK_OPAQUE_STIPPLED fill styles (set with set_fill). stip must have a depth of 1, it is a bitmap.


Gdk_GC::set_subwindow - Set the subwindow clipping mode.

void set_subwindow(GdkSubwindowMode mode);
GdkSubwindowMode is an enum. Subwindow modes: GDK_CLIP_BY_CHILDREN, GDK_INCLUDE_INFERIORS.


Gdk_GC::set_tile - Set the background tile for the GDK_TILED fill style.

void set_tile(Gdk_Pixmap& tile);
This has an effect only if the fill style of this GC is set to GDK_TILED with set_fill.


Gdk_GC::set_ts_origin - Set the origin of the first tile or stipple.

void set_ts_origin(gint x, gint y);
This has an effect for fill styles (see set_fill) different from GDK_SOLID. It sets the origin of the first tile or stiple. Tiles and stiples are copied everywhere so that they cover every Pixel.


Gdk_GC::unref - (internal function) decrement gdk reference counter

void unref();

Gdk_GC::~Gdk_GC - Delete this handle.

~Gdk_GC();