{- |
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 #PopplerLinkMapping structure represents the location
of @action on the page
-}

module GI.Poppler.Structs.LinkMapping
    ( 

-- * Exported types
    LinkMapping(..)                         ,
    noLinkMapping                           ,


 -- * Methods
-- ** linkMappingCopy
    linkMappingCopy                         ,


-- ** linkMappingFree
    linkMappingFree                         ,


-- ** linkMappingNew
    linkMappingNew                          ,




 -- * Properties
-- ** Action
    linkMappingReadAction                   ,


-- ** Area
    linkMappingReadArea                     ,




    ) 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 LinkMapping = LinkMapping (ForeignPtr LinkMapping)
foreign import ccall "poppler_link_mapping_get_type" c_poppler_link_mapping_get_type :: 
    IO GType

instance BoxedObject LinkMapping where
    boxedType _ = c_poppler_link_mapping_get_type

noLinkMapping :: Maybe LinkMapping
noLinkMapping = Nothing

linkMappingReadArea :: LinkMapping -> IO Rectangle
linkMappingReadArea s = withManagedPtr s $ \ptr -> do
    val <- peek (ptr `plusPtr` 0) :: IO (Ptr Rectangle)
    val' <- (newBoxed Rectangle) val
    return val'

linkMappingReadAction :: LinkMapping -> IO Action
linkMappingReadAction s = withManagedPtr s $ \ptr -> do
    val <- peek (ptr `plusPtr` 32) :: IO (Ptr Action)
    val' <- (newBoxed Action) val
    return val'

-- method LinkMapping::new
-- method type : Constructor
-- Args : []
-- Lengths : []
-- hInArgs : []
-- returnType : TInterface "Poppler" "LinkMapping"
-- throws : False
-- Skip return : False

foreign import ccall "poppler_link_mapping_new" poppler_link_mapping_new :: 
    IO (Ptr LinkMapping)


linkMappingNew ::
    (MonadIO m) =>
    m LinkMapping
linkMappingNew  = liftIO $ do
    result <- poppler_link_mapping_new
    checkUnexpectedReturnNULL "poppler_link_mapping_new" result
    result' <- (wrapBoxed LinkMapping) result
    return result'

-- method LinkMapping::copy
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Poppler" "LinkMapping", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "Poppler" "LinkMapping", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TInterface "Poppler" "LinkMapping"
-- throws : False
-- Skip return : False

foreign import ccall "poppler_link_mapping_copy" poppler_link_mapping_copy :: 
    Ptr LinkMapping ->                      -- _obj : TInterface "Poppler" "LinkMapping"
    IO (Ptr LinkMapping)


linkMappingCopy ::
    (MonadIO m) =>
    LinkMapping ->                          -- _obj
    m LinkMapping
linkMappingCopy _obj = liftIO $ do
    let _obj' = unsafeManagedPtrGetPtr _obj
    result <- poppler_link_mapping_copy _obj'
    checkUnexpectedReturnNULL "poppler_link_mapping_copy" result
    result' <- (wrapBoxed LinkMapping) result
    touchManagedPtr _obj
    return result'

-- method LinkMapping::free
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Poppler" "LinkMapping", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "Poppler" "LinkMapping", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TBasicType TVoid
-- throws : False
-- Skip return : False

foreign import ccall "poppler_link_mapping_free" poppler_link_mapping_free :: 
    Ptr LinkMapping ->                      -- _obj : TInterface "Poppler" "LinkMapping"
    IO ()


linkMappingFree ::
    (MonadIO m) =>
    LinkMapping ->                          -- _obj
    m ()
linkMappingFree _obj = liftIO $ do
    let _obj' = unsafeManagedPtrGetPtr _obj
    poppler_link_mapping_free _obj'
    touchManagedPtr _obj
    return ()