A graphic context is a structure that describes all the attributes used by the drawing functions in Gdk. The colors, line styles, Fill styles and so on are defined through this structure.
On X11 systems, this structure is stored directly on the XServer, which speeds up the transfer of the drawing attributes a lot. Instead of transferring all of them every time you call one of the drawing functions, you simply specify which GC you want to use.
Thus, it is recommended to create as many GCs as you need, instead of creating a single one that is modified every time you need to modify one of the attributes.
On Unix machines, you should have a look at the external utility 'xgc' which demonstrates all the basic settings of the graphic contexts.
Types |
---|
subtype Gdk_GC is Gdk.Gdk_GC; | |
A graphic context that contain all the information to draw graphics
on the screen.
Creating these GC is more efficient than passing a lot of parameters
to each of the drawing functions, since these GC are stored on the
server side and do not need to be pass through the network.
| |
type Gdk_GC_Values is new Gdk.C_Proxy; | |
A structure used on the client side to store the same information
as the GC. Creating a GC from this structure is more efficient than
calling a lot of functions to modify the GC directly, since there is
a single call to the server.
|
Subprograms |
---|
Gdk_GC | ||
procedure Gdk_New (GC : out Gdk_GC; Window : in Gdk.Window.Gdk_Window); | ||
Create a new graphic context. | ||
procedure Gdk_New (GC : out Gdk_GC; Window : in Gdk.Window.Gdk_Window; Values : in Gdk_GC_Values; Values_Mask : in Types.Gdk_GC_Values_Mask); | ||
Create a new graphic context. | ||
procedure Destroy (GC : in Gdk_GC); | ||
Free the memory allocated on the server for the graphic context. | ||
procedure Ref (GC : in Gdk_GC); | ||
Increment the reference counting for the graphic context. | ||
procedure Unref (GC : in Gdk_GC); | ||
Decrement the reference counting for the graphic context. | ||
procedure Get_Values (GC : in Gdk_GC; Values : in Gdk_GC_Values); | ||
Get the values set in the GC. | ||
procedure Set_Foreground (GC : in Gdk_GC; Color : in Gdk.Color.Gdk_Color); | ||
Set the foreground color for the graphic context. | ||
procedure Set_Background (GC : in Gdk_GC; Color : in Gdk.Color.Gdk_Color); | ||
Set the background color for the graphic context.
| ||
procedure Set_Font (GC : in Gdk_GC; Font : in Gdk.Font.Gdk_Font); | ||
Set the font used by the graphic context. | ||
procedure Set_Function (GC : in Gdk_GC; Func : in Types.Gdk_Function); | ||
Set the function in the graphic context.
In general, there are three basic steps to drawing: reading the source
pixels, reading the destination pixels, and writing the destination
pixels. Some functions only perform the third step (Set and Clear),
some do not need the middle step (Copy), whereas most require the three
steps, and thus can be much slower.
| ||
procedure Set_Fill (GC : in Gdk_GC; Fill : in Types.Gdk_Fill); | ||
Set the pattern used for filling the polygons.
| ||
procedure Set_Tile (GC : in Gdk_GC; Tile : in Gdk.Gdk_Pixmap); | ||
| ||
procedure Set_Stipple (GC : in Gdk_GC; Stipple : in Gdk.Gdk_Pixmap); | ||
| ||
procedure Set_Clip_Mask (GC : in Gdk.GC.Gdk_GC; Mask : in Gdk.Gdk_Bitmap); | ||
If Mask is set to Null_Bitmap, then no clip_mask is used for drawing. | ||
procedure Set_Ts_Origin (GC : in Gdk_GC; X, Y : in Gint); | ||
Set the Tile and Stipple origin in the graphic context.
| ||
procedure Set_Clip_Origin (GC : in Gdk_GC; X, Y : in Gint); | ||
Set the origin of the clip mask. | ||
procedure Set_Clip_Rectangle (GC : in Gdk_GC; Rectangle : in Gdk.Rectangle.Gdk_Rectangle); | ||
Set the clip rectangle. | ||
procedure Set_Clip_Region (GC : in Gdk_GC; Region : in Gdk.Region.Gdk_Region); | ||
Define a clip region on the screen. | ||
procedure Set_Subwindow (GC : in Gdk_GC; Mode : in Types.Gdk_Subwindow_Mode); | ||
Set the subwindow mode for the graphic context. | ||
procedure Set_Exposures (GC : in Gdk_GC; Exposures : in Boolean); | ||
Exposures indicates whether you want "expose" and "noexpose" events to | ||
procedure Set_Line_Attributes (GC : in Gdk_GC; Line_Width : in Gint; Line_Style : in Types.Gdk_Line_Style; Cap_Style : in Types.Gdk_Cap_Style; Join_Style : in Types.Gdk_Join_Style); | ||
Set the line attributes for this GC. Line_Style specifies whether the line should be solid or dashed. With Line_On_Off_Dash, the colors are alternatively the foreground color, and blank. With Line_Double_Dash, the colors are alternatively the foreground and background colors. Cap_Style specifies how the line should end, either flat or rounded.
Join_Style specifies how two consecutive lines drawn by Draw_Lines are
connected.
| ||
procedure Set_Dashes (Gc : in Gdk_GC; Dash_Offset : in Gint; Dash_List : in Guchar_Array); | ||
Specify the dash pattern when the line's style is anything but solid. | ||
procedure Copy (Dst_GC : in Gdk_GC; Src_GC : in Gdk_GC); | ||
Copy a Src_GC to Dst_GC.
| ||
Gdk_Color_Values | ||
function Gdk_New return Gdk_GC_Values; | ||
Allocate a new Values structure on the client. | ||
procedure Free (Values : in Gdk_GC_Values); | ||
Free the C structure associated with Values.
| ||
procedure Set_Foreground (Values : in Gdk_GC_Values; Color : in Gdk.Color.Gdk_Color); | ||
Same as Set_Foreground, but on the client side
| ||
procedure Set_Background (Values : in Gdk_GC_Values; Color : in Gdk.Color.Gdk_Color); | ||
Same as Set_Background, but on the client side
| ||
procedure Set_Font (Values : in Gdk_GC_Values; Font : in Gdk.Font.Gdk_Font); | ||
Same as Set_Font, but on the client side
| ||
procedure Set_Function (Values : in Gdk_GC_Values; Func : in Types.Gdk_Function); | ||
Same as Set_Function, but on the client side
| ||
procedure Set_Fill (Values : in Gdk_GC_Values; Fill : in Types.Gdk_Fill); | ||
Same as Set_Fill, but on the client side
| ||
procedure Set_Ts_Origin (Values : in Gdk_GC_Values; X, Y : in Gint); | ||
Same as Set_Ts_Origin, but on the client side
| ||
procedure Set_Clip_Origin (Values : in Gdk_GC_Values; X, Y : in Gint); | ||
Same as Set_Clip_Origin, but on the client side
| ||
procedure Set_Subwindow (Values : in Gdk_GC_Values; Mode : in Types.Gdk_Subwindow_Mode); | ||
Same as Set_Subwindow, but on the client side
| ||
procedure Set_Exposures (Values : in Gdk_GC_Values; Exposures : in Boolean); | ||
Same as Set_Exposures, but on the client side
| ||
procedure Set_Line_Attributes (Values : in Gdk_GC_Values; Line_Width : in Gint; Line_Style : in Types.Gdk_Line_Style; Cap_Style : in Types.Gdk_Cap_Style; Join_Style : in Types.Gdk_Join_Style); | ||
Same as Set_Line_Attributes, but on the client side
|