{- |
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 structure used to store a rectangle used by AtkText.
-}

#define ENABLE_OVERLOADING \
       (!defined(__HADDOCK_VERSION__))

module GI.Atk.Structs.TextRectangle
    ( 

-- * Exported types
    TextRectangle(..)                       ,
    newZeroTextRectangle                    ,
    noTextRectangle                         ,


 -- * Properties
-- ** height #attr:height#
{- | The height of a rectangle
-}
    getTextRectangleHeight                  ,
    setTextRectangleHeight                  ,
#if ENABLE_OVERLOADING
    textRectangle_height                    ,
#endif


-- ** width #attr:width#
{- | The width of a rectangle
-}
    getTextRectangleWidth                   ,
    setTextRectangleWidth                   ,
#if ENABLE_OVERLOADING
    textRectangle_width                     ,
#endif


-- ** x #attr:x#
{- | The horizontal coordinate of a rectangle
-}
    getTextRectangleX                       ,
    setTextRectangleX                       ,
#if ENABLE_OVERLOADING
    textRectangle_x                         ,
#endif


-- ** y #attr:y#
{- | The vertical coordinate of a rectangle
-}
    getTextRectangleY                       ,
    setTextRectangleY                       ,
#if ENABLE_OVERLOADING
    textRectangle_y                         ,
#endif




    ) 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.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.Text as T
import qualified Data.ByteString.Char8 as B
import qualified Data.Map as Map
import qualified Foreign.Ptr as FP


-- | Memory-managed wrapper type.
newtype TextRectangle = TextRectangle (ManagedPtr TextRectangle)
instance WrappedPtr TextRectangle where
    wrappedPtrCalloc :: IO (Ptr TextRectangle)
wrappedPtrCalloc = Int -> IO (Ptr TextRectangle)
forall a. Int -> IO (Ptr a)
callocBytes 16
    wrappedPtrCopy :: TextRectangle -> IO TextRectangle
