gtk-0.11.0: Binding to the Gtk+ graphical user interface library.

Portabilityportable (depends on GHC)




Graphics contexts - objects to encapsulate drawing properties



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 gcNewWithValues. A few of the values in the GC, such as the dash pattern, can only be set by the latter method.

data GC Source

class GObjectClass o => GCClass o Source


castToGC :: GObjectClass obj => obj -> GCSource

gcNew :: DrawableClass d => d -> IO GCSource

Create an empty graphics context.

data GCValues Source

Intermediate data structure for GCs.

  • If graphicsExposure is set then copying portions into a drawable will generate an "exposure" event, even if the destination area is not currently visible.


data Color


  • Specifies a color with three integer values for red, green and blue. All values range from 0 (least intense) to 65535 (highest intensity).


Color Word16 Word16 Word16 

data Function Source

Determine how bitmap operations are carried out.

data Fill Source

How objects are filled.


data LineStyle Source

Determines if a line is solid or dashed.

data CapStyle Source

Specify the how the ends of a line is drawn.

gcNewWithValues :: DrawableClass d => d -> GCValues -> IO GCSource

Creates a graphics context with specific values.

gcSetValues :: GC -> GCValues -> IO ()Source

Change some of the values of a graphics context.

gcGetValues :: GC -> IO GCValuesSource

Retrieve the values in a graphics context.

gcSetClipRectangle :: GC -> Rectangle -> IO ()Source

Set a clipping rectangle.

  • All drawing operations are restricted to this rectangle. This rectangle is interpreted relative to the clip origin.

gcSetClipRegion :: GC -> Region -> IO ()Source

Set a clipping region.

  • All drawing operations are restricted to this region. This region is interpreted relative to the clip origin.

gcSetDashes :: GC -> Int -> [(Int, Int)] -> IO ()Source

Specify the pattern with which lines are drawn.

  • Every tuple in the list contains an even and an odd segment. Even segments are drawn normally, whereby the lineStyle member of the graphics context defines if odd segements are drawn or not. A phase argument greater than 0 will drop phase pixels before starting to draw.