{- |
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.Poppler.Structs.TextSpan
    ( 

-- * Exported types
    TextSpan(..)                            ,
    noTextSpan                              ,


 -- * Methods
-- ** textSpanCopy
    textSpanCopy                            ,


-- ** textSpanFree
    textSpanFree                            ,


-- ** textSpanGetColor
    textSpanGetColor                        ,


-- ** textSpanGetFontName
    textSpanGetFontName                     ,


-- ** textSpanGetText
    textSpanGetText                         ,


-- ** textSpanIsBoldFont
    textSpanIsBoldFont                      ,


-- ** textSpanIsFixedWidthFont
    textSpanIsFixedWidthFont                ,


-- ** textSpanIsSerifFont
    textSpanIsSerifFont                     ,




    ) 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.Poppler.Types
import GI.Poppler.Callbacks

newtype TextSpan = TextSpan (ForeignPtr TextSpan)
foreign import ccall "poppler_text_span_get_type" c_poppler_text_span_get_type :: 
    IO GType

instance BoxedObject TextSpan where
    boxedType _ = c_poppler_text_span_get_type

noTextSpan :: Maybe TextSpan
noTextSpan = Nothing

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

foreign import ccall "poppler_text_span_copy" poppler_text_span_copy :: 
    Ptr TextSpan ->                         -- _obj : TInterface "Poppler" "TextSpan"
    IO (Ptr TextSpan)


textSpanCopy ::
    (MonadIO m) =>
    TextSpan ->                             -- _obj
    m TextSpan
textSpanCopy _obj = liftIO $ do
    let _obj' = unsafeManagedPtrGetPtr _obj
    result <- poppler_text_span_copy _obj'
    checkUnexpectedReturnNULL "poppler_text_span_copy" result
    result' <- (wrapBoxed TextSpan) result
    touchManagedPtr _obj
    return result'

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

foreign import ccall "poppler_text_span_free" poppler_text_span_free :: 
    Ptr TextSpan ->                         -- _obj : TInterface "Poppler" "TextSpan"
    IO ()


textSpanFree ::
    (MonadIO m) =>
    TextSpan ->                             -- _obj
    m ()
textSpanFree _obj = liftIO $ do
    let _obj' = unsafeManagedPtrGetPtr _obj
    poppler_text_span_free _obj'
    touchManagedPtr _obj
    return ()

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

foreign import ccall "poppler_text_span_get_color" poppler_text_span_get_color :: 
    Ptr TextSpan ->                         -- _obj : TInterface "Poppler" "TextSpan"
    Ptr Color ->                            -- color : TInterface "Poppler" "Color"
    IO ()


textSpanGetColor ::
    (MonadIO m) =>
    TextSpan ->                             -- _obj
    m (Color)
textSpanGetColor _obj = liftIO $ do
    let _obj' = unsafeManagedPtrGetPtr _obj
    color <- callocBoxedBytes 6 :: IO (Ptr Color)
    poppler_text_span_get_color _obj' color
    color' <- (wrapBoxed Color) color
    touchManagedPtr _obj
    return color'

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

foreign import ccall "poppler_text_span_get_font_name" poppler_text_span_get_font_name :: 
    Ptr TextSpan ->                         -- _obj : TInterface "Poppler" "TextSpan"
    IO CString


textSpanGetFontName ::
    (MonadIO m) =>
    TextSpan ->                             -- _obj
    m T.Text
textSpanGetFontName _obj = liftIO $ do
    let _obj' = unsafeManagedPtrGetPtr _obj
    result <- poppler_text_span_get_font_name _obj'
    checkUnexpectedReturnNULL "poppler_text_span_get_font_name" result
    result' <- cstringToText result
    touchManagedPtr _obj
    return result'

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

foreign import ccall "poppler_text_span_get_text" poppler_text_span_get_text :: 
    Ptr TextSpan ->                         -- _obj : TInterface "Poppler" "TextSpan"
    IO CString


textSpanGetText ::
    (MonadIO m) =>
    TextSpan ->                             -- _obj
    m T.Text
textSpanGetText _obj = liftIO $ do
    let _obj' = unsafeManagedPtrGetPtr _obj
    result <- poppler_text_span_get_text _obj'
    checkUnexpectedReturnNULL "poppler_text_span_get_text" result
    result' <- cstringToText result
    touchManagedPtr _obj
    return result'

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

foreign import ccall "poppler_text_span_is_bold_font" poppler_text_span_is_bold_font :: 
    Ptr TextSpan ->                         -- _obj : TInterface "Poppler" "TextSpan"
    IO CInt


textSpanIsBoldFont ::
    (MonadIO m) =>
    TextSpan ->                             -- _obj
    m Bool
textSpanIsBoldFont _obj = liftIO $ do
    let _obj' = unsafeManagedPtrGetPtr _obj
    result <- poppler_text_span_is_bold_font _obj'
    let result' = (/= 0) result
    touchManagedPtr _obj
    return result'

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

foreign import ccall "poppler_text_span_is_fixed_width_font" poppler_text_span_is_fixed_width_font :: 
    Ptr TextSpan ->                         -- _obj : TInterface "Poppler" "TextSpan"
    IO CInt


textSpanIsFixedWidthFont ::
    (MonadIO m) =>
    TextSpan ->                             -- _obj
    m Bool
textSpanIsFixedWidthFont _obj = liftIO $ do
    let _obj' = unsafeManagedPtrGetPtr _obj
    result <- poppler_text_span_is_fixed_width_font _obj'
    let result' = (/= 0) result
    touchManagedPtr _obj
    return result'

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

foreign import ccall "poppler_text_span_is_serif_font" poppler_text_span_is_serif_font :: 
    Ptr TextSpan ->                         -- _obj : TInterface "Poppler" "TextSpan"
    IO CInt


textSpanIsSerifFont ::
    (MonadIO m) =>
    TextSpan ->                             -- _obj
    m Bool
textSpanIsSerifFont _obj = liftIO $ do
    let _obj' = unsafeManagedPtrGetPtr _obj
    result <- poppler_text_span_is_serif_font _obj'
    let result' = (/= 0) result
    touchManagedPtr _obj
    return result'