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

'GI.Atk.Interfaces.Component.Component' should be implemented by most if not all UI elements
with an actual on-screen presence, i.e. components which can be
said to have a screen-coordinate bounding box.  Virtually all
widgets will need to have 'GI.Atk.Interfaces.Component.Component' implementations provided
for their corresponding 'GI.Atk.Objects.Object.Object' class.  In short, only UI
elements which are *not* GUI elements will omit this ATK interface.

A possible exception might be textual information with a
transparent background, in which case text glyph bounding box
information is provided by 'GI.Atk.Interfaces.Text.Text'.
-}

module GI.Atk.Interfaces.Component
    ( 

-- * Exported types
    Component(..)                           ,
    noComponent                             ,
    IsComponent                             ,


 -- * Methods
-- ** contains #method:contains#
    ComponentContainsMethodInfo             ,
    componentContains                       ,


-- ** getAlpha #method:getAlpha#
    ComponentGetAlphaMethodInfo             ,
    componentGetAlpha                       ,


-- ** getExtents #method:getExtents#
    ComponentGetExtentsMethodInfo           ,
    componentGetExtents                     ,


-- ** getLayer #method:getLayer#
    ComponentGetLayerMethodInfo             ,
    componentGetLayer                       ,


-- ** getMdiZorder #method:getMdiZorder#
    ComponentGetMdiZorderMethodInfo         ,
    componentGetMdiZorder                   ,


-- ** getPosition #method:getPosition#
    ComponentGetPositionMethodInfo          ,
    componentGetPosition                    ,


-- ** getSize #method:getSize#
    ComponentGetSizeMethodInfo              ,
    componentGetSize                        ,


-- ** grabFocus #method:grabFocus#
    ComponentGrabFocusMethodInfo            ,
    componentGrabFocus                      ,


-- ** refAccessibleAtPoint #method:refAccessibleAtPoint#
    ComponentRefAccessibleAtPointMethodInfo ,
    componentRefAccessibleAtPoint           ,


-- ** removeFocusHandler #method:removeFocusHandler#
    ComponentRemoveFocusHandlerMethodInfo   ,
    componentRemoveFocusHandler             ,


-- ** setExtents #method:setExtents#
    ComponentSetExtentsMethodInfo           ,
    componentSetExtents                     ,


-- ** setPosition #method:setPosition#
    ComponentSetPositionMethodInfo          ,
    componentSetPosition                    ,


-- ** setSize #method:setSize#
    ComponentSetSizeMethodInfo              ,
    componentSetSize                        ,




 -- * Signals
-- ** boundsChanged #signal:boundsChanged#
    C_ComponentBoundsChangedCallback        ,
    ComponentBoundsChangedCallback          ,
    ComponentBoundsChangedSignalInfo        ,
    afterComponentBoundsChanged             ,
    genClosure_ComponentBoundsChanged       ,
    mk_ComponentBoundsChangedCallback       ,
    noComponentBoundsChangedCallback        ,
    onComponentBoundsChanged                ,
    wrap_ComponentBoundsChangedCallback     ,




    ) 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.GError as B.GError
