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

/No description available in the introspection data./
-}

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

module GI.Poppler.Structs.TextSpan
    (

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


 -- * Methods
-- ** copy #method:copy#

#if ENABLE_OVERLOADING
    TextSpanCopyMethodInfo                  ,
#endif
    textSpanCopy                            ,


-- ** free #method:free#

#if ENABLE_OVERLOADING
    TextSpanFreeMethodInfo                  ,
#endif
    textSpanFree                            ,


-- ** getColor #method:getColor#

#if ENABLE_OVERLOADING
    TextSpanGetColorMethodInfo              ,
#endif
    textSpanGetColor                        ,


-- ** getFontName #method:getFontName#

#if ENABLE_OVERLOADING
    TextSpanGetFontNameMethodInfo           ,
#endif
    textSpanGetFontName                     ,


-- ** getText #method:getText#

#if ENABLE_OVERLOADING
    TextSpanGetTextMethodInfo               ,
#endif
    textSpanGetText                         ,


-- ** isBoldFont #method:isBoldFont#

#if ENABLE_OVERLOADING
    TextSpanIsBoldFontMethodInfo            ,
#endif
    textSpanIsBoldFont                      ,


-- ** isFixedWidthFont #method:isFixedWidthFont#

#if ENABLE_OVERLOADING
    TextSpanIsFixedWidthFontMethodInfo      ,
#endif
    textSpanIsFixedWidthFont                ,


-- ** isSerifFont #method:isSerifFont#

#if ENABLE_OVERLOADING
    TextSpanIsSerifFontMethodInfo           ,
#endif
    textSpanIsSerifFont                     ,




    ) 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.GClosure as B.GClosure
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.GI.Base.Properties as B.Properties
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 {-# SOURCE #-} qualified GI.Poppler.Structs.Color as Poppler.Color

-- | Memory-managed wrapper type.
newtype TextSpan = TextSpan (ManagedPtr 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

-- | A convenience alias for `Nothing` :: `Maybe` `TextSpan`.
noTextSpan :: Maybe TextSpan
noTextSpan = Nothing


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

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

foreign import ccall "poppler_text_span_copy" poppler_text_span_copy ::
    Ptr TextSpan ->                         -- poppler_text_span : TInterface (Name {namespace = "Poppler", name = "TextSpan"})
    IO (Ptr TextSpan)

{- |
Makes a copy of a text span.

/Since: 0.26/
-}
textSpanCopy ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    TextSpan
    {- ^ /@popplerTextSpan@/: a 'GI.Poppler.Structs.TextSpan.TextSpan' -}
    -> m TextSpan
    {- ^ __Returns:__ A new 'GI.Poppler.Structs.TextSpan.TextSpan' -}
textSpanCopy popplerTextSpan = liftIO $ do
    popplerTextSpan' <- unsafeManagedPtrGetPtr popplerTextSpan
    result <- poppler_text_span_copy popplerTextSpan'
    checkUnexpectedReturnNULL "textSpanCopy" result
    result' <- (wrapBoxed TextSpan) result
    touchManagedPtr popplerTextSpan
    return result'

#if ENABLE_OVERLOADING
data TextSpanCopyMethodInfo
instance (signature ~ (m TextSpan), MonadIO m) => O.MethodInfo TextSpanCopyMethodInfo TextSpan signature where
    overloadedMethod _ = textSpanCopy

#endif

-- method TextSpan::free
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "poppler_text_span", argType = TInterface (Name {namespace = "Poppler", name = "TextSpan"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "A #PopplerTextSpan", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "poppler_text_span_free" poppler_text_span_free ::
    Ptr TextSpan ->                         -- poppler_text_span : TInterface (Name {namespace = "Poppler", name = "TextSpan"})
    IO ()

{- |
Frees a text span.

/Since: 0.26/
-}
textSpanFree ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    TextSpan
    {- ^ /@popplerTextSpan@/: A 'GI.Poppler.Structs.TextSpan.TextSpan' -}
    -> m ()
textSpanFree popplerTextSpan = liftIO $ do
    popplerTextSpan' <- unsafeManagedPtrGetPtr popplerTextSpan
    poppler_text_span_free popplerTextSpan'
    touchManagedPtr popplerTextSpan
    return ()

#if ENABLE_OVERLOADING
data TextSpanFreeMethodInfo
instance (signature ~ (m ()), MonadIO m) => O.MethodInfo TextSpanFreeMethodInfo TextSpan signature where
    overloadedMethod _ = textSpanFree

#endif

-- method TextSpan::get_color
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "poppler_text_span", argType = TInterface (Name {namespace = "Poppler", name = "TextSpan"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #PopplerTextSpan", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "color", argType = TInterface (Name {namespace = "Poppler", name = "Color"}), direction = DirectionOut, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a return location for a #PopplerColor", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = True, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "poppler_text_span_get_color" poppler_text_span_get_color ::
    Ptr TextSpan ->                         -- poppler_text_span : TInterface (Name {namespace = "Poppler", name = "TextSpan"})
    Ptr Poppler.Color.Color ->              -- color : TInterface (Name {namespace = "Poppler", name = "Color"})
    IO ()

{- |
Obtains the color in which the text is to be rendered.

/Since: 0.26/
-}
textSpanGetColor ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    TextSpan
    {- ^ /@popplerTextSpan@/: a 'GI.Poppler.Structs.TextSpan.TextSpan' -}
    -> m (Poppler.Color.Color)
textSpanGetColor popplerTextSpan = liftIO $ do
    popplerTextSpan' <- unsafeManagedPtrGetPtr popplerTextSpan
    color <- callocBoxedBytes 6 :: IO (Ptr Poppler.Color.Color)
    poppler_text_span_get_color popplerTextSpan' color
    color' <- (wrapBoxed Poppler.Color.Color) color
    touchManagedPtr popplerTextSpan
    return color'

#if ENABLE_OVERLOADING
data TextSpanGetColorMethodInfo
instance (signature ~ (m (Poppler.Color.Color)), MonadIO m) => O.MethodInfo TextSpanGetColorMethodInfo TextSpan signature where
    overloadedMethod _ = textSpanGetColor

#endif

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

foreign import ccall "poppler_text_span_get_font_name" poppler_text_span_get_font_name ::
    Ptr TextSpan ->                         -- poppler_text_span : TInterface (Name {namespace = "Poppler", name = "TextSpan"})
    IO CString

{- |
Obtains the name of the font in which the span is to be rendered.

/Since: 0.26/
-}
textSpanGetFontName ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    TextSpan
    {- ^ /@popplerTextSpan@/: a 'GI.Poppler.Structs.TextSpan.TextSpan' -}
    -> m T.Text
    {- ^ __Returns:__ A string containing the font name, or
  'Nothing' if a font is not defined. -}
textSpanGetFontName popplerTextSpan = liftIO $ do
    popplerTextSpan' <- unsafeManagedPtrGetPtr popplerTextSpan
    result <- poppler_text_span_get_font_name popplerTextSpan'
    checkUnexpectedReturnNULL "textSpanGetFontName" result
    result' <- cstringToText result
    touchManagedPtr popplerTextSpan
    return result'

#if ENABLE_OVERLOADING
data TextSpanGetFontNameMethodInfo
instance (signature ~ (m T.Text), MonadIO m) => O.MethodInfo TextSpanGetFontNameMethodInfo TextSpan signature where
    overloadedMethod _ = textSpanGetFontName

#endif

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

foreign import ccall "poppler_text_span_get_text" poppler_text_span_get_text ::
    Ptr TextSpan ->                         -- poppler_text_span : TInterface (Name {namespace = "Poppler", name = "TextSpan"})
    IO CString

{- |
Obtains the text contained in the span.

/Since: 0.26/
-}
textSpanGetText ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    TextSpan
    {- ^ /@popplerTextSpan@/: a 'GI.Poppler.Structs.TextSpan.TextSpan' -}
    -> m T.Text
    {- ^ __Returns:__ A string. -}
textSpanGetText popplerTextSpan = liftIO $ do
    popplerTextSpan' <- unsafeManagedPtrGetPtr popplerTextSpan
    result <- poppler_text_span_get_text popplerTextSpan'
    checkUnexpectedReturnNULL "textSpanGetText" result
    result' <- cstringToText result
    touchManagedPtr popplerTextSpan
    return result'

#if ENABLE_OVERLOADING
data TextSpanGetTextMethodInfo
instance (signature ~ (m T.Text), MonadIO m) => O.MethodInfo TextSpanGetTextMethodInfo TextSpan signature where
    overloadedMethod _ = textSpanGetText

#endif

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

foreign import ccall "poppler_text_span_is_bold_font" poppler_text_span_is_bold_font ::
    Ptr TextSpan ->                         -- poppler_text_span : TInterface (Name {namespace = "Poppler", name = "TextSpan"})
    IO CInt

{- |
Check whether a text span is meant to be rendered using a bold font.

/Since: 0.26/
-}
textSpanIsBoldFont ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    TextSpan
    {- ^ /@popplerTextSpan@/: a 'GI.Poppler.Structs.TextSpan.TextSpan' -}
    -> m Bool
    {- ^ __Returns:__ Whether the span uses bold font. -}
textSpanIsBoldFont popplerTextSpan = liftIO $ do
    popplerTextSpan' <- unsafeManagedPtrGetPtr popplerTextSpan
    result <- poppler_text_span_is_bold_font popplerTextSpan'
    let result' = (/= 0) result
    touchManagedPtr popplerTextSpan
    return result'

#if ENABLE_OVERLOADING
data TextSpanIsBoldFontMethodInfo
instance (signature ~ (m Bool), MonadIO m) => O.MethodInfo TextSpanIsBoldFontMethodInfo TextSpan signature where
    overloadedMethod _ = textSpanIsBoldFont

#endif

-- method TextSpan::is_fixed_width_font
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "poppler_text_span", argType = TInterface (Name {namespace = "Poppler", name = "TextSpan"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #PopplerTextSpan", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (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 ->                         -- poppler_text_span : TInterface (Name {namespace = "Poppler", name = "TextSpan"})
    IO CInt

{- |
Check wether a text span is meant to be rendered using a fixed-width font.

/Since: 0.26/
-}
textSpanIsFixedWidthFont ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    TextSpan
    {- ^ /@popplerTextSpan@/: a 'GI.Poppler.Structs.TextSpan.TextSpan' -}
    -> m Bool
    {- ^ __Returns:__ Whether the span uses a fixed-width font. -}
textSpanIsFixedWidthFont popplerTextSpan = liftIO $ do
    popplerTextSpan' <- unsafeManagedPtrGetPtr popplerTextSpan
    result <- poppler_text_span_is_fixed_width_font popplerTextSpan'
    let result' = (/= 0) result
    touchManagedPtr popplerTextSpan
    return result'

#if ENABLE_OVERLOADING
data TextSpanIsFixedWidthFontMethodInfo
instance (signature ~ (m Bool), MonadIO m) => O.MethodInfo TextSpanIsFixedWidthFontMethodInfo TextSpan signature where
    overloadedMethod _ = textSpanIsFixedWidthFont

#endif

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

foreign import ccall "poppler_text_span_is_serif_font" poppler_text_span_is_serif_font ::
    Ptr TextSpan ->                         -- poppler_text_span : TInterface (Name {namespace = "Poppler", name = "TextSpan"})
    IO CInt

{- |
Check whether a text span is meant to be rendered using a serif font.

/Since: 0.26/
-}
textSpanIsSerifFont ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    TextSpan
    {- ^ /@popplerTextSpan@/: a 'GI.Poppler.Structs.TextSpan.TextSpan' -}
    -> m Bool
    {- ^ __Returns:__ Whether the span uses a serif font. -}
textSpanIsSerifFont popplerTextSpan = liftIO $ do
    popplerTextSpan' <- unsafeManagedPtrGetPtr popplerTextSpan
    result <- poppler_text_span_is_serif_font popplerTextSpan'
    let result' = (/= 0) result
    touchManagedPtr popplerTextSpan
    return result'

#if ENABLE_OVERLOADING
data TextSpanIsSerifFontMethodInfo
instance (signature ~ (m Bool), MonadIO m) => O.MethodInfo TextSpanIsSerifFontMethodInfo TextSpan signature where
    overloadedMethod _ = textSpanIsSerifFont

#endif

#if ENABLE_OVERLOADING
type family ResolveTextSpanMethod (t :: Symbol) (o :: *) :: * where
    ResolveTextSpanMethod "copy" o = TextSpanCopyMethodInfo
    ResolveTextSpanMethod "free" o = TextSpanFreeMethodInfo
    ResolveTextSpanMethod "isBoldFont" o = TextSpanIsBoldFontMethodInfo
    ResolveTextSpanMethod "isFixedWidthFont" o = TextSpanIsFixedWidthFontMethodInfo
    ResolveTextSpanMethod "isSerifFont" o = TextSpanIsSerifFontMethodInfo
    ResolveTextSpanMethod "getColor" o = TextSpanGetColorMethodInfo
    ResolveTextSpanMethod "getFontName" o = TextSpanGetFontNameMethodInfo
    ResolveTextSpanMethod "getText" o = TextSpanGetTextMethodInfo
    ResolveTextSpanMethod l o = O.MethodResolutionFailed l o

instance (info ~ ResolveTextSpanMethod t TextSpan, O.MethodInfo info TextSpan p) => OL.IsLabel t (TextSpan -> 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