wrappedPtrCopy = \p :: TextRectangle
p -> TextRectangle
-> (Ptr TextRectangle -> IO TextRectangle) -> IO TextRectangle
forall a c.
(HasCallStack, ManagedPtrNewtype a) =>
a -> (Ptr a -> IO c) -> IO c
withManagedPtr TextRectangle
p (Int -> Ptr TextRectangle -> IO (Ptr TextRectangle)
forall a. WrappedPtr a => Int -> Ptr a -> IO (Ptr a)
copyBytes 16 (Ptr TextRectangle -> IO (Ptr TextRectangle))
-> (Ptr TextRectangle -> IO TextRectangle)
-> Ptr TextRectangle
-> IO TextRectangle
forall (m :: * -> *) a b c.
Monad m =>
(a -> m b) -> (b -> m c) -> a -> m c
>=> (ManagedPtr TextRectangle -> TextRectangle)
-> Ptr TextRectangle -> IO TextRectangle
forall a.
(HasCallStack, WrappedPtr a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
wrapPtr ManagedPtr TextRectangle -> TextRectangle
TextRectangle)
    wrappedPtrFree :: Maybe (FunPtr (Ptr TextRectangle -> IO ()))
wrappedPtrFree = FunPtr (Ptr TextRectangle -> IO ())
-> Maybe (FunPtr (Ptr TextRectangle -> IO ()))
forall a. a -> Maybe a
Just FunPtr (Ptr TextRectangle -> IO ())
forall a. FunPtr (Ptr a -> IO ())
ptr_to_g_free

-- | Construct a `TextRectangle` struct initialized to zero.
newZeroTextRectangle :: MonadIO m => m TextRectangle
newZeroTextRectangle :: m TextRectangle
newZeroTextRectangle = IO TextRectangle -> m TextRectangle
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO TextRectangle -> m TextRectangle)
-> IO TextRectangle -> m TextRectangle
forall a b. (a -> b) -> a -> b
$ IO (Ptr TextRectangle)
forall a. WrappedPtr a => IO (Ptr a)
wrappedPtrCalloc IO (Ptr TextRectangle)
-> (Ptr TextRectangle -> IO TextRectangle) -> IO TextRectangle
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= (ManagedPtr TextRectangle -> TextRectangle)
-> Ptr TextRectangle -> IO TextRectangle
forall a.
(HasCallStack, WrappedPtr a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
wrapPtr ManagedPtr TextRectangle -> TextRectangle
TextRectangle

instance tag ~ 'AttrSet => Constructible TextRectangle tag where
    new :: (ManagedPtr TextRectangle -> TextRectangle)
-> [AttrOp TextRectangle tag] -> m TextRectangle
new _ attrs :: [AttrOp TextRectangle tag]
attrs = do
        TextRectangle
o <- m TextRectangle
forall (m :: * -> *). MonadIO m => m TextRectangle
newZeroTextRectangle
        TextRectangle -> [AttrOp TextRectangle 'AttrSet] -> m ()
forall o (m :: * -> *).
MonadIO m =>
o -> [AttrOp o 'AttrSet] -> m ()
GI.Attributes.set TextRectangle
o [AttrOp TextRectangle tag]
[AttrOp TextRectangle 'AttrSet]
attrs
        TextRectangle -> m TextRectangle
forall (m :: * -> *) a. Monad m => a -> m a
return TextRectangle
o


-- | A convenience alias for `Nothing` :: `Maybe` `TextRectangle`.
noTextRectangle :: Maybe TextRectangle
noTextRectangle :: Maybe TextRectangle
noTextRectangle = Maybe TextRectangle
forall a. Maybe a
Nothing

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

@
'Data.GI.Base.Attributes.get' textRectangle #x
@
-}
getTextRectangleX :: MonadIO m => TextRectangle -> m Int32
getTextRectangleX :: TextRectangle -> m Int32
getTextRectangleX s :: TextRectangle
s = IO Int32 -> m Int32
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Int32 -> m Int32) -> IO Int32 -> m Int32
forall a b. (a -> b) -> a -> b
$ TextRectangle -> (Ptr TextRectangle -> IO Int32) -> IO Int32
forall a c.
(HasCallStack, ManagedPtrNewtype a) =>
a -> (Ptr a -> IO c) -> IO c
withManagedPtr TextRectangle
s ((Ptr TextRectangle -> IO Int32) -> IO Int32)
-> (Ptr TextRectangle -> IO Int32) -> IO Int32
forall a b. (a -> b) -> a -> b
$ \ptr :: Ptr TextRectangle
ptr -> do
    Int32
val <- Ptr Int32 -> IO Int32
forall a. Storable a => Ptr a -> IO a
peek (Ptr TextRectangle
ptr Ptr TextRectangle -> Int -> Ptr Int32
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 0) :: IO Int32
    Int32 -> IO Int32
forall (m :: * -> *) a. Monad m => a -> m a
return Int32
val

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

@
'Data.GI.Base.Attributes.set' textRectangle [ #x 'Data.GI.Base.Attributes.:=' value ]
@
-}
setTextRectangleX :: MonadIO m => TextRectangle -> Int32 -> m ()
setTextRectangleX :: TextRectangle -> Int32 -> m ()
setTextRectangleX s :: TextRectangle
s val :: Int32
val = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ TextRectangle -> (Ptr TextRectangle -> IO ()) -> IO ()
forall a c.
(HasCallStack, ManagedPtrNewtype a) =>
a -> (Ptr a -> IO c) -> IO c
withManagedPtr TextRectangle
s ((Ptr TextRectangle -> IO ()) -> IO ())
-> (Ptr TextRectangle -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \ptr :: Ptr TextRectangle
ptr -> do
    Ptr Int32 -> Int32 -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke (Ptr TextRectangle
ptr Ptr TextRectangle -> Int -> Ptr Int32
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 0) (Int32
val :: Int32)

#if ENABLE_OVERLOADING
data TextRectangleXFieldInfo
instance AttrInfo TextRectangleXFieldInfo where
    type AttrAllowedOps TextRectangleXFieldInfo = '[ 'AttrSet, 'AttrGet]
    type AttrSetTypeConstraint TextRectangleXFieldInfo = (~) Int32
    type AttrBaseTypeConstraint TextRectangleXFieldInfo = (~) TextRectangle
    type AttrGetType TextRectangleXFieldInfo = Int32
    type AttrLabel TextRectangleXFieldInfo = "x"
    type AttrOrigin TextRectangleXFieldInfo = TextRectangle
    attrGet _ = getTextRectangleX
    attrSet _ = setTextRectangleX
    attrConstruct = undefined
    attrClear _ = undefined

textRectangle_x :: AttrLabelProxy "x"
textRectangle_x = AttrLabelProxy

#endif


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

@
'Data.GI.Base.Attributes.get' textRectangle #y
@
-}
getTextRectangleY :: MonadIO m => TextRectangle -> m Int32
getTextRectangleY :: TextRectangle -> m Int32
getTextRectangleY s :: TextRectangle
s = IO Int32 -> m Int32
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Int32 -> m Int32) -> IO Int32 -> m Int32
forall a b. (a -> b) -> a -> b
$ TextRectangle -> (Ptr TextRectangle -> IO Int32) -> IO Int32
forall a c.
(HasCallStack, ManagedPtrNewtype a) =>
a -> (Ptr a -> IO c) -> IO c
withManagedPtr TextRectangle
s ((Ptr TextRectangle -> IO Int32) -> IO Int32)
-> (Ptr TextRectangle -> IO Int32) -> IO Int32
forall a b. (a -> b) -> a -> b
$ \ptr :: Ptr TextRectangle
ptr -> do
    Int32
val <- Ptr Int32 -> IO Int32
forall a. Storable a => Ptr a -> IO a
peek (Ptr TextRectangle
ptr Ptr TextRectangle -> Int -> Ptr Int32
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 4) :: IO Int32
    Int32 -> IO Int32
forall (m :: * -> *) a. Monad m => a -> m a
return Int32
val

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

@
'Data.GI.Base.Attributes.set' textRectangle [ #y 'Data.GI.Base.Attributes.:=' value ]
@
-}
setTextRectangleY :: MonadIO m => TextRectangle -> Int32 -> m ()
setTextRectangleY :: TextRectangle -> Int32 -> m ()
setTextRectangleY s :: TextRectangle
s val :: Int32
val = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ TextRectangle -> (Ptr TextRectangle -> IO ()) -> IO ()
forall a c.
(HasCallStack, ManagedPtrNewtype a) =>
a -> (Ptr a -> IO c) -> IO c
withManagedPtr TextRectangle
s ((Ptr TextRectangle -> IO ()) -> IO ())
-> (Ptr TextRectangle -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \ptr :: Ptr TextRectangle
ptr -> do
    Ptr Int32 -> Int32 -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke (Ptr TextRectangle
ptr Ptr TextRectangle -> Int -> Ptr Int32
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 4) (Int32
val :: Int32)

#if ENABLE_OVERLOADING
data TextRectangleYFieldInfo
instance AttrInfo TextRectangleYFieldInfo where
    type AttrAllowedOps TextRectangleYFieldInfo = '[ 'AttrSet, 'AttrGet]
    type AttrSetTypeConstraint TextRectangleYFieldInfo = (~) Int32
    type AttrBaseTypeConstraint TextRectangleYFieldInfo = (~) TextRectangle
    type AttrGetType TextRectangleYFieldInfo = Int32
    type AttrLabel TextRectangleYFieldInfo = "y"
    type AttrOrigin TextRectangleYFieldInfo = TextRectangle
    attrGet _ = getTextRectangleY
    attrSet _ = setTextRectangleY
    attrConstruct = undefined
    attrClear _ = undefined

textRectangle_y :: AttrLabelProxy "y"
textRectangle_y = AttrLabelProxy

#endif


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

@
'Data.GI.Base.Attributes.get' textRectangle #width
@
-}
getTextRectangleWidth :: MonadIO m => TextRectangle -> m Int32
getTextRectangleWidth :: TextRectangle -> m Int32
getTextRectangleWidth s :: TextRectangle
s = IO Int32 -> m Int32
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Int32 -> m Int32) -> IO Int32 -> m Int32
forall a b. (a -> b) -> a -> b
$ TextRectangle -> (Ptr TextRectangle -> IO Int32) -> IO Int32
forall a c.
(HasCallStack, ManagedPtrNewtype a) =>
a -> (Ptr a -> IO c) -> IO c
withManagedPtr TextRectangle
s ((Ptr TextRectangle -> IO Int32) -> IO Int32)
-> (Ptr TextRectangle -> IO Int32) -> IO Int32
forall a b. (a -> b) -> a -> b
$ \ptr :: Ptr TextRectangle
ptr -> do
    Int32
