----------------------------------------------------------------------------- -- Module : Graphics.X11.Xrender -- Copyright : Clemens Fruhwirth 2007 -- -- Haskell bindings for the Xrender extension. -- ----------------------------------------------------------------------------- module Graphics.X11.Xrender where import Graphics.X11 import Graphics.X11.Xlib.Types import Foreign import Foreign.C import Foreign.C.Types import Foreign.Ptr import Foreign.Storable( Storable(..) ) #include peekCUShort :: Ptr a -> CInt -> IO Int peekCUShort ptr off = do v <- peekByteOff ptr (fromIntegral off) return (fromIntegral (v::CUShort)) pokeCUShort :: Ptr a -> CInt -> Int -> IO () pokeCUShort ptr off v = pokeByteOff ptr (fromIntegral off) (fromIntegral v::CUShort) peekCShort :: Ptr a -> CInt -> IO Int peekCShort ptr off = do v <- peekByteOff ptr (fromIntegral off) return (fromIntegral (v::CShort)) pokeCShort :: Ptr a -> CInt -> Int -> IO () pokeCShort ptr off v = pokeByteOff ptr (fromIntegral off) (fromIntegral v::CShort) data XRenderColor = XRenderColor { xrc_red :: Int, xrc_green :: Int, xrc_blue :: Int, xrc_alpha :: Int } instance Storable XRenderColor where sizeOf _ = #{size XRenderColor} alignment _ = alignment (undefined::CInt) peek p = do red <- peekCUShort p #{offset XRenderColor, red} blue <- peekCUShort p #{offset XRenderColor, blue} green <- peekCUShort p #{offset XRenderColor, green} alpha <- peekCUShort p #{offset XRenderColor, alpha} return (XRenderColor red blue green alpha) poke p (XRenderColor red blue green alpha) = do pokeCUShort p #{offset XRenderColor,red} red pokeCUShort p #{offset XRenderColor,blue} blue pokeCUShort p #{offset XRenderColor,green} green pokeCUShort p #{offset XRenderColor,alpha} alpha data XGlyphInfo = XGlyphInfo { gi_width :: Int, gi_height :: Int, gi_x :: Int, gi_y :: Int, gi_xOff :: Int, gi_yOff :: Int } instance Storable XGlyphInfo where sizeOf _ = #{size XGlyphInfo} alignment _ = alignment (undefined::CInt) peek p = do width <- peekCUShort p #{offset XGlyphInfo, width} height <- peekCUShort p #{offset XGlyphInfo, height} x <- peekCShort p #{offset XGlyphInfo, x} y <- peekCShort p #{offset XGlyphInfo, y} xOff <- peekCShort p #{offset XGlyphInfo, xOff} yOff <- peekCShort p #{offset XGlyphInfo, yOff} return (XGlyphInfo width height x y xOff yOff) poke p (XGlyphInfo width height x y xOff yOff) = do pokeCUShort p #{offset XGlyphInfo,width} width pokeCUShort p #{offset XGlyphInfo,height} height pokeCShort p #{offset XGlyphInfo,x} x pokeCShort p #{offset XGlyphInfo,y} y pokeCShort p #{offset XGlyphInfo,xOff} xOff pokeCShort p #{offset XGlyphInfo,yOff} yOff