{- |
Copyright  : Will Thompson, Iñaki García Etxebarria and Jonas Platte
License    : LGPL-2.1
Maintainer : Iñaki García Etxebarria (garetxe@gmail.com)
-}

module GI.Poppler.Objects.AnnotSquare
    ( 

-- * Exported types
    AnnotSquare(..)                         ,
    AnnotSquareK                            ,
    toAnnotSquare                           ,
    noAnnotSquare                           ,


 -- * Methods
-- ** annotSquareGetInteriorColor
    annotSquareGetInteriorColor             ,


-- ** annotSquareNew
    annotSquareNew                          ,


-- ** annotSquareSetInteriorColor
    annotSquareSetInteriorColor             ,




    ) 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
import qualified GI.GObject as GObject

newtype AnnotSquare = AnnotSquare (ForeignPtr AnnotSquare)
foreign import ccall "poppler_annot_square_get_type"
    c_poppler_annot_square_get_type :: IO GType

type instance ParentTypes AnnotSquare = AnnotSquareParentTypes
type AnnotSquareParentTypes = '[AnnotMarkup, Annot, GObject.Object]

instance GObject AnnotSquare where
    gobjectIsInitiallyUnowned _ = False
    gobjectType _ = c_poppler_annot_square_get_type
    

class GObject o => AnnotSquareK o
instance (GObject o, IsDescendantOf AnnotSquare o) => AnnotSquareK o

toAnnotSquare :: AnnotSquareK o => o -> IO AnnotSquare
toAnnotSquare = unsafeCastTo AnnotSquare

noAnnotSquare :: Maybe AnnotSquare
noAnnotSquare = Nothing

type instance AttributeList AnnotSquare = AnnotSquareAttributeList
type AnnotSquareAttributeList = ('[ ] :: [(Symbol, *)])

type instance SignalList AnnotSquare = AnnotSquareSignalList
type AnnotSquareSignalList = ('[ '("notify", GObject.ObjectNotifySignalInfo), '("notify::[property]", GObjectNotifySignalInfo)] :: [(Symbol, *)])

-- method AnnotSquare::new
-- method type : Constructor
-- Args : [Arg {argName = "doc", argType = TInterface "Poppler" "Document", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "rect", argType = TInterface "Poppler" "Rectangle", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "doc", argType = TInterface "Poppler" "Document", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "rect", argType = TInterface "Poppler" "Rectangle", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TInterface "Poppler" "AnnotSquare"
-- throws : False
-- Skip return : False

foreign import ccall "poppler_annot_square_new" poppler_annot_square_new :: 
    Ptr Document ->                         -- doc : TInterface "Poppler" "Document"
    Ptr Rectangle ->                        -- rect : TInterface "Poppler" "Rectangle"
    IO (Ptr AnnotSquare)


annotSquareNew ::
    (MonadIO m, DocumentK a) =>
    a ->                                    -- doc
    Rectangle ->                            -- rect
    m AnnotSquare
annotSquareNew doc rect = liftIO $ do
    let doc' = unsafeManagedPtrCastPtr doc
    let rect' = unsafeManagedPtrGetPtr rect
    result <- poppler_annot_square_new doc' rect'
    checkUnexpectedReturnNULL "poppler_annot_square_new" result
    result' <- (wrapObject AnnotSquare) result
    touchManagedPtr doc
    touchManagedPtr rect
    return result'

-- method AnnotSquare::get_interior_color
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Poppler" "AnnotSquare", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "Poppler" "AnnotSquare", 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_annot_square_get_interior_color" poppler_annot_square_get_interior_color :: 
    Ptr AnnotSquare ->                      -- _obj : TInterface "Poppler" "AnnotSquare"
    IO (Ptr Color)


annotSquareGetInteriorColor ::
    (MonadIO m, AnnotSquareK a) =>
    a ->                                    -- _obj
    m Color
annotSquareGetInteriorColor _obj = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    result <- poppler_annot_square_get_interior_color _obj'
    checkUnexpectedReturnNULL "poppler_annot_square_get_interior_color" result
    result' <- (wrapBoxed Color) result
    touchManagedPtr _obj
    return result'

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

foreign import ccall "poppler_annot_square_set_interior_color" poppler_annot_square_set_interior_color :: 
    Ptr AnnotSquare ->                      -- _obj : TInterface "Poppler" "AnnotSquare"
    Ptr Color ->                            -- poppler_color : TInterface "Poppler" "Color"
    IO ()


annotSquareSetInteriorColor ::
    (MonadIO m, AnnotSquareK a) =>
    a ->                                    -- _obj
    Maybe (Color) ->                        -- poppler_color
    m ()
annotSquareSetInteriorColor _obj poppler_color = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    maybePoppler_color <- case poppler_color of
        Nothing -> return nullPtr
        Just jPoppler_color -> do
            let jPoppler_color' = unsafeManagedPtrGetPtr jPoppler_color
            return jPoppler_color'
    poppler_annot_square_set_interior_color _obj' maybePoppler_color
    touchManagedPtr _obj
    whenJust poppler_color touchManagedPtr
    return ()