{-# LANGUAGE ForeignFunctionInterface #-} module Graphics.UI.FLTK.Image (Image, newImage, deimage, image, width, height) where import Graphics.UI.FLTK.Widget import Foreign import Foreign.C.String -- | Type for images. newtype Image = Image (Ptr Image) foreign import ccall "fl_Image_new" _newImage :: CString -> IO (Ptr Image) -- | Load new image from a file. Supports bmp, png, jpeg, gif and xpm... newImage :: FilePath -> IO Image newImage fp = throwIfNull "newImage" (withCString fp _newImage) >>= return.Image foreign import ccall "fl_Widget_deimage_AG" fl_Widget_deimage_AG :: Ptr Widget -> IO Image foreign import ccall "fl_Widget_deimage_AS" fl_Widget_deimage_AS :: Ptr Widget -> Image -> IO () -- | Image for deactived widget. deimage :: Widget_C w => Attr w Image deimage = Attr (fl_Widget_deimage_AG . _widget) (fl_Widget_deimage_AS . _widget) foreign import ccall "fl_Widget_image_AG" fl_Widget_image_AG :: Ptr Widget -> IO Image foreign import ccall "fl_Widget_image_AS" fl_Widget_image_AS :: Ptr Widget -> Image -> IO () -- | Image for actived widget. image :: Widget_C w => Attr w Image image = Attr (fl_Widget_image_AG . _widget) (fl_Widget_image_AS . _widget) foreign import ccall "fl_Image_w" width :: Image -> IO Int foreign import ccall "fl_Image_h" height :: Image -> IO Int