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

The #PangoItem structure stores information about a segment of text.
-}

module GI.Pango.Structs.Item
    ( 

-- * Exported types
    Item(..)                                ,
    noItem                                  ,


 -- * Methods
-- ** itemCopy
    itemCopy                                ,


-- ** itemFree
    itemFree                                ,


-- ** itemNew
    itemNew                                 ,


-- ** itemSplit
    itemSplit                               ,




 -- * Properties
-- ** Analysis
    itemReadAnalysis                        ,


-- ** Length
    itemReadLength                          ,


-- ** NumChars
    itemReadNumChars                        ,


-- ** Offset
    itemReadOffset                          ,




    ) 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

newtype Item = Item (ForeignPtr Item)
foreign import ccall "pango_item_get_type" c_pango_item_get_type :: 
    IO GType

instance BoxedObject Item where
    boxedType _ = c_pango_item_get_type

noItem :: Maybe Item
noItem = Nothing

itemReadOffset :: Item -> IO Int32
itemReadOffset s = withManagedPtr s $ \ptr -> do
    val <- peek (ptr `plusPtr` 0) :: IO Int32
    return val

itemReadLength :: Item -> IO Int32
itemReadLength s = withManagedPtr s $ \ptr -> do
    val <- peek (ptr `plusPtr` 4) :: IO Int32
    return val

itemReadNumChars :: Item -> IO Int32
itemReadNumChars s = withManagedPtr s $ \ptr -> do
    val <- peek (ptr `plusPtr` 8) :: IO Int32
    return val

itemReadAnalysis :: Item -> IO Analysis
itemReadAnalysis s = withManagedPtr s $ \ptr -> do
    val <- peek (ptr `plusPtr` 16) :: IO (Ptr Analysis)
    val' <- (newPtr 48 Analysis) val
    return val'

-- method Item::new
-- method type : Constructor
-- Args : []
-- Lengths : []
-- hInArgs : []
-- returnType : TInterface "Pango" "Item"
-- throws : False
-- Skip return : False

foreign import ccall "pango_item_new" pango_item_new :: 
    IO (Ptr Item)


itemNew ::
    (MonadIO m) =>
    m Item
itemNew  = liftIO $ do
    result <- pango_item_new
    checkUnexpectedReturnNULL "pango_item_new" result
    result' <- (wrapBoxed Item) result
    return result'

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

foreign import ccall "pango_item_copy" pango_item_copy :: 
    Ptr Item ->                             -- _obj : TInterface "Pango" "Item"
    IO (Ptr Item)


itemCopy ::
    (MonadIO m) =>
    Item ->                                 -- _obj
    m Item
itemCopy _obj = liftIO $ do
    let _obj' = unsafeManagedPtrGetPtr _obj
    result <- pango_item_copy _obj'
    checkUnexpectedReturnNULL "pango_item_copy" result
    result' <- (wrapBoxed Item) result
    touchManagedPtr _obj
    return result'

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

foreign import ccall "pango_item_free" pango_item_free :: 
    Ptr Item ->                             -- _obj : TInterface "Pango" "Item"
    IO ()


itemFree ::
    (MonadIO m) =>
    Item ->                                 -- _obj
    m ()
itemFree _obj = liftIO $ do
    let _obj' = unsafeManagedPtrGetPtr _obj
    pango_item_free _obj'
    touchManagedPtr _obj
    return ()

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

foreign import ccall "pango_item_split" pango_item_split :: 
    Ptr Item ->                             -- _obj : TInterface "Pango" "Item"
    Int32 ->                                -- split_index : TBasicType TInt32
    Int32 ->                                -- split_offset : TBasicType TInt32
    IO (Ptr Item)


itemSplit ::
    (MonadIO m) =>
    Item ->                                 -- _obj
    Int32 ->                                -- split_index
    Int32 ->                                -- split_offset
    m Item
itemSplit _obj split_index split_offset = liftIO $ do
    let _obj' = unsafeManagedPtrGetPtr _obj
    result <- pango_item_split _obj' split_index split_offset
    checkUnexpectedReturnNULL "pango_item_split" result
    result' <- (wrapBoxed Item) result
    touchManagedPtr _obj
    return result'