{-# LANGUAGE TypeApplications #-}


-- | Copyright  : Will Thompson, Iñaki García Etxebarria and Jonas Platte
-- License    : LGPL-2.1
-- Maintainer : Iñaki García Etxebarria
-- 
-- The t'GI.Pango.Structs.AttrColor.AttrColor' structure is used to represent attributes that
-- are colors.

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

module GI.Pango.Structs.AttrColor
    ( 

-- * Exported types
    AttrColor(..)                           ,
    newZeroAttrColor                        ,


 -- * Methods
-- ** Overloaded methods #method:Overloaded methods#

#if defined(ENABLE_OVERLOADING)
    ResolveAttrColorMethod                  ,
#endif




 -- * Properties
-- ** attr #attr:attr#
-- | the common portion of the attribute

#if defined(ENABLE_OVERLOADING)
    attrColor_attr                          ,
#endif
    getAttrColorAttr                        ,


-- ** color #attr:color#
-- | the t'GI.Pango.Structs.Color.Color' which is the value of the attribute

#if defined(ENABLE_OVERLOADING)
    attrColor_color                         ,
#endif
    getAttrColorColor                       ,




    ) 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.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.GI.Base.Signals as B.Signals
import qualified Control.Monad.IO.Class as MIO
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.Pango.Structs.Attribute as Pango.Attribute
import {-# SOURCE #-} qualified GI.Pango.Structs.Color as Pango.Color

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

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

instance BoxedPtr AttrColor where
    boxedPtrCopy :: AttrColor -> IO AttrColor
boxedPtrCopy = \AttrColor
p -> AttrColor -> (Ptr AttrColor -> IO AttrColor) -> IO AttrColor
forall a c.
(HasCallStack, ManagedPtrNewtype a) =>
a -> (Ptr a -> IO c) -> IO c
B.ManagedPtr.withManagedPtr AttrColor
p (Int -> Ptr AttrColor -> IO (Ptr AttrColor)
forall a. (HasCallStack, CallocPtr a) => Int -> Ptr a -> IO (Ptr a)
copyBytes Int
24 (Ptr AttrColor -> IO (Ptr AttrColor))
-> (Ptr AttrColor -> IO AttrColor) -> Ptr AttrColor -> IO AttrColor
forall (m :: * -> *) a b c.
Monad m =>
(a -> m b) -> (b -> m c) -> a -> m c
>=> (ManagedPtr AttrColor -> AttrColor)
-> Ptr AttrColor -> IO AttrColor
forall a.
(HasCallStack, BoxedPtr a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
B.ManagedPtr.wrapPtr ManagedPtr AttrColor -> AttrColor
AttrColor)
    boxedPtrFree :: AttrColor -> IO ()
boxedPtrFree = \AttrColor
x -> AttrColor -> (Ptr AttrColor -> IO ()) -> IO ()
forall a c.
(HasCallStack, ManagedPtrNewtype a) =>
a -> (Ptr a -> IO c) -> IO c
SP.withManagedPtr AttrColor
x Ptr AttrColor -> IO ()
forall a. Ptr a -> IO ()
SP.freeMem
instance CallocPtr AttrColor where
    boxedPtrCalloc :: IO (Ptr AttrColor)
boxedPtrCalloc = Int -> IO (Ptr AttrColor)
forall a. Int -> IO (Ptr a)
callocBytes Int
24


-- | Construct a `AttrColor` struct initialized to zero.
newZeroAttrColor :: MonadIO m => m AttrColor
newZeroAttrColor :: m AttrColor
newZeroAttrColor = IO AttrColor -> m AttrColor
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO AttrColor -> m AttrColor) -> IO AttrColor -> m AttrColor
forall a b. (a -> b) -> a -> b
$ IO (Ptr AttrColor)
forall a. CallocPtr a => IO (Ptr a)
boxedPtrCalloc IO (Ptr AttrColor)
-> (Ptr AttrColor -> IO AttrColor) -> IO AttrColor
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= (ManagedPtr AttrColor -> AttrColor)
-> Ptr AttrColor -> IO AttrColor
forall a.
(HasCallStack, BoxedPtr a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
wrapPtr ManagedPtr AttrColor -> AttrColor
AttrColor

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


-- | Get the value of the “@attr@” field.
-- When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to
-- 
-- @
-- 'Data.GI.Base.Attributes.get' attrColor #attr
-- @
getAttrColorAttr :: MonadIO m => AttrColor -> m Pango.Attribute.Attribute
getAttrColorAttr :: AttrColor -> m Attribute
getAttrColorAttr AttrColor
s = IO Attribute -> m Attribute
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Attribute -> m Attribute) -> IO Attribute -> m Attribute
forall a b. (a -> b) -> a -> b
$ AttrColor -> (Ptr AttrColor -> IO Attribute) -> IO Attribute
forall a c.
(HasCallStack, ManagedPtrNewtype a) =>
a -> (Ptr a -> IO c) -> IO c
withManagedPtr AttrColor
s ((Ptr AttrColor -> IO Attribute) -> IO Attribute)
-> (Ptr AttrColor -> IO Attribute) -> IO Attribute
forall a b. (a -> b) -> a -> b
$ \Ptr AttrColor
ptr -> do
    let val :: Ptr Attribute
val = Ptr AttrColor
ptr Ptr AttrColor -> Int -> Ptr Attribute
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
0 :: (Ptr Pango.Attribute.Attribute)
    Attribute
val' <- ((ManagedPtr Attribute -> Attribute)
-> Ptr Attribute -> IO Attribute
forall a.
(HasCallStack, GBoxed a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
newBoxed ManagedPtr Attribute -> Attribute
Pango.Attribute.Attribute) Ptr Attribute
val
    Attribute -> IO Attribute
forall (m :: * -> *) a. Monad m => a -> m a
return Attribute
val'

#if defined(ENABLE_OVERLOADING)
data AttrColorAttrFieldInfo
instance AttrInfo AttrColorAttrFieldInfo where
    type AttrBaseTypeConstraint AttrColorAttrFieldInfo = (~) AttrColor
    type AttrAllowedOps AttrColorAttrFieldInfo = '[ 'AttrGet]
    type AttrSetTypeConstraint AttrColorAttrFieldInfo = (~) (Ptr Pango.Attribute.Attribute)
    type AttrTransferTypeConstraint AttrColorAttrFieldInfo = (~)(Ptr Pango.Attribute.Attribute)
    type AttrTransferType AttrColorAttrFieldInfo = (Ptr Pango.Attribute.Attribute)
    type AttrGetType AttrColorAttrFieldInfo = Pango.Attribute.Attribute
    type AttrLabel AttrColorAttrFieldInfo = "attr"
    type AttrOrigin AttrColorAttrFieldInfo = AttrColor
    attrGet = getAttrColorAttr
    attrSet = undefined
    attrConstruct = undefined
    attrClear = undefined
    attrTransfer = undefined

attrColor_attr :: AttrLabelProxy "attr"
attrColor_attr = AttrLabelProxy

#endif


-- | Get the value of the “@color@” field.
-- When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to
-- 
-- @
-- 'Data.GI.Base.Attributes.get' attrColor #color
-- @
getAttrColorColor :: MonadIO m => AttrColor -> m Pango.Color.Color
getAttrColorColor :: AttrColor -> m Color
getAttrColorColor AttrColor
s = IO Color -> m Color
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Color -> m Color) -> IO Color -> m Color
forall a b. (a -> b) -> a -> b
$ AttrColor -> (Ptr AttrColor -> IO Color) -> IO Color
forall a c.
(HasCallStack, ManagedPtrNewtype a) =>
a -> (Ptr a -> IO c) -> IO c
withManagedPtr AttrColor
s ((Ptr AttrColor -> IO Color) -> IO Color)
-> (Ptr AttrColor -> IO Color) -> IO Color
forall a b. (a -> b) -> a -> b
$ \Ptr AttrColor
ptr -> do
    let val :: Ptr Color
