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

Portability | portable (depends on GHC)
Stability | provisional
Maintainer | gtk2hs-users@lists.sourceforge.net

Graphics.UI.Gtk.Gdk.Drawable

Description

Drawing primitives.

This module defines drawing primitives that can operate on `DrawWindow`s and `Pixmap`s.

Synopsis

- data Drawable
- class GObjectClass o => DrawableClass o
- castToDrawable :: GObjectClass obj => obj -> Drawable
- gTypeDrawable :: GType
- toDrawable :: DrawableClass o => o -> Drawable
- drawableGetDepth :: DrawableClass d => d -> IO Int
- drawableGetSize :: DrawableClass d => d -> IO (Int, Int)
- drawableGetClipRegion :: DrawableClass d => d -> IO Region
- drawableGetVisibleRegion :: DrawableClass d => d -> IO Region
- drawableGetID :: DrawableClass d => d -> IO NativeWindowId
- type Point = (Int, Int)
- drawPoint :: DrawableClass d => d -> GC -> Point -> IO ()
- drawPoints :: DrawableClass d => d -> GC -> [Point] -> IO ()
- drawLine :: DrawableClass d => d -> GC -> Point -> Point -> IO ()
- drawLines :: DrawableClass d => d -> GC -> [Point] -> IO ()
- data Dither
  - = RgbDitherNone
  - | RgbDitherNormal
  - | RgbDitherMax
- drawPixbuf :: DrawableClass d => d -> GC -> Pixbuf -> Int -> Int -> Int -> Int -> Int -> Int -> Dither -> Int -> Int -> IO ()
- drawSegments :: DrawableClass d => d -> GC -> [(Point, Point)] -> IO ()
- drawRectangle :: DrawableClass d => d -> GC -> Bool -> Int -> Int -> Int -> Int -> IO ()
- drawArc :: DrawableClass d => d -> GC -> Bool -> Int -> Int -> Int -> Int -> Int -> Int -> IO ()
- drawPolygon :: DrawableClass d => d -> GC -> Bool -> [Point] -> IO ()
- drawGlyphs :: DrawableClass d => d -> GC -> Int -> Int -> GlyphItem -> IO ()
- drawLayoutLine :: DrawableClass d => d -> GC -> Int -> Int -> LayoutLine -> IO ()
- drawLayoutLineWithColors :: DrawableClass d => d -> GC -> Int -> Int -> LayoutLine -> Maybe Color -> Maybe Color -> IO ()
- drawLayout :: DrawableClass d => d -> GC -> Int -> Int -> PangoLayout -> IO ()
- drawLayoutWithColors :: DrawableClass d => d -> GC -> Int -> Int -> PangoLayout -> Maybe Color -> Maybe Color -> IO ()
- drawDrawable :: (DrawableClass src, DrawableClass dest) => dest -> GC -> src -> Int -> Int -> Int -> Int -> Int -> Int -> IO ()

# Documentation

data Drawable

Instances

Eq Drawable |
Ord Drawable |
GObjectClass Drawable |
DrawableClass Drawable |

class GObjectClass o => DrawableClass o

Instances

DrawableClass Pixmap |
DrawableClass DrawWindow |
DrawableClass Drawable |

castToDrawable :: GObjectClass obj => obj -> Drawable

gTypeDrawable :: GType

toDrawable :: DrawableClass o => o -> Drawable

drawableGetDepth :: DrawableClass d => d -> IO Int

Get the size of pixels.

- Returns the number of bits which are use to store information on each pixels in this `Drawable`.

drawableGetSize :: DrawableClass d => d -> IO (Int, Int)

Retrieve the size of the `Drawable`.

- The result might not be up-to-date if there are still resizing messages to be processed.

drawableGetClipRegion :: DrawableClass d => d -> IO Region

Determine where not to draw.

- Computes the region of a drawable that potentially can be written to by drawing primitives. This region will not take into account the clip region for the GC, and may also not take into account other factors such as if the window is obscured by other windows, but no area outside of this region will be affected by drawing primitives.

drawableGetVisibleRegion :: DrawableClass d => d -> IO Region

Determine what not to redraw.

- Computes the region of a drawable that is potentially visible. This does not necessarily take into account if the window is obscured by other windows, but no area outside of this region is visible.

drawableGetID :: DrawableClass d => d -> IO NativeWindowId

Get `NativeWindowId` of `Drawable`.

type Point = (Int, Int)

Represents the x and y coordinate of a point.

drawPoint :: DrawableClass d => d -> GC -> Point -> IO ()

Draw a point into a `Drawable`.

drawPoints :: DrawableClass d => d -> GC -> [Point] -> IO ()

Draw several points into a `Drawable`.

- This function is more efficient than calling `drawPoint` on several points.

drawLine :: DrawableClass d => d -> GC -> Point -> Point -> IO ()

Draw a line into a `Drawable`.

- The parameters are x1, y1, x2, y2.
- Drawing several separate lines can be done more efficiently by `drawSegments`.

drawLines :: DrawableClass d => d -> GC -> [Point] -> IO ()

Draw several lines.

