module GI.Pango.Structs.LayoutLine
(
LayoutLine(..) ,
newZeroLayoutLine ,
noLayoutLine ,
LayoutLineGetExtentsMethodInfo ,
layoutLineGetExtents ,
LayoutLineGetPixelExtentsMethodInfo ,
layoutLineGetPixelExtents ,
LayoutLineGetXRangesMethodInfo ,
layoutLineGetXRanges ,
LayoutLineIndexToXMethodInfo ,
layoutLineIndexToX ,
LayoutLineRefMethodInfo ,
layoutLineRef ,
LayoutLineUnrefMethodInfo ,
layoutLineUnref ,
LayoutLineXToIndexMethodInfo ,
layoutLineXToIndex ,
getLayoutLineIsParagraphStart ,
layoutLine_isParagraphStart ,
setLayoutLineIsParagraphStart ,
clearLayoutLineLayout ,
getLayoutLineLayout ,
layoutLine_layout ,
setLayoutLineLayout ,
getLayoutLineLength ,
layoutLine_length ,
setLayoutLineLength ,
getLayoutLineResolvedDir ,
layoutLine_resolvedDir ,
setLayoutLineResolvedDir ,
clearLayoutLineRuns ,
getLayoutLineRuns ,
layoutLine_runs ,
setLayoutLineRuns ,
getLayoutLineStartIndex ,
layoutLine_startIndex ,
setLayoutLineStartIndex ,
) 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.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 qualified GI.Pango.Objects.Layout as Pango.Layout
import qualified GI.Pango.Structs.Rectangle as Pango.Rectangle
newtype LayoutLine = LayoutLine (ManagedPtr LayoutLine)
foreign import ccall "pango_layout_line_get_type" c_pango_layout_line_get_type ::
IO GType
instance BoxedObject LayoutLine where
boxedType _ = c_pango_layout_line_get_type
newZeroLayoutLine :: MonadIO m => m LayoutLine
newZeroLayoutLine = liftIO $ callocBoxedBytes 32 >>= wrapBoxed LayoutLine
instance tag ~ 'AttrSet => Constructible LayoutLine tag where
new _ attrs = do
o <- newZeroLayoutLine
GI.Attributes.set o attrs
return o
noLayoutLine :: Maybe LayoutLine
noLayoutLine = Nothing
getLayoutLineLayout :: MonadIO m => LayoutLine -> m (Maybe Pango.Layout.Layout)
getLayoutLineLayout s = liftIO $ withManagedPtr s $ \ptr -> do
val <- peek (ptr `plusPtr` 0) :: IO (Ptr Pango.Layout.Layout)
result <- SP.convertIfNonNull val $ \val' -> do
val'' <- (newObject Pango.Layout.Layout) val'
return val''
return result
setLayoutLineLayout :: MonadIO m => LayoutLine -> Ptr Pango.Layout.Layout -> m ()
setLayoutLineLayout s val = liftIO $ withManagedPtr s $ \ptr -> do
poke (ptr `plusPtr` 0) (val :: Ptr Pango.Layout.Layout)
clearLayoutLineLayout :: MonadIO m => LayoutLine -> m ()
clearLayoutLineLayout s = liftIO $ withManagedPtr s $ \ptr -> do
poke (ptr `plusPtr` 0) (FP.nullPtr :: Ptr Pango.Layout.Layout)
data LayoutLineLayoutFieldInfo
instance AttrInfo LayoutLineLayoutFieldInfo where
type AttrAllowedOps LayoutLineLayoutFieldInfo = '[ 'AttrSet, 'AttrGet, 'AttrClear]
type AttrSetTypeConstraint LayoutLineLayoutFieldInfo = (~) (Ptr Pango.Layout.Layout)
type AttrBaseTypeConstraint LayoutLineLayoutFieldInfo = (~) LayoutLine
type AttrGetType LayoutLineLayoutFieldInfo = Maybe Pango.Layout.Layout
type AttrLabel LayoutLineLayoutFieldInfo = "layout"
type AttrOrigin LayoutLineLayoutFieldInfo = LayoutLine
attrGet _ = getLayoutLineLayout
attrSet _ = setLayoutLineLayout
attrConstruct = undefined
attrClear _ = clearLayoutLineLayout
layoutLine_layout :: AttrLabelProxy "layout"
layoutLine_layout = AttrLabelProxy
getLayoutLineStartIndex :: MonadIO m => LayoutLine -> m Int32
getLayoutLineStartIndex s = liftIO $ withManagedPtr s $ \ptr -> do
val <- peek (ptr `plusPtr` 8) :: IO Int32
return val
setLayoutLineStartIndex :: MonadIO m => LayoutLine -> Int32 -> m ()
setLayoutLineStartIndex s val = liftIO $ withManagedPtr s $ \ptr -> do
poke (ptr `plusPtr` 8) (val :: Int32)
data LayoutLineStartIndexFieldInfo
instance AttrInfo LayoutLineStartIndexFieldInfo where
type AttrAllowedOps LayoutLineStartIndexFieldInfo = '[ 'AttrSet, 'AttrGet]
type AttrSetTypeConstraint LayoutLineStartIndexFieldInfo = (~) Int32
type AttrBaseTypeConstraint LayoutLineStartIndexFieldInfo = (~) LayoutLine
type AttrGetType LayoutLineStartIndexFieldInfo = Int32
type AttrLabel LayoutLineStartIndexFieldInfo = "start_index"
type AttrOrigin LayoutLineStartIndexFieldInfo = LayoutLine
attrGet _ = getLayoutLineStartIndex
attrSet _ = setLayoutLineStartIndex
attrConstruct = undefined
attrClear _ = undefined
layoutLine_startIndex :: AttrLabelProxy "startIndex"
layoutLine_startIndex = AttrLabelProxy
getLayoutLineLength :: MonadIO m => LayoutLine -> m Int32
getLayoutLineLength s = liftIO $ withManagedPtr s $ \ptr -> do
val <- peek (ptr `plusPtr` 12) :: IO Int32
return val
setLayoutLineLength :: MonadIO m => LayoutLine -> Int32 -> m ()
setLayoutLineLength s val = liftIO $ withManagedPtr s $ \ptr -> do
poke (ptr `plusPtr` 12) (val :: Int32)
data LayoutLineLengthFieldInfo
instance AttrInfo LayoutLineLengthFieldInfo where
type AttrAllowedOps LayoutLineLengthFieldInfo = '[ 'AttrSet, 'AttrGet]
type AttrSetTypeConstraint LayoutLineLengthFieldInfo = (~) Int32
type AttrBaseTypeConstraint LayoutLineLengthFieldInfo = (~) LayoutLine
type AttrGetType LayoutLineLengthFieldInfo = Int32
type AttrLabel LayoutLineLengthFieldInfo = "length"
type AttrOrigin LayoutLineLengthFieldInfo = LayoutLine
attrGet _ = getLayoutLineLength
attrSet _ = setLayoutLineLength
attrConstruct = undefined
attrClear _ = undefined
layoutLine_length :: AttrLabelProxy "length"
layoutLine_length = AttrLabelProxy
getLayoutLineRuns :: MonadIO m => LayoutLine -> m ([Ptr ()])
getLayoutLineRuns s = liftIO $ withManagedPtr s $ \ptr -> do
val <- peek (ptr `plusPtr` 16) :: IO (Ptr (GSList (Ptr ())))
val' <- unpackGSList val
return val'
setLayoutLineRuns :: MonadIO m => LayoutLine -> Ptr (GSList (Ptr ())) -> m ()
setLayoutLineRuns s val = liftIO $ withManagedPtr s $ \ptr -> do
poke (ptr `plusPtr` 16) (val :: Ptr (GSList (Ptr ())))
clearLayoutLineRuns :: MonadIO m => LayoutLine -> m ()
clearLayoutLineRuns s = liftIO $ withManagedPtr s $ \ptr -> do
poke (ptr `plusPtr` 16) (FP.nullPtr :: Ptr (GSList (Ptr ())))
data LayoutLineRunsFieldInfo
instance AttrInfo LayoutLineRunsFieldInfo where
type AttrAllowedOps LayoutLineRunsFieldInfo = '[ 'AttrSet, 'AttrGet, 'AttrClear]
type AttrSetTypeConstraint LayoutLineRunsFieldInfo = (~) (Ptr (GSList (Ptr ())))
type AttrBaseTypeConstraint LayoutLineRunsFieldInfo = (~) LayoutLine
type AttrGetType LayoutLineRunsFieldInfo = [Ptr ()]
type AttrLabel LayoutLineRunsFieldInfo = "runs"
type AttrOrigin LayoutLineRunsFieldInfo = LayoutLine
attrGet _ = getLayoutLineRuns
attrSet _ = setLayoutLineRuns
attrConstruct = undefined
attrClear _ = clearLayoutLineRuns
layoutLine_runs :: AttrLabelProxy "runs"
layoutLine_runs = AttrLabelProxy
getLayoutLineIsParagraphStart :: MonadIO m => LayoutLine -> m Word32
getLayoutLineIsParagraphStart s = liftIO $ withManagedPtr s $ \ptr -> do
val <- peek (ptr `plusPtr` 24) :: IO Word32
return val
setLayoutLineIsParagraphStart :: MonadIO m => LayoutLine -> Word32 -> m ()
setLayoutLineIsParagraphStart s val = liftIO $ withManagedPtr s $ \ptr -> do
poke (ptr `plusPtr` 24) (val :: Word32)
data LayoutLineIsParagraphStartFieldInfo
instance AttrInfo LayoutLineIsParagraphStartFieldInfo where
type AttrAllowedOps LayoutLineIsParagraphStartFieldInfo = '[ 'AttrSet, 'AttrGet]
type AttrSetTypeConstraint LayoutLineIsParagraphStartFieldInfo = (~) Word32
type AttrBaseTypeConstraint LayoutLineIsParagraphStartFieldInfo = (~) LayoutLine
type AttrGetType LayoutLineIsParagraphStartFieldInfo = Word32
type AttrLabel LayoutLineIsParagraphStartFieldInfo = "is_paragraph_start"
type AttrOrigin LayoutLineIsParagraphStartFieldInfo = LayoutLine
attrGet _ = getLayoutLineIsParagraphStart
attrSet _ = setLayoutLineIsParagraphStart
attrConstruct = undefined
attrClear _ = undefined
layoutLine_isParagraphStart :: AttrLabelProxy "isParagraphStart"
layoutLine_isParagraphStart = AttrLabelProxy
getLayoutLineResolvedDir :: MonadIO m => LayoutLine -> m Word32
getLayoutLineResolvedDir s = liftIO $ withManagedPtr s $ \ptr -> do
val <- peek (ptr `plusPtr` 28) :: IO Word32
return val
setLayoutLineResolvedDir :: MonadIO m => LayoutLine -> Word32 -> m ()
setLayoutLineResolvedDir s val = liftIO $ withManagedPtr s $ \ptr -> do
poke (ptr `plusPtr` 28) (val :: Word32)
data LayoutLineResolvedDirFieldInfo
instance AttrInfo LayoutLineResolvedDirFieldInfo where
type AttrAllowedOps LayoutLineResolvedDirFieldInfo = '[ 'AttrSet, 'AttrGet]
type AttrSetTypeConstraint LayoutLineResolvedDirFieldInfo = (~) Word32
type AttrBaseTypeConstraint LayoutLineResolvedDirFieldInfo = (~) LayoutLine
type AttrGetType LayoutLineResolvedDirFieldInfo = Word32
type AttrLabel LayoutLineResolvedDirFieldInfo = "resolved_dir"
type AttrOrigin LayoutLineResolvedDirFieldInfo = LayoutLine
attrGet _ = getLayoutLineResolvedDir
attrSet _ = setLayoutLineResolvedDir
attrConstruct = undefined
attrClear _ = undefined
layoutLine_resolvedDir :: AttrLabelProxy "resolvedDir"
layoutLine_resolvedDir = AttrLabelProxy
instance O.HasAttributeList LayoutLine
type instance O.AttributeList LayoutLine = LayoutLineAttributeList
type LayoutLineAttributeList = ('[ '("layout", LayoutLineLayoutFieldInfo), '("startIndex", LayoutLineStartIndexFieldInfo), '("length", LayoutLineLengthFieldInfo), '("runs", LayoutLineRunsFieldInfo), '("isParagraphStart", LayoutLineIsParagraphStartFieldInfo), '("resolvedDir", LayoutLineResolvedDirFieldInfo)] :: [(Symbol, *)])
foreign import ccall "pango_layout_line_get_extents" pango_layout_line_get_extents ::
Ptr LayoutLine ->
Ptr Pango.Rectangle.Rectangle ->
Ptr Pango.Rectangle.Rectangle ->
IO ()
layoutLineGetExtents ::
(B.CallStack.HasCallStack, MonadIO m) =>
LayoutLine
-> m (Pango.Rectangle.Rectangle,Pango.Rectangle.Rectangle)
layoutLineGetExtents line = liftIO $ do
line' <- unsafeManagedPtrGetPtr line
inkRect <- callocBytes 16 :: IO (Ptr Pango.Rectangle.Rectangle)
logicalRect <- callocBytes 16 :: IO (Ptr Pango.Rectangle.Rectangle)
pango_layout_line_get_extents line' inkRect logicalRect
inkRect' <- (wrapPtr Pango.Rectangle.Rectangle) inkRect
logicalRect' <- (wrapPtr Pango.Rectangle.Rectangle) logicalRect
touchManagedPtr line
return (inkRect', logicalRect')
data LayoutLineGetExtentsMethodInfo
instance (signature ~ (m (Pango.Rectangle.Rectangle,Pango.Rectangle.Rectangle)), MonadIO m) => O.MethodInfo LayoutLineGetExtentsMethodInfo LayoutLine signature where
overloadedMethod _ = layoutLineGetExtents
foreign import ccall "pango_layout_line_get_pixel_extents" pango_layout_line_get_pixel_extents ::
Ptr LayoutLine ->
Ptr Pango.Rectangle.Rectangle ->
Ptr Pango.Rectangle.Rectangle ->
IO ()
layoutLineGetPixelExtents ::
(B.CallStack.HasCallStack, MonadIO m) =>
LayoutLine
-> m (Pango.Rectangle.Rectangle,Pango.Rectangle.Rectangle)
layoutLineGetPixelExtents layoutLine = liftIO $ do
layoutLine' <- unsafeManagedPtrGetPtr layoutLine
inkRect <- callocBytes 16 :: IO (Ptr Pango.Rectangle.Rectangle)
logicalRect <- callocBytes 16 :: IO (Ptr Pango.Rectangle.Rectangle)
pango_layout_line_get_pixel_extents layoutLine' inkRect logicalRect
inkRect' <- (wrapPtr Pango.Rectangle.Rectangle) inkRect
logicalRect' <- (wrapPtr Pango.Rectangle.Rectangle) logicalRect
touchManagedPtr layoutLine
return (inkRect', logicalRect')
data LayoutLineGetPixelExtentsMethodInfo
instance (signature ~ (m (Pango.Rectangle.Rectangle,Pango.Rectangle.Rectangle)), MonadIO m) => O.MethodInfo LayoutLineGetPixelExtentsMethodInfo LayoutLine signature where
overloadedMethod _ = layoutLineGetPixelExtents
foreign import ccall "pango_layout_line_get_x_ranges" pango_layout_line_get_x_ranges ::
Ptr LayoutLine ->
Int32 ->
Int32 ->
Ptr (Ptr Int32) ->
Ptr Int32 ->
IO ()
layoutLineGetXRanges ::
(B.CallStack.HasCallStack, MonadIO m) =>
LayoutLine
-> Int32
-> Int32
-> m ([Int32])
layoutLineGetXRanges line startIndex endIndex = liftIO $ do
line' <- unsafeManagedPtrGetPtr line
ranges <- allocMem :: IO (Ptr (Ptr Int32))
nRanges <- allocMem :: IO (Ptr Int32)
pango_layout_line_get_x_ranges line' startIndex endIndex ranges nRanges
nRanges' <- peek nRanges
ranges' <- peek ranges
ranges'' <- (unpackStorableArrayWithLength nRanges') ranges'
freeMem ranges'
touchManagedPtr line
freeMem ranges
freeMem nRanges
return ranges''
data LayoutLineGetXRangesMethodInfo
instance (signature ~ (Int32 -> Int32 -> m ([Int32])), MonadIO m) => O.MethodInfo LayoutLineGetXRangesMethodInfo LayoutLine signature where
overloadedMethod _ = layoutLineGetXRanges
foreign import ccall "pango_layout_line_index_to_x" pango_layout_line_index_to_x ::
Ptr LayoutLine ->
Int32 ->
CInt ->
Ptr Int32 ->
IO ()
layoutLineIndexToX ::
(B.CallStack.HasCallStack, MonadIO m) =>
LayoutLine
-> Int32
-> Bool
-> m (Int32)
layoutLineIndexToX line index_ trailing = liftIO $ do
line' <- unsafeManagedPtrGetPtr line
let trailing' = (fromIntegral . fromEnum) trailing
xPos <- allocMem :: IO (Ptr Int32)
pango_layout_line_index_to_x line' index_ trailing' xPos
xPos' <- peek xPos
touchManagedPtr line
freeMem xPos
return xPos'
data LayoutLineIndexToXMethodInfo
instance (signature ~ (Int32 -> Bool -> m (Int32)), MonadIO m) => O.MethodInfo LayoutLineIndexToXMethodInfo LayoutLine signature where
overloadedMethod _ = layoutLineIndexToX
foreign import ccall "pango_layout_line_ref" pango_layout_line_ref ::
Ptr LayoutLine ->
IO (Ptr LayoutLine)
layoutLineRef ::
(B.CallStack.HasCallStack, MonadIO m) =>
LayoutLine
-> m LayoutLine
layoutLineRef line = liftIO $ do
line' <- unsafeManagedPtrGetPtr line
result <- pango_layout_line_ref line'
checkUnexpectedReturnNULL "layoutLineRef" result
result' <- (wrapBoxed LayoutLine) result
touchManagedPtr line
return result'
data LayoutLineRefMethodInfo
instance (signature ~ (m LayoutLine), MonadIO m) => O.MethodInfo LayoutLineRefMethodInfo LayoutLine signature where
overloadedMethod _ = layoutLineRef
foreign import ccall "pango_layout_line_unref" pango_layout_line_unref ::
Ptr LayoutLine ->
IO ()
layoutLineUnref ::
(B.CallStack.HasCallStack, MonadIO m) =>
LayoutLine
-> m ()
layoutLineUnref line = liftIO $ do
line' <- unsafeManagedPtrGetPtr line
pango_layout_line_unref line'
touchManagedPtr line
return ()
data LayoutLineUnrefMethodInfo
instance (signature ~ (m ()), MonadIO m) => O.MethodInfo LayoutLineUnrefMethodInfo LayoutLine signature where
overloadedMethod _ = layoutLineUnref
foreign import ccall "pango_layout_line_x_to_index" pango_layout_line_x_to_index ::
Ptr LayoutLine ->
Int32 ->
Ptr Int32 ->
Ptr Int32 ->
IO CInt
layoutLineXToIndex ::
(B.CallStack.HasCallStack, MonadIO m) =>
LayoutLine
-> Int32
-> m (Bool,Int32,Int32)
layoutLineXToIndex line xPos = liftIO $ do
line' <- unsafeManagedPtrGetPtr line
index_ <- allocMem :: IO (Ptr Int32)
trailing <- allocMem :: IO (Ptr Int32)
result <- pango_layout_line_x_to_index line' xPos index_ trailing
let result' = (/= 0) result
index_' <- peek index_
trailing' <- peek trailing
touchManagedPtr line
freeMem index_
freeMem trailing
return (result', index_', trailing')
data LayoutLineXToIndexMethodInfo
instance (signature ~ (Int32 -> m (Bool,Int32,Int32)), MonadIO m) => O.MethodInfo LayoutLineXToIndexMethodInfo LayoutLine signature where
overloadedMethod _ = layoutLineXToIndex
type family ResolveLayoutLineMethod (t :: Symbol) (o :: *) :: * where
ResolveLayoutLineMethod "indexToX" o = LayoutLineIndexToXMethodInfo
ResolveLayoutLineMethod "ref" o = LayoutLineRefMethodInfo
ResolveLayoutLineMethod "unref" o = LayoutLineUnrefMethodInfo
ResolveLayoutLineMethod "xToIndex" o = LayoutLineXToIndexMethodInfo
ResolveLayoutLineMethod "getExtents" o = LayoutLineGetExtentsMethodInfo
ResolveLayoutLineMethod "getPixelExtents" o = LayoutLineGetPixelExtentsMethodInfo
ResolveLayoutLineMethod "getXRanges" o = LayoutLineGetXRangesMethodInfo
ResolveLayoutLineMethod l o = O.MethodResolutionFailed l o
instance (info ~ ResolveLayoutLineMethod t LayoutLine, O.MethodInfo info LayoutLine p) => O.IsLabelProxy t (LayoutLine -> p) where
fromLabelProxy _ = O.overloadedMethod (O.MethodProxy :: O.MethodProxy info)
#if MIN_VERSION_base(4,9,0)
instance (info ~ ResolveLayoutLineMethod t LayoutLine, O.MethodInfo info LayoutLine p) => O.IsLabel t (LayoutLine -> p) where
fromLabel _ = O.overloadedMethod (O.MethodProxy :: O.MethodProxy info)
#endif