val <- Ptr Int32 -> IO Int32
forall a. Storable a => Ptr a -> IO a
peek (Ptr TextRectangle
ptr Ptr TextRectangle -> Int -> Ptr Int32
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 8) :: IO Int32
    Int32 -> IO Int32
forall (m :: * -> *) a. Monad m => a -> m a
return Int32
val

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

@
'Data.GI.Base.Attributes.set' textRectangle [ #width 'Data.GI.Base.Attributes.:=' value ]
@
-}
setTextRectangleWidth :: MonadIO m => TextRectangle -> Int32 -> m ()
setTextRectangleWidth :: TextRectangle -> Int32 -> m ()
setTextRectangleWidth s :: TextRectangle
s val :: Int32
val = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ TextRectangle -> (Ptr TextRectangle -> IO ()) -> IO ()
forall a c.
(HasCallStack, ManagedPtrNewtype a) =>
a -> (Ptr a -> IO c) -> IO c
withManagedPtr TextRectangle
s ((Ptr TextRectangle -> IO ()) -> IO ())
-> (Ptr TextRectangle -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \ptr :: Ptr TextRectangle
ptr -> do
    Ptr Int32 -> Int32 -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke (Ptr TextRectangle
ptr Ptr TextRectangle -> Int -> Ptr Int32
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 8) (Int32
val :: Int32)

#if ENABLE_OVERLOADING
data TextRectangleWidthFieldInfo
instance AttrInfo TextRectangleWidthFieldInfo where
    type AttrAllowedOps TextRectangleWidthFieldInfo = '[ 'AttrSet, 'AttrGet]
    type AttrSetTypeConstraint TextRectangleWidthFieldInfo = (~) Int32
    type AttrBaseTypeConstraint TextRectangleWidthFieldInfo = (~) TextRectangle
    type AttrGetType TextRectangleWidthFieldInfo = Int32
    type AttrLabel TextRectangleWidthFieldInfo = "width"
    type AttrOrigin TextRectangleWidthFieldInfo = TextRectangle
    attrGet _ = getTextRectangleWidth
    attrSet _ = setTextRectangleWidth
    attrConstruct = undefined
    attrClear _ = undefined

textRectangle_width :: AttrLabelProxy "width"
textRectangle_width = AttrLabelProxy

#endif


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

@
'Data.GI.Base.Attributes.get' textRectangle #height
@
-}
getTextRectangleHeight :: MonadIO m => TextRectangle -> m Int32
getTextRectangleHeight :: TextRectangle -> m Int32
getTextRectangleHeight s :: TextRectangle
s = IO Int32 -> m Int32
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Int32 -> m Int32) -> IO Int32 -> m Int32
forall a b. (a -> b) -> a -> b
$ TextRectangle -> (Ptr TextRectangle -> IO Int32) -> IO Int32
forall a c.
(HasCallStack, ManagedPtrNewtype a) =>
a -> (Ptr a -> IO c) -> IO c
withManagedPtr TextRectangle
s ((Ptr TextRectangle -> IO Int32) -> IO Int32)
-> (Ptr TextRectangle -> IO Int32) -> IO Int32
forall a b. (a -> b) -> a -> b
$ \ptr :: Ptr TextRectangle
ptr -> do
    Int32
