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

The 'GI.Pango.Objects.Context.Context' structure stores global information
used to control the itemization process.
-}

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

module GI.Pango.Objects.Context
    (

-- * Exported types
    Context(..)                             ,
    IsContext                               ,
    toContext                               ,
    noContext                               ,


 -- * Methods
-- ** changed #method:changed#

#if ENABLE_OVERLOADING
    ContextChangedMethodInfo                ,
#endif
    contextChanged                          ,


-- ** getBaseDir #method:getBaseDir#

#if ENABLE_OVERLOADING
    ContextGetBaseDirMethodInfo             ,
#endif
    contextGetBaseDir                       ,


-- ** getBaseGravity #method:getBaseGravity#

#if ENABLE_OVERLOADING
    ContextGetBaseGravityMethodInfo         ,
#endif
    contextGetBaseGravity                   ,


-- ** getFontDescription #method:getFontDescription#

#if ENABLE_OVERLOADING
    ContextGetFontDescriptionMethodInfo     ,
#endif
    contextGetFontDescription               ,


-- ** getFontMap #method:getFontMap#

#if ENABLE_OVERLOADING
    ContextGetFontMapMethodInfo             ,
#endif
    contextGetFontMap                       ,


-- ** getGravity #method:getGravity#

#if ENABLE_OVERLOADING
    ContextGetGravityMethodInfo             ,
#endif
    contextGetGravity                       ,


-- ** getGravityHint #method:getGravityHint#

#if ENABLE_OVERLOADING
    ContextGetGravityHintMethodInfo         ,
#endif
    contextGetGravityHint                   ,


-- ** getLanguage #method:getLanguage#

#if ENABLE_OVERLOADING
    ContextGetLanguageMethodInfo            ,
#endif
    contextGetLanguage                      ,


-- ** getMatrix #method:getMatrix#

#if ENABLE_OVERLOADING
    ContextGetMatrixMethodInfo              ,
#endif
    contextGetMatrix                        ,


-- ** getMetrics #method:getMetrics#

#if ENABLE_OVERLOADING
    ContextGetMetricsMethodInfo             ,
#endif
    contextGetMetrics                       ,


-- ** getSerial #method:getSerial#

#if ENABLE_OVERLOADING
    ContextGetSerialMethodInfo              ,
#endif
    contextGetSerial                        ,


-- ** listFamilies #method:listFamilies#

#if ENABLE_OVERLOADING
    ContextListFamiliesMethodInfo           ,
#endif
    contextListFamilies                     ,


-- ** loadFont #method:loadFont#

#if ENABLE_OVERLOADING
    ContextLoadFontMethodInfo               ,
#endif
    contextLoadFont                         ,


-- ** loadFontset #method:loadFontset#

#if ENABLE_OVERLOADING
    ContextLoadFontsetMethodInfo            ,
#endif
    contextLoadFontset                      ,


-- ** new #method:new#

    contextNew                              ,


-- ** setBaseDir #method:setBaseDir#

#if ENABLE_OVERLOADING
    ContextSetBaseDirMethodInfo             ,
#endif
    contextSetBaseDir                       ,


-- ** setBaseGravity #method:setBaseGravity#

#if ENABLE_OVERLOADING
    ContextSetBaseGravityMethodInfo         ,
#endif
    contextSetBaseGravity                   ,


-- ** setFontDescription #method:setFontDescription#

#if ENABLE_OVERLOADING
    ContextSetFontDescriptionMethodInfo     ,
#endif
    contextSetFontDescription               ,


-- ** setFontMap #method:setFontMap#

#if ENABLE_OVERLOADING
    ContextSetFontMapMethodInfo             ,
#endif
    contextSetFontMap                       ,


-- ** setGravityHint #method:setGravityHint#

#if ENABLE_OVERLOADING
    ContextSetGravityHintMethodInfo         ,
#endif
    contextSetGravityHint                   ,


-- ** setLanguage #method:setLanguage#

#if ENABLE_OVERLOADING
    ContextSetLanguageMethodInfo            ,
#endif
    contextSetLanguage                      ,


-- ** setMatrix #method:setMatrix#

#if ENABLE_OVERLOADING
    ContextSetMatrixMethodInfo              ,
#endif
    contextSetMatrix                        ,




    ) 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