import qualified Data.GI.Base.GVariant as B.GVariant
import qualified Data.GI.Base.GParamSpec as B.GParamSpec
import qualified Data.GI.Base.CallStack as B.CallStack
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 {-# SOURCE #-} qualified GI.Atk.Enums as Atk.Enums
import {-# SOURCE #-} qualified GI.Atk.Objects.Object as Atk.Object
import {-# SOURCE #-} qualified GI.Atk.Structs.Rectangle as Atk.Rectangle

-- interface Component 
newtype Component = Component (ManagedPtr Component)
noComponent :: Maybe Component
noComponent = Nothing

type family ResolveComponentMethod (t :: Symbol) (o :: *) :: * where
    ResolveComponentMethod "contains" o = ComponentContainsMethodInfo
    ResolveComponentMethod "grabFocus" o = ComponentGrabFocusMethodInfo
    ResolveComponentMethod "refAccessibleAtPoint" o = ComponentRefAccessibleAtPointMethodInfo
    ResolveComponentMethod "removeFocusHandler" o = ComponentRemoveFocusHandlerMethodInfo
    ResolveComponentMethod "getAlpha" o = ComponentGetAlphaMethodInfo
    ResolveComponentMethod "getExtents" o = ComponentGetExtentsMethodInfo
    ResolveComponentMethod "getLayer" o = ComponentGetLayerMethodInfo
    ResolveComponentMethod "getMdiZorder" o = ComponentGetMdiZorderMethodInfo
    ResolveComponentMethod "getPosition" o = ComponentGetPositionMethodInfo
    ResolveComponentMethod "getSize" o = ComponentGetSizeMethodInfo
    ResolveComponentMethod "setExtents" o = ComponentSetExtentsMethodInfo
    ResolveComponentMethod "setPosition" o = ComponentSetPositionMethodInfo
    ResolveComponentMethod "setSize" o = ComponentSetSizeMethodInfo
    ResolveComponentMethod l o = O.MethodResolutionFailed l o

instance (info ~ ResolveComponentMethod t Component, O.MethodInfo info Component p) => O.IsLabelProxy t (Component -> p) where
    fromLabelProxy _ = O.overloadedMethod (O.MethodProxy :: O.MethodProxy info)

#if MIN_VERSION_base(4,9,0)
instance (info ~ ResolveComponentMethod t Component, O.MethodInfo info Component p) => O.IsLabel t (Component -> p) where
    fromLabel _ = O.overloadedMethod (O.MethodProxy :: O.MethodProxy info)
#endif

-- signal Component::bounds-changed
type ComponentBoundsChangedCallback =
    Atk.Rectangle.Rectangle ->
    IO ()

noComponentBoundsChangedCallback :: Maybe ComponentBoundsChangedCallback
noComponentBoundsChangedCallback = Nothing

type C_ComponentBoundsChangedCallback =
    Ptr () ->                               -- object
    Ptr Atk.Rectangle.Rectangle ->
    Ptr () ->                               -- user_data
    IO ()

foreign import ccall "wrapper"
    mk_ComponentBoundsChangedCallback :: C_ComponentBoundsChangedCallback -> IO (FunPtr C_ComponentBoundsChangedCallback)

genClosure_ComponentBoundsChanged :: ComponentBoundsChangedCallback -> IO Closure
genClosure_ComponentBoundsChanged cb = do
    let cb' = wrap_ComponentBoundsChangedCallback cb
    mk_ComponentBoundsChangedCallback cb' >>= newCClosure


wrap_ComponentBoundsChangedCallback ::
    ComponentBoundsChangedCallback ->
    Ptr () ->
    Ptr Atk.Rectangle.Rectangle ->
    Ptr () ->
    IO ()
wrap_ComponentBoundsChangedCallback _cb _ arg1 _ = do
    arg1' <- (newBoxed Atk.Rectangle.Rectangle) arg1
    _cb  arg1'


onComponentBoundsChanged :: (GObject a, MonadIO m) => a -> ComponentBoundsChangedCallback -> m SignalHandlerId
onComponentBoundsChanged obj cb = liftIO $ connectComponentBoundsChanged obj cb SignalConnectBefore
afterComponentBoundsChanged :: (GObject a, MonadIO m) => a -> ComponentBoundsChangedCallback -> m SignalHandlerId
afterComponentBoundsChanged obj cb = connectComponentBoundsChanged obj cb SignalConnectAfter

connectComponentBoundsChanged :: (GObject a, MonadIO m) =>
                                 a -> ComponentBoundsChangedCallback -> SignalConnectMode -> m SignalHandlerId
connectComponentBoundsChanged obj cb after = liftIO $ do
    let cb' = wrap_ComponentBoundsChangedCallback cb
    cb'' <- mk_ComponentBoundsChangedCallback cb'
    connectSignalFunPtr obj "bounds-changed" cb'' after

instance O.HasAttributeList Component
type instance O.AttributeList Component = ComponentAttributeList
type ComponentAttributeList = ('[ ] :: [(Symbol, *)])

data ComponentBoundsChangedSignalInfo
instance SignalInfo ComponentBoundsChangedSignalInfo where
    type HaskellCallbackType ComponentBoundsChangedSignalInfo = ComponentBoundsChangedCallback
    connectSignal _ = connectComponentBoundsChanged

type instance O.SignalList Component = ComponentSignalList
type ComponentSignalList = ('[ '("boundsChanged", ComponentBoundsChangedSignalInfo)] :: [(Symbol, *)])

class ManagedPtrNewtype a => IsComponent a
instance IsComponent Component
-- XXX Wrapping a foreign struct/union with no known destructor or size, leak?
instance WrappedPtr Component where
    wrappedPtrCalloc = return nullPtr
    wrappedPtrCopy = return
    wrappedPtrFree = Nothing


-- method Component::contains
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "component", argType = TInterface (Name {namespace = "Atk", name = "Component"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the #AtkComponent", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "x", argType = TBasicType TInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "x coordinate", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "y", argType = TBasicType TInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "y coordinate", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "coord_type", argType = TInterface (Name {namespace = "Atk", name = "CoordType"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "specifies whether the coordinates are relative to the screen\nor to the components top level window", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : False
-- Skip return : False

foreign import ccall "atk_component_contains" atk_component_contains :: 
    Ptr Component ->                        -- component : TInterface (Name {namespace = "Atk", name = "Component"})
    Int32 ->                                -- x : TBasicType TInt
    Int32 ->                                -- y : TBasicType TInt
    CUInt ->                                -- coord_type : TInterface (Name {namespace = "Atk", name = "CoordType"})
    IO CInt

{- |
Checks whether the specified point is within the extent of the /@component@/.

Toolkit implementor note: ATK provides a default implementation for
this virtual method. In general there are little reason to
re-implement it.
-}
componentContains ::
    (B.CallStack.HasCallStack, MonadIO m, IsComponent a) =>
    a
    {- ^ /@component@/: the 'GI.Atk.Interfaces.Component.Component' -}
    -> Int32
    {- ^ /@x@/: x coordinate -}
    -> Int32
    {- ^ /@y@/: y coordinate -}
    -> Atk.Enums.CoordType
    {- ^ /@coordType@/: specifies whether the coordinates are relative to the screen
or to the components top level window -}
    -> m Bool
    {- ^ __Returns:__ 'True' or 'False' indicating whether the specified point is within
the extent of the /@component@/ or not -}
componentContains component x y coordType = liftIO $ do
    component' <- unsafeManagedPtrCastPtr component
    let coordType' = (fromIntegral . fromEnum) coordType
    result <- atk_component_contains component' x y coordType'
    let result' = (/= 0) result
    touchManagedPtr component
    return result'

data ComponentContainsMethodInfo
instance (signature ~ (Int32 -> Int32 -> Atk.Enums.CoordType -> m Bool), MonadIO m, IsComponent a) => O.MethodInfo ComponentContainsMethodInfo a signature where
    overloadedMethod _ = componentContains

-- method Component::get_alpha
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "component", argType = TInterface (Name {namespace = "Atk", name = "Component"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "an #AtkComponent", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TDouble)
-- throws : False
-- Skip return : False

foreign import ccall "atk_component_get_alpha" atk_component_get_alpha :: 
    Ptr Component ->                        -- component : TInterface (Name {namespace = "Atk", name = "Component"})
    IO CDouble

{- |
Returns the alpha value (i.e. the opacity) for this
/@component@/, on a scale from 0 (fully transparent) to 1.0
(fully opaque).

@since 1.12
-}
componentGetAlpha ::
    (B.CallStack.HasCallStack, MonadIO m, IsComponent a) =>
    a
    {- ^ /@component@/: an 'GI.Atk.Interfaces.Component.Component' -}
    -> m Double
    {- ^ __Returns:__ An alpha value from 0 to 1.0, inclusive. -}
componentGetAlpha component = liftIO $ do
    component' <- unsafeManagedPtrCastPtr component
    result <- atk_component_get_alpha component'
    let result' = realToFrac result
    touchManagedPtr component
    return result'

data ComponentGetAlphaMethodInfo
instance (signature ~ (m Double), MonadIO m, IsComponent a) => O.MethodInfo ComponentGetAlphaMethodInfo a signature where
    overloadedMethod _ = componentGetAlpha

-- method Component::get_extents
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "component", argType = TInterface (Name {namespace = "Atk", name = "Component"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "an #AtkComponent", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "x", argType = TBasicType TInt, direction = DirectionOut, mayBeNull = False, argDoc = Documentation {rawDocText = Just "address of #gint to put x coordinate", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferEverything},Arg {argCName = "y", argType = TBasicType TInt, direction = DirectionOut, mayBeNull = False, argDoc = Documentation {rawDocText = Just "address of #gint to put y coordinate", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferEverything},Arg {argCName = "width", argType = TBasicType TInt, direction = DirectionOut, mayBeNull = False, argDoc = Documentation {rawDocText = Just "address of #gint to put width", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferEverything},Arg {argCName = "height", argType = TBasicType TInt, direction = DirectionOut, mayBeNull = False, argDoc = Documentation {rawDocText = Just "address of #gint to put height", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferEverything},Arg {argCName = "coord_type", argType = TInterface (Name {namespace = "Atk", name = "CoordType"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "specifies whether the coordinates are relative to the screen\nor to the components top level window", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "atk_component_get_extents" atk_component_get_extents :: 
    Ptr Component ->                        -- component : TInterface (Name {namespace = "Atk", name = "Component"})
    Ptr Int32 ->                            -- x : TBasicType TInt
    Ptr Int32 ->                            -- y : TBasicType TInt
    Ptr Int32 ->                            -- width : TBasicType TInt
    Ptr Int32 ->                            -- height : TBasicType TInt
    CUInt ->                                -- coord_type : TInterface (Name {namespace = "Atk", name = "CoordType"})
    IO ()

{- |
Gets the rectangle which gives the extent of the /@component@/.
-}
componentGetExtents ::
    (B.CallStack.HasCallStack, MonadIO m, IsComponent a) =>
    a
    {- ^ /@component@/: an 'GI.Atk.Interfaces.Component.Component' -}
    -> Atk.Enums.CoordType
    {- ^ /@coordType@/: specifies whether the coordinates are relative to the screen
or to the components top level window -}
    -> m (Int32,Int32,Int32,Int32)
componentGetExtents component coordType = liftIO $ do
    component' <- unsafeManagedPtrCastPtr component
    x <- allocMem :: IO (Ptr Int32)
    y <- allocMem :: IO (Ptr Int32)
    width <- allocMem :: IO (Ptr Int32)
    height <- allocMem :: IO (Ptr Int32)
    let coordType' = (fromIntegral . fromEnum) coordType
    atk_component_get_extents component' x y width height coordType'
    x' <- peek x
    y' <- peek y
    width' <- peek width
    height' <- peek height
    touchManagedPtr component
    freeMem x
    freeMem y
    freeMem width
    freeMem height
    return (x', y', width', height')

data ComponentGetExtentsMethodInfo
instance (signature ~ (Atk.Enums.CoordType -> m (Int32,Int32,Int32,Int32)), MonadIO m, IsComponent a) => O.MethodInfo ComponentGetExtentsMethodInfo a signature where
    overloadedMethod _ = componentGetExtents

-- method Component::get_layer
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "component", argType = TInterface (Name {namespace = "Atk", name = "Component"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "an #AtkComponent", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "Atk", name = "Layer"}))
-- throws : False
-- Skip return : False

foreign import ccall "atk_component_get_layer" atk_component_get_layer :: 
    Ptr Component ->                        -- component : TInterface (Name {namespace = "Atk", name = "Component"})
    IO CUInt

{- |
Gets the layer of the component.
-}
componentGetLayer ::
    (B.CallStack.HasCallStack, MonadIO m, IsComponent a) =>
    a
    {- ^ /@component@/: an 'GI.Atk.Interfaces.Component.Component' -}
    -> m Atk.Enums.Layer
    {- ^ __Returns:__ an 'GI.Atk.Enums.Layer' which is the layer of the component -}
componentGetLayer component = liftIO $ do
    component' <- unsafeManagedPtrCastPtr component
    result <- atk_component_get_layer component'
    let result' = (toEnum . fromIntegral) result
    touchManagedPtr component
    return result'

data ComponentGetLayerMethodInfo
instance (signature ~ (m Atk.Enums.Layer), MonadIO m, IsComponent a) => O.MethodInfo ComponentGetLayerMethodInfo a signature where
    overloadedMethod _ = componentGetLayer

-- method Component::get_mdi_zorder
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "component", argType = TInterface (Name {namespace = "Atk", name = "Component"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "an #AtkComponent", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TInt)
-- throws : False
-- Skip return : False

foreign import ccall "atk_component_get_mdi_zorder" atk_component_get_mdi_zorder :: 
    Ptr Component ->                        -- component : TInterface (Name {namespace = "Atk", name = "Component"})
    IO Int32

{- |
Gets the zorder of the component. The value G_MININT will be returned
if the layer of the component is not ATK_LAYER_MDI or ATK_LAYER_WINDOW.
-}
componentGetMdiZorder ::
    (B.CallStack.HasCallStack, MonadIO m, IsComponent a) =>
    a
    {- ^ /@component@/: an 'GI.Atk.Interfaces.Component.Component' -}
    -> m Int32
    {- ^ __Returns:__ a gint which is the zorder of the component, i.e. the depth at
which the component is shown in relation to other components in the same
container. -}
componentGetMdiZorder component = liftIO $ do
    component' <- unsafeManagedPtrCastPtr component
    result <- atk_component_get_mdi_zorder component'
    touchManagedPtr component
    return result

data ComponentGetMdiZorderMethodInfo
instance (signature ~ (m Int32), MonadIO m, IsComponent a) => O.MethodInfo ComponentGetMdiZorderMethodInfo a signature where
    overloadedMethod _ = componentGetMdiZorder

-- method Component::get_position
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "component", argType = TInterface (Name {namespace = "Atk", name = "Component"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "an #AtkComponent", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "x", argType = TBasicType TInt, direction = DirectionOut, mayBeNull = False, argDoc = Documentation {rawDocText = Just "address of #gint to put x coordinate position", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferEverything},Arg {argCName = "y", argType = TBasicType TInt, direction = DirectionOut, mayBeNull = False, argDoc = Documentation {rawDocText = Just "address of #gint to put y coordinate position", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferEverything},Arg {argCName = "coord_type", argType = TInterface (Name {namespace = "Atk", name = "CoordType"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "specifies whether the coordinates are relative to the screen\nor to the components top level window", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "atk_component_get_position" atk_component_get_position :: 
    Ptr Component ->                        -- component : TInterface (Name {namespace = "Atk", name = "Component"})
    Ptr Int32 ->                            -- x : TBasicType TInt
    Ptr Int32 ->                            -- y : TBasicType TInt
    CUInt ->                                -- coord_type : TInterface (Name {namespace = "Atk", name = "CoordType"})
    IO ()

{-# DEPRECATED componentGetPosition ["Since 2.12. Use 'GI.Atk.Interfaces.Component.componentGetExtents' instead."] #-}
{- |
Gets the position of /@component@/ in the form of
a point specifying /@component@/\'s top-left corner.
-}
componentGetPosition ::
    (B.CallStack.HasCallStack, MonadIO m, IsComponent a) =>
    a
    {- ^ /@component@/: an 'GI.Atk.Interfaces.Component.Component' -}
    -> Atk.Enums.CoordType
    {- ^ /@coordType@/: specifies whether the coordinates are relative to the screen
or to the components top level window -}
    -> m (Int32,Int32)
componentGetPosition component coordType = liftIO $ do
    component' <- unsafeManagedPtrCastPtr component
    x <- allocMem :: IO (Ptr Int32)
    y <- allocMem :: IO (Ptr Int32)
    let coordType' = (fromIntegral . fromEnum) coordType
    atk_component_get_position component' x y coordType'
    x' <- peek x
    y' <- peek y
    touchManagedPtr component
    freeMem x
    freeMem y
    return (x', y')

data ComponentGetPositionMethodInfo
instance (signature ~ (Atk.Enums.CoordType -> m (Int32,Int32)), MonadIO m, IsComponent a) => O.MethodInfo ComponentGetPositionMethodInfo a signature where
    overloadedMethod _ = componentGetPosition

-- method Component::get_size
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "component", argType = TInterface (Name {namespace = "Atk", name = "Component"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "an #AtkComponent", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "width", argType = TBasicType TInt, direction = DirectionOut, mayBeNull = False, argDoc = Documentation {rawDocText = Just "address of #gint to put width of @component", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferEverything},Arg {argCName = "height", argType = TBasicType TInt, direction = DirectionOut, mayBeNull = False, argDoc = Documentation {rawDocText = Just "address of #gint to put height of @component", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferEverything}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "atk_component_get_size" atk_component_get_size :: 
    Ptr Component ->                        -- component : TInterface (Name {namespace = "Atk", name = "Component"})
    Ptr Int32 ->                            -- width : TBasicType TInt
    Ptr Int32 ->                            -- height : TBasicType TInt
    IO ()

{-# DEPRECATED componentGetSize ["Since 2.12. Use 'GI.Atk.Interfaces.Component.componentGetExtents' instead."] #-}
{- |
Gets the size of the /@component@/ in terms of width and height.
-}
componentGetSize ::
    (B.CallStack.HasCallStack, MonadIO m, IsComponent a) =>
    a
    {- ^ /@component@/: an 'GI.Atk.Interfaces.Component.Component' -}
    -> m (Int32,Int32)
componentGetSize component = liftIO $ do
    component' <- unsafeManagedPtrCastPtr component
    width <- allocMem :: IO (Ptr Int32)
    height <- allocMem :: IO (Ptr Int32)
    atk_component_get_size component' width height
    width' <- peek width
    height' <- peek height
    touchManagedPtr component
    freeMem width
    freeMem height
    return (width', height')

data ComponentGetSizeMethodInfo
instance (signature ~ (m (Int32,Int32)), MonadIO m, IsComponent a) => O.MethodInfo ComponentGetSizeMethodInfo a signature where
    overloadedMethod _ = componentGetSize

-- method Component::grab_focus
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "component", argType = TInterface (Name {namespace = "Atk", name = "Component"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "an #AtkComponent", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : False
-- Skip return : False

foreign import ccall "atk_component_grab_focus" atk_component_grab_focus :: 
    Ptr Component ->                        -- component : TInterface (Name {namespace = "Atk", name = "Component"})
    IO CInt

{- |
Grabs focus for this /@component@/.
-}
componentGrabFocus ::
    (B.CallStack.HasCallStack, MonadIO m, IsComponent a) =>
    a
    {- ^ /@component@/: an 'GI.Atk.Interfaces.Component.Component' -}
    -> m Bool
    {- ^ __Returns:__ 'True' if successful, 'False' otherwise. -}
componentGrabFocus component = liftIO $ do
    component' <- unsafeManagedPtrCastPtr component
    result <- atk_component_grab_focus component'
    let result' = (/= 0) result
    touchManagedPtr component
    return result'

data ComponentGrabFocusMethodInfo
instance (signature ~ (m Bool), MonadIO m, IsComponent a) => O.MethodInfo ComponentGrabFocusMethodInfo a signature where
    overloadedMethod _ = componentGrabFocus

-- method Component::ref_accessible_at_point
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "component", argType = TInterface (Name {namespace = "Atk", name = "Component"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the #AtkComponent", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "x", argType = TBasicType TInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "x coordinate", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "y", argType = TBasicType TInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "y coordinate", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "coord_type", argType = TInterface (Name {namespace = "Atk", name = "CoordType"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "specifies whether the coordinates are relative to the screen\nor to the components top level window", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "Atk", name = "Object"}))
-- throws : False
-- Skip return : False

foreign import ccall "atk_component_ref_accessible_at_point" atk_component_ref_accessible_at_point :: 
    Ptr Component ->                        -- component : TInterface (Name {namespace = "Atk", name = "Component"})
    Int32 ->                                -- x : TBasicType TInt
    Int32 ->                                -- y : TBasicType TInt
    CUInt ->                                -- coord_type : TInterface (Name {namespace = "Atk", name = "CoordType"})
    IO (Ptr Atk.Object.Object)

{- |
Gets a reference to the accessible child, if one exists, at the
coordinate point specified by /@x@/ and /@y@/.
-}
componentRefAccessibleAtPoint ::
    (B.CallStack.HasCallStack, MonadIO m, IsComponent a) =>
    a
    {- ^ /@component@/: the 'GI.Atk.Interfaces.Component.Component' -}
    -> Int32
    {- ^ /@x@/: x coordinate -}
    -> Int32
    {- ^ /@y@/: y coordinate -}
    -> Atk.Enums.CoordType
    {- ^ /@coordType@/: specifies whether the coordinates are relative to the screen
or to the components top level window -}
    -> m (Maybe Atk.Object.Object)
    {- ^ __Returns:__ a reference to the accessible
child, if one exists -}
componentRefAccessibleAtPoint component x y coordType = liftIO $ do
    component' <- unsafeManagedPtrCastPtr component
    let coordType' = (fromIntegral . fromEnum) coordType
    result <- atk_component_ref_accessible_at_point component' x y coordType'
    maybeResult <- convertIfNonNull result $ \result' -> do
        result'' <- (wrapObject Atk.Object.Object) result'
        return result''
    touchManagedPtr component
    return maybeResult

data ComponentRefAccessibleAtPointMethodInfo
instance (signature ~ (Int32 -> Int32 -> Atk.Enums.CoordType -> m (Maybe Atk.Object.Object)), MonadIO m, IsComponent a) => O.MethodInfo ComponentRefAccessibleAtPointMethodInfo a signature where
    overloadedMethod _ = componentRefAccessibleAtPoint

-- method Component::remove_focus_handler
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "component", argType = TInterface (Name {namespace = "Atk", name = "Component"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the #AtkComponent to remove the focus handler from", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "handler_id", argType = TBasicType TUInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the handler id of the focus handler to be removed\nfrom @component", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "atk_component_remove_focus_handler" atk_component_remove_focus_handler :: 
    Ptr Component ->                        -- component : TInterface (Name {namespace = "Atk", name = "Component"})
    Word32 ->                               -- handler_id : TBasicType TUInt
    IO ()

{-# DEPRECATED componentRemoveFocusHandler ["(Since version 2.9.4)","If you need to track when an object gains or","lose the focus, use the 'GI.Atk.Objects.Object.Object'::@/state-change/@ \\\"focused\\\" notification instead."] #-}
{- |
Remove the handler specified by /@handlerId@/ from the list of
functions to be executed when this object receives focus events
(in or out).
-}
componentRemoveFocusHandler ::
    (B.CallStack.HasCallStack, MonadIO m, IsComponent a) =>
    a
    {- ^ /@component@/: the 'GI.Atk.Interfaces.Component.Component' to remove the focus handler from -}
    -> Word32
    {- ^ /@handlerId@/: the handler id of the focus handler to be removed
from /@component@/ -}
    -> m ()
componentRemoveFocusHandler component handlerId = liftIO $ do
    component' <- unsafeManagedPtrCastPtr component
    atk_component_remove_focus_handler component' handlerId
    touchManagedPtr component
    return ()

data ComponentRemoveFocusHandlerMethodInfo
instance (signature ~ (Word32 -> m ()), MonadIO m, IsComponent a) => O.MethodInfo ComponentRemoveFocusHandlerMethodInfo a signature where
    overloadedMethod _ = componentRemoveFocusHandler

-- method Component::set_extents
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "component", argType = TInterface (Name {namespace = "Atk", name = "Component"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "an #AtkComponent", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "x", argType = TBasicType TInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "x coordinate", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "y", argType = TBasicType TInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "y coordinate", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "width", argType = TBasicType TInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "width to set for @component", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "height", argType = TBasicType TInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "height to set for @component", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "coord_type", argType = TInterface (Name {namespace = "Atk", name = "CoordType"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "specifies whether the coordinates are relative to the screen\nor to the components top level window", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : False
-- Skip return : False

foreign import ccall "atk_component_set_extents" atk_component_set_extents :: 
    Ptr Component ->                        -- component : TInterface (Name {namespace = "Atk", name = "Component"})
    Int32 ->                                -- x : TBasicType TInt
    Int32 ->                                -- y : TBasicType TInt
    Int32 ->                                -- width : TBasicType TInt
    Int32 ->                                -- height : TBasicType TInt
    CUInt ->                                -- coord_type : TInterface (Name {namespace = "Atk", name = "CoordType"})
    IO CInt

{- |
Sets the extents of /@component@/.
-}
componentSetExtents ::
    (B.CallStack.HasCallStack, MonadIO m, IsComponent a) =>
    a
    {- ^ /@component@/: an 'GI.Atk.Interfaces.Component.Component' -}
    -> Int32
    {- ^ /@x@/: x coordinate -}
    -> Int32
    {- ^ /@y@/: y coordinate -}
    -> Int32
    {- ^ /@width@/: width to set for /@component@/ -}
    -> Int32
    {- ^ /@height@/: height to set for /@component@/ -}
    -> Atk.Enums.CoordType
    {- ^ /@coordType@/: specifies whether the coordinates are relative to the screen
or to the components top level window -}
    -> m Bool
    {- ^ __Returns:__ 'True' or 'False' whether the extents were set or not -}
componentSetExtents component x y width height coordType = liftIO $ do
    component' <- unsafeManagedPtrCastPtr component
    let coordType' = (fromIntegral . fromEnum) coordType
    result <- atk_component_set_extents component' x y width height coordType'
    let result' = (/= 0) result
    touchManagedPtr component
    return result'

data ComponentSetExtentsMethodInfo
instance (signature ~ (Int32 -> Int32 -> Int32 -> Int32 -> Atk.Enums.CoordType -> m Bool), MonadIO m, IsComponent a) => O.MethodInfo ComponentSetExtentsMethodInfo a signature where
    overloadedMethod _ = componentSetExtents

-- method Component::set_position
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "component", argType = TInterface (Name {namespace = "Atk", name = "Component"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "an #AtkComponent", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "x", argType = TBasicType TInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "x coordinate", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "y", argType = TBasicType TInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "y coordinate", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "coord_type", argType = TInterface (Name {namespace = "Atk", name = "CoordType"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "specifies whether the coordinates are relative to the screen\nor to the components top level window", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : False
-- Skip return : False

foreign import ccall "atk_component_set_position" atk_component_set_position :: 
    Ptr Component ->                        -- component : TInterface (Name {namespace = "Atk", name = "Component"})
    Int32 ->                                -- x : TBasicType TInt
    Int32 ->                                -- y : TBasicType TInt
    CUInt ->                                -- coord_type : TInterface (Name {namespace = "Atk", name = "CoordType"})
    IO CInt

{- |
Sets the postition of /@component@/.
-}
componentSetPosition ::
    (B.CallStack.HasCallStack, MonadIO m, IsComponent a) =>
    a
    {- ^ /@component@/: an 'GI.Atk.Interfaces.Component.Component' -}
    -> Int32
    {- ^ /@x@/: x coordinate -}
    -> Int32
    {- ^ /@y@/: y coordinate -}
    -> Atk.Enums.CoordType
    {- ^ /@coordType@/: specifies whether the coordinates are relative to the screen
or to the components top level window -}
    -> m Bool
    {- ^ __Returns:__ 'True' or 'False' whether or not the position was set or not -}
componentSetPosition component x y coordType = liftIO $ do
    component' <- unsafeManagedPtrCastPtr component
    let coordType' = (fromIntegral . fromEnum) coordType
    result <- atk_component_set_position component' x y coordType'
    let result' = (/= 0) result
    touchManagedPtr component
    return result'

data ComponentSetPositionMethodInfo
instance (signature ~ (Int32 -> Int32 -> Atk.Enums.CoordType -> m Bool), MonadIO m, IsComponent a) => O.MethodInfo ComponentSetPositionMethodInfo a signature where
    overloadedMethod _ = componentSetPosition

-- method Component::set_size
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "component", argType = TInterface (Name {namespace = "Atk", name = "Component"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "an #AtkComponent", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "width", argType = TBasicType TInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "width to set for @component", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "height", argType = TBasicType TInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "height to set for @component", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : False
-- Skip return : False

foreign import ccall "atk_component_set_size" atk_component_set_size :: 
    Ptr Component ->                        -- component : TInterface (Name {namespace = "Atk", name = "Component"})
    Int32 ->                                -- width : TBasicType TInt
    Int32 ->                                -- height : TBasicType TInt
    IO CInt

{- |
Set the size of the /@component@/ in terms of width and height.
-}
componentSetSize ::
    (B.CallStack.HasCallStack, MonadIO m, IsComponent a) =>
    a
    {- ^ /@component@/: an 'GI.Atk.Interfaces.Component.Component' -}
    -> Int32
    {- ^ /@width@/: width to set for /@component@/ -}
    -> Int32
    {- ^ /@height@/: height to set for /@component@/ -}
    -> m Bool
    {- ^ __Returns:__ 'True' or 'False' whether the size was set or not -}
componentSetSize component width height = liftIO $ do
    component' <- unsafeManagedPtrCastPtr component
    result <- atk_component_set_size component' width height
    let result' = (/= 0) result
    touchManagedPtr component
    return result'

data ComponentSetSizeMethodInfo
instance (signature ~ (Int32 -> Int32 -> m Bool), MonadIO m, IsComponent a) => O.MethodInfo ComponentSetSizeMethodInfo a signature where
    overloadedMethod _ = componentSetSize