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

    A 'GI.Pango.Structs.TabArray.TabArray' struct contains an array
    of tab stops. Each tab stop has an alignment and a position.
    -}

    #define ENABLE_OVERLOADING \
           (!defined(__HADDOCK_VERSION__))

    module GI.Pango.Structs.TabArray
        (

    -- * Exported types
        TabArray(..)                            ,
        noTabArray                              ,

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

    #if ENABLE_OVERLOADING
        TabArrayCopyMethodInfo                  ,
    #endif
        tabArrayCopy                            ,

    -- ** free #method:free#

    #if ENABLE_OVERLOADING
        TabArrayFreeMethodInfo                  ,
    #endif
        tabArrayFree                            ,

    -- ** getPositionsInPixels #method:getPositionsInPixels#

    #if ENABLE_OVERLOADING
        TabArrayGetPositionsInPixelsMethodInfo  ,
    #endif
        tabArrayGetPositionsInPixels            ,

    -- ** getSize #method:getSize#

    #if ENABLE_OVERLOADING
        TabArrayGetSizeMethodInfo               ,
    #endif
        tabArrayGetSize                         ,

    -- ** getTab #method:getTab#

    #if ENABLE_OVERLOADING
        TabArrayGetTabMethodInfo                ,
    #endif
        tabArrayGetTab                          ,

    -- ** new #method:new#

        tabArrayNew                             ,

    -- ** resize #method:resize#

    #if ENABLE_OVERLOADING
        TabArrayResizeMethodInfo                ,
    #endif
        tabArrayResize                          ,

    -- ** setTab #method:setTab#

    #if ENABLE_OVERLOADING
        TabArraySetTabMethodInfo                ,
    #endif
        tabArraySetTab                          ,

        ) 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 {-# SOURCE #-} qualified GI.Pango.Enums as Pango.Enums

    -- | Memory-managed wrapper type.
    newtype TabArray = TabArray (ManagedPtr TabArray)
    foreign import ccall "pango_tab_array_get_type" c_pango_tab_array_get_type ::
        IO GType

    instance BoxedObject TabArray where
        boxedType _ = c_pango_tab_array_get_type

    -- | A convenience alias for `Nothing` :: `Maybe` `TabArray`.
    noTabArray :: Maybe TabArray
    noTabArray = Nothing

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

    -- method TabArray::new
    -- method type : Constructor
    -- Args : [Arg {argCName = "initial_size", argType = TBasicType TInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "Initial number of tab stops to allocate, can be 0", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "positions_in_pixels", argType = TBasicType TBoolean, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "whether positions are in pixel units", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
    -- Lengths : []
    -- returnType : Just (TInterface (Name {namespace = "Pango", name = "TabArray"}))
    -- throws : False
    -- Skip return : False

    foreign import ccall "pango_tab_array_new" pango_tab_array_new ::
        Int32 ->                                -- initial_size : TBasicType TInt
        CInt ->                                 -- positions_in_pixels : TBasicType TBoolean
        IO (Ptr TabArray)

    {- |
    Creates an array of /@initialSize@/ tab stops. Tab stops are specified in
    pixel units if /@positionsInPixels@/ is 'True', otherwise in Pango
    units. All stops are initially at position 0.
    -}
    tabArrayNew ::
        (B.CallStack.HasCallStack, MonadIO m) =>
        Int32
        {- ^ /@initialSize@/: Initial number of tab stops to allocate, can be 0 -}
        -> Bool
        {- ^ /@positionsInPixels@/: whether positions are in pixel units -}
        -> m TabArray
        {- ^ __Returns:__ the newly allocated 'GI.Pango.Structs.TabArray.TabArray', which should
                  be freed with 'GI.Pango.Structs.TabArray.tabArrayFree'. -}
    tabArrayNew initialSize positionsInPixels = liftIO $ do
        let positionsInPixels' = (fromIntegral . fromEnum) positionsInPixels
        result <- pango_tab_array_new initialSize positionsInPixels'
        checkUnexpectedReturnNULL "tabArrayNew" result
        result' <- (wrapBoxed TabArray) result
        return result'

    #if ENABLE_OVERLOADING
    #endif

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

    foreign import ccall "pango_tab_array_copy" pango_tab_array_copy ::
        Ptr TabArray ->                         -- src : TInterface (Name {namespace = "Pango", name = "TabArray"})
        IO (Ptr TabArray)

    {- |
    Copies a 'GI.Pango.Structs.TabArray.TabArray'
    -}
    tabArrayCopy ::
        (B.CallStack.HasCallStack, MonadIO m) =>
        TabArray
        {- ^ /@src@/: 'GI.Pango.Structs.TabArray.TabArray' to copy -}
        -> m TabArray
        {- ^ __Returns:__ the newly allocated 'GI.Pango.Structs.TabArray.TabArray', which should
                  be freed with 'GI.Pango.Structs.TabArray.tabArrayFree'. -}
    tabArrayCopy src = liftIO $ do
        src' <- unsafeManagedPtrGetPtr src
        result <- pango_tab_array_copy src'
        checkUnexpectedReturnNULL "tabArrayCopy" result
        result' <- (wrapBoxed TabArray) result
        touchManagedPtr src
        return result'

    #if ENABLE_OVERLOADING
    data TabArrayCopyMethodInfo
    instance (signature ~ (m TabArray), MonadIO m) => O.MethodInfo TabArrayCopyMethodInfo TabArray signature where
        overloadedMethod _ = tabArrayCopy

    #endif

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

    foreign import ccall "pango_tab_array_free" pango_tab_array_free ::
        Ptr TabArray ->                         -- tab_array : TInterface (Name {namespace = "Pango", name = "TabArray"})
        IO ()

    {- |
    Frees a tab array and associated resources.
    -}
    tabArrayFree ::
        (B.CallStack.HasCallStack, MonadIO m) =>
        TabArray
        {- ^ /@tabArray@/: a 'GI.Pango.Structs.TabArray.TabArray' -}
        -> m ()
    tabArrayFree tabArray = liftIO $ do
        tabArray' <- unsafeManagedPtrGetPtr tabArray
        pango_tab_array_free tabArray'
        touchManagedPtr tabArray
        return ()

    #if ENABLE_OVERLOADING
    data TabArrayFreeMethodInfo
    instance (signature ~ (m ()), MonadIO m) => O.MethodInfo TabArrayFreeMethodInfo TabArray signature where
        overloadedMethod _ = tabArrayFree

    #endif

    -- method TabArray::get_positions_in_pixels
    -- method type : OrdinaryMethod
    -- Args : [Arg {argCName = "tab_array", argType = TInterface (Name {namespace = "Pango", name = "TabArray"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #PangoTabArray", 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 "pango_tab_array_get_positions_in_pixels" pango_tab_array_get_positions_in_pixels ::
        Ptr TabArray ->                         -- tab_array : TInterface (Name {namespace = "Pango", name = "TabArray"})
        IO CInt

    {- |
    Returns 'True' if the tab positions are in pixels, 'False' if they are
    in Pango units.
    -}
    tabArrayGetPositionsInPixels ::
        (B.CallStack.HasCallStack, MonadIO m) =>
        TabArray
        {- ^ /@tabArray@/: a 'GI.Pango.Structs.TabArray.TabArray' -}
        -> m Bool
        {- ^ __Returns:__ whether positions are in pixels. -}
    tabArrayGetPositionsInPixels tabArray = liftIO $ do
        tabArray' <- unsafeManagedPtrGetPtr tabArray
        result <- pango_tab_array_get_positions_in_pixels tabArray'
        let result' = (/= 0) result
        touchManagedPtr tabArray
        return result'

    #if ENABLE_OVERLOADING
    data TabArrayGetPositionsInPixelsMethodInfo
    instance (signature ~ (m Bool), MonadIO m) => O.MethodInfo TabArrayGetPositionsInPixelsMethodInfo TabArray signature where
        overloadedMethod _ = tabArrayGetPositionsInPixels

    #endif

    -- method TabArray::get_size
    -- method type : OrdinaryMethod
    -- Args : [Arg {argCName = "tab_array", argType = TInterface (Name {namespace = "Pango", name = "TabArray"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #PangoTabArray", 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_tab_array_get_size" pango_tab_array_get_size ::
        Ptr TabArray ->                         -- tab_array : TInterface (Name {namespace = "Pango", name = "TabArray"})
        IO Int32

    {- |
    Gets the number of tab stops in /@tabArray@/.
    -}
    tabArrayGetSize ::
        (B.CallStack.HasCallStack, MonadIO m) =>
        TabArray
        {- ^ /@tabArray@/: a 'GI.Pango.Structs.TabArray.TabArray' -}
        -> m Int32
        {- ^ __Returns:__ the number of tab stops in the array. -}
    tabArrayGetSize tabArray = liftIO $ do
        tabArray' <- unsafeManagedPtrGetPtr tabArray
        result <- pango_tab_array_get_size tabArray'
        touchManagedPtr tabArray
        return result

    #if ENABLE_OVERLOADING
    data TabArrayGetSizeMethodInfo
    instance (signature ~ (m Int32), MonadIO m) => O.MethodInfo TabArrayGetSizeMethodInfo TabArray signature where
        overloadedMethod _ = tabArrayGetSize

    #endif

    -- method TabArray::get_tab
    -- method type : OrdinaryMethod
    -- Args : [Arg {argCName = "tab_array", argType = TInterface (Name {namespace = "Pango", name = "TabArray"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #PangoTabArray", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "tab_index", argType = TBasicType TInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "tab stop index", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "alignment", argType = TInterface (Name {namespace = "Pango", name = "TabAlign"}), direction = DirectionOut, mayBeNull = False, argDoc = Documentation {rawDocText = Just "location to store alignment, or %NULL", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferEverything},Arg {argCName = "location", argType = TBasicType TInt, direction = DirectionOut, mayBeNull = False, argDoc = Documentation {rawDocText = Just "location to store tab position, or %NULL", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferEverything}]
    -- Lengths : []
    -- returnType : Nothing
    -- throws : False
    -- Skip return : False

    foreign import ccall "pango_tab_array_get_tab" pango_tab_array_get_tab ::
        Ptr TabArray ->                         -- tab_array : TInterface (Name {namespace = "Pango", name = "TabArray"})
        Int32 ->                                -- tab_index : TBasicType TInt
        Ptr CUInt ->                            -- alignment : TInterface (Name {namespace = "Pango", name = "TabAlign"})
        Ptr Int32 ->                            -- location : TBasicType TInt
        IO ()

    {- |
    Gets the alignment and position of a tab stop.
    -}
    tabArrayGetTab ::
        (B.CallStack.HasCallStack, MonadIO m) =>
        TabArray
        {- ^ /@tabArray@/: a 'GI.Pango.Structs.TabArray.TabArray' -}
        -> Int32
        {- ^ /@tabIndex@/: tab stop index -}
        -> m ((Pango.Enums.TabAlign, Int32))
    tabArrayGetTab tabArray tabIndex = liftIO $ do
        tabArray' <- unsafeManagedPtrGetPtr tabArray
        alignment <- allocMem :: IO (Ptr CUInt)
        location <- allocMem :: IO (Ptr Int32)
        pango_tab_array_get_tab tabArray' tabIndex alignment location
        alignment' <- peek alignment
        let alignment'' = (toEnum . fromIntegral) alignment'
        location' <- peek location
        touchManagedPtr tabArray
        freeMem alignment
        freeMem location
        return (alignment'', location')

    #if ENABLE_OVERLOADING
    data TabArrayGetTabMethodInfo
    instance (signature ~ (Int32 -> m ((Pango.Enums.TabAlign, Int32))), MonadIO m) => O.MethodInfo TabArrayGetTabMethodInfo TabArray signature where
        overloadedMethod _ = tabArrayGetTab

    #endif

    -- XXX Could not generate method TabArray::get_tabs
    -- Error was : Bad introspection data: "`TCArray False (-1) (-1) (TBasicType TInt)' is an array type, but contains no length information,\nso it cannot be unpacked."
    -- method TabArray::resize
    -- method type : OrdinaryMethod
    -- Args : [Arg {argCName = "tab_array", argType = TInterface (Name {namespace = "Pango", name = "TabArray"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #PangoTabArray", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "new_size", argType = TBasicType TInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "new size of the array", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
    -- Lengths : []
    -- returnType : Nothing
    -- throws : False
    -- Skip return : False

    foreign import ccall "pango_tab_array_resize" pango_tab_array_resize ::
        Ptr TabArray ->                         -- tab_array : TInterface (Name {namespace = "Pango", name = "TabArray"})
        Int32 ->                                -- new_size : TBasicType TInt
        IO ()

    {- |
    Resizes a tab array. You must subsequently initialize any tabs that
    were added as a result of growing the array.
    -}
    tabArrayResize ::
        (B.CallStack.HasCallStack, MonadIO m) =>
        TabArray
        {- ^ /@tabArray@/: a 'GI.Pango.Structs.TabArray.TabArray' -}
        -> Int32
        {- ^ /@newSize@/: new size of the array -}
        -> m ()
    tabArrayResize tabArray newSize = liftIO $ do
        tabArray' <- unsafeManagedPtrGetPtr tabArray
        pango_tab_array_resize tabArray' newSize
        touchManagedPtr tabArray
        return ()

    #if ENABLE_OVERLOADING
    data TabArrayResizeMethodInfo
    instance (signature ~ (Int32 -> m ()), MonadIO m) => O.MethodInfo TabArrayResizeMethodInfo TabArray signature where
        overloadedMethod _ = tabArrayResize

    #endif

    -- method TabArray::set_tab
    -- method type : OrdinaryMethod
    -- Args : [Arg {argCName = "tab_array", argType = TInterface (Name {namespace = "Pango", name = "TabArray"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #PangoTabArray", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "tab_index", argType = TBasicType TInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the index of a tab stop", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "alignment", argType = TInterface (Name {namespace = "Pango", name = "TabAlign"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "tab alignment", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "location", argType = TBasicType TInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "tab location in Pango units", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
    -- Lengths : []
    -- returnType : Nothing
    -- throws : False
    -- Skip return : False

    foreign import ccall "pango_tab_array_set_tab" pango_tab_array_set_tab ::
        Ptr TabArray ->                         -- tab_array : TInterface (Name {namespace = "Pango", name = "TabArray"})
        Int32 ->                                -- tab_index : TBasicType TInt
        CUInt ->                                -- alignment : TInterface (Name {namespace = "Pango", name = "TabAlign"})
        Int32 ->                                -- location : TBasicType TInt
        IO ()

    {- |
    Sets the alignment and location of a tab stop.
    /@alignment@/ must always be @/PANGO_TAB_LEFT/@ in the current
    implementation.
    -}
    tabArraySetTab ::
        (B.CallStack.HasCallStack, MonadIO m) =>
        TabArray
        {- ^ /@tabArray@/: a 'GI.Pango.Structs.TabArray.TabArray' -}
        -> Int32
        {- ^ /@tabIndex@/: the index of a tab stop -}
        -> Pango.Enums.TabAlign
        {- ^ /@alignment@/: tab alignment -}
        -> Int32
        {- ^ /@location@/: tab location in Pango units -}
        -> m ()
    tabArraySetTab tabArray tabIndex alignment location = liftIO $ do
        tabArray' <- unsafeManagedPtrGetPtr tabArray
        let alignment' = (fromIntegral . fromEnum) alignment
        pango_tab_array_set_tab tabArray' tabIndex alignment' location
        touchManagedPtr tabArray
        return ()

    #if ENABLE_OVERLOADING
    data TabArraySetTabMethodInfo
    instance (signature ~ (Int32 -> Pango.Enums.TabAlign -> Int32 -> m ()), MonadIO m) => O.MethodInfo TabArraySetTabMethodInfo TabArray signature where
        overloadedMethod _ = tabArraySetTab

    #endif

    #if ENABLE_OVERLOADING
    type family ResolveTabArrayMethod (t :: Symbol) (o :: *) :: * where
        ResolveTabArrayMethod "copy" o = TabArrayCopyMethodInfo
        ResolveTabArrayMethod "free" o = TabArrayFreeMethodInfo
        ResolveTabArrayMethod "resize" o = TabArrayResizeMethodInfo
        ResolveTabArrayMethod "getPositionsInPixels" o = TabArrayGetPositionsInPixelsMethodInfo
        ResolveTabArrayMethod "getSize" o = TabArrayGetSizeMethodInfo
        ResolveTabArrayMethod "getTab" o = TabArrayGetTabMethodInfo
        ResolveTabArrayMethod "setTab" o = TabArraySetTabMethodInfo
        ResolveTabArrayMethod l o = O.MethodResolutionFailed l o

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

    #if MIN_VERSION_base(4,9,0)
    instance (info ~ ResolveTabArrayMethod t TabArray, O.MethodInfo info TabArray p) => O.IsLabel t (TabArray -> 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