import qualified GI.GObject.Objects.Object as GObject.Object
import {-# SOURCE #-} qualified GI.Pango.Enums as Pango.Enums
import {-# SOURCE #-} qualified GI.Pango.Objects.Font as Pango.Font
import {-# SOURCE #-} qualified GI.Pango.Objects.FontFamily as Pango.FontFamily
import {-# SOURCE #-} qualified GI.Pango.Objects.FontMap as Pango.FontMap
import {-# SOURCE #-} qualified GI.Pango.Objects.Fontset as Pango.Fontset
import {-# SOURCE #-} qualified GI.Pango.Structs.FontDescription as Pango.FontDescription
import {-# SOURCE #-} qualified GI.Pango.Structs.FontMetrics as Pango.FontMetrics
import {-# SOURCE #-} qualified GI.Pango.Structs.Language as Pango.Language
import {-# SOURCE #-} qualified GI.Pango.Structs.Matrix as Pango.Matrix

-- | Memory-managed wrapper type.
newtype Context = Context (ManagedPtr Context)
foreign import ccall "pango_context_get_type"
    c_pango_context_get_type :: IO GType

instance GObject Context where
    gobjectType _ = c_pango_context_get_type


-- | Type class for types which can be safely cast to `Context`, for instance with `toContext`.
class GObject o => IsContext o
#if MIN_VERSION_base(4,9,0)
instance {-# OVERLAPPABLE #-} (GObject a, O.UnknownAncestorError Context a) =>
    IsContext a
#endif
instance IsContext Context
instance GObject.Object.IsObject Context

-- | Cast to `Context`, for types for which this is known to be safe. For general casts, use `Data.GI.Base.ManagedPtr.castTo`.
toContext :: (MonadIO m, IsContext o) => o -> m Context
toContext = liftIO . unsafeCastTo Context

-- | A convenience alias for `Nothing` :: `Maybe` `Context`.
noContext :: Maybe Context
noContext = Nothing

#if ENABLE_OVERLOADING
type family ResolveContextMethod (t :: Symbol) (o :: *) :: * where
    ResolveContextMethod "bindProperty" o = GObject.Object.ObjectBindPropertyMethodInfo
    ResolveContextMethod "bindPropertyFull" o = GObject.Object.ObjectBindPropertyFullMethodInfo
    ResolveContextMethod "changed" o = ContextChangedMethodInfo
    ResolveContextMethod "forceFloating" o = GObject.Object.ObjectForceFloatingMethodInfo
    ResolveContextMethod "freezeNotify" o = GObject.Object.ObjectFreezeNotifyMethodInfo
    ResolveContextMethod "getv" o = GObject.Object.ObjectGetvMethodInfo
    ResolveContextMethod "isFloating" o = GObject.Object.ObjectIsFloatingMethodInfo
    ResolveContextMethod "listFamilies" o = ContextListFamiliesMethodInfo
    ResolveContextMethod "loadFont" o = ContextLoadFontMethodInfo
    ResolveContextMethod "loadFontset" o = ContextLoadFontsetMethodInfo
    ResolveContextMethod "notify" o = GObject.Object.ObjectNotifyMethodInfo
    ResolveContextMethod "notifyByPspec" o = GObject.Object.ObjectNotifyByPspecMethodInfo
    ResolveContextMethod "ref" o = GObject.Object.ObjectRefMethodInfo
    ResolveContextMethod "refSink" o = GObject.Object.ObjectRefSinkMethodInfo
    ResolveContextMethod "runDispose" o = GObject.Object.ObjectRunDisposeMethodInfo
    ResolveContextMethod "stealData" o = GObject.Object.ObjectStealDataMethodInfo
    ResolveContextMethod "stealQdata" o = GObject.Object.ObjectStealQdataMethodInfo
    ResolveContextMethod "thawNotify" o = GObject.Object.ObjectThawNotifyMethodInfo
    ResolveContextMethod "unref" o = GObject.Object.ObjectUnrefMethodInfo
    ResolveContextMethod "watchClosure" o = GObject.Object.ObjectWatchClosureMethodInfo
    ResolveContextMethod "getBaseDir" o = ContextGetBaseDirMethodInfo
    ResolveContextMethod "getBaseGravity" o = ContextGetBaseGravityMethodInfo
    ResolveContextMethod "getData" o = GObject.Object.ObjectGetDataMethodInfo
    ResolveContextMethod "getFontDescription" o = ContextGetFontDescriptionMethodInfo
    ResolveContextMethod "getFontMap" o = ContextGetFontMapMethodInfo
    ResolveContextMethod "getGravity" o = ContextGetGravityMethodInfo
    ResolveContextMethod "getGravityHint" o = ContextGetGravityHintMethodInfo
    ResolveContextMethod "getLanguage" o = ContextGetLanguageMethodInfo
    ResolveContextMethod "getMatrix" o = ContextGetMatrixMethodInfo
    ResolveContextMethod "getMetrics" o = ContextGetMetricsMethodInfo
    ResolveContextMethod "getProperty" o = GObject.Object.ObjectGetPropertyMethodInfo
    ResolveContextMethod "getQdata" o = GObject.Object.ObjectGetQdataMethodInfo
    ResolveContextMethod "getSerial" o = ContextGetSerialMethodInfo
    ResolveContextMethod "setBaseDir" o = ContextSetBaseDirMethodInfo
    ResolveContextMethod "setBaseGravity" o = ContextSetBaseGravityMethodInfo
    ResolveContextMethod "setData" o = GObject.Object.ObjectSetDataMethodInfo
    ResolveContextMethod "setFontDescription" o = ContextSetFontDescriptionMethodInfo
    ResolveContextMethod "setFontMap" o = ContextSetFontMapMethodInfo
    ResolveContextMethod "setGravityHint" o = ContextSetGravityHintMethodInfo
    ResolveContextMethod "setLanguage" o = ContextSetLanguageMethodInfo
    ResolveContextMethod "setMatrix" o = ContextSetMatrixMethodInfo
    ResolveContextMethod "setProperty" o = GObject.Object.ObjectSetPropertyMethodInfo
    ResolveContextMethod l o = O.MethodResolutionFailed l o

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

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

#if ENABLE_OVERLOADING
instance O.HasAttributeList Context
type instance O.AttributeList Context = ContextAttributeList
type ContextAttributeList = ('[ ] :: [(Symbol, *)])
#endif

#if ENABLE_OVERLOADING
#endif

#if ENABLE_OVERLOADING
type instance O.SignalList Context = ContextSignalList
type ContextSignalList = ('[ '("notify", GObject.Object.ObjectNotifySignalInfo)] :: [(Symbol, *)])

#endif

-- method Context::new
-- method type : Constructor
-- Args : []
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "Pango", name = "Context"}))
-- throws : False
-- Skip return : False

foreign import ccall "pango_context_new" pango_context_new ::
    IO (Ptr Context)

{- |
Creates a new 'GI.Pango.Objects.Context.Context' initialized to default values.

This function is not particularly useful as it should always
be followed by a 'GI.Pango.Objects.Context.contextSetFontMap' call, and the
function 'GI.Pango.Objects.FontMap.fontMapCreateContext' does these two steps
together and hence users are recommended to use that.

If you are using Pango as part of a higher-level system,
that system may have it\'s own way of create a 'GI.Pango.Objects.Context.Context'.
For instance, the GTK+ toolkit has, among others,
@/gdk_pango_context_get_for_screen()/@, and
@/gtk_widget_get_pango_context()/@.  Use those instead.
-}
contextNew ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    m Context
    {- ^ __Returns:__ the newly allocated 'GI.Pango.Objects.Context.Context', which should
              be freed with 'GI.GObject.Objects.Object.objectUnref'. -}
contextNew  = liftIO $ do
    result <- pango_context_new
    checkUnexpectedReturnNULL "contextNew" result
    result' <- (wrapObject Context) result
    return result'

#if ENABLE_OVERLOADING
#endif

-- method Context::changed
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "context", argType = TInterface (Name {namespace = "Pango", name = "Context"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #PangoContext", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "pango_context_changed" pango_context_changed ::
    Ptr Context ->                          -- context : TInterface (Name {namespace = "Pango", name = "Context"})
    IO ()

{- |
Forces a change in the context, which will cause any 'GI.Pango.Objects.Layout.Layout'
using this context to re-layout.

This function is only useful when implementing a new backend
for Pango, something applications won\'t do. Backends should
call this function if they have attached extra data to the context
and such data is changed.

/Since: 1.32.4/
-}
contextChanged ::
    (B.CallStack.HasCallStack, MonadIO m, IsContext a) =>
    a
    {- ^ /@context@/: a 'GI.Pango.Objects.Context.Context' -}
    -> m ()
contextChanged context = liftIO $ do
    context' <- unsafeManagedPtrCastPtr context
    pango_context_changed context'
    touchManagedPtr context
    return ()

#if ENABLE_OVERLOADING
data ContextChangedMethodInfo
instance (signature ~ (m ()), MonadIO m, IsContext a) => O.MethodInfo ContextChangedMethodInfo a signature where
    overloadedMethod _ = contextChanged

#endif

-- method Context::get_base_dir
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "context", argType = TInterface (Name {namespace = "Pango", name = "Context"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #PangoContext", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "Pango", name = "Direction"}))
-- throws : False
-- Skip return : False

foreign import ccall "pango_context_get_base_dir" pango_context_get_base_dir ::
    Ptr Context ->                          -- context : TInterface (Name {namespace = "Pango", name = "Context"})
    IO CUInt

{- |
Retrieves the base direction for the context. See
'GI.Pango.Objects.Context.contextSetBaseDir'.
-}
contextGetBaseDir ::
    (B.CallStack.HasCallStack, MonadIO m, IsContext a) =>
    a
    {- ^ /@context@/: a 'GI.Pango.Objects.Context.Context' -}
    -> m Pango.Enums.Direction
    {- ^ __Returns:__ the base direction for the context. -}
contextGetBaseDir context = liftIO $ do
    context' <- unsafeManagedPtrCastPtr context
    result <- pango_context_get_base_dir context'
    let result' = (toEnum . fromIntegral) result
    touchManagedPtr context
    return result'

#if ENABLE_OVERLOADING
data ContextGetBaseDirMethodInfo
instance (signature ~ (m Pango.Enums.Direction), MonadIO m, IsContext a) => O.MethodInfo ContextGetBaseDirMethodInfo a signature where
    overloadedMethod _ = contextGetBaseDir

#endif

-- method Context::get_base_gravity
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "context", argType = TInterface (Name {namespace = "Pango", name = "Context"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #PangoContext", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "Pango", name = "Gravity"}))
-- throws : False
-- Skip return : False

foreign import ccall "pango_context_get_base_gravity" pango_context_get_base_gravity ::
    Ptr Context ->                          -- context : TInterface (Name {namespace = "Pango", name = "Context"})
    IO CUInt

{- |
Retrieves the base gravity for the context. See
'GI.Pango.Objects.Context.contextSetBaseGravity'.

/Since: 1.16/
-}
contextGetBaseGravity ::
    (B.CallStack.HasCallStack, MonadIO m, IsContext a) =>
    a
    {- ^ /@context@/: a 'GI.Pango.Objects.Context.Context' -}
    -> m Pango.Enums.Gravity
    {- ^ __Returns:__ the base gravity for the context. -}
contextGetBaseGravity context = liftIO $ do
    context' <- unsafeManagedPtrCastPtr context
    result <- pango_context_get_base_gravity context'
    let result' = (toEnum . fromIntegral) result
    touchManagedPtr context
    return result'

#if ENABLE_OVERLOADING
data ContextGetBaseGravityMethodInfo
instance (signature ~ (m Pango.Enums.Gravity), MonadIO m, IsContext a) => O.MethodInfo ContextGetBaseGravityMethodInfo a signature where
    overloadedMethod _ = contextGetBaseGravity

#endif

-- method Context::get_font_description
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "context", argType = TInterface (Name {namespace = "Pango", name = "Context"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #PangoContext", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "Pango", name = "FontDescription"}))
-- throws : False
-- Skip return : False

foreign import ccall "pango_context_get_font_description" pango_context_get_font_description ::
    Ptr Context ->                          -- context : TInterface (Name {namespace = "Pango", name = "Context"})
    IO (Ptr Pango.FontDescription.FontDescription)

{- |
Retrieve the default font description for the context.
-}
contextGetFontDescription ::
    (B.CallStack.HasCallStack, MonadIO m, IsContext a) =>
    a
    {- ^ /@context@/: a 'GI.Pango.Objects.Context.Context' -}
    -> m Pango.FontDescription.FontDescription
    {- ^ __Returns:__ a pointer to the context\'s default font
              description. This value must not be modified or freed. -}
contextGetFontDescription context = liftIO $ do
    context' <- unsafeManagedPtrCastPtr context
    result <- pango_context_get_font_description context'
    checkUnexpectedReturnNULL "contextGetFontDescription" result
    result' <- (newBoxed Pango.FontDescription.FontDescription) result
    touchManagedPtr context
    return result'

#if ENABLE_OVERLOADING
data ContextGetFontDescriptionMethodInfo
instance (signature ~ (m Pango.FontDescription.FontDescription), MonadIO m, IsContext a) => O.MethodInfo ContextGetFontDescriptionMethodInfo a signature where
    overloadedMethod _ = contextGetFontDescription

#endif

-- method Context::get_font_map
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "context", argType = TInterface (Name {namespace = "Pango", name = "Context"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #PangoContext", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "Pango", name = "FontMap"}))
-- throws : False
-- Skip return : False

foreign import ccall "pango_context_get_font_map" pango_context_get_font_map ::
    Ptr Context ->                          -- context : TInterface (Name {namespace = "Pango", name = "Context"})
    IO (Ptr Pango.FontMap.FontMap)

{- |
Gets the 'GI.Pango.Objects.FontMap.FontMap' used to look up fonts for this context.

/Since: 1.6/
-}
contextGetFontMap ::
    (B.CallStack.HasCallStack, MonadIO m, IsContext a) =>
    a
    {- ^ /@context@/: a 'GI.Pango.Objects.Context.Context' -}
    -> m Pango.FontMap.FontMap
    {- ^ __Returns:__ the font map for the 'GI.Pango.Objects.Context.Context'.
              This value is owned by Pango and should not be unreferenced. -}
contextGetFontMap context = liftIO $ do
    context' <- unsafeManagedPtrCastPtr context
    result <- pango_context_get_font_map context'
    checkUnexpectedReturnNULL "contextGetFontMap" result
    result' <- (newObject Pango.FontMap.FontMap) result
    touchManagedPtr context
    return result'

#if ENABLE_OVERLOADING
data ContextGetFontMapMethodInfo
instance (signature ~ (m Pango.FontMap.FontMap), MonadIO m, IsContext a) => O.MethodInfo ContextGetFontMapMethodInfo a signature where
    overloadedMethod _ = contextGetFontMap

#endif

-- method Context::get_gravity
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "context", argType = TInterface (Name {namespace = "Pango", name = "Context"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #PangoContext", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "Pango", name = "Gravity"}))
-- throws : False
-- Skip return : False

foreign import ccall "pango_context_get_gravity" pango_context_get_gravity ::
    Ptr Context ->                          -- context : TInterface (Name {namespace = "Pango", name = "Context"})
    IO CUInt

{- |
Retrieves the gravity for the context. This is similar to
'GI.Pango.Objects.Context.contextGetBaseGravity', except for when the base gravity
is 'GI.Pango.Enums.GravityAuto' for which 'GI.Pango.Functions.gravityGetForMatrix' is used
to return the gravity from the current context matrix.

/Since: 1.16/
-}
contextGetGravity ::
    (B.CallStack.HasCallStack, MonadIO m, IsContext a) =>
    a
    {- ^ /@context@/: a 'GI.Pango.Objects.Context.Context' -}
    -> m Pango.Enums.Gravity
    {- ^ __Returns:__ the resolved gravity for the context. -}
contextGetGravity context = liftIO $ do
    context' <- unsafeManagedPtrCastPtr context
    result <- pango_context_get_gravity context'
    let result' = (toEnum . fromIntegral) result
    touchManagedPtr context
    return result'

#if ENABLE_OVERLOADING
data ContextGetGravityMethodInfo
instance (signature ~ (m Pango.Enums.Gravity), MonadIO m, IsContext a) => O.MethodInfo ContextGetGravityMethodInfo a signature where
    overloadedMethod _ = contextGetGravity

#endif

-- method Context::get_gravity_hint
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "context", argType = TInterface (Name {namespace = "Pango", name = "Context"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #PangoContext", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "Pango", name = "GravityHint"}))
-- throws : False
-- Skip return : False

foreign import ccall "pango_context_get_gravity_hint" pango_context_get_gravity_hint ::
    Ptr Context ->                          -- context : TInterface (Name {namespace = "Pango", name = "Context"})
    IO CUInt

{- |
Retrieves the gravity hint for the context. See
'GI.Pango.Objects.Context.contextSetGravityHint' for details.

/Since: 1.16/
-}
contextGetGravityHint ::
    (B.CallStack.HasCallStack, MonadIO m, IsContext a) =>
    a
    {- ^ /@context@/: a 'GI.Pango.Objects.Context.Context' -}
    -> m Pango.Enums.GravityHint
    {- ^ __Returns:__ the gravity hint for the context. -}
contextGetGravityHint context = liftIO $ do
    context' <- unsafeManagedPtrCastPtr context
    result <- pango_context_get_gravity_hint context'
    let result' = (toEnum . fromIntegral) result
    touchManagedPtr context
    return result'

#if ENABLE_OVERLOADING
data ContextGetGravityHintMethodInfo
instance (signature ~ (m Pango.Enums.GravityHint), MonadIO m, IsContext a) => O.MethodInfo ContextGetGravityHintMethodInfo a signature where
    overloadedMethod _ = contextGetGravityHint

#endif

-- method Context::get_language
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "context", argType = TInterface (Name {namespace = "Pango", name = "Context"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #PangoContext", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "Pango", name = "Language"}))
-- throws : False
-- Skip return : False

foreign import ccall "pango_context_get_language" pango_context_get_language ::
    Ptr Context ->                          -- context : TInterface (Name {namespace = "Pango", name = "Context"})
    IO (Ptr Pango.Language.Language)

{- |
Retrieves the global language tag for the context.
-}
contextGetLanguage ::
    (B.CallStack.HasCallStack, MonadIO m, IsContext a) =>
    a
    {- ^ /@context@/: a 'GI.Pango.Objects.Context.Context' -}
    -> m Pango.Language.Language
    {- ^ __Returns:__ the global language tag. -}
contextGetLanguage context = liftIO $ do
    context' <- unsafeManagedPtrCastPtr context
    result <- pango_context_get_language context'
    checkUnexpectedReturnNULL "contextGetLanguage" result
    result' <- (wrapBoxed Pango.Language.Language) result
    touchManagedPtr context
    return result'

#if ENABLE_OVERLOADING
data ContextGetLanguageMethodInfo
instance (signature ~ (m Pango.Language.Language), MonadIO m, IsContext a) => O.MethodInfo ContextGetLanguageMethodInfo a signature where
    overloadedMethod _ = contextGetLanguage

#endif

-- method Context::get_matrix
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "context", argType = TInterface (Name {namespace = "Pango", name = "Context"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #PangoContext", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "Pango", name = "Matrix"}))
-- throws : False
-- Skip return : False

foreign import ccall "pango_context_get_matrix" pango_context_get_matrix ::
    Ptr Context ->                          -- context : TInterface (Name {namespace = "Pango", name = "Context"})
    IO (Ptr Pango.Matrix.Matrix)

{- |
Gets the transformation matrix that will be applied when
rendering with this context. See 'GI.Pango.Objects.Context.contextSetMatrix'.

/Since: 1.6/
-}
contextGetMatrix ::
    (B.CallStack.HasCallStack, MonadIO m, IsContext a) =>
    a
    {- ^ /@context@/: a 'GI.Pango.Objects.Context.Context' -}
    -> m (Maybe Pango.Matrix.Matrix)
    {- ^ __Returns:__ the matrix, or 'Nothing' if no matrix has
 been set (which is the same as the identity matrix). The returned
 matrix is owned by Pango and must not be modified or freed. -}
contextGetMatrix context = liftIO $ do
    context' <- unsafeManagedPtrCastPtr context
    result <- pango_context_get_matrix context'
    maybeResult <- convertIfNonNull result $ \result' -> do
        result'' <- (newBoxed Pango.Matrix.Matrix) result'
        return result''
    touchManagedPtr context
    return maybeResult

#if ENABLE_OVERLOADING
data ContextGetMatrixMethodInfo
instance (signature ~ (m (Maybe Pango.Matrix.Matrix)), MonadIO m, IsContext a) => O.MethodInfo ContextGetMatrixMethodInfo a signature where
    overloadedMethod _ = contextGetMatrix

#endif

-- method Context::get_metrics
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "context", argType = TInterface (Name {namespace = "Pango", name = "Context"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #PangoContext", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "desc", argType = TInterface (Name {namespace = "Pango", name = "FontDescription"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "a #PangoFontDescription structure.  %NULL means that the\n           font description from the context will be used.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "language", argType = TInterface (Name {namespace = "Pango", name = "Language"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "language tag used to determine which script to get\n           the metrics for. %NULL means that the language tag from the context\n           will be used. If no language tag is set on the context, metrics\n           for the default language (as determined by pango_language_get_default())\n           will be returned.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "Pango", name = "FontMetrics"}))
-- throws : False
-- Skip return : False

foreign import ccall "pango_context_get_metrics" pango_context_get_metrics ::
    Ptr Context ->                          -- context : TInterface (Name {namespace = "Pango", name = "Context"})
    Ptr Pango.FontDescription.FontDescription -> -- desc : TInterface (Name {namespace = "Pango", name = "FontDescription"})
    Ptr Pango.Language.Language ->          -- language : TInterface (Name {namespace = "Pango", name = "Language"})
    IO (Ptr Pango.FontMetrics.FontMetrics)

{- |
Get overall metric information for a particular font
description.  Since the metrics may be substantially different for
different scripts, a language tag can be provided to indicate that
the metrics should be retrieved that correspond to the script(s)
used by that language.

The 'GI.Pango.Structs.FontDescription.FontDescription' is interpreted in the same way as
by 'GI.Pango.Functions.itemize', and the family name may be a comma separated
list of figures. If characters from multiple of these families
would be used to render the string, then the returned fonts would
be a composite of the metrics for the fonts loaded for the
individual families.
-}
contextGetMetrics ::
    (B.CallStack.HasCallStack, MonadIO m, IsContext a) =>
    a
    {- ^ /@context@/: a 'GI.Pango.Objects.Context.Context' -}
    -> Maybe (Pango.FontDescription.FontDescription)
    {- ^ /@desc@/: a 'GI.Pango.Structs.FontDescription.FontDescription' structure.  'Nothing' means that the
           font description from the context will be used. -}
    -> Maybe (Pango.Language.Language)
    {- ^ /@language@/: language tag used to determine which script to get
           the metrics for. 'Nothing' means that the language tag from the context
           will be used. If no language tag is set on the context, metrics
           for the default language (as determined by 'GI.Pango.Functions.languageGetDefault')
           will be returned. -}
    -> m Pango.FontMetrics.FontMetrics
    {- ^ __Returns:__ a 'GI.Pango.Structs.FontMetrics.FontMetrics' object. The caller must call 'GI.Pango.Structs.FontMetrics.fontMetricsUnref'
  when finished using the object. -}
contextGetMetrics context desc language = liftIO $ do
    context' <- unsafeManagedPtrCastPtr context
    maybeDesc <- case desc of
        Nothing -> return nullPtr
        Just jDesc -> do
            jDesc' <- unsafeManagedPtrGetPtr jDesc
            return jDesc'
    maybeLanguage <- case language of
        Nothing -> return nullPtr
        Just jLanguage -> do
            jLanguage' <- unsafeManagedPtrGetPtr jLanguage
            return jLanguage'
    result <- pango_context_get_metrics context' maybeDesc maybeLanguage
    checkUnexpectedReturnNULL "contextGetMetrics" result
    result' <- (wrapBoxed Pango.FontMetrics.FontMetrics) result
    touchManagedPtr context
    whenJust desc touchManagedPtr
    whenJust language touchManagedPtr
    return result'

#if ENABLE_OVERLOADING
data ContextGetMetricsMethodInfo
instance (signature ~ (Maybe (Pango.FontDescription.FontDescription) -> Maybe (Pango.Language.Language) -> m Pango.FontMetrics.FontMetrics), MonadIO m, IsContext a) => O.MethodInfo ContextGetMetricsMethodInfo a signature where
    overloadedMethod _ = contextGetMetrics

#endif

-- method Context::get_serial
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "context", argType = TInterface (Name {namespace = "Pango", name = "Context"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #PangoContext", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TUInt)
-- throws : False
-- Skip return : False

foreign import ccall "pango_context_get_serial" pango_context_get_serial ::
    Ptr Context ->                          -- context : TInterface (Name {namespace = "Pango", name = "Context"})
    IO Word32

{- |
Returns the current serial number of /@context@/.  The serial number is
initialized to an small number larger than zero when a new context
is created and is increased whenever the context is changed using any
of the setter functions, or the 'GI.Pango.Objects.FontMap.FontMap' it uses to find fonts has
changed. The serial may wrap, but will never have the value 0. Since it
can wrap, never compare it with \"less than\", always use \"not equals\".

This can be used to automatically detect changes to a 'GI.Pango.Objects.Context.Context', and
is only useful when implementing objects that need update when their
'GI.Pango.Objects.Context.Context' changes, like 'GI.Pango.Objects.Layout.Layout'.

/Since: 1.32.4/
-}
contextGetSerial ::
    (B.CallStack.HasCallStack, MonadIO m, IsContext a) =>
    a
    {- ^ /@context@/: a 'GI.Pango.Objects.Context.Context' -}
    -> m Word32
    {- ^ __Returns:__ The current serial number of /@context@/. -}
contextGetSerial context = liftIO $ do
    context' <- unsafeManagedPtrCastPtr context
    result <- pango_context_get_serial context'
    touchManagedPtr context
    return result

#if ENABLE_OVERLOADING
data ContextGetSerialMethodInfo
instance (signature ~ (m Word32), MonadIO m, IsContext a) => O.MethodInfo ContextGetSerialMethodInfo a signature where
    overloadedMethod _ = contextGetSerial

#endif

-- method Context::list_families
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "context", argType = TInterface (Name {namespace = "Pango", name = "Context"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #PangoContext", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "families", argType = TCArray False (-1) 2 (TInterface (Name {namespace = "Pango", name = "FontFamily"})), direction = DirectionOut, mayBeNull = False, argDoc = Documentation {rawDocText = Just "location to store a pointer to\n           an array of #PangoFontFamily *. This array should be freed\n           with g_free().", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferContainer},Arg {argCName = "n_families", argType = TBasicType TInt, direction = DirectionOut, mayBeNull = False, argDoc = Documentation {rawDocText = Just "location to store the number of elements in @descs", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferEverything}]
-- Lengths : [Arg {argCName = "n_families", argType = TBasicType TInt, direction = DirectionOut, mayBeNull = False, argDoc = Documentation {rawDocText = Just "location to store the number of elements in @descs", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferEverything}]
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "pango_context_list_families" pango_context_list_families ::
    Ptr Context ->                          -- context : TInterface (Name {namespace = "Pango", name = "Context"})
    Ptr (Ptr (Ptr Pango.FontFamily.FontFamily)) -> -- families : TCArray False (-1) 2 (TInterface (Name {namespace = "Pango", name = "FontFamily"}))
    Ptr Int32 ->                            -- n_families : TBasicType TInt
    IO ()

{- |
List all families for a context.
-}
contextListFamilies ::
    (B.CallStack.HasCallStack, MonadIO m, IsContext a) =>
    a
    {- ^ /@context@/: a 'GI.Pango.Objects.Context.Context' -}
    -> m ([Pango.FontFamily.FontFamily])
contextListFamilies context = liftIO $ do
    context' <- unsafeManagedPtrCastPtr context
    families <- allocMem :: IO (Ptr (Ptr (Ptr Pango.FontFamily.FontFamily)))
    nFamilies <- allocMem :: IO (Ptr Int32)
    pango_context_list_families context' families nFamilies
    nFamilies' <- peek nFamilies
    families' <- peek families
    families'' <- (unpackPtrArrayWithLength nFamilies') families'
    families''' <- mapM (newObject Pango.FontFamily.FontFamily) families''
    freeMem families'
    touchManagedPtr context
    freeMem families
    freeMem nFamilies
    return families'''

#if ENABLE_OVERLOADING
data ContextListFamiliesMethodInfo
instance (signature ~ (m ([Pango.FontFamily.FontFamily])), MonadIO m, IsContext a) => O.MethodInfo ContextListFamiliesMethodInfo a signature where
    overloadedMethod _ = contextListFamilies

#endif

-- method Context::load_font
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "context", argType = TInterface (Name {namespace = "Pango", name = "Context"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #PangoContext", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "desc", argType = TInterface (Name {namespace = "Pango", name = "FontDescription"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #PangoFontDescription describing the font to load", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "Pango", name = "Font"}))
-- throws : False
-- Skip return : False

foreign import ccall "pango_context_load_font" pango_context_load_font ::
    Ptr Context ->                          -- context : TInterface (Name {namespace = "Pango", name = "Context"})
    Ptr Pango.FontDescription.FontDescription -> -- desc : TInterface (Name {namespace = "Pango", name = "FontDescription"})
    IO (Ptr Pango.Font.Font)

{- |
Loads the font in one of the fontmaps in the context
that is the closest match for /@desc@/.
-}
contextLoadFont ::
    (B.CallStack.HasCallStack, MonadIO m, IsContext a) =>
    a
    {- ^ /@context@/: a 'GI.Pango.Objects.Context.Context' -}
    -> Pango.FontDescription.FontDescription
    {- ^ /@desc@/: a 'GI.Pango.Structs.FontDescription.FontDescription' describing the font to load -}
    -> m (Maybe Pango.Font.Font)
    {- ^ __Returns:__ the newly allocated 'GI.Pango.Objects.Font.Font'
         that was loaded, or 'Nothing' if no font matched. -}
contextLoadFont context desc = liftIO $ do
    context' <- unsafeManagedPtrCastPtr context
    desc' <- unsafeManagedPtrGetPtr desc
    result <- pango_context_load_font context' desc'
    maybeResult <- convertIfNonNull result $ \result' -> do
        result'' <- (wrapObject Pango.Font.Font) result'
        return result''
    touchManagedPtr context
    touchManagedPtr desc
    return maybeResult

#if ENABLE_OVERLOADING
data ContextLoadFontMethodInfo
instance (signature ~ (Pango.FontDescription.FontDescription -> m (Maybe Pango.Font.Font)), MonadIO m, IsContext a) => O.MethodInfo ContextLoadFontMethodInfo a signature where
    overloadedMethod _ = contextLoadFont

#endif

-- method Context::load_fontset
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "context", argType = TInterface (Name {namespace = "Pango", name = "Context"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #PangoContext", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "desc", argType = TInterface (Name {namespace = "Pango", name = "FontDescription"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #PangoFontDescription describing the fonts to load", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "language", argType = TInterface (Name {namespace = "Pango", name = "Language"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #PangoLanguage the fonts will be used for", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "Pango", name = "Fontset"}))
-- throws : False
-- Skip return : False

foreign import ccall "pango_context_load_fontset" pango_context_load_fontset ::
    Ptr Context ->                          -- context : TInterface (Name {namespace = "Pango", name = "Context"})
    Ptr Pango.FontDescription.FontDescription -> -- desc : TInterface (Name {namespace = "Pango", name = "FontDescription"})
    Ptr Pango.Language.Language ->          -- language : TInterface (Name {namespace = "Pango", name = "Language"})
    IO (Ptr Pango.Fontset.Fontset)

{- |
Load a set of fonts in the context that can be used to render
a font matching /@desc@/.
-}
contextLoadFontset ::
    (B.CallStack.HasCallStack, MonadIO m, IsContext a) =>
    a
    {- ^ /@context@/: a 'GI.Pango.Objects.Context.Context' -}
    -> Pango.FontDescription.FontDescription
    {- ^ /@desc@/: a 'GI.Pango.Structs.FontDescription.FontDescription' describing the fonts to load -}
    -> Pango.Language.Language
    {- ^ /@language@/: a 'GI.Pango.Structs.Language.Language' the fonts will be used for -}
    -> m (Maybe Pango.Fontset.Fontset)
    {- ^ __Returns:__ the newly allocated
         'GI.Pango.Objects.Fontset.Fontset' loaded, or 'Nothing' if no font matched. -}
contextLoadFontset context desc language = liftIO $ do
    context' <- unsafeManagedPtrCastPtr context
    desc' <- unsafeManagedPtrGetPtr desc
    language' <- unsafeManagedPtrGetPtr language
    result <- pango_context_load_fontset context' desc' language'
    maybeResult <- convertIfNonNull result $ \result' -> do
        result'' <- (wrapObject Pango.Fontset.Fontset) result'
        return result''
    touchManagedPtr context
    touchManagedPtr desc
    touchManagedPtr language
    return maybeResult

#if ENABLE_OVERLOADING
data ContextLoadFontsetMethodInfo
instance (signature ~ (Pango.FontDescription.FontDescription -> Pango.Language.Language -> m (Maybe Pango.Fontset.Fontset)), MonadIO m, IsContext a) => O.MethodInfo ContextLoadFontsetMethodInfo a signature where
    overloadedMethod _ = contextLoadFontset

#endif

-- method Context::set_base_dir
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "context", argType = TInterface (Name {namespace = "Pango", name = "Context"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #PangoContext", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "direction", argType = TInterface (Name {namespace = "Pango", name = "Direction"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the new base direction", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "pango_context_set_base_dir" pango_context_set_base_dir ::
    Ptr Context ->                          -- context : TInterface (Name {namespace = "Pango", name = "Context"})
    CUInt ->                                -- direction : TInterface (Name {namespace = "Pango", name = "Direction"})
    IO ()

{- |
Sets the base direction for the context.

The base direction is used in applying the Unicode bidirectional
algorithm; if the /@direction@/ is 'GI.Pango.Enums.DirectionLtr' or
'GI.Pango.Enums.DirectionRtl', then the value will be used as the paragraph
direction in the Unicode bidirectional algorithm.  A value of
'GI.Pango.Enums.DirectionWeakLtr' or 'GI.Pango.Enums.DirectionWeakRtl' is used only
for paragraphs that do not contain any strong characters themselves.
-}
contextSetBaseDir ::
    (B.CallStack.HasCallStack, MonadIO m, IsContext a) =>
    a
    {- ^ /@context@/: a 'GI.Pango.Objects.Context.Context' -}
    -> Pango.Enums.Direction
    {- ^ /@direction@/: the new base direction -}
    -> m ()
contextSetBaseDir context direction = liftIO $ do
    context' <- unsafeManagedPtrCastPtr context
    let direction' = (fromIntegral . fromEnum) direction
    pango_context_set_base_dir context' direction'
    touchManagedPtr context
    return ()

#if ENABLE_OVERLOADING
data ContextSetBaseDirMethodInfo
instance (signature ~ (Pango.Enums.Direction -> m ()), MonadIO m, IsContext a) => O.MethodInfo ContextSetBaseDirMethodInfo a signature where
    overloadedMethod _ = contextSetBaseDir

#endif

-- method Context::set_base_gravity
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "context", argType = TInterface (Name {namespace = "Pango", name = "Context"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #PangoContext", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "gravity", argType = TInterface (Name {namespace = "Pango", name = "Gravity"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the new base gravity", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "pango_context_set_base_gravity" pango_context_set_base_gravity ::
    Ptr Context ->                          -- context : TInterface (Name {namespace = "Pango", name = "Context"})
    CUInt ->                                -- gravity : TInterface (Name {namespace = "Pango", name = "Gravity"})
    IO ()

{- |
Sets the base gravity for the context.

The base gravity is used in laying vertical text out.

/Since: 1.16/
-}
contextSetBaseGravity ::
    (B.CallStack.HasCallStack, MonadIO m, IsContext a) =>
    a
    {- ^ /@context@/: a 'GI.Pango.Objects.Context.Context' -}
    -> Pango.Enums.Gravity
    {- ^ /@gravity@/: the new base gravity -}
    -> m ()
contextSetBaseGravity context gravity = liftIO $ do
    context' <- unsafeManagedPtrCastPtr context
    let gravity' = (fromIntegral . fromEnum) gravity
    pango_context_set_base_gravity context' gravity'
    touchManagedPtr context
    return ()

#if ENABLE_OVERLOADING
data ContextSetBaseGravityMethodInfo
instance (signature ~ (Pango.Enums.Gravity -> m ()), MonadIO m, IsContext a) => O.MethodInfo ContextSetBaseGravityMethodInfo a signature where
    overloadedMethod _ = contextSetBaseGravity

#endif

-- method Context::set_font_description
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "context", argType = TInterface (Name {namespace = "Pango", name = "Context"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #PangoContext", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "desc", argType = TInterface (Name {namespace = "Pango", name = "FontDescription"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the new pango font description", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "pango_context_set_font_description" pango_context_set_font_description ::
    Ptr Context ->                          -- context : TInterface (Name {namespace = "Pango", name = "Context"})
    Ptr Pango.FontDescription.FontDescription -> -- desc : TInterface (Name {namespace = "Pango", name = "FontDescription"})
    IO ()

{- |
Set the default font description for the context
-}
contextSetFontDescription ::
    (B.CallStack.HasCallStack, MonadIO m, IsContext a) =>
    a
    {- ^ /@context@/: a 'GI.Pango.Objects.Context.Context' -}
    -> Pango.FontDescription.FontDescription
    {- ^ /@desc@/: the new pango font description -}
    -> m ()
contextSetFontDescription context desc = liftIO $ do
    context' <- unsafeManagedPtrCastPtr context
    desc' <- unsafeManagedPtrGetPtr desc
    pango_context_set_font_description context' desc'
    touchManagedPtr context
    touchManagedPtr desc
    return ()

#if ENABLE_OVERLOADING
data ContextSetFontDescriptionMethodInfo
instance (signature ~ (Pango.FontDescription.FontDescription -> m ()), MonadIO m, IsContext a) => O.MethodInfo ContextSetFontDescriptionMethodInfo a signature where
    overloadedMethod _ = contextSetFontDescription

#endif

-- method Context::set_font_map
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "context", argType = TInterface (Name {namespace = "Pango", name = "Context"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #PangoContext", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "font_map", argType = TInterface (Name {namespace = "Pango", name = "FontMap"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the #PangoFontMap to set.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "pango_context_set_font_map" pango_context_set_font_map ::
    Ptr Context ->                          -- context : TInterface (Name {namespace = "Pango", name = "Context"})
    Ptr Pango.FontMap.FontMap ->            -- font_map : TInterface (Name {namespace = "Pango", name = "FontMap"})
    IO ()

{- |
Sets the font map to be searched when fonts are looked-up in this context.
This is only for internal use by Pango backends, a 'GI.Pango.Objects.Context.Context' obtained
via one of the recommended methods should already have a suitable font map.
-}
contextSetFontMap ::
    (B.CallStack.HasCallStack, MonadIO m, IsContext a, Pango.FontMap.IsFontMap b) =>
    a
    {- ^ /@context@/: a 'GI.Pango.Objects.Context.Context' -}
    -> b
    {- ^ /@fontMap@/: the 'GI.Pango.Objects.FontMap.FontMap' to set. -}
    -> m ()
contextSetFontMap context fontMap = liftIO $ do
    context' <- unsafeManagedPtrCastPtr context
    fontMap' <- unsafeManagedPtrCastPtr fontMap
    pango_context_set_font_map context' fontMap'
    touchManagedPtr context
    touchManagedPtr fontMap
    return ()

#if ENABLE_OVERLOADING
data ContextSetFontMapMethodInfo
instance (signature ~ (b -> m ()), MonadIO m, IsContext a, Pango.FontMap.IsFontMap b) => O.MethodInfo ContextSetFontMapMethodInfo a signature where
    overloadedMethod _ = contextSetFontMap

#endif

-- method Context::set_gravity_hint
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "context", argType = TInterface (Name {namespace = "Pango", name = "Context"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #PangoContext", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "hint", argType = TInterface (Name {namespace = "Pango", name = "GravityHint"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the new gravity hint", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "pango_context_set_gravity_hint" pango_context_set_gravity_hint ::
    Ptr Context ->                          -- context : TInterface (Name {namespace = "Pango", name = "Context"})
    CUInt ->                                -- hint : TInterface (Name {namespace = "Pango", name = "GravityHint"})
    IO ()

{- |
Sets the gravity hint for the context.

The gravity hint is used in laying vertical text out, and is only relevant
if gravity of the context as returned by 'GI.Pango.Objects.Context.contextGetGravity'
is set 'GI.Pango.Enums.GravityEast' or 'GI.Pango.Enums.GravityWest'.

/Since: 1.16/
-}
contextSetGravityHint ::
    (B.CallStack.HasCallStack, MonadIO m, IsContext a) =>
    a
    {- ^ /@context@/: a 'GI.Pango.Objects.Context.Context' -}
    -> Pango.Enums.GravityHint
    {- ^ /@hint@/: the new gravity hint -}
    -> m ()
contextSetGravityHint context hint = liftIO $ do
    context' <- unsafeManagedPtrCastPtr context
    let hint' = (fromIntegral . fromEnum) hint
    pango_context_set_gravity_hint context' hint'
    touchManagedPtr context
    return ()

#if ENABLE_OVERLOADING
data ContextSetGravityHintMethodInfo
instance (signature ~ (Pango.Enums.GravityHint -> m ()), MonadIO m, IsContext a) => O.MethodInfo ContextSetGravityHintMethodInfo a signature where
    overloadedMethod _ = contextSetGravityHint

#endif

-- method Context::set_language
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "context", argType = TInterface (Name {namespace = "Pango", name = "Context"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #PangoContext", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "language", argType = TInterface (Name {namespace = "Pango", name = "Language"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the new language tag.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "pango_context_set_language" pango_context_set_language ::
    Ptr Context ->                          -- context : TInterface (Name {namespace = "Pango", name = "Context"})
    Ptr Pango.Language.Language ->          -- language : TInterface (Name {namespace = "Pango", name = "Language"})
    IO ()

{- |
Sets the global language tag for the context.  The default language
for the locale of the running process can be found using
'GI.Pango.Functions.languageGetDefault'.
-}
contextSetLanguage ::
    (B.CallStack.HasCallStack, MonadIO m, IsContext a) =>
    a
    {- ^ /@context@/: a 'GI.Pango.Objects.Context.Context' -}
    -> Pango.Language.Language
    {- ^ /@language@/: the new language tag. -}
    -> m ()
contextSetLanguage context language = liftIO $ do
    context' <- unsafeManagedPtrCastPtr context
    language' <- unsafeManagedPtrGetPtr language
    pango_context_set_language context' language'
    touchManagedPtr context
    touchManagedPtr language
    return ()

#if ENABLE_OVERLOADING
data ContextSetLanguageMethodInfo
instance (signature ~ (Pango.Language.Language -> m ()), MonadIO m, IsContext a) => O.MethodInfo ContextSetLanguageMethodInfo a signature where
    overloadedMethod _ = contextSetLanguage

#endif

-- method Context::set_matrix
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "context", argType = TInterface (Name {namespace = "Pango", name = "Context"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #PangoContext", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "matrix", argType = TInterface (Name {namespace = "Pango", name = "Matrix"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "a #PangoMatrix, or %NULL to unset any existing\nmatrix. (No matrix set is the same as setting the identity matrix.)", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "pango_context_set_matrix" pango_context_set_matrix ::
    Ptr Context ->                          -- context : TInterface (Name {namespace = "Pango", name = "Context"})
    Ptr Pango.Matrix.Matrix ->              -- matrix : TInterface (Name {namespace = "Pango", name = "Matrix"})
    IO ()

{- |
Sets the transformation matrix that will be applied when rendering
with this context. Note that reported metrics are in the user space
coordinates before the application of the matrix, not device-space
coordinates after the application of the matrix. So, they don\'t scale
with the matrix, though they may change slightly for different
matrices, depending on how the text is fit to the pixel grid.

/Since: 1.6/
-}
contextSetMatrix ::
    (B.CallStack.HasCallStack, MonadIO m, IsContext a) =>
    a
    {- ^ /@context@/: a 'GI.Pango.Objects.Context.Context' -}
    -> Maybe (Pango.Matrix.Matrix)
    {- ^ /@matrix@/: a 'GI.Pango.Structs.Matrix.Matrix', or 'Nothing' to unset any existing
matrix. (No matrix set is the same as setting the identity matrix.) -}
    -> m ()
contextSetMatrix context matrix = liftIO $ do
    context' <- unsafeManagedPtrCastPtr context
    maybeMatrix <- case matrix of
        Nothing -> return nullPtr
        Just jMatrix -> do
            jMatrix' <- unsafeManagedPtrGetPtr jMatrix
            return jMatrix'
    pango_context_set_matrix context' maybeMatrix
    touchManagedPtr context
    whenJust matrix touchManagedPtr
    return ()

#if ENABLE_OVERLOADING
data ContextSetMatrixMethodInfo
instance (signature ~ (Maybe (Pango.Matrix.Matrix) -> m ()), MonadIO m, IsContext a) => O.MethodInfo ContextSetMatrixMethodInfo a signature where
    overloadedMethod _ = contextSetMatrix

#endif