{- |
Copyright  : Will Thompson, Iñaki García Etxebarria and Jonas Platte
License    : LGPL-2.1
Maintainer : Iñaki García Etxebarria (inaki@blueleaf.cc)

A 'GI.Poppler.Structs.ImageMapping.ImageMapping' structure represents the location
of an image on the page
-}

#define ENABLE_OVERLOADING (MIN_VERSION_haskell_gi_overloading(1,0,0) \
       && !defined(__HADDOCK_VERSION__))

module GI.Poppler.Structs.ImageMapping
    (

-- * Exported types
    ImageMapping(..)                        ,
    newZeroImageMapping                     ,
    noImageMapping                          ,


 -- * Methods
-- ** copy #method:copy#

#if ENABLE_OVERLOADING
    ImageMappingCopyMethodInfo              ,
#endif
    imageMappingCopy                        ,


-- ** free #method:free#

#if ENABLE_OVERLOADING
    ImageMappingFreeMethodInfo              ,
#endif
    imageMappingFree                        ,


-- ** new #method:new#

    imageMappingNew                         ,




 -- * Properties
-- ** area #attr:area#
{- | a 'GI.Poppler.Structs.Rectangle.Rectangle' representing an area of the page
-}
    getImageMappingArea                     ,
#if ENABLE_OVERLOADING
    imageMapping_area                       ,
#endif


-- ** imageId #attr:imageId#
{- | an image identifier
-}
    getImageMappingImageId                  ,
#if ENABLE_OVERLOADING
    imageMapping_imageId                    ,
#endif
    setImageMappingImageId                  ,




    ) where

import Data.GI.Base.ShortPrelude
import qualified Data.GI.Base.ShortPrelude as SP
import qualified Data.GI.Base.Overloading as O
import qualified Prelude as P

import qualified Data.GI.Base.Attributes as GI.Attributes
import qualified Data.GI.Base.ManagedPtr as B.ManagedPtr
import qualified Data.GI.Base.GClosure as B.GClosure
import qualified Data.GI.Base.GError as B.GError
import qualified Data.GI.Base.GVariant as B.GVariant
import qualified Data.GI.Base.GValue as B.GValue
import qualified Data.GI.Base.GParamSpec as B.GParamSpec
import qualified Data.GI.Base.CallStack as B.CallStack
import qualified Data.GI.Base.Properties as B.Properties
import qualified Data.Text as T
import qualified Data.ByteString.Char8 as B
import qualified Data.Map as Map
import qualified Foreign.Ptr as FP
import qualified GHC.OverloadedLabels as OL

import {-# SOURCE #-} qualified GI.Poppler.Structs.Rectangle as Poppler.Rectangle

-- | Memory-managed wrapper type.
newtype ImageMapping = ImageMapping (ManagedPtr ImageMapping)
foreign import ccall "poppler_image_mapping_get_type" c_poppler_image_mapping_get_type ::
    IO GType

instance BoxedObject ImageMapping where
    boxedType _ = c_poppler_image_mapping_get_type

-- | Construct a `ImageMapping` struct initialized to zero.
newZeroImageMapping :: MonadIO m => m ImageMapping
newZeroImageMapping = liftIO $ callocBoxedBytes 40 >>= wrapBoxed ImageMapping

instance tag ~ 'AttrSet => Constructible ImageMapping tag where
    new _ attrs = do
        o <- newZeroImageMapping
        GI.Attributes.set o attrs
        return o


-- | A convenience alias for `Nothing` :: `Maybe` `ImageMapping`.
noImageMapping :: Maybe ImageMapping
noImageMapping = Nothing

{- |
Get the value of the “@area@” field.
When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to

@
'Data.GI.Base.Attributes.get' imageMapping #area
@
-}
getImageMappingArea :: MonadIO m => ImageMapping -> m Poppler.Rectangle.Rectangle
getImageMappingArea s = liftIO $ withManagedPtr s $ \ptr -> do
    let val = ptr `plusPtr` 0 :: (Ptr Poppler.Rectangle.Rectangle)
    val' <- (newBoxed Poppler.Rectangle.Rectangle) val
    return val'

#if ENABLE_OVERLOADING
data ImageMappingAreaFieldInfo
instance AttrInfo ImageMappingAreaFieldInfo where
    type AttrAllowedOps ImageMappingAreaFieldInfo = '[ 'AttrGet]
    type AttrSetTypeConstraint ImageMappingAreaFieldInfo = (~) (Ptr Poppler.Rectangle.Rectangle)
    type AttrBaseTypeConstraint ImageMappingAreaFieldInfo = (~) ImageMapping
    type AttrGetType ImageMappingAreaFieldInfo = Poppler.Rectangle.Rectangle
    type AttrLabel ImageMappingAreaFieldInfo = "area"
    type AttrOrigin ImageMappingAreaFieldInfo = ImageMapping
    attrGet _ = getImageMappingArea
    attrSet _ = undefined
    attrConstruct = undefined
    attrClear _ = undefined