val <- Ptr Int32 -> IO Int32
forall a. Storable a => Ptr a -> IO a
peek (Ptr TextRectangle
ptr Ptr TextRectangle -> Int -> Ptr Int32
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 12) :: IO Int32
    Int32 -> IO Int32
forall (m :: * -> *) a. Monad m => a -> m a
return Int32
val

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

@
'Data.GI.Base.Attributes.set' textRectangle [ #height 'Data.GI.Base.Attributes.:=' value ]
@
-}
setTextRectangleHeight :: MonadIO m => TextRectangle -> Int32 -> m ()
setTextRectangleHeight :: TextRectangle -> Int32 -> m ()
setTextRectangleHeight s :: TextRectangle
s val :: Int32
val = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ TextRectangle -> (Ptr TextRectangle -> IO ()) -> IO ()
forall a c.
(HasCallStack, ManagedPtrNewtype a) =>
a -> (Ptr a -> IO c) -> IO c
withManagedPtr TextRectangle
s ((Ptr TextRectangle -> IO ()) -> IO ())
-> (Ptr TextRectangle -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \ptr :: Ptr TextRectangle
ptr -> do
    Ptr Int32 -> Int32 -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke (Ptr TextRectangle
ptr Ptr TextRectangle -> Int -> Ptr Int32
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 12) (Int32
val :: Int32)

#if ENABLE_OVERLOADING
data TextRectangleHeightFieldInfo
instance AttrInfo TextRectangleHeightFieldInfo where
    type AttrAllowedOps TextRectangleHeightFieldInfo = '[ 'AttrSet, 'AttrGet]
    type AttrSetTypeConstraint TextRectangleHeightFieldInfo = (~) Int32
    type AttrBaseTypeConstraint TextRectangleHeightFieldInfo = (~) TextRectangle
    type AttrGetType TextRectangleHeightFieldInfo = Int32
    type AttrLabel TextRectangleHeightFieldInfo = "height"
    type AttrOrigin TextRectangleHeightFieldInfo = TextRectangle
    attrGet _ = getTextRectangleHeight
    attrSet _ = setTextRectangleHeight
    attrConstruct = undefined
    attrClear _ = undefined

textRectangle_height :: AttrLabelProxy "height"
textRectangle_height = AttrLabelProxy

#endif



#if ENABLE_OVERLOADING
instance O.HasAttributeList TextRectangle
type instance O.AttributeList TextRectangle = TextRectangleAttributeList
type TextRectangleAttributeList = ('[ '("x", TextRectangleXFieldInfo), '("y", TextRectangleYFieldInfo), '("width", TextRectangleWidthFieldInfo), '("height", TextRectangleHeightFieldInfo)] :: [(Symbol, *)])
#endif

#if ENABLE_OVERLOADING
type family ResolveTextRectangleMethod (t :: Symbol) (o :: *) :: * where
    ResolveTextRectangleMethod l o = O.MethodResolutionFailed l o

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

#if MIN_VERSION_base(4,9,0)
instance (info ~ ResolveTextRectangleMethod t TextRectangle, O.MethodInfo info TextRectangle p) => O.IsLabel t (TextRectangle -> 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

#endif