module Graphics.UI.Gtk.Gdk.Drawable (
Drawable,
DrawableClass,
castToDrawable, gTypeDrawable,
toDrawable,
drawableGetDepth,
drawableGetSize,
drawableGetClipRegion,
drawableGetVisibleRegion,
drawableGetID,
Point,
drawPoint,
drawPoints,
drawLine,
drawLines,
Dither(..),
drawPixbuf,
drawSegments,
drawRectangle,
drawArc,
drawPolygon,
drawGlyphs,
drawLayoutLine,
drawLayoutLineWithColors,
drawLayout,
drawLayoutWithColors,
drawDrawable,
) where
import Control.Monad (liftM)
import System.Glib.FFI
import Graphics.UI.Gtk.General.Structs (Point, drawableGetID)
import Graphics.Rendering.Pango.Structs
import Graphics.Rendering.Pango.Types
import Graphics.Rendering.Pango.BasicTypes
import Graphics.UI.Gtk.Types
import Graphics.UI.Gtk.Gdk.Region (Region, makeNewRegion)
import Graphics.UI.Gtk.Gdk.Enums (Dither(..))
drawableGetDepth :: DrawableClass d => d -> IO Int
drawableGetDepth d = liftM fromIntegral $
(\(Drawable arg1) -> withForeignPtr arg1 $ \argPtr1 ->gdk_drawable_get_depth argPtr1) (toDrawable d)
drawableGetSize :: DrawableClass d => d -> IO (Int, Int)
drawableGetSize d = alloca $ \wPtr -> alloca $ \hPtr -> do
(\(Drawable arg1) arg2 arg3 -> withForeignPtr arg1 $ \argPtr1 ->gdk_drawable_get_size argPtr1 arg2 arg3) (toDrawable d) wPtr hPtr
(w::(CInt)) <- peek wPtr
(h::(CInt)) <- peek hPtr
return (fromIntegral w, fromIntegral h)
drawableGetClipRegion :: DrawableClass d => d -> IO Region
drawableGetClipRegion d = do
rPtr <- (\(Drawable arg1) -> withForeignPtr arg1 $ \argPtr1 ->gdk_drawable_get_clip_region argPtr1) (toDrawable d)
makeNewRegion rPtr
drawableGetVisibleRegion :: DrawableClass d => d -> IO Region
drawableGetVisibleRegion d = do
rPtr <- (\(Drawable arg1) -> withForeignPtr arg1 $ \argPtr1 ->gdk_drawable_get_visible_region argPtr1) (toDrawable d)
makeNewRegion rPtr
drawPoint :: DrawableClass d => d -> GC -> Point -> IO ()
drawPoint d gc (x,y) = (\(Drawable arg1) (GC arg2) arg3 arg4 -> withForeignPtr arg1 $ \argPtr1 ->withForeignPtr arg2 $ \argPtr2 ->gdk_draw_point argPtr1 argPtr2 arg3 arg4) (toDrawable d)
(toGC gc) (fromIntegral x) (fromIntegral y)
drawPoints :: DrawableClass d => d -> GC -> [Point] -> IO ()
drawPoints d gc [] = return ()
drawPoints d gc points =
withArray (concatMap (\(x,y) -> [fromIntegral x, fromIntegral y]) points) $
\(aPtr :: Ptr (CInt)) -> (\(Drawable arg1) (GC arg2) arg3 arg4 -> withForeignPtr arg1 $ \argPtr1 ->withForeignPtr arg2 $ \argPtr2 ->gdk_draw_points argPtr1 argPtr2 arg3 arg4) (toDrawable d)
(toGC gc) (castPtr aPtr) (fromIntegral (length points))
drawLine :: DrawableClass d => d -> GC -> Point -> Point -> IO ()
drawLine d gc (x1,y1) (x2,y2) = (\(Drawable arg1) (GC arg2) arg3 arg4 arg5 arg6 -> withForeignPtr arg1 $ \argPtr1 ->withForeignPtr arg2 $ \argPtr2 ->gdk_draw_line argPtr1 argPtr2 arg3 arg4 arg5 arg6) (toDrawable d)
(toGC gc) (fromIntegral x1) (fromIntegral y1) (fromIntegral x2)
(fromIntegral y2)
drawLines :: DrawableClass d => d -> GC -> [Point] -> IO ()
drawLines d gc [] = return ()
drawLines d gc points =
withArray (concatMap (\(x,y) -> [fromIntegral x, fromIntegral y]) points) $
\(aPtr :: Ptr (CInt)) -> (\(Drawable arg1) (GC arg2) arg3 arg4 -> withForeignPtr arg1 $ \argPtr1 ->withForeignPtr arg2 $ \argPtr2 ->gdk_draw_lines argPtr1 argPtr2 arg3 arg4) (toDrawable d)
(toGC gc) (castPtr aPtr) (fromIntegral (length points))
drawPixbuf :: DrawableClass d => d -> GC -> Pixbuf -> Int -> Int ->
Int -> Int -> Int -> Int -> Dither ->
Int -> Int -> IO ()
drawPixbuf d gc pb srcX srcY destX destY srcWidth srcHeight dither
xDither yDither = (\(Drawable arg1) (GC arg2) (Pixbuf arg3) arg4 arg5 arg6 arg7 arg8 arg9 arg10 arg11 arg12 -> withForeignPtr arg1 $ \argPtr1 ->withForeignPtr arg2 $ \argPtr2 ->withForeignPtr arg3 $ \argPtr3 ->gdk_draw_pixbuf argPtr1 argPtr2 argPtr3 arg4 arg5 arg6 arg7 arg8 arg9 arg10 arg11 arg12) (toDrawable d)
gc pb (fromIntegral srcX) (fromIntegral srcY) (fromIntegral destX)
(fromIntegral destY) (fromIntegral srcWidth) (fromIntegral srcHeight)
((fromIntegral . fromEnum) dither) (fromIntegral xDither)
(fromIntegral yDither)
drawSegments :: DrawableClass d => d -> GC -> [(Point,Point)] -> IO ()
drawSegments d gc [] = return ()
drawSegments d gc pps = withArray (concatMap (\((x1,y1),(x2,y2)) ->
[fromIntegral x1, fromIntegral y1, fromIntegral x2, fromIntegral y2])
pps) $ \(aPtr :: Ptr (CInt)) ->
(\(Drawable arg1) (GC arg2) arg3 arg4 -> withForeignPtr arg1 $ \argPtr1 ->withForeignPtr arg2 $ \argPtr2 ->gdk_draw_segments argPtr1 argPtr2 arg3 arg4) (toDrawable d) (toGC gc)
(castPtr aPtr) (fromIntegral (length pps))
drawRectangle :: DrawableClass d => d
-> GC
-> Bool
-> Int
-> Int
-> Int
-> Int
-> IO ()
drawRectangle d gc filled x y width height = (\(Drawable arg1) (GC arg2) arg3 arg4 arg5 arg6 arg7 -> withForeignPtr arg1 $ \argPtr1 ->withForeignPtr arg2 $ \argPtr2 ->gdk_draw_rectangle argPtr1 argPtr2 arg3 arg4 arg5 arg6 arg7)
(toDrawable d) (toGC gc) (fromBool filled) (fromIntegral x)
(fromIntegral y) (fromIntegral width) (fromIntegral height)
drawArc :: DrawableClass d => d -> GC -> Bool -> Int -> Int ->
Int -> Int -> Int -> Int -> IO ()
drawArc d gc filled x y width height aStart aEnd =
(\(Drawable arg1) (GC arg2) arg3 arg4 arg5 arg6 arg7 arg8 arg9 -> withForeignPtr arg1 $ \argPtr1 ->withForeignPtr arg2 $ \argPtr2 ->gdk_draw_arc argPtr1 argPtr2 arg3 arg4 arg5 arg6 arg7 arg8 arg9) (toDrawable d) (toGC gc) (fromBool filled)
(fromIntegral x) (fromIntegral y) (fromIntegral width) (fromIntegral height)
(fromIntegral aStart) (fromIntegral aEnd)
drawPolygon :: DrawableClass d => d -> GC -> Bool -> [Point] -> IO ()
drawPolygon _ _ _ [] = return ()
drawPolygon d gc filled points =
withArray (concatMap (\(x,y) -> [fromIntegral x, fromIntegral y]) points) $
\(aPtr::Ptr (CInt)) -> (\(Drawable arg1) (GC arg2) arg3 arg4 arg5 -> withForeignPtr arg1 $ \argPtr1 ->withForeignPtr arg2 $ \argPtr2 ->gdk_draw_polygon argPtr1 argPtr2 arg3 arg4 arg5) (toDrawable d)
(toGC gc) (fromBool filled) (castPtr aPtr) (fromIntegral (length points))
drawGlyphs :: DrawableClass d => d -> GC -> Int -> Int -> GlyphItem -> IO ()
drawGlyphs d gc x y (GlyphItem pi gs) = do
font <- pangoItemGetFont pi
(\(Drawable arg1) (GC arg2) (Font arg3) arg4 arg5 (GlyphStringRaw arg6) -> withForeignPtr arg1 $ \argPtr1 ->withForeignPtr arg2 $ \argPtr2 ->withForeignPtr arg3 $ \argPtr3 ->withForeignPtr arg6 $ \argPtr6 ->gdk_draw_glyphs argPtr1 argPtr2 argPtr3 arg4 arg5 argPtr6) (toDrawable d) (toGC gc) font
(fromIntegral x) (fromIntegral y) gs
drawLayoutLine :: DrawableClass d => d -> GC -> Int -> Int -> LayoutLine ->
IO ()
drawLayoutLine d gc x y (LayoutLine _ ll) =
(\(Drawable arg1) (GC arg2) arg3 arg4 (LayoutLineRaw arg5) -> withForeignPtr arg1 $ \argPtr1 ->withForeignPtr arg2 $ \argPtr2 ->withForeignPtr arg5 $ \argPtr5 ->gdk_draw_layout_line argPtr1 argPtr2 arg3 arg4 argPtr5) (toDrawable d) (toGC gc)
(fromIntegral x) (fromIntegral y) ll
drawLayoutLineWithColors :: DrawableClass d => d -> GC -> Int -> Int ->
LayoutLine -> Maybe Color -> Maybe Color -> IO ()
drawLayoutLineWithColors d gc x y (LayoutLine _ ll) foreground background = let
withMB :: Storable a => Maybe a -> (Ptr a -> IO b) -> IO b
withMB Nothing f = f nullPtr
withMB (Just x) f = with x f
in
withMB foreground $ \fPtr -> withMB background $ \bPtr ->
(\(Drawable arg1) (GC arg2) arg3 arg4 (LayoutLineRaw arg5) arg6 arg7 -> withForeignPtr arg1 $ \argPtr1 ->withForeignPtr arg2 $ \argPtr2 ->withForeignPtr arg5 $ \argPtr5 ->gdk_draw_layout_line_with_colors argPtr1 argPtr2 arg3 arg4 argPtr5 arg6 arg7) (toDrawable d) (toGC gc)
(fromIntegral x) (fromIntegral y) ll (castPtr fPtr) (castPtr bPtr)
drawLayout :: DrawableClass d => d -> GC -> Int -> Int -> PangoLayout -> IO ()
drawLayout d gc x y (PangoLayout _ pl) =
(\(Drawable arg1) (GC arg2) arg3 arg4 (PangoLayoutRaw arg5) -> withForeignPtr arg1 $ \argPtr1 ->withForeignPtr arg2 $ \argPtr2 ->withForeignPtr arg5 $ \argPtr5 ->gdk_draw_layout argPtr1 argPtr2 arg3 arg4 argPtr5) (toDrawable d) (toGC gc)
(fromIntegral x) (fromIntegral y) pl
drawLayoutWithColors :: DrawableClass d => d -> GC -> Int -> Int ->
PangoLayout -> Maybe Color -> Maybe Color -> IO ()
drawLayoutWithColors d gc x y (PangoLayout _ pl) foreground background = let
withMB :: Storable a => Maybe a -> (Ptr a -> IO b) -> IO b
withMB Nothing f = f nullPtr
withMB (Just x) f = with x f
in
withMB foreground $ \fPtr -> withMB background $ \bPtr ->
(\(Drawable arg1) (GC arg2) arg3 arg4 (PangoLayoutRaw arg5) arg6 arg7 -> withForeignPtr arg1 $ \argPtr1 ->withForeignPtr arg2 $ \argPtr2 ->withForeignPtr arg5 $ \argPtr5 ->gdk_draw_layout_with_colors argPtr1 argPtr2 arg3 arg4 argPtr5 arg6 arg7) (toDrawable d) (toGC gc)
(fromIntegral x) (fromIntegral y) pl (castPtr fPtr) (castPtr bPtr)
drawDrawable :: (DrawableClass src, DrawableClass dest)
=> dest
-> GC
-> src
-> Int
-> Int
-> Int
-> Int
-> Int
-> Int
-> IO ()
drawDrawable dest gc src xSrc ySrc xDest yDest width height =
(\(Drawable arg1) (GC arg2) (Drawable arg3) arg4 arg5 arg6 arg7 arg8 arg9 -> withForeignPtr arg1 $ \argPtr1 ->withForeignPtr arg2 $ \argPtr2 ->withForeignPtr arg3 $ \argPtr3 ->gdk_draw_drawable argPtr1 argPtr2 argPtr3 arg4 arg5 arg6 arg7 arg8 arg9) (toDrawable dest) (toGC gc)
(toDrawable src)
(fromIntegral xSrc) (fromIntegral ySrc) (fromIntegral xDest)
(fromIntegral yDest) (fromIntegral width) (fromIntegral height)
foreign import ccall unsafe "gdk_drawable_get_depth"
gdk_drawable_get_depth :: ((Ptr Drawable) -> (IO CInt))
foreign import ccall unsafe "gdk_drawable_get_size"
gdk_drawable_get_size :: ((Ptr Drawable) -> ((Ptr CInt) -> ((Ptr CInt) -> (IO ()))))
foreign import ccall unsafe "gdk_drawable_get_clip_region"
gdk_drawable_get_clip_region :: ((Ptr Drawable) -> (IO (Ptr Region)))
foreign import ccall unsafe "gdk_drawable_get_visible_region"
gdk_drawable_get_visible_region :: ((Ptr Drawable) -> (IO (Ptr Region)))
foreign import ccall unsafe "gdk_draw_point"
gdk_draw_point :: ((Ptr Drawable) -> ((Ptr GC) -> (CInt -> (CInt -> (IO ())))))
foreign import ccall unsafe "gdk_draw_points"
gdk_draw_points :: ((Ptr Drawable) -> ((Ptr GC) -> ((Ptr ()) -> (CInt -> (IO ())))))
foreign import ccall unsafe "gdk_draw_line"
gdk_draw_line :: ((Ptr Drawable) -> ((Ptr GC) -> (CInt -> (CInt -> (CInt -> (CInt -> (IO ())))))))
foreign import ccall unsafe "gdk_draw_lines"
gdk_draw_lines :: ((Ptr Drawable) -> ((Ptr GC) -> ((Ptr ()) -> (CInt -> (IO ())))))
foreign import ccall unsafe "gdk_draw_pixbuf"
gdk_draw_pixbuf :: ((Ptr Drawable) -> ((Ptr GC) -> ((Ptr Pixbuf) -> (CInt -> (CInt -> (CInt -> (CInt -> (CInt -> (CInt -> (CInt -> (CInt -> (CInt -> (IO ())))))))))))))
foreign import ccall unsafe "gdk_draw_segments"
gdk_draw_segments :: ((Ptr Drawable) -> ((Ptr GC) -> ((Ptr ()) -> (CInt -> (IO ())))))
foreign import ccall unsafe "gdk_draw_rectangle"
gdk_draw_rectangle :: ((Ptr Drawable) -> ((Ptr GC) -> (CInt -> (CInt -> (CInt -> (CInt -> (CInt -> (IO ()))))))))
foreign import ccall unsafe "gdk_draw_arc"
gdk_draw_arc :: ((Ptr Drawable) -> ((Ptr GC) -> (CInt -> (CInt -> (CInt -> (CInt -> (CInt -> (CInt -> (CInt -> (IO ()))))))))))
foreign import ccall unsafe "gdk_draw_polygon"
gdk_draw_polygon :: ((Ptr Drawable) -> ((Ptr GC) -> (CInt -> ((Ptr ()) -> (CInt -> (IO ()))))))
foreign import ccall unsafe "gdk_draw_glyphs"
gdk_draw_glyphs :: ((Ptr Drawable) -> ((Ptr GC) -> ((Ptr Font) -> (CInt -> (CInt -> ((Ptr GlyphStringRaw) -> (IO ())))))))
foreign import ccall unsafe "gdk_draw_layout_line"
gdk_draw_layout_line :: ((Ptr Drawable) -> ((Ptr GC) -> (CInt -> (CInt -> ((Ptr LayoutLineRaw) -> (IO ()))))))
foreign import ccall unsafe "gdk_draw_layout_line_with_colors"
gdk_draw_layout_line_with_colors :: ((Ptr Drawable) -> ((Ptr GC) -> (CInt -> (CInt -> ((Ptr LayoutLineRaw) -> ((Ptr ()) -> ((Ptr ()) -> (IO ()))))))))
foreign import ccall unsafe "gdk_draw_layout"
gdk_draw_layout :: ((Ptr Drawable) -> ((Ptr GC) -> (CInt -> (CInt -> ((Ptr PangoLayoutRaw) -> (IO ()))))))
foreign import ccall unsafe "gdk_draw_layout_with_colors"
gdk_draw_layout_with_colors :: ((Ptr Drawable) -> ((Ptr GC) -> (CInt -> (CInt -> ((Ptr PangoLayoutRaw) -> ((Ptr ()) -> ((Ptr ()) -> (IO ()))))))))
foreign import ccall unsafe "gdk_draw_drawable"
gdk_draw_drawable :: ((Ptr Drawable) -> ((Ptr GC) -> ((Ptr Drawable) -> (CInt -> (CInt -> (CInt -> (CInt -> (CInt -> (CInt -> (IO ()))))))))))