{-# LANGUAGE TypeApplications #-}


-- | Copyright  : Will Thompson and Iñaki García Etxebarria
-- License    : LGPL-2.1
-- Maintainer : Iñaki García Etxebarria
-- 
-- The @PangoAttrFontFeatures@ structure is used to represent OpenType
-- font features as an attribute.
-- 
-- /Since: 1.38/

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

module GI.Pango.Structs.AttrFontFeatures
    ( 

-- * Exported types
    AttrFontFeatures(..)                    ,
    newZeroAttrFontFeatures                 ,


 -- * Methods

#if defined(ENABLE_OVERLOADING)
    ResolveAttrFontFeaturesMethod           ,
#endif

-- ** new #method:new#

    attrFontFeaturesNew                     ,




 -- * Properties


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

#if defined(ENABLE_OVERLOADING)
    attrFontFeatures_attr                   ,
#endif
    getAttrFontFeaturesAttr                 ,


-- ** features #attr:features#
-- | the featues, as a string in CSS syntax

#if defined(ENABLE_OVERLOADING)
    attrFontFeatures_features               ,
#endif
    clearAttrFontFeaturesFeatures           ,
    getAttrFontFeaturesFeatures             ,
    setAttrFontFeaturesFeatures             ,




    ) 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.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.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 {-# SOURCE #-} qualified GI.Pango.Structs.Attribute as Pango.Attribute

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

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

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


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

instance tag ~ 'AttrSet => Constructible AttrFontFeatures tag where
    new :: forall (m :: * -> *).
MonadIO m =>
(ManagedPtr AttrFontFeatures -> AttrFontFeatures)
-> [AttrOp AttrFontFeatures tag] -> m AttrFontFeatures
new ManagedPtr AttrFontFeatures -> AttrFontFeatures
_ [AttrOp AttrFontFeatures tag]
attrs = do
        AttrFontFeatures
o <- m AttrFontFeatures
forall (m :: * -> *). MonadIO m => m AttrFontFeatures
newZeroAttrFontFeatures
        AttrFontFeatures -> [AttrOp AttrFontFeatures 'AttrSet] -> m ()
forall o (m :: * -> *).
MonadIO m =>
o -> [AttrOp o 'AttrSet] -> m ()
GI.Attributes.set AttrFontFeatures
o [AttrOp AttrFontFeatures tag]
[AttrOp AttrFontFeatures 'AttrSet]
attrs
        AttrFontFeatures -> m AttrFontFeatures
forall (m :: * -> *) a. Monad m => a -> m a
return AttrFontFeatures
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' attrFontFeatures #attr
-- @
getAttrFontFeaturesAttr :: MonadIO m => AttrFontFeatures -> m Pango.Attribute.Attribute
getAttrFontFeaturesAttr :: forall (m :: * -> *). MonadIO m => AttrFontFeatures -> m Attribute
getAttrFontFeaturesAttr AttrFontFeatures
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
$ AttrFontFeatures
-> (Ptr AttrFontFeatures -> IO Attribute) -> IO Attribute
forall a c.
(HasCallStack, ManagedPtrNewtype a) =>
a -> (Ptr a -> IO c) -> IO c
withManagedPtr AttrFontFeatures
s ((Ptr AttrFontFeatures -> IO Attribute) -> IO Attribute)
-> (Ptr AttrFontFeatures -> IO Attribute) -> IO Attribute
forall a b. (a -> b) -> a -> b
$ \Ptr AttrFontFeatures
ptr -> do
    let val :: Ptr Attribute
val = Ptr AttrFontFeatures
ptr Ptr AttrFontFeatures -> 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 AttrFontFeaturesAttrFieldInfo
instance AttrInfo AttrFontFeaturesAttrFieldInfo where
    type AttrBaseTypeConstraint AttrFontFeaturesAttrFieldInfo = (~) AttrFontFeatures
    type AttrAllowedOps AttrFontFeaturesAttrFieldInfo = '[ 'AttrGet]
    type AttrSetTypeConstraint AttrFontFeaturesAttrFieldInfo = (~) (Ptr Pango.Attribute.Attribute)
    type AttrTransferTypeConstraint AttrFontFeaturesAttrFieldInfo = (~)(Ptr Pango.Attribute.Attribute)
    type AttrTransferType AttrFontFeaturesAttrFieldInfo = (Ptr Pango.Attribute.Attribute)
    type AttrGetType AttrFontFeaturesAttrFieldInfo = Pango.Attribute.Attribute
    type AttrLabel AttrFontFeaturesAttrFieldInfo = "attr"
    type AttrOrigin AttrFontFeaturesAttrFieldInfo = AttrFontFeatures
    attrGet = getAttrFontFeaturesAttr
    attrSet = undefined
    attrConstruct = undefined
    attrClear = undefined
    attrTransfer = undefined
    dbgAttrInfo = P.Just (O.ResolvedSymbolInfo {
        O.resolvedSymbolName = "GI.Pango.Structs.AttrFontFeatures.attr"
        , O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-pango-1.0.25/docs/GI-Pango-Structs-AttrFontFeatures.html#g:attr:attr"
        })

attrFontFeatures_attr :: AttrLabelProxy "attr"
attrFontFeatures_attr = AttrLabelProxy

#endif


-- | Get the value of the “@features@” field.
-- When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to
-- 
-- @
-- 'Data.GI.Base.Attributes.get' attrFontFeatures #features
-- @
getAttrFontFeaturesFeatures :: MonadIO m => AttrFontFeatures -> m (Maybe T.Text)
getAttrFontFeaturesFeatures :: forall (m :: * -> *).
MonadIO m =>
AttrFontFeatures -> m (Maybe Text)
getAttrFontFeaturesFeatures AttrFontFeatures
s = IO (Maybe Text) -> m (Maybe Text)
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (Maybe Text) -> m (Maybe Text))
-> IO (Maybe Text) -> m (Maybe Text)
forall a b. (a -> b) -> a -> b
$ AttrFontFeatures
-> (Ptr AttrFontFeatures -> IO (Maybe Text)) -> IO (Maybe Text)
forall a c.
(HasCallStack, ManagedPtrNewtype a) =>
a -> (Ptr a -> IO c) -> IO c
withManagedPtr AttrFontFeatures
s ((Ptr AttrFontFeatures -> IO (Maybe Text)) -> IO (Maybe Text))
-> (Ptr AttrFontFeatures -> IO (Maybe Text)) -> IO (Maybe Text)
forall a b. (a -> b) -> a -> b
$ \Ptr AttrFontFeatures
ptr -> do
    CString
val <- Ptr CString -> IO CString
forall a. Storable a => Ptr a -> IO a
peek (Ptr AttrFontFeatures
ptr Ptr AttrFontFeatures -> Int -> Ptr CString
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
16) :: IO CString
    Maybe Text
result <- CString -> (CString -> IO Text) -> IO (Maybe Text)
forall a b. Ptr a -> (Ptr a -> IO b) -> IO (Maybe b)
SP.convertIfNonNull CString
val ((CString -> IO Text) -> IO (Maybe Text))
-> (CString -> IO Text) -> IO (Maybe Text)
forall a b. (a -> b) -> a -> b
$ \CString
val' -> do
        Text
val'' <- HasCallStack => CString -> IO Text
CString -> IO Text
cstringToText CString
val'
        Text -> IO Text
forall (m :: * -> *) a. Monad m => a -> m a
return Text
val''
    Maybe Text -> IO (Maybe Text)
forall (m :: * -> *) a. Monad m => a -> m a
return Maybe Text
result

-- | Set the value of the “@features@” field.
-- When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to
-- 
-- @
-- 'Data.GI.Base.Attributes.set' attrFontFeatures [ #features 'Data.GI.Base.Attributes.:=' value ]
-- @
setAttrFontFeaturesFeatures :: MonadIO m => AttrFontFeatures -> CString -> m ()
setAttrFontFeaturesFeatures :: forall (m :: * -> *).
MonadIO m =>
AttrFontFeatures -> CString -> m ()
setAttrFontFeaturesFeatures AttrFontFeatures
s CString
val = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ AttrFontFeatures -> (Ptr AttrFontFeatures -> IO ()) -> IO ()
forall a c.
(HasCallStack, ManagedPtrNewtype a) =>
a -> (Ptr a -> IO c) -> IO c
withManagedPtr AttrFontFeatures
s ((Ptr AttrFontFeatures -> IO ()) -> IO ())
-> (Ptr AttrFontFeatures -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \Ptr AttrFontFeatures
ptr -> do
    Ptr CString -> CString -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke (Ptr AttrFontFeatures
ptr Ptr AttrFontFeatures -> Int -> Ptr CString
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
16) (CString
val :: CString)

-- | Set the value of the “@features@” field to `Nothing`.
-- When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to
-- 
-- @
-- 'Data.GI.Base.Attributes.clear' #features
-- @
clearAttrFontFeaturesFeatures :: MonadIO m => AttrFontFeatures -> m ()
clearAttrFontFeaturesFeatures :: forall (m :: * -> *). MonadIO m => AttrFontFeatures -> m ()
clearAttrFontFeaturesFeatures AttrFontFeatures
s = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ AttrFontFeatures -> (Ptr AttrFontFeatures -> IO ()) -> IO ()
forall a c.
(HasCallStack, ManagedPtrNewtype a) =>
a -> (Ptr a -> IO c) -> IO c
withManagedPtr AttrFontFeatures
s ((Ptr AttrFontFeatures -> IO ()) -> IO ())
-> (Ptr AttrFontFeatures -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \Ptr AttrFontFeatures
ptr -> do
    Ptr CString -> CString -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke (Ptr AttrFontFeatures
ptr Ptr AttrFontFeatures -> Int -> Ptr CString
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
16) (CString
forall a. Ptr a
FP.nullPtr :: CString)

#if defined(ENABLE_OVERLOADING)
data AttrFontFeaturesFeaturesFieldInfo
instance AttrInfo AttrFontFeaturesFeaturesFieldInfo where
    type AttrBaseTypeConstraint AttrFontFeaturesFeaturesFieldInfo = (~) AttrFontFeatures
    type AttrAllowedOps AttrFontFeaturesFeaturesFieldInfo = '[ 'AttrSet, 'AttrGet, 'AttrClear]
    type AttrSetTypeConstraint AttrFontFeaturesFeaturesFieldInfo = (~) CString
    type AttrTransferTypeConstraint AttrFontFeaturesFeaturesFieldInfo = (~)CString
    type AttrTransferType AttrFontFeaturesFeaturesFieldInfo = CString
    type AttrGetType AttrFontFeaturesFeaturesFieldInfo = Maybe T.Text
    type AttrLabel AttrFontFeaturesFeaturesFieldInfo = "features"
    type AttrOrigin AttrFontFeaturesFeaturesFieldInfo = AttrFontFeatures
    attrGet = getAttrFontFeaturesFeatures
    attrSet = setAttrFontFeaturesFeatures
    attrConstruct = undefined
    attrClear = clearAttrFontFeaturesFeatures
    attrTransfer _ v = do
        return v
    dbgAttrInfo = P.Just (O.ResolvedSymbolInfo {
        O.resolvedSymbolName = "GI.Pango.Structs.AttrFontFeatures.features"
        , O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-pango-1.0.25/docs/GI-Pango-Structs-AttrFontFeatures.html#g:attr:features"
        })

attrFontFeatures_features :: AttrLabelProxy "features"
attrFontFeatures_features = AttrLabelProxy

#endif



#if defined(ENABLE_OVERLOADING)
instance O.HasAttributeList AttrFontFeatures
type instance O.AttributeList AttrFontFeatures = AttrFontFeaturesAttributeList
type AttrFontFeaturesAttributeList = ('[ '("attr", AttrFontFeaturesAttrFieldInfo), '("features", AttrFontFeaturesFeaturesFieldInfo)] :: [(Symbol, *)])
#endif

-- method AttrFontFeatures::new
-- method type : MemberFunction
-- Args: [ Arg
--           { argCName = "features"
--           , argType = TBasicType TUTF8
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText =
--                     Just
--                       "a string with OpenType font features, with the syntax of the [CSS\nfont-feature-settings property](https://www.w3.org/TR/css-fonts-4/#font-rend-desc)"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just (TInterface Name { namespace = "Pango" , name = "Attribute" })
-- throws : False
-- Skip return : False

foreign import ccall "pango_attr_font_features_new" pango_attr_font_features_new :: 
    CString ->                              -- features : TBasicType TUTF8
    IO (Ptr Pango.Attribute.Attribute)

-- | Create a new font features tag attribute.
-- 
-- You can use this attribute to select OpenType font features like small-caps,
-- alternative glyphs, ligatures, etc. for fonts that support them.
-- 
-- /Since: 1.38/
attrFontFeaturesNew ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    T.Text
    -- ^ /@features@/: a string with OpenType font features, with the syntax of the <https://www.w3.org/TR/css-fonts-4/#font-rend-desc CSS
    -- font-feature-settings property>
    -> m Pango.Attribute.Attribute
    -- ^ __Returns:__ the newly allocated
    --   @PangoAttribute@, which should be freed with
    --   'GI.Pango.Structs.Attribute.attributeDestroy'
attrFontFeaturesNew :: forall (m :: * -> *).
(HasCallStack, MonadIO m) =>
Text -> m Attribute
attrFontFeaturesNew Text
features = 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
$ do
    CString
features' <- Text -> IO CString
textToCString Text
features
    Ptr Attribute
result <- CString -> IO (Ptr Attribute)
pango_attr_font_features_new CString
features'
    Text -> Ptr Attribute -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL Text
"attrFontFeaturesNew" Ptr Attribute
result
    Attribute
result' <- ((ManagedPtr Attribute -> Attribute)
-> Ptr Attribute -> IO Attribute
forall a.
(HasCallStack, GBoxed a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
wrapBoxed ManagedPtr Attribute -> Attribute
Pango.Attribute.Attribute) Ptr Attribute
result
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
features'
    Attribute -> IO Attribute
forall (m :: * -> *) a. Monad m => a -> m a
return Attribute
result'

#if defined(ENABLE_OVERLOADING)
#endif

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

instance (info ~ ResolveAttrFontFeaturesMethod t AttrFontFeatures, O.OverloadedMethod info AttrFontFeatures p) => OL.IsLabel t (AttrFontFeatures -> 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 ~ ResolveAttrFontFeaturesMethod t AttrFontFeatures, O.OverloadedMethod info AttrFontFeatures p, R.HasField t AttrFontFeatures p) => R.HasField t AttrFontFeatures p where
    getField = O.overloadedMethod @info

#endif

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

#endif