{-# LANGUAGE TypeApplications #-}


-- | Copyright  : Will Thompson and Iñaki García Etxebarria
-- License    : LGPL-2.1
-- Maintainer : Iñaki García Etxebarria
-- 
-- @PangoCairoFont@ is an interface exported by fonts for
-- use with Cairo.
-- 
-- The actual type of the font will depend on the particular
-- font technology Cairo was compiled to use.
-- 
-- /Since: 1.18/

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

module GI.PangoCairo.Interfaces.Font
    ( 

-- * Exported types
    Font(..)                                ,
    IsFont                                  ,
    toFont                                  ,


 -- * Methods
-- | 
-- 
--  === __Click to display all available methods, including inherited ones__
-- ==== Methods
-- [bindProperty]("GI.GObject.Objects.Object#g:method:bindProperty"), [bindPropertyFull]("GI.GObject.Objects.Object#g:method:bindPropertyFull"), [describe]("GI.Pango.Objects.Font#g:method:describe"), [describeWithAbsoluteSize]("GI.Pango.Objects.Font#g:method:describeWithAbsoluteSize"), [forceFloating]("GI.GObject.Objects.Object#g:method:forceFloating"), [freezeNotify]("GI.GObject.Objects.Object#g:method:freezeNotify"), [getv]("GI.GObject.Objects.Object#g:method:getv"), [hasChar]("GI.Pango.Objects.Font#g:method:hasChar"), [isFloating]("GI.GObject.Objects.Object#g:method:isFloating"), [notify]("GI.GObject.Objects.Object#g:method:notify"), [notifyByPspec]("GI.GObject.Objects.Object#g:method:notifyByPspec"), [ref]("GI.GObject.Objects.Object#g:method:ref"), [refSink]("GI.GObject.Objects.Object#g:method:refSink"), [runDispose]("GI.GObject.Objects.Object#g:method:runDispose"), [serialize]("GI.Pango.Objects.Font#g:method:serialize"), [stealData]("GI.GObject.Objects.Object#g:method:stealData"), [stealQdata]("GI.GObject.Objects.Object#g:method:stealQdata"), [thawNotify]("GI.GObject.Objects.Object#g:method:thawNotify"), [unref]("GI.GObject.Objects.Object#g:method:unref"), [watchClosure]("GI.GObject.Objects.Object#g:method:watchClosure").
-- 
-- ==== Getters
-- [getCoverage]("GI.Pango.Objects.Font#g:method:getCoverage"), [getData]("GI.GObject.Objects.Object#g:method:getData"), [getFace]("GI.Pango.Objects.Font#g:method:getFace"), [getFeatures]("GI.Pango.Objects.Font#g:method:getFeatures"), [getFontMap]("GI.Pango.Objects.Font#g:method:getFontMap"), [getGlyphExtents]("GI.Pango.Objects.Font#g:method:getGlyphExtents"), [getLanguages]("GI.Pango.Objects.Font#g:method:getLanguages"), [getMetrics]("GI.Pango.Objects.Font#g:method:getMetrics"), [getProperty]("GI.GObject.Objects.Object#g:method:getProperty"), [getQdata]("GI.GObject.Objects.Object#g:method:getQdata"), [getScaledFont]("GI.PangoCairo.Interfaces.Font#g:method:getScaledFont").
-- 
-- ==== Setters
-- [setData]("GI.GObject.Objects.Object#g:method:setData"), [setDataFull]("GI.GObject.Objects.Object#g:method:setDataFull"), [setProperty]("GI.GObject.Objects.Object#g:method:setProperty").

#if defined(ENABLE_OVERLOADING)
    ResolveFontMethod                       ,
#endif

-- ** getScaledFont #method:getScaledFont#

#if defined(ENABLE_OVERLOADING)
    FontGetScaledFontMethodInfo             ,
#endif
    fontGetScaledFont                       ,




    ) 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.GHashTable as B.GHT
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 qualified GI.Cairo.Structs.ScaledFont as Cairo.ScaledFont
import qualified GI.GObject.Objects.Object as GObject.Object
import qualified GI.Pango.Objects.Font as Pango.Font

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

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

foreign import ccall "pango_cairo_font_get_type"
    c_pango_cairo_font_get_type :: IO B.Types.GType

instance B.Types.TypedObject Font where
    glibType :: IO GType
glibType = IO GType
c_pango_cairo_font_get_type

instance B.Types.GObject Font

-- | Type class for types which can be safely cast to `Font`, for instance with `toFont`.
class (SP.GObject o, O.IsDescendantOf Font o) => IsFont o
instance (SP.GObject o, O.IsDescendantOf Font o) => IsFont o

instance O.HasParentTypes Font
type instance O.ParentTypes Font = '[Pango.Font.Font, GObject.Object.Object]

-- | Cast to `Font`, for types for which this is known to be safe. For general casts, use `Data.GI.Base.ManagedPtr.castTo`.
toFont :: (MIO.MonadIO m, IsFont o) => o -> m Font
toFont :: forall (m :: * -> *) o. (MonadIO m, IsFont o) => o -> m Font
toFont = IO Font -> m Font
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
MIO.liftIO (IO Font -> m Font) -> (o -> IO Font) -> o -> m Font
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (ManagedPtr Font -> Font) -> o -> IO Font
forall o o'.
(HasCallStack, ManagedPtrNewtype o, TypedObject o,
 ManagedPtrNewtype o', TypedObject o') =>
(ManagedPtr o' -> o') -> o -> IO o'
B.ManagedPtr.unsafeCastTo ManagedPtr Font -> Font
Font

-- | Convert 'Font' to and from 'Data.GI.Base.GValue.GValue'. See 'Data.GI.Base.GValue.toGValue' and 'Data.GI.Base.GValue.fromGValue'.
instance B.GValue.IsGValue (Maybe Font) where
    gvalueGType_ :: IO GType
gvalueGType_ = IO GType
c_pango_cairo_font_get_type
    gvalueSet_ :: Ptr GValue -> Maybe Font -> IO ()
gvalueSet_ Ptr GValue
gv Maybe Font
P.Nothing = Ptr GValue -> Ptr Font -> IO ()
forall a. GObject a => Ptr GValue -> Ptr a -> IO ()
B.GValue.set_object Ptr GValue
gv (Ptr Font
forall a. Ptr a
FP.nullPtr :: FP.Ptr Font)
    gvalueSet_ Ptr GValue
gv (P.Just Font
obj) = Font -> (Ptr Font -> IO ()) -> IO ()
forall a c.
(HasCallStack, ManagedPtrNewtype a) =>
a -> (Ptr a -> IO c) -> IO c
B.ManagedPtr.withManagedPtr Font
obj (Ptr GValue -> Ptr Font -> IO ()
forall a. GObject a => Ptr GValue -> Ptr a -> IO ()
B.GValue.set_object Ptr GValue
gv)
    gvalueGet_ :: Ptr GValue -> IO (Maybe Font)
gvalueGet_ Ptr GValue
gv = do
        Ptr Font
ptr <- Ptr GValue -> IO (Ptr Font)
forall a. GObject a => Ptr GValue -> IO (Ptr a)
B.GValue.get_object Ptr GValue
gv :: IO (FP.Ptr Font)
        if Ptr Font
ptr Ptr Font -> Ptr Font -> Bool
forall a. Eq a => a -> a -> Bool
/= Ptr Font
forall a. Ptr a
FP.nullPtr
        then Font -> Maybe Font
forall a. a -> Maybe a
P.Just (Font -> Maybe Font) -> IO Font -> IO (Maybe Font)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (ManagedPtr Font -> Font) -> Ptr Font -> IO Font
forall a b.
(HasCallStack, GObject a, GObject b) =>
(ManagedPtr a -> a) -> Ptr b -> IO a
B.ManagedPtr.newObject ManagedPtr Font -> Font
Font Ptr Font
ptr
        else Maybe Font -> IO (Maybe Font)
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return Maybe Font
forall a. Maybe a
P.Nothing
        
    

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

#if defined(ENABLE_OVERLOADING)
#endif

#if defined(ENABLE_OVERLOADING)
type family ResolveFontMethod (t :: Symbol) (o :: *) :: * where
    ResolveFontMethod "bindProperty" o = GObject.Object.ObjectBindPropertyMethodInfo
    ResolveFontMethod "bindPropertyFull" o = GObject.Object.ObjectBindPropertyFullMethodInfo
    ResolveFontMethod "describe" o = Pango.Font.FontDescribeMethodInfo
    ResolveFontMethod "describeWithAbsoluteSize" o = Pango.Font.FontDescribeWithAbsoluteSizeMethodInfo
    ResolveFontMethod "forceFloating" o = GObject.Object.ObjectForceFloatingMethodInfo
    ResolveFontMethod "freezeNotify" o = GObject.Object.ObjectFreezeNotifyMethodInfo
    ResolveFontMethod "getv" o = GObject.Object.ObjectGetvMethodInfo
    ResolveFontMethod "hasChar" o = Pango.Font.FontHasCharMethodInfo
    ResolveFontMethod "isFloating" o = GObject.Object.ObjectIsFloatingMethodInfo
    ResolveFontMethod "notify" o = GObject.Object.ObjectNotifyMethodInfo
    ResolveFontMethod "notifyByPspec" o = GObject.Object.ObjectNotifyByPspecMethodInfo
    ResolveFontMethod "ref" o = GObject.Object.ObjectRefMethodInfo
    ResolveFontMethod "refSink" o = GObject.Object.ObjectRefSinkMethodInfo
    ResolveFontMethod "runDispose" o = GObject.Object.ObjectRunDisposeMethodInfo
    ResolveFontMethod "serialize" o = Pango.Font.FontSerializeMethodInfo
    ResolveFontMethod "stealData" o = GObject.Object.ObjectStealDataMethodInfo
    ResolveFontMethod "stealQdata" o = GObject.Object.ObjectStealQdataMethodInfo
    ResolveFontMethod "thawNotify" o = GObject.Object.ObjectThawNotifyMethodInfo
    ResolveFontMethod "unref" o = GObject.Object.ObjectUnrefMethodInfo
    ResolveFontMethod "watchClosure" o = GObject.Object.ObjectWatchClosureMethodInfo
    ResolveFontMethod "getCoverage" o = Pango.Font.FontGetCoverageMethodInfo
    ResolveFontMethod "getData" o = GObject.Object.ObjectGetDataMethodInfo
    ResolveFontMethod "getFace" o = Pango.Font.FontGetFaceMethodInfo
    ResolveFontMethod "getFeatures" o = Pango.Font.FontGetFeaturesMethodInfo
    ResolveFontMethod "getFontMap" o = Pango.Font.FontGetFontMapMethodInfo
    ResolveFontMethod "getGlyphExtents" o = Pango.Font.FontGetGlyphExtentsMethodInfo
    ResolveFontMethod "getLanguages" o = Pango.Font.FontGetLanguagesMethodInfo
    ResolveFontMethod "getMetrics" o = Pango.Font.FontGetMetricsMethodInfo
    ResolveFontMethod "getProperty" o = GObject.Object.ObjectGetPropertyMethodInfo
    ResolveFontMethod "getQdata" o = GObject.Object.ObjectGetQdataMethodInfo
    ResolveFontMethod "getScaledFont" o = FontGetScaledFontMethodInfo
    ResolveFontMethod "setData" o = GObject.Object.ObjectSetDataMethodInfo
    ResolveFontMethod "setDataFull" o = GObject.Object.ObjectSetDataFullMethodInfo
    ResolveFontMethod "setProperty" o = GObject.Object.ObjectSetPropertyMethodInfo
    ResolveFontMethod l o = O.MethodResolutionFailed l o

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

#endif

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

#endif

-- method Font::get_scaled_font
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "font"
--           , argType =
--               TInterface Name { namespace = "PangoCairo" , name = "Font" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a `PangoFont` from a `PangoCairoFontMap`"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just
--               (TInterface Name { namespace = "cairo" , name = "ScaledFont" })
-- throws : False
-- Skip return : False

foreign import ccall "pango_cairo_font_get_scaled_font" pango_cairo_font_get_scaled_font :: 
    Ptr Font ->                             -- font : TInterface (Name {namespace = "PangoCairo", name = "Font"})
    IO (Ptr Cairo.ScaledFont.ScaledFont)

-- | Gets the @cairo_scaled_font_t@ used by /@font@/.
-- The scaled font can be referenced and kept using
-- @/cairo_scaled_font_reference()/@.
-- 
-- /Since: 1.18/
fontGetScaledFont ::
    (B.CallStack.HasCallStack, MonadIO m, IsFont a) =>
    a
    -- ^ /@font@/: a @PangoFont@ from a @PangoCairoFontMap@
    -> m (Maybe Cairo.ScaledFont.ScaledFont)
    -- ^ __Returns:__ the @cairo_scaled_font_t@
    --   used by /@font@/
fontGetScaledFont :: forall (m :: * -> *) a.
(HasCallStack, MonadIO m, IsFont a) =>
a -> m (Maybe ScaledFont)
fontGetScaledFont a
font = IO (Maybe ScaledFont) -> m (Maybe ScaledFont)
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (Maybe ScaledFont) -> m (Maybe ScaledFont))
-> IO (Maybe ScaledFont) -> m (Maybe ScaledFont)
forall a b. (a -> b) -> a -> b
$ do
    Ptr Font
font' <- a -> IO (Ptr Font)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
font
    Ptr ScaledFont
result <- Ptr Font -> IO (Ptr ScaledFont)
pango_cairo_font_get_scaled_font Ptr Font
font'
    Maybe ScaledFont
maybeResult <- Ptr ScaledFont
-> (Ptr ScaledFont -> IO ScaledFont) -> IO (Maybe ScaledFont)
forall a b. Ptr a -> (Ptr a -> IO b) -> IO (Maybe b)
convertIfNonNull Ptr ScaledFont
result ((Ptr ScaledFont -> IO ScaledFont) -> IO (Maybe ScaledFont))
-> (Ptr ScaledFont -> IO ScaledFont) -> IO (Maybe ScaledFont)
forall a b. (a -> b) -> a -> b
$ \Ptr ScaledFont
result' -> do
        ScaledFont
result'' <- ((ManagedPtr ScaledFont -> ScaledFont)
-> Ptr ScaledFont -> IO ScaledFont
forall a.
(HasCallStack, GBoxed a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
newBoxed ManagedPtr ScaledFont -> ScaledFont
Cairo.ScaledFont.ScaledFont) Ptr ScaledFont
result'
        ScaledFont -> IO ScaledFont
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return ScaledFont
result''
    a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
font
    Maybe ScaledFont -> IO (Maybe ScaledFont)
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return Maybe ScaledFont
maybeResult

#if defined(ENABLE_OVERLOADING)
data FontGetScaledFontMethodInfo
instance (signature ~ (m (Maybe Cairo.ScaledFont.ScaledFont)), MonadIO m, IsFont a) => O.OverloadedMethod FontGetScaledFontMethodInfo a signature where
    overloadedMethod = fontGetScaledFont

instance O.OverloadedMethodInfo FontGetScaledFontMethodInfo a where
    overloadedMethodInfo = P.Just (O.ResolvedSymbolInfo {
        O.resolvedSymbolName = "GI.PangoCairo.Interfaces.Font.fontGetScaledFont",
        O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-pangocairo-1.0.28/docs/GI-PangoCairo-Interfaces-Font.html#v:fontGetScaledFont"
        })


#endif

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

#endif