val = Ptr AttrColor
ptr Ptr AttrColor -> Int -> Ptr Color
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
16 :: (Ptr Pango.Color.Color)
    Color
val' <- ((ManagedPtr Color -> Color) -> Ptr Color -> IO Color
forall a.
(HasCallStack, GBoxed a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
newBoxed ManagedPtr Color -> Color
Pango.Color.Color) Ptr Color
val
    Color -> IO Color
forall (m :: * -> *) a. Monad m => a -> m a
return Color
val'

#if defined(ENABLE_OVERLOADING)
data AttrColorColorFieldInfo
instance AttrInfo AttrColorColorFieldInfo where
    type AttrBaseTypeConstraint AttrColorColorFieldInfo = (~) AttrColor
    type AttrAllowedOps AttrColorColorFieldInfo = '[ 'AttrGet]
    type AttrSetTypeConstraint AttrColorColorFieldInfo = (~) (Ptr Pango.Color.Color)
    type AttrTransferTypeConstraint AttrColorColorFieldInfo = (~)(Ptr Pango.Color.Color)
    type AttrTransferType AttrColorColorFieldInfo = (Ptr Pango.Color.Color)
    type AttrGetType AttrColorColorFieldInfo = Pango.Color.Color
    type AttrLabel AttrColorColorFieldInfo = "color"
    type AttrOrigin AttrColorColorFieldInfo = AttrColor
    attrGet = getAttrColorColor
    attrSet = undefined
    attrConstruct = undefined
    attrClear = undefined
    attrTransfer = undefined

attrColor_color :: AttrLabelProxy "color"
attrColor_color = AttrLabelProxy

#endif



#if defined(ENABLE_OVERLOADING)
instance O.HasAttributeList AttrColor
type instance O.AttributeList AttrColor = AttrColorAttributeList
type AttrColorAttributeList = ('[ '("attr", AttrColorAttrFieldInfo), '("color", AttrColorColorFieldInfo)] :: [(Symbol, *)])
#endif

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

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

#endif