- The function uses the current line width, dashing and especially the joining specification in the graphics context (in contrast to `drawSegments`.

data Dither

Specify how to dither colors onto the screen.

Constructors

RgbDitherNone |
RgbDitherNormal |
RgbDitherMax |

Instances

Enum Dither |
Eq Dither |
Show Dither |

drawPixbuf :: DrawableClass d => d -> GC -> Pixbuf -> Int -> Int -> Int -> Int -> Int -> Int -> Dither -> Int -> Int -> IO ()

Render a `Pixbuf`.

- Usage: `drawPixbuf d gc pb srcX srcY destX destY srcWidth srcHeight dither` Renders a rectangular portion of a `Pixbuf` to a `Drawable`. The `srcX`, `srcY`, `srcWidth` and `srcHeight` specify what part of the `Pixbuf` should be rendered. The latter two values may be `-1` in which case the width and height are taken from `pb`. The image is placed at `destX`, `destY`. If you render parts of an image at a time, set `ditherX` and `ditherY` to the origin of the image you are rendering.
- Since 2.2.

drawSegments :: DrawableClass d => d -> GC -> [(Point, Point)] -> IO ()

Draw several unconnected lines.

- This method draws several unrelated lines.

drawRectangle :: DrawableClass d => d -> GC -> Bool -> Int -> Int -> Int -> Int -> IO ()

Draw a rectangular object.

- Draws a rectangular outline or filled rectangle, using the foreground color and other attributes of the `GC`.
- A rectangle drawn filled is 1 pixel smaller in both dimensions than a rectangle outlined. Calling `drawRectangle` w gc True 0 0 20 20 results in a filled rectangle 20 pixels wide and 20 pixels high. Calling `drawRectangle` d gc False 0 0 20 20 results in an outlined rectangle with corners at (0, 0), (0, 20), (20, 20), and (20, 0), which makes it 21 pixels wide and 21 pixels high.

drawArc :: DrawableClass d => d -> GC -> Bool -> Int -> Int -> Int -> Int -> Int -> Int -> IO ()

Draws an arc or a filled 'pie slice'.

- The arc is defined by the bounding rectangle of the entire ellipse, and the start and end angles of the part of the ellipse to be drawn.
- The starting angle `aStart` is relative to the 3 o'clock position, counter-clockwise, in 1/64ths of a degree. `aEnd` is measured similarly, but relative to `aStart`.

drawPolygon :: DrawableClass d => d -> GC -> Bool -> [Point] -> IO ()

Draws an outlined or filled polygon.

- The polygon is closed automatically, connecting the last point to the first point if necessary.

drawGlyphs :: DrawableClass d => d -> GC -> Int -> Int -> GlyphItem -> IO ()

Draw a segment of text.

- This function draws a segment of text. These segements are the result of itemizing a string into segments with the same characteristics (font, text direction, etc.) using `Graphics.Rendering.Pango.Rendering.itemize`. Each item is then turned into a shapes by calling `Graphics.Rendering.Pango.Rendering.shape`. These shapes can then be drawn onto screen using this function. A simpler interface, that also takes care of breaking a paragraph into several lines is a `Graphics.Rendering.Pango.Layout.LayoutLine`.

drawLayoutLine :: DrawableClass d => d -> GC -> Int -> Int -> LayoutLine -> IO ()

Draw a single line of text.

- The `x` coordinate specifies the start of the string, the `y` coordinate specifies the base line.

drawLayoutLineWithColors :: DrawableClass d => d -> GC -> Int -> Int -> LayoutLine -> Maybe Color -> Maybe Color -> IO ()

Draw a single line of text.

- The `x` coordinate specifies the start of the string, the `y` coordinate specifies the base line.
- If both colors are `Nothing` this function will behave like `drawLayoutLine` in that it uses the default colors from the graphics context.

drawLayout :: DrawableClass d => d -> GC -> Int -> Int -> PangoLayout -> IO ()

Draw a paragraph of text.

- The `x` and `y` values specify the upper left point of the layout.

drawLayoutWithColors :: DrawableClass d => d -> GC -> Int -> Int -> PangoLayout -> Maybe Color -> Maybe Color -> IO ()

Draw a paragraph of text.

- The `x` and `y` values specify the upper left point of the layout.
- If both colors are `Nothing` this function will behave like `drawLayout` in that it uses the default colors from the graphics context.

drawDrawable :: (DrawableClass src, DrawableClass dest) => dest -> GC -> src -> Int -> Int -> Int -> Int -> Int -> Int -> IO ()

Copies another `Drawable`.

- Copies the (width,height) region of the `src` at coordinates (`xSrc`, `ySrc`) to coordinates (`xDest`, `yDest`) in the `dest`. The `width` and/or `height` may be given as -1, in which case the entire source drawable will be copied.
- Most fields in `gc` are not used for this operation, but notably the clip mask or clip region will be honored. The source and destination drawables must have the same visual and colormap, or errors will result. (On X11, failure to match visual/colormap results in a BadMatch error from the X server.) A common cause of this problem is an attempt to draw a bitmap to a color drawable. The way to draw a bitmap is to set the bitmap as a clip mask on your `GC`, then use `drawRectangle` to draw a rectangle clipped to the bitmap.