imageMapping_area :: AttrLabelProxy "area"
imageMapping_area = AttrLabelProxy

#endif


{- |
Get the value of the “@image_id@” field.
When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to

@
'Data.GI.Base.Attributes.get' imageMapping #imageId
@
-}
getImageMappingImageId :: MonadIO m => ImageMapping -> m Int32
getImageMappingImageId s = liftIO $ withManagedPtr s $ \ptr -> do
    val <- peek (ptr `plusPtr` 32) :: IO Int32
    return val

{- |
Set the value of the “@image_id@” field.
When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to

@
'Data.GI.Base.Attributes.set' imageMapping [ #imageId 'Data.GI.Base.Attributes.:=' value ]
@
-}
setImageMappingImageId :: MonadIO m => ImageMapping -> Int32 -> m ()
setImageMappingImageId s val = liftIO $ withManagedPtr s $ \ptr -> do
    poke (ptr `plusPtr` 32) (val :: Int32)

#if ENABLE_OVERLOADING
data ImageMappingImageIdFieldInfo
instance AttrInfo ImageMappingImageIdFieldInfo where
    type AttrAllowedOps ImageMappingImageIdFieldInfo = '[ 'AttrSet, 'AttrGet]
    type AttrSetTypeConstraint ImageMappingImageIdFieldInfo = (~) Int32
    type AttrBaseTypeConstraint ImageMappingImageIdFieldInfo = (~) ImageMapping
    type AttrGetType ImageMappingImageIdFieldInfo = Int32
    type AttrLabel ImageMappingImageIdFieldInfo = "image_id"
    type AttrOrigin ImageMappingImageIdFieldInfo = ImageMapping
    attrGet _ = getImageMappingImageId
    attrSet _ = setImageMappingImageId
    attrConstruct = undefined
    attrClear _ = undefined

imageMapping_imageId :: AttrLabelProxy "imageId"
imageMapping_imageId = AttrLabelProxy

#endif



#if ENABLE_OVERLOADING
instance O.HasAttributeList ImageMapping
type instance O.AttributeList ImageMapping = ImageMappingAttributeList
type ImageMappingAttributeList = ('[ '("area", ImageMappingAreaFieldInfo), '("imageId", ImageMappingImageIdFieldInfo)] :: [(Symbol, *)])
#endif

-- method ImageMapping::new
-- method type : Constructor
-- Args : []
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "Poppler", name = "ImageMapping"}))
-- throws : False
-- Skip return : False

foreign import ccall "poppler_image_mapping_new" poppler_image_mapping_new ::
    IO (Ptr ImageMapping)

{- |
Creates a new 'GI.Poppler.Structs.ImageMapping.ImageMapping'
-}
imageMappingNew ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    m ImageMapping
    {- ^ __Returns:__ a new 'GI.Poppler.Structs.ImageMapping.ImageMapping', use 'GI.Poppler.Structs.ImageMapping.imageMappingFree' to free it -}
imageMappingNew  = liftIO $ do
    result <- poppler_image_mapping_new
    checkUnexpectedReturnNULL "imageMappingNew" result
    result' <- (wrapBoxed ImageMapping) result
    return result'

#if ENABLE_OVERLOADING
#endif

-- method ImageMapping::copy
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "mapping", argType = TInterface (Name {namespace = "Poppler", name = "ImageMapping"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #PopplerImageMapping to copy", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "Poppler", name = "ImageMapping"}))
-- throws : False
-- Skip return : False

foreign import ccall "poppler_image_mapping_copy" poppler_image_mapping_copy ::
    Ptr ImageMapping ->                     -- mapping : TInterface (Name {namespace = "Poppler", name = "ImageMapping"})
    IO (Ptr ImageMapping)

{- |
Creates a copy of /@mapping@/
-}
imageMappingCopy ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    ImageMapping
    {- ^ /@mapping@/: a 'GI.Poppler.Structs.ImageMapping.ImageMapping' to copy -}
    -> m ImageMapping
    {- ^ __Returns:__ a new allocated copy of /@mapping@/ -}
imageMappingCopy mapping = liftIO $ do
    mapping' <- unsafeManagedPtrGetPtr mapping
    result <- poppler_image_mapping_copy mapping'
    checkUnexpectedReturnNULL "imageMappingCopy" result
    result' <- (wrapBoxed ImageMapping) result
    touchManagedPtr mapping
    return result'

#if ENABLE_OVERLOADING
data ImageMappingCopyMethodInfo
instance (signature ~ (m ImageMapping), MonadIO m) => O.MethodInfo ImageMappingCopyMethodInfo ImageMapping signature where
    overloadedMethod _ = imageMappingCopy

#endif

-- method ImageMapping::free
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "mapping", argType = TInterface (Name {namespace = "Poppler", name = "ImageMapping"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #PopplerImageMapping", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "poppler_image_mapping_free" poppler_image_mapping_free ::
    Ptr ImageMapping ->                     -- mapping : TInterface (Name {namespace = "Poppler", name = "ImageMapping"})
    IO ()

{- |
Frees the given 'GI.Poppler.Structs.ImageMapping.ImageMapping'
-}
imageMappingFree ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    ImageMapping
    {- ^ /@mapping@/: a 'GI.Poppler.Structs.ImageMapping.ImageMapping' -}
    -> m ()
imageMappingFree mapping = liftIO $ do
    mapping' <- unsafeManagedPtrGetPtr mapping
    poppler_image_mapping_free mapping'
    touchManagedPtr mapping
    return ()

#if ENABLE_OVERLOADING
data ImageMappingFreeMethodInfo
instance (signature ~ (m ()), MonadIO m) => O.MethodInfo ImageMappingFreeMethodInfo ImageMapping signature where
    overloadedMethod _ = imageMappingFree

#endif

#if ENABLE_OVERLOADING
type family ResolveImageMappingMethod (t :: Symbol) (o :: *) :: * where
    ResolveImageMappingMethod "copy" o = ImageMappingCopyMethodInfo
    ResolveImageMappingMethod "free" o = ImageMappingFreeMethodInfo
    ResolveImageMappingMethod l o = O.MethodResolutionFailed l o

instance (info ~ ResolveImageMappingMethod t ImageMapping, O.MethodInfo info ImageMapping p) => OL.IsLabel t (ImageMapping -> p) where
#if MIN_VERSION_base(4,10,0)
    fromLabel = O.overloadedMethod (O.MethodProxy :: O.MethodProxy info)
#else
    fromLabel _ = O.overloadedMethod (O.MethodProxy :: O.MethodProxy info)
#endif

#endif