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

'GI.Pango.Objects.FontsetSimple.FontsetSimple' is a implementation of the abstract
'GI.Pango.Objects.Fontset.Fontset' base class in terms of an array of fonts,
which the creator provides when constructing the
'GI.Pango.Objects.FontsetSimple.FontsetSimple'.
-}

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

module GI.Pango.Objects.FontsetSimple
    (

-- * Exported types
    FontsetSimple(..)                       ,
    IsFontsetSimple                         ,
    toFontsetSimple                         ,
    noFontsetSimple                         ,


 -- * Methods
-- ** append #method:append#

#if ENABLE_OVERLOADING
    FontsetSimpleAppendMethodInfo           ,
#endif
    fontsetSimpleAppend                     ,


-- ** new #method:new#

    fontsetSimpleNew                        ,


-- ** size #method:size#

#if ENABLE_OVERLOADING
    FontsetSimpleSizeMethodInfo             ,
#endif
    fontsetSimpleSize                       ,




    ) 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.Objects.Font as Pango.Font
import {-# SOURCE #-} qualified GI.Pango.Objects.Fontset as Pango.Fontset
import {-# SOURCE #-} qualified GI.Pango.Structs.Language as Pango.Language

-- | Memory-managed wrapper type.
newtype FontsetSimple = FontsetSimple (ManagedPtr FontsetSimple)
foreign import ccall "pango_fontset_simple_get_type"
    c_pango_fontset_simple_get_type :: IO GType

instance GObject FontsetSimple where
    gobjectType _ = c_pango_fontset_simple_get_type


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

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

-- | A convenience alias for `Nothing` :: `Maybe` `FontsetSimple`.
noFontsetSimple :: Maybe FontsetSimple
noFontsetSimple = Nothing

#if ENABLE_OVERLOADING
type family ResolveFontsetSimpleMethod (t :: Symbol) (o :: *) :: * where
    ResolveFontsetSimpleMethod "append" o = FontsetSimpleAppendMethodInfo
    ResolveFontsetSimpleMethod "bindProperty" o = GObject.Object.ObjectBindPropertyMethodInfo
    ResolveFontsetSimpleMethod "bindPropertyFull" o = GObject.Object.ObjectBindPropertyFullMethodInfo
    ResolveFontsetSimpleMethod "forceFloating" o = GObject.Object.ObjectForceFloatingMethodInfo
    ResolveFontsetSimpleMethod "foreach" o = Pango.Fontset.FontsetForeachMethodInfo
    ResolveFontsetSimpleMethod "freezeNotify" o = GObject.Object.ObjectFreezeNotifyMethodInfo
    ResolveFontsetSimpleMethod "getv" o = GObject.Object.ObjectGetvMethodInfo
    ResolveFontsetSimpleMethod "isFloating" o = GObject.Object.ObjectIsFloatingMethodInfo
    ResolveFontsetSimpleMethod "notify" o = GObject.Object.ObjectNotifyMethodInfo
    ResolveFontsetSimpleMethod "notifyByPspec" o = GObject.Object.ObjectNotifyByPspecMethodInfo
    ResolveFontsetSimpleMethod "ref" o = GObject.Object.ObjectRefMethodInfo
    ResolveFontsetSimpleMethod "refSink" o = GObject.Object.ObjectRefSinkMethodInfo
    ResolveFontsetSimpleMethod "runDispose" o = GObject.Object.ObjectRunDisposeMethodInfo
    ResolveFontsetSimpleMethod "size" o = FontsetSimpleSizeMethodInfo
    ResolveFontsetSimpleMethod "stealData" o = GObject.Object.ObjectStealDataMethodInfo
    ResolveFontsetSimpleMethod "stealQdata" o = GObject.Object.ObjectStealQdataMethodInfo
    ResolveFontsetSimpleMethod "thawNotify" o = GObject.Object.ObjectThawNotifyMethodInfo
    ResolveFontsetSimpleMethod "unref" o = GObject.Object.ObjectUnrefMethodInfo
    ResolveFontsetSimpleMethod "watchClosure" o = GObject.Object.ObjectWatchClosureMethodInfo
    ResolveFontsetSimpleMethod "getData" o = GObject.Object.ObjectGetDataMethodInfo
    ResolveFontsetSimpleMethod "getFont" o = Pango.Fontset.FontsetGetFontMethodInfo
    ResolveFontsetSimpleMethod "getMetrics" o = Pango.Fontset.FontsetGetMetricsMethodInfo
    ResolveFontsetSimpleMethod "getProperty" o = GObject.Object.ObjectGetPropertyMethodInfo
    ResolveFontsetSimpleMethod "getQdata" o = GObject.Object.ObjectGetQdataMethodInfo
    ResolveFontsetSimpleMethod "setData" o = GObject.Object.ObjectSetDataMethodInfo
    ResolveFontsetSimpleMethod "setProperty" o = GObject.Object.ObjectSetPropertyMethodInfo
    ResolveFontsetSimpleMethod l o = O.MethodResolutionFailed l o

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

#if MIN_VERSION_base(4,9,0)
instance (info ~ ResolveFontsetSimpleMethod t FontsetSimple, O.MethodInfo info FontsetSimple p) => O.IsLabel t (FontsetSimple -> 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 FontsetSimple
type instance O.AttributeList FontsetSimple = FontsetSimpleAttributeList
type FontsetSimpleAttributeList = ('[ ] :: [(Symbol, *)])
#endif

#if ENABLE_OVERLOADING
#endif

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

#endif

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

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

{- |
Creates a new 'GI.Pango.Objects.FontsetSimple.FontsetSimple' for the given language.
-}
fontsetSimpleNew ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Pango.Language.Language
    {- ^ /@language@/: a 'GI.Pango.Structs.Language.Language' tag -}
    -> m FontsetSimple
    {- ^ __Returns:__ the newly allocated 'GI.Pango.Objects.FontsetSimple.FontsetSimple', which should
              be freed with 'GI.GObject.Objects.Object.objectUnref'. -}
fontsetSimpleNew language = liftIO $ do
    language' <- unsafeManagedPtrGetPtr language
    result <- pango_fontset_simple_new language'
    checkUnexpectedReturnNULL "fontsetSimpleNew" result
    result' <- (wrapObject FontsetSimple) result
    touchManagedPtr language
    return result'

#if ENABLE_OVERLOADING
#endif

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

foreign import ccall "pango_fontset_simple_append" pango_fontset_simple_append ::
    Ptr FontsetSimple ->                    -- fontset : TInterface (Name {namespace = "Pango", name = "FontsetSimple"})
    Ptr Pango.Font.Font ->                  -- font : TInterface (Name {namespace = "Pango", name = "Font"})
    IO ()

{- |
Adds a font to the fontset.
-}
fontsetSimpleAppend ::
    (B.CallStack.HasCallStack, MonadIO m, IsFontsetSimple a, Pango.Font.IsFont b) =>
    a
    {- ^ /@fontset@/: a 'GI.Pango.Objects.FontsetSimple.FontsetSimple'. -}
    -> b
    {- ^ /@font@/: a 'GI.Pango.Objects.Font.Font'. -}
    -> m ()
fontsetSimpleAppend fontset font = liftIO $ do
    fontset' <- unsafeManagedPtrCastPtr fontset
    font' <- unsafeManagedPtrCastPtr font
    pango_fontset_simple_append fontset' font'
    touchManagedPtr fontset
    touchManagedPtr font
    return ()

#if ENABLE_OVERLOADING
data FontsetSimpleAppendMethodInfo
instance (signature ~ (b -> m ()), MonadIO m, IsFontsetSimple a, Pango.Font.IsFont b) => O.MethodInfo FontsetSimpleAppendMethodInfo a signature where
    overloadedMethod _ = fontsetSimpleAppend

#endif

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

foreign import ccall "pango_fontset_simple_size" pango_fontset_simple_size ::
    Ptr FontsetSimple ->                    -- fontset : TInterface (Name {namespace = "Pango", name = "FontsetSimple"})
    IO Int32

{- |
Returns the number of fonts in the fontset.
-}
fontsetSimpleSize ::
    (B.CallStack.HasCallStack, MonadIO m, IsFontsetSimple a) =>
    a
    {- ^ /@fontset@/: a 'GI.Pango.Objects.FontsetSimple.FontsetSimple'. -}
    -> m Int32
    {- ^ __Returns:__ the size of /@fontset@/. -}
fontsetSimpleSize fontset = liftIO $ do
    fontset' <- unsafeManagedPtrCastPtr fontset
    result <- pango_fontset_simple_size fontset'
    touchManagedPtr fontset
    return result

#if ENABLE_OVERLOADING
data FontsetSimpleSizeMethodInfo
instance (signature ~ (m Int32), MonadIO m, IsFontsetSimple a) => O.MethodInfo FontsetSimpleSizeMethodInfo a signature where
    overloadedMethod _ = fontsetSimpleSize

#endif