    {-# LANGUAGE TypeApplications #-}

    -- | Copyright  : Will Thompson and Iñaki García Etxebarria
    -- License    : LGPL-2.1
    -- Maintainer : Iñaki García Etxebarria
    --
    -- A render node for a paste.
    --
    -- /Since: 4.22/

    #if !defined(__HADDOCK_VERSION__)
    #define ENABLE_OVERLOADING
    #endif

    module GI.Gsk.Objects.PasteNode
        (

    -- * Exported types
        PasteNode(..)                           ,
        IsPasteNode                             ,
        toPasteNode                             ,

     -- * Methods
    -- |
    --
    --  === __Click to display all available methods, including inherited ones__
    -- ==== Methods
    -- [draw]("GI.Gsk.Objects.RenderNode#g:method:draw"), [ref]("GI.Gsk.Objects.RenderNode#g:method:ref"), [serialize]("GI.Gsk.Objects.RenderNode#g:method:serialize"), [unref]("GI.Gsk.Objects.RenderNode#g:method:unref"), [writeToFile]("GI.Gsk.Objects.RenderNode#g:method:writeToFile").
    --
    -- ==== Getters
    -- [getBounds]("GI.Gsk.Objects.RenderNode#g:method:getBounds"), [getDepth]("GI.Gsk.Objects.PasteNode#g:method:getDepth"), [getNodeType]("GI.Gsk.Objects.RenderNode#g:method:getNodeType"), [getOpaqueRect]("GI.Gsk.Objects.RenderNode#g:method:getOpaqueRect").
    --
    -- ==== Setters
    -- /None/.

    #if defined(ENABLE_OVERLOADING)
        ResolvePasteNodeMethod                  ,
    #endif

    -- ** getDepth #method:getDepth#

    #if defined(ENABLE_OVERLOADING)
        PasteNodeGetDepthMethodInfo             ,
    #endif
        pasteNodeGetDepth                       ,

    -- ** new #method:new#

        pasteNodeNew                            ,

        ) 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.BasicTypes as B.Types
    import qualified Data.GI.Base.ManagedPtr as B.ManagedPtr
    import qualified Data.GI.Base.GArray as B.GArray
    import qualified Data.GI.Base.GClosure as B.GClosure
    import qualified Data.GI.Base.GError as B.GError
    import qualified Data.GI.Base.GHashTable as B.GHT
    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.GI.Base.Signals as B.Signals
    import qualified Control.Monad.IO.Class as MIO
    import qualified Data.Coerce as Coerce
    import qualified Data.Text as T
    import qualified Data.Kind as DK
    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 qualified GHC.Records as R
    import qualified Data.Word as DW
    import qualified Data.Int as DI
    import qualified System.Posix.Types as SPT
    import qualified Foreign.C.Types as FCT

    -- Workaround for https://gitlab.haskell.org/ghc/ghc/-/issues/23392
    #if MIN_VERSION_base(4,18,0)
    import qualified GI.Cairo.Structs.Context as Cairo.Context
    import qualified GI.GLib.Structs.Bytes as GLib.Bytes
    import qualified GI.Graphene.Structs.Rect as Graphene.Rect
    import qualified GI.Gsk.Callbacks as Gsk.Callbacks
    import {-# SOURCE #-} qualified GI.Gsk.Enums as Gsk.Enums
    import {-# SOURCE #-} qualified GI.Gsk.Objects.RenderNode as Gsk.RenderNode

    #else
    import qualified GI.Graphene.Structs.Rect as Graphene.Rect
    import {-# SOURCE #-} qualified GI.Gsk.Objects.RenderNode as Gsk.RenderNode

    #endif

    -- | Memory-managed wrapper type.
    newtype PasteNode = PasteNode (SP.ManagedPtr PasteNode)
        deriving (PasteNode -> PasteNode -> Bool
    (PasteNode -> PasteNode -> Bool)
    -> (PasteNode -> PasteNode -> Bool) -> Eq PasteNode
    forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
    $c== :: PasteNode -> PasteNode -> Bool
    == :: PasteNode -> PasteNode -> Bool
    $c/= :: PasteNode -> PasteNode -> Bool
    /= :: PasteNode -> PasteNode -> Bool
    Eq)

    instance SP.ManagedPtrNewtype PasteNode where
        toManagedPtr :: PasteNode -> ManagedPtr PasteNode
    toManagedPtr (PasteNode ManagedPtr PasteNode
    p) = ManagedPtr PasteNode
    p

    foreign import ccall "gsk_paste_node_get_type"
        c_gsk_paste_node_get_type :: IO B.Types.GType

    instance B.Types.TypedObject PasteNode where
        glibType :: IO GType
    glibType = IO GType
    c_gsk_paste_node_get_type

    -- | Type class for types which can be safely cast to t'PasteNode', for instance with `toPasteNode`.
    class (SP.BoxedPtr o, SP.TypedObject o, O.IsDescendantOf PasteNode o) => IsPasteNode o
    instance (SP.BoxedPtr o, SP.TypedObject o, O.IsDescendantOf PasteNode o) => IsPasteNode o

    instance O.HasParentTypes PasteNode
    type instance O.ParentTypes PasteNode = '[Gsk.RenderNode.RenderNode]

    -- | Cast to t'PasteNode', for types for which this is known to be safe. For general casts, use 'Data.GI.Base.ManagedPtr.castTo'.
    toPasteNode :: (MIO.MonadIO m, IsPasteNode o) => o -> m PasteNode
    toPasteNode :: forall (m :: * -> *) o.
    (MonadIO m, IsPasteNode o) =>
    o -> m PasteNode
    toPasteNode = IO PasteNode -> m PasteNode
    forall a. IO a -> m a
    forall (m :: * -> *) a. MonadIO m => IO a -> m a
    MIO.liftIO (IO PasteNode -> m PasteNode)
    -> (o -> IO PasteNode) -> o -> m PasteNode
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . (ManagedPtr PasteNode -> PasteNode) -> o -> IO PasteNode
    forall o o'.
    (HasCallStack, ManagedPtrNewtype o, TypedObject o,
     ManagedPtrNewtype o', TypedObject o') =>
    (ManagedPtr o' -> o') -> o -> IO o'
    B.ManagedPtr.unsafeCastTo ManagedPtr PasteNode -> PasteNode
    PasteNode

    --- XXX Missing getter and/or setter, so no GValue instance could be generated.
    #if defined(ENABLE_OVERLOADING)
    type family ResolvePasteNodeMethod (t :: Symbol) (o :: DK.Type) :: DK.Type where
        ResolvePasteNodeMethod "draw" o = Gsk.RenderNode.RenderNodeDrawMethodInfo
        ResolvePasteNodeMethod "ref" o = Gsk.RenderNode.RenderNodeRefMethodInfo
        ResolvePasteNodeMethod "serialize" o = Gsk.RenderNode.RenderNodeSerializeMethodInfo
        ResolvePasteNodeMethod "unref" o = Gsk.RenderNode.RenderNodeUnrefMethodInfo
        ResolvePasteNodeMethod "writeToFile" o = Gsk.RenderNode.RenderNodeWriteToFileMethodInfo
        ResolvePasteNodeMethod "getBounds" o = Gsk.RenderNode.RenderNodeGetBoundsMethodInfo
        ResolvePasteNodeMethod "getDepth" o = PasteNodeGetDepthMethodInfo
        ResolvePasteNodeMethod "getNodeType" o = Gsk.RenderNode.RenderNodeGetNodeTypeMethodInfo
        ResolvePasteNodeMethod "getOpaqueRect" o = Gsk.RenderNode.RenderNodeGetOpaqueRectMethodInfo
        ResolvePasteNodeMethod l o = O.MethodResolutionFailed l o

    instance (info ~ ResolvePasteNodeMethod t PasteNode, O.OverloadedMethod info PasteNode p) => OL.IsLabel t (PasteNode -> p) where
    #if MIN_VERSION_base(4,10,0)
        fromLabel = O.overloadedMethod @info
    #else
        fromLabel _ = O.overloadedMethod @info
    #endif

    #if MIN_VERSION_base(4,13,0)
    instance (info ~ ResolvePasteNodeMethod t PasteNode, O.OverloadedMethod info PasteNode p, R.HasField t PasteNode p) => R.HasField t PasteNode p where
        getField = O.overloadedMethod @info

    #endif

    instance (info ~ ResolvePasteNodeMethod t PasteNode, O.OverloadedMethodInfo info PasteNode) => OL.IsLabel t (O.MethodProxy info PasteNode) where
    #if MIN_VERSION_base(4,10,0)
        fromLabel = O.MethodProxy
    #else
        fromLabel _ = O.MethodProxy
    #endif

    #endif

    -- XXX Wrapping a foreign struct/union with no known destructor or size, leak?
    instance BoxedPtr PasteNode where
        boxedPtrCopy :: PasteNode -> IO PasteNode
    boxedPtrCopy = PasteNode -> IO PasteNode
    forall a. a -> IO a
    forall (m :: * -> *) a. Monad m => a -> m a
    return
        boxedPtrFree :: PasteNode -> IO ()
    boxedPtrFree = \PasteNode
    _x -> () -> IO ()
    forall a. a -> IO a
    forall (m :: * -> *) a. Monad m => a -> m a
    return ()

    -- method PasteNode::new
    -- method type : Constructor
    -- Args: [ Arg
    --           { argCName = "bounds"
    --           , argType =
    --               TInterface Name { namespace = "Graphene" , name = "Rect" }
    --           , argCType = Just "const graphene_rect_t*"
    --           , direction = DirectionIn
    --           , mayBeNull = False
    --           , argDoc =
    --               Documentation
    --                 { rawDocText = Just "the rectangle to render the paste into"
    --                 , sinceVersion = Nothing
    --                 }
    --           , argScope = ScopeTypeInvalid
    --           , argClosure = -1
    --           , argDestroy = -1
    --           , argCallerAllocates = False
    --           , argCallbackUserData = False
    --           , transfer = TransferNothing
    --           }
    --       , Arg
    --           { argCName = "depth"
    --           , argType = TBasicType TSize
    --           , argCType = Just "gsize"
    --           , direction = DirectionIn
    --           , mayBeNull = False
    --           , argDoc =
    --               Documentation
    --                 { rawDocText =
    --                     Just "the index of which copy to paste. This will usually be 0."
    --                 , sinceVersion = Nothing
    --                 }
    --           , argScope = ScopeTypeInvalid
    --           , argClosure = -1
    --           , argDestroy = -1
    --           , argCallerAllocates = False
    --           , argCallbackUserData = False
    --           , transfer = TransferNothing
    --           }
    --       ]
    -- Lengths: []
    -- returnType: Just (TInterface Name { namespace = "Gsk" , name = "PasteNode" })
    -- throws : False
    -- Skip return : False

    foreign import ccall "gsk_paste_node_new" gsk_paste_node_new ::
        Ptr Graphene.Rect.Rect ->               -- bounds : TInterface (Name {namespace = "Graphene", name = "Rect"})
        FCT.CSize ->                            -- depth : TBasicType TSize
        IO (Ptr PasteNode)

    -- | Creates a @GskRenderNode@ that will paste copied contents.
    --
    -- /Since: 4.22/
    pasteNodeNew ::
        (B.CallStack.HasCallStack, MonadIO m) =>
        Graphene.Rect.Rect
        -- ^ /@bounds@/: the rectangle to render the paste into
        -> FCT.CSize
        -- ^ /@depth@/: the index of which copy to paste. This will usually be 0.
        -> m PasteNode
        -- ^ __Returns:__ A new @GskRenderNode@
    pasteNodeNew :: forall (m :: * -> *).
    (HasCallStack, MonadIO m) =>
    Rect -> CSize -> m PasteNode
    pasteNodeNew Rect
    bounds CSize
    depth = IO PasteNode -> m PasteNode
    forall a. IO a -> m a
    forall (m :: * -> *) a. MonadIO m => IO a -> m a
    liftIO (IO PasteNode -> m PasteNode) -> IO PasteNode -> m PasteNode
    forall a b. (a -> b) -> a -> b
    $ do
        bounds' <- Rect -> IO (Ptr Rect)
    forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
    unsafeManagedPtrGetPtr Rect
    bounds
        result <- gsk_paste_node_new bounds' depth
        checkUnexpectedReturnNULL "pasteNodeNew" result
        result' <- (wrapPtr PasteNode) result
        touchManagedPtr bounds
        return result'

    #if defined(ENABLE_OVERLOADING)
    #endif

    -- method PasteNode::get_depth
    -- method type : OrdinaryMethod
    -- Args: [ Arg
    --           { argCName = "node"
    --           , argType =
    --               TInterface Name { namespace = "Gsk" , name = "PasteNode" }
    --           , argCType = Just "const GskRenderNode*"
    --           , direction = DirectionIn
    --           , mayBeNull = False
    --           , argDoc =
    --               Documentation
    --                 { rawDocText = Just "a `GskRenderNode`" , sinceVersion = Nothing }
    --           , argScope = ScopeTypeInvalid
    --           , argClosure = -1
    --           , argDestroy = -1
    --           , argCallerAllocates = False
    --           , argCallbackUserData = False
    --           , transfer = TransferNothing
    --           }
    --       ]
    -- Lengths: []
    -- returnType: Just (TBasicType TSize)
    -- throws : False
    -- Skip return : False

    foreign import ccall "gsk_paste_node_get_depth" gsk_paste_node_get_depth ::
        Ptr PasteNode ->                        -- node : TInterface (Name {namespace = "Gsk", name = "PasteNode"})
        IO FCT.CSize

    -- | Retrieves the index of the copy that should be pasted.
    --
    -- /Since: 4.22/
    pasteNodeGetDepth ::
        (B.CallStack.HasCallStack, MonadIO m, IsPasteNode a) =>
        a
        -- ^ /@node@/: a @GskRenderNode@
        -> m FCT.CSize
        -- ^ __Returns:__ the index of the copy to paste.
    pasteNodeGetDepth :: forall (m :: * -> *) a.
    (HasCallStack, MonadIO m, IsPasteNode a) =>
    a -> m CSize
    pasteNodeGetDepth a
    node = IO CSize -> m CSize
    forall a. IO a -> m a
    forall (m :: * -> *) a. MonadIO m => IO a -> m a
    liftIO (IO CSize -> m CSize) -> IO CSize -> m CSize
    forall a b. (a -> b) -> a -> b
    $ do
        node' <- a -> IO (Ptr PasteNode)
    forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
    unsafeManagedPtrCastPtr a
    node
        result <- gsk_paste_node_get_depth node'
        touchManagedPtr node
        return result

    #if defined(ENABLE_OVERLOADING)
    data PasteNodeGetDepthMethodInfo
    instance (signature ~ (m FCT.CSize), MonadIO m, IsPasteNode a) => O.OverloadedMethod PasteNodeGetDepthMethodInfo a signature where
        overloadedMethod = pasteNodeGetDepth

    instance O.OverloadedMethodInfo PasteNodeGetDepthMethodInfo a where
        overloadedMethodInfo = P.Just (O.ResolvedSymbolInfo {
            O.resolvedSymbolName = "GI.Gsk.Objects.PasteNode.pasteNodeGetDepth",
            O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-gsk-4.0.9/docs/GI-Gsk-Objects-PasteNode.html#v:pasteNodeGetDepth"
            })

    #endif