{-# 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                        ,
    noAttrColor                             ,


 -- * 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.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 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 (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 WrappedPtr AttrColor where
    wrappedPtrCalloc :: IO (Ptr AttrColor)
wrappedPtrCalloc = Int -> IO (Ptr AttrColor)
forall a. Int -> IO (Ptr a)
callocBytes 24
    wrappedPtrCopy :: AttrColor -> IO AttrColor
wrappedPtrCopy = \p :: AttrColor
p -> AttrColor -> (Ptr AttrColor -> IO AttrColor) -> IO AttrColor
forall a c.
(HasCallStack, ManagedPtrNewtype a) =>
a -> (Ptr a -> IO c) -> IO c
withManagedPtr AttrColor
p (Int -> Ptr AttrColor -> IO (Ptr AttrColor)
forall a. WrappedPtr a => Int -> Ptr a -> IO (Ptr a)
copyBytes 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, WrappedPtr a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
wrapPtr ManagedPtr AttrColor -> AttrColor
AttrColor)
    wrappedPtrFree :: Maybe (GDestroyNotify AttrColor)
wrappedPtrFree = GDestroyNotify AttrColor -> Maybe (GDestroyNotify AttrColor)
forall a. a -> Maybe a
Just GDestroyNotify AttrColor
forall a. FunPtr (Ptr a -> IO ())
ptr_to_g_free

-- | 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. WrappedPtr a => IO (Ptr a)
wrappedPtrCalloc 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, WrappedPtr 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 _ attrs :: [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


-- | A convenience alias for `Nothing` :: `Maybe` `AttrColor`.
noAttrColor :: Maybe AttrColor
noAttrColor :: Maybe AttrColor
noAttrColor = Maybe AttrColor
forall a. Maybe a
Nothing

-- | 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 s :: 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 :: 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` 0 :: (Ptr Pango.Attribute.Attribute)
    Attribute
val' <- ((ManagedPtr Attribute -> Attribute)
-> Ptr Attribute -> IO Attribute
forall a.
(HasCallStack, WrappedPtr a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
newPtr 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 s :: 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 :: 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` 16 :: (Ptr Pango.Color.Color)
    Color
val' <- ((ManagedPtr Color -> Color) -> Ptr Color -> IO Color
forall a.
(HasCallStack, BoxedObject 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