gi-poppler-0.0.30.12: GI/Poppler/Structs/Color.hs
{- |
Copyright : Will Thompson, Iñaki García Etxebarria and Jonas Platte
License : LGPL-2.1
Maintainer : Iñaki García Etxebarria (garetxe@gmail.com)
A #PopplerColor describes a RGB color. Color components
are values between 0 and 65535
-}
module GI.Poppler.Structs.Color
(
-- * Exported types
Color(..) ,
noColor ,
-- * Methods
-- ** colorCopy
colorCopy ,
-- ** colorFree
colorFree ,
-- ** colorNew
colorNew ,
-- * Properties
-- ** Blue
colorReadBlue ,
-- ** Green
colorReadGreen ,
-- ** Red
colorReadRed ,
) where
import Prelude ()
import Data.GI.Base.ShortPrelude
import qualified Data.Text as T
import qualified Data.ByteString.Char8 as B
import qualified Data.Map as Map
import GI.Poppler.Types
import GI.Poppler.Callbacks
newtype Color = Color (ForeignPtr Color)
foreign import ccall "poppler_color_get_type" c_poppler_color_get_type ::
IO GType
instance BoxedObject Color where
boxedType _ = c_poppler_color_get_type
noColor :: Maybe Color
noColor = Nothing
colorReadRed :: Color -> IO Word16
colorReadRed s = withManagedPtr s $ \ptr -> do
val <- peek (ptr `plusPtr` 0) :: IO Word16
return val
colorReadGreen :: Color -> IO Word16
colorReadGreen s = withManagedPtr s $ \ptr -> do
val <- peek (ptr `plusPtr` 2) :: IO Word16
return val
colorReadBlue :: Color -> IO Word16
colorReadBlue s = withManagedPtr s $ \ptr -> do
val <- peek (ptr `plusPtr` 4) :: IO Word16
return val
-- method Color::new
-- method type : Constructor
-- Args : []
-- Lengths : []
-- hInArgs : []
-- returnType : TInterface "Poppler" "Color"
-- throws : False
-- Skip return : False
foreign import ccall "poppler_color_new" poppler_color_new ::
IO (Ptr Color)
colorNew ::
(MonadIO m) =>
m Color
colorNew = liftIO $ do
result <- poppler_color_new
checkUnexpectedReturnNULL "poppler_color_new" result
result' <- (wrapBoxed Color) result
return result'
-- method Color::copy
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Poppler" "Color", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "Poppler" "Color", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TInterface "Poppler" "Color"
-- throws : False
-- Skip return : False
foreign import ccall "poppler_color_copy" poppler_color_copy ::
Ptr Color -> -- _obj : TInterface "Poppler" "Color"
IO (Ptr Color)
colorCopy ::
(MonadIO m) =>
Color -> -- _obj
m Color
colorCopy _obj = liftIO $ do
let _obj' = unsafeManagedPtrGetPtr _obj
result <- poppler_color_copy _obj'
checkUnexpectedReturnNULL "poppler_color_copy" result
result' <- (wrapBoxed Color) result
touchManagedPtr _obj
return result'
-- method Color::free
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Poppler" "Color", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "Poppler" "Color", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TBasicType TVoid
-- throws : False
-- Skip return : False
foreign import ccall "poppler_color_free" poppler_color_free ::
Ptr Color -> -- _obj : TInterface "Poppler" "Color"
IO ()
colorFree ::
(MonadIO m) =>
Color -> -- _obj
m ()
colorFree _obj = liftIO $ do
let _obj' = unsafeManagedPtrGetPtr _obj
poppler_color_free _obj'
touchManagedPtr _obj
return ()