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

module GI.Pango.Objects.FontMap
    ( 

-- * Exported types
    FontMap(..)                             ,
    FontMapK                                ,
    toFontMap                               ,
    noFontMap                               ,


 -- * Methods
-- ** fontMapChanged
    fontMapChanged                          ,


-- ** fontMapCreateContext
    fontMapCreateContext                    ,


-- ** fontMapGetSerial
    fontMapGetSerial                        ,


-- ** fontMapGetShapeEngineType
    fontMapGetShapeEngineType               ,


-- ** fontMapListFamilies
    fontMapListFamilies                     ,


-- ** fontMapLoadFont
    fontMapLoadFont                         ,


-- ** fontMapLoadFontset
    fontMapLoadFontset                      ,




    ) where

import Prelude ()
import Data.GI.Base.ShortPrelude

import qualified Data.Text as T
import qualified Data.ByteString.Char8 as B
import qualified Data.Map as Map

import GI.Pango.Types
import GI.Pango.Callbacks
import qualified GI.GObject as GObject

newtype FontMap = FontMap (ForeignPtr FontMap)
foreign import ccall "pango_font_map_get_type"
    c_pango_font_map_get_type :: IO GType

type instance ParentTypes FontMap = FontMapParentTypes
type FontMapParentTypes = '[GObject.Object]

instance GObject FontMap where
    gobjectIsInitiallyUnowned _ = False
    gobjectType _ = c_pango_font_map_get_type
    

class GObject o => FontMapK o
instance (GObject o, IsDescendantOf FontMap o) => FontMapK o

toFontMap :: FontMapK o => o -> IO FontMap
toFontMap = unsafeCastTo FontMap

noFontMap :: Maybe FontMap
noFontMap = Nothing

type instance AttributeList FontMap = FontMapAttributeList
type FontMapAttributeList = ('[ ] :: [(Symbol, *)])

type instance SignalList FontMap = FontMapSignalList
type FontMapSignalList = ('[ '("notify", GObject.ObjectNotifySignalInfo), '("notify::[property]", GObjectNotifySignalInfo)] :: [(Symbol, *)])

-- method FontMap::changed
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Pango" "FontMap", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "Pango" "FontMap", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TBasicType TVoid
-- throws : False
-- Skip return : False

foreign import ccall "pango_font_map_changed" pango_font_map_changed :: 
    Ptr FontMap ->                          -- _obj : TInterface "Pango" "FontMap"
    IO ()


fontMapChanged ::
    (MonadIO m, FontMapK a) =>
    a ->                                    -- _obj
    m ()
fontMapChanged _obj = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    pango_font_map_changed _obj'
    touchManagedPtr _obj
    return ()

-- method FontMap::create_context
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Pango" "FontMap", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "Pango" "FontMap", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TInterface "Pango" "Context"
-- throws : False
-- Skip return : False

foreign import ccall "pango_font_map_create_context" pango_font_map_create_context :: 
    Ptr FontMap ->                          -- _obj : TInterface "Pango" "FontMap"
    IO (Ptr Context)


fontMapCreateContext ::
    (MonadIO m, FontMapK a) =>
    a ->                                    -- _obj
    m Context
fontMapCreateContext _obj = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    result <- pango_font_map_create_context _obj'
    checkUnexpectedReturnNULL "pango_font_map_create_context" result
    result' <- (wrapObject Context) result
    touchManagedPtr _obj
    return result'

-- method FontMap::get_serial
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Pango" "FontMap", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "Pango" "FontMap", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TBasicType TUInt32
-- throws : False
-- Skip return : False

foreign import ccall "pango_font_map_get_serial" pango_font_map_get_serial :: 
    Ptr FontMap ->                          -- _obj : TInterface "Pango" "FontMap"
    IO Word32


fontMapGetSerial ::
    (MonadIO m, FontMapK a) =>
    a ->                                    -- _obj
    m Word32
fontMapGetSerial _obj = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    result <- pango_font_map_get_serial _obj'
    touchManagedPtr _obj
    return result

-- method FontMap::get_shape_engine_type
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Pango" "FontMap", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "Pango" "FontMap", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TBasicType TUTF8
-- throws : False
-- Skip return : False

foreign import ccall "pango_font_map_get_shape_engine_type" pango_font_map_get_shape_engine_type :: 
    Ptr FontMap ->                          -- _obj : TInterface "Pango" "FontMap"
    IO CString

{-# DEPRECATED fontMapGetShapeEngineType ["(Since version 1.38)"]#-}
fontMapGetShapeEngineType ::
    (MonadIO m, FontMapK a) =>
    a ->                                    -- _obj
    m T.Text
fontMapGetShapeEngineType _obj = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    result <- pango_font_map_get_shape_engine_type _obj'
    checkUnexpectedReturnNULL "pango_font_map_get_shape_engine_type" result
    result' <- cstringToText result
    touchManagedPtr _obj
    return result'

-- method FontMap::list_families
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Pango" "FontMap", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "families", argType = TCArray False (-1) 2 (TInterface "Pango" "FontFamily"), direction = DirectionOut, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferContainer},Arg {argName = "n_families", argType = TBasicType TInt32, direction = DirectionOut, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferEverything}]
-- Lengths : [Arg {argName = "n_families", argType = TBasicType TInt32, direction = DirectionOut, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferEverything}]
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "Pango" "FontMap", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TBasicType TVoid
-- throws : False
-- Skip return : False

foreign import ccall "pango_font_map_list_families" pango_font_map_list_families :: 
    Ptr FontMap ->                          -- _obj : TInterface "Pango" "FontMap"
    Ptr (Ptr (Ptr FontFamily)) ->           -- families : TCArray False (-1) 2 (TInterface "Pango" "FontFamily")
    Ptr Int32 ->                            -- n_families : TBasicType TInt32
    IO ()


fontMapListFamilies ::
    (MonadIO m, FontMapK a) =>
    a ->                                    -- _obj
    m ([FontFamily])
fontMapListFamilies _obj = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    families <- allocMem :: IO (Ptr (Ptr (Ptr FontFamily)))
    n_families <- allocMem :: IO (Ptr Int32)
    pango_font_map_list_families _obj' families n_families
    n_families' <- peek n_families
    families' <- peek families
    families'' <- (unpackPtrArrayWithLength n_families') families'
    families''' <- mapM (newObject FontFamily) families''
    freeMem families'
    touchManagedPtr _obj
    freeMem families
    freeMem n_families
    return families'''

-- method FontMap::load_font
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Pango" "FontMap", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "context", argType = TInterface "Pango" "Context", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "desc", argType = TInterface "Pango" "FontDescription", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "Pango" "FontMap", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "context", argType = TInterface "Pango" "Context", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "desc", argType = TInterface "Pango" "FontDescription", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TInterface "Pango" "Font"
-- throws : False
-- Skip return : False

foreign import ccall "pango_font_map_load_font" pango_font_map_load_font :: 
    Ptr FontMap ->                          -- _obj : TInterface "Pango" "FontMap"
    Ptr Context ->                          -- context : TInterface "Pango" "Context"
    Ptr FontDescription ->                  -- desc : TInterface "Pango" "FontDescription"
    IO (Ptr Font)


fontMapLoadFont ::
    (MonadIO m, FontMapK a, ContextK b) =>
    a ->                                    -- _obj
    b ->                                    -- context
    FontDescription ->                      -- desc
    m Font
fontMapLoadFont _obj context desc = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    let context' = unsafeManagedPtrCastPtr context
    let desc' = unsafeManagedPtrGetPtr desc
    result <- pango_font_map_load_font _obj' context' desc'
    checkUnexpectedReturnNULL "pango_font_map_load_font" result
    result' <- (wrapObject Font) result
    touchManagedPtr _obj
    touchManagedPtr context
    touchManagedPtr desc
    return result'

-- method FontMap::load_fontset
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Pango" "FontMap", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "context", argType = TInterface "Pango" "Context", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "desc", argType = TInterface "Pango" "FontDescription", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "language", argType = TInterface "Pango" "Language", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "Pango" "FontMap", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "context", argType = TInterface "Pango" "Context", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "desc", argType = TInterface "Pango" "FontDescription", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "language", argType = TInterface "Pango" "Language", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TInterface "Pango" "Fontset"
-- throws : False
-- Skip return : False

foreign import ccall "pango_font_map_load_fontset" pango_font_map_load_fontset :: 
    Ptr FontMap ->                          -- _obj : TInterface "Pango" "FontMap"
    Ptr Context ->                          -- context : TInterface "Pango" "Context"
    Ptr FontDescription ->                  -- desc : TInterface "Pango" "FontDescription"
    Ptr Language ->                         -- language : TInterface "Pango" "Language"
    IO (Ptr Fontset)


fontMapLoadFontset ::
    (MonadIO m, FontMapK a, ContextK b) =>
    a ->                                    -- _obj
    b ->                                    -- context
    FontDescription ->                      -- desc
    Language ->                             -- language
    m Fontset
fontMapLoadFontset _obj context desc language = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    let context' = unsafeManagedPtrCastPtr context
    let desc' = unsafeManagedPtrGetPtr desc
    let language' = unsafeManagedPtrGetPtr language
    result <- pango_font_map_load_fontset _obj' context' desc' language'
    checkUnexpectedReturnNULL "pango_font_map_load_fontset" result
    result' <- (wrapObject Fontset) result
    touchManagedPtr _obj
    touchManagedPtr context
    touchManagedPtr desc
    touchManagedPtr language
    return result'