Maintainer | gtk2hs-users@lists.sourceforge.net |
---|---|
Stability | provisional |
Portability | portable (depends on GHC) |
Safe Haskell | None |
Language | Haskell98 |
Drawing primitives.
This module defines drawing primitives that can operate on DrawWindow
s
and Pixmap
s.
This module is empty when built with Gtk3 because GTKDrawable has been removed.
- 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
- 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
class GObjectClass o => DrawableClass o Source
castToDrawable :: GObjectClass obj => obj -> Drawable Source
toDrawable :: DrawableClass o => o -> Drawable Source
drawableGetDepth :: DrawableClass d => d -> IO Int Source
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) Source
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 Source
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 Source
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 Source
Get NativeWindowId
of Drawable
.
drawPoints :: DrawableClass d => d -> GC -> [Point] -> IO () Source
drawLine :: DrawableClass d => d -> GC -> Point -> Point -> IO () Source
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 () Source
Draw several lines.
- The function uses the current line width, dashing and especially the
joining specification in the graphics context (in contrast to
drawSegments
.
drawPixbuf :: DrawableClass d => d -> GC -> Pixbuf -> Int -> Int -> Int -> Int -> Int -> Int -> Dither -> Int -> Int -> IO () Source
Render a Pixbuf
.
- Usage:
drawPixbuf d gc pb srcX srcY destX destY srcWidth srcHeight dither xDither yDither
Renders a rectangular portion of aPixbuf
to aDrawable
. ThesrcX
,srcY
,srcWidth
andsrcHeight
specify what part of thePixbuf
should be rendered. The latter two values may be-1
in which case the width and height are taken frompb
. The image is placed atdestX
,destY
. If you render parts of an image at a time, setditherX
andditherY
to the origin of the image you are rendering. - Since 2.2.
drawSegments :: DrawableClass d => d -> GC -> [(Point, Point)] -> IO () Source
Draw several unconnected lines.
- This method draws several unrelated lines.
:: DrawableClass d | |
=> d | drawable |
-> GC | graphics context |
-> Bool | filled |
-> Int | x |
-> Int | y |
-> Int | width |
-> Int | height |
-> 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. CallingdrawRectangle
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 () Source
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 toaStart
.
drawPolygon :: DrawableClass d => d -> GC -> Bool -> [Point] -> IO () Source
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 () Source
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
itemize
. Each item is then turned into a shapes by callingshape
. 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 aLayoutLine
.
drawLayoutLine :: DrawableClass d => d -> GC -> Int -> Int -> LayoutLine -> IO () Source
Draw a single line of text.
- The
x
coordinate specifies the start of the string, they
coordinate specifies the base line.
drawLayoutLineWithColors :: DrawableClass d => d -> GC -> Int -> Int -> LayoutLine -> Maybe Color -> Maybe Color -> IO () Source
Draw a single line of text.
- The
x
coordinate specifies the start of the string, they
coordinate specifies the base line. - If both colors are
Nothing
this function will behave likedrawLayoutLine
in that it uses the default colors from the graphics context.
drawLayout :: DrawableClass d => d -> GC -> Int -> Int -> PangoLayout -> IO () Source
Draw a paragraph of text.
- The
x
andy
values specify the upper left point of the layout.
drawLayoutWithColors :: DrawableClass d => d -> GC -> Int -> Int -> PangoLayout -> Maybe Color -> Maybe Color -> IO () Source
Draw a paragraph of text.
- The
x
andy
values specify the upper left point of the layout. - If both colors are
Nothing
this function will behave likedrawLayout
in that it uses the default colors from the graphics context.
:: (DrawableClass src, DrawableClass dest) | |
=> dest | destination drawable |
-> GC | graphics context |
-> src | source drawable |
-> Int | xSrc |
-> Int | ySrc |
-> Int | xDest |
-> Int | yDest |
-> Int | width |
-> Int | height |
-> IO () |
Copies another Drawable
.
- Copies the (width,height) region of the
src
at coordinates (xSrc
,ySrc
) to coordinates (xDest
,yDest
) in thedest
. Thewidth
and/orheight
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 yourGC
, then usedrawRectangle
to draw a rectangle clipped to the bitmap.