gi-poppler-0.0.34.13: GI/Poppler/Structs/Dest.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)
Data structure for holding a destination
-}
module GI.Poppler.Structs.Dest
(
-- * Exported types
Dest(..) ,
newZeroDest ,
noDest ,
-- * Methods
-- ** destCopy
DestCopyMethodInfo ,
destCopy ,
-- ** destFree
DestFreeMethodInfo ,
destFree ,
-- * Properties
-- ** Bottom
destReadBottom ,
-- ** ChangeLeft
destReadChangeLeft ,
-- ** ChangeTop
destReadChangeTop ,
-- ** ChangeZoom
destReadChangeZoom ,
-- ** Left
destReadLeft ,
-- ** NamedDest
destReadNamedDest ,
-- ** PageNum
destReadPageNum ,
-- ** Right
destReadRight ,
-- ** Top
destReadTop ,
-- ** Type
destReadType ,
-- ** Zoom
destReadZoom ,
) 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 Dest = Dest (ForeignPtr Dest)
foreign import ccall "poppler_dest_get_type" c_poppler_dest_get_type ::
IO GType
instance BoxedObject Dest where
boxedType _ = c_poppler_dest_get_type
-- | Construct a `Dest` struct initialized to zero.
newZeroDest :: MonadIO m => m Dest
newZeroDest = liftIO $ callocBoxedBytes 72 >>= wrapBoxed Dest
noDest :: Maybe Dest
noDest = Nothing
destReadType :: Dest -> IO DestType
destReadType s = withManagedPtr s $ \ptr -> do
val <- peek (ptr `plusPtr` 0) :: IO CUInt
let val' = (toEnum . fromIntegral) val
return val'
destReadPageNum :: Dest -> IO Int32
destReadPageNum s = withManagedPtr s $ \ptr -> do
val <- peek (ptr `plusPtr` 4) :: IO Int32
return val
destReadLeft :: Dest -> IO Double
destReadLeft s = withManagedPtr s $ \ptr -> do
val <- peek (ptr `plusPtr` 8) :: IO CDouble
let val' = realToFrac val
return val'
destReadBottom :: Dest -> IO Double
destReadBottom s = withManagedPtr s $ \ptr -> do
val <- peek (ptr `plusPtr` 16) :: IO CDouble
let val' = realToFrac val
return val'
destReadRight :: Dest -> IO Double
destReadRight s = withManagedPtr s $ \ptr -> do
val <- peek (ptr `plusPtr` 24) :: IO CDouble
let val' = realToFrac val
return val'
destReadTop :: Dest -> IO Double
destReadTop s = withManagedPtr s $ \ptr -> do
val <- peek (ptr `plusPtr` 32) :: IO CDouble
let val' = realToFrac val
return val'
destReadZoom :: Dest -> IO Double
destReadZoom s = withManagedPtr s $ \ptr -> do
val <- peek (ptr `plusPtr` 40) :: IO CDouble
let val' = realToFrac val
return val'
destReadNamedDest :: Dest -> IO T.Text
destReadNamedDest s = withManagedPtr s $ \ptr -> do
val <- peek (ptr `plusPtr` 48) :: IO CString
val' <- cstringToText val
return val'
destReadChangeLeft :: Dest -> IO Word32
destReadChangeLeft s = withManagedPtr s $ \ptr -> do
val <- peek (ptr `plusPtr` 56) :: IO Word32
return val
destReadChangeTop :: Dest -> IO Word32
destReadChangeTop s = withManagedPtr s $ \ptr -> do
val <- peek (ptr `plusPtr` 60) :: IO Word32
return val
destReadChangeZoom :: Dest -> IO Word32
destReadChangeZoom s = withManagedPtr s $ \ptr -> do
val <- peek (ptr `plusPtr` 64) :: IO Word32
return val
-- method Dest::copy
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "_obj", argType = TInterface "Poppler" "Dest", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : TInterface "Poppler" "Dest"
-- throws : False
-- Skip return : False
foreign import ccall "poppler_dest_copy" poppler_dest_copy ::
Ptr Dest -> -- _obj : TInterface "Poppler" "Dest"
IO (Ptr Dest)
destCopy ::
(MonadIO m) =>
Dest -- _obj
-> m Dest -- result
destCopy _obj = liftIO $ do
let _obj' = unsafeManagedPtrGetPtr _obj
result <- poppler_dest_copy _obj'
checkUnexpectedReturnNULL "poppler_dest_copy" result
result' <- (wrapBoxed Dest) result
touchManagedPtr _obj
return result'
data DestCopyMethodInfo
instance (signature ~ (m Dest), MonadIO m) => MethodInfo DestCopyMethodInfo Dest signature where
overloadedMethod _ = destCopy
-- method Dest::free
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "_obj", argType = TInterface "Poppler" "Dest", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : TBasicType TVoid
-- throws : False
-- Skip return : False
foreign import ccall "poppler_dest_free" poppler_dest_free ::
Ptr Dest -> -- _obj : TInterface "Poppler" "Dest"
IO ()
destFree ::
(MonadIO m) =>
Dest -- _obj
-> m () -- result
destFree _obj = liftIO $ do
let _obj' = unsafeManagedPtrGetPtr _obj
poppler_dest_free _obj'
touchManagedPtr _obj
return ()
data DestFreeMethodInfo
instance (signature ~ (m ()), MonadIO m) => MethodInfo DestFreeMethodInfo Dest signature where
overloadedMethod _ = destFree
type family ResolveDestMethod (t :: Symbol) (o :: *) :: * where
ResolveDestMethod "copy" o = DestCopyMethodInfo
ResolveDestMethod "free" o = DestFreeMethodInfo
ResolveDestMethod l o = MethodResolutionFailed l o
instance (info ~ ResolveDestMethod t Dest, MethodInfo info Dest p) => IsLabelProxy t (Dest -> p) where
fromLabelProxy _ = overloadedMethod (MethodProxy :: MethodProxy info)
#if MIN_VERSION_base(4,9,0)
instance (info ~ ResolveDestMethod t Dest, MethodInfo info Dest p) => IsLabel t (Dest -> p) where
fromLabel _ = overloadedMethod (MethodProxy :: MethodProxy info)
#endif