{-# LANGUAGE OverloadedStrings #-}
{-# LINE 2 "./Graphics/Rendering/Pango/Layout.chs" #-}
module Graphics.Rendering.Pango.Layout (
PangoRectangle(..),
PangoLayout,
layoutEmpty,
layoutText,
layoutCopy,
layoutGetContext,
layoutContextChanged,
layoutSetText,
layoutGetText,
layoutSetMarkup,
escapeMarkup,
layoutSetMarkupWithAccel,
layoutSetAttributes,
layoutGetAttributes,
layoutSetFontDescription,
layoutGetFontDescription,
layoutSetWidth,
layoutGetWidth,
LayoutWrapMode(..),
layoutSetWrap,
layoutGetWrap,
EllipsizeMode(..),
layoutSetEllipsize,
layoutGetEllipsize,
layoutSetIndent,
layoutGetIndent,
layoutSetSpacing,
layoutGetSpacing,
layoutSetJustify,
layoutGetJustify,
layoutSetAutoDir,
layoutGetAutoDir,
LayoutAlignment(..),
layoutSetAlignment,
layoutGetAlignment,
TabAlign,
TabPosition,
layoutSetTabs,
layoutResetTabs,
layoutGetTabs,
layoutSetSingleParagraphMode,
layoutGetSingleParagraphMode,
layoutXYToIndex,
layoutIndexToPos,
layoutGetCursorPos,
CursorPos(..),
layoutMoveCursorVisually,
layoutGetExtents,
layoutGetPixelExtents,
layoutGetLineCount,
layoutGetLine,
layoutGetLines,
LayoutIter,
layoutGetIter,
layoutIterNextItem,
layoutIterNextChar,
layoutIterNextCluster,
layoutIterNextLine,
layoutIterAtLastLine,
layoutIterGetIndex,
layoutIterGetBaseline,
layoutIterGetItem,
layoutIterGetLine,
layoutIterGetCharExtents,
layoutIterGetClusterExtents,
layoutIterGetRunExtents,
layoutIterGetLineYRange,
layoutIterGetLineExtents,
LayoutLine,
layoutLineGetExtents,
layoutLineGetPixelExtents,
layoutLineIndexToX,
layoutLineXToIndex,
layoutLineGetXRanges
) where
import Control.Monad (liftM)
import Data.Char (ord, chr)
import Data.Text (Text)
import System.Glib.FFI
import System.Glib.UTFString
import System.Glib.GList (readGSList)
import System.Glib.GObject (wrapNewGObject, makeNewGObject)
import Graphics.Rendering.Pango.Structs
import Graphics.Rendering.Pango.BasicTypes
{-# LINE 133 "./Graphics/Rendering/Pango/Layout.chs" #-}
import Graphics.Rendering.Pango.Types
import Graphics.Rendering.Pango.Enums (EllipsizeMode(..))
import Graphics.Rendering.Pango.Rendering
import Graphics.Rendering.Pango.Attributes ( withAttrList, fromAttrList)
import Data.IORef
import Control.Exception (throwIO, ArrayException(IndexOutOfBounds))
{-# LINE 143 "./Graphics/Rendering/Pango/Layout.chs" #-}
layoutEmpty :: PangoContext -> IO PangoLayout
layoutEmpty pc = do
pl <- wrapNewGObject mkPangoLayoutRaw
((\(PangoContext arg1) -> withForeignPtr arg1 $ \argPtr1 ->pango_layout_new argPtr1) (toPangoContext pc))
ps <- makeNewPangoString ("" :: Text)
psRef <- newIORef ps
return (PangoLayout psRef pl)
layoutText :: GlibString string => PangoContext -> string -> IO PangoLayout
layoutText pc txt = do
pl <- wrapNewGObject mkPangoLayoutRaw
((\(PangoContext arg1) -> withForeignPtr arg1 $ \argPtr1 ->pango_layout_new argPtr1) (toPangoContext pc))
withUTFStringLen txt $ \(strPtr,len) ->
(\(PangoLayoutRaw arg1) arg2 arg3 -> withForeignPtr arg1 $ \argPtr1 ->pango_layout_set_text argPtr1 arg2 arg3) pl strPtr (fromIntegral len)
ps <- makeNewPangoString txt
psRef <- newIORef ps
return (PangoLayout psRef pl)
layoutCopy :: PangoLayout -> IO PangoLayout
layoutCopy (PangoLayout uc pl) = do
pl <- wrapNewGObject mkPangoLayoutRaw
((\(PangoLayoutRaw arg1) -> withForeignPtr arg1 $ \argPtr1 ->pango_layout_copy argPtr1) pl)
return (PangoLayout uc pl)
layoutGetContext :: PangoLayout -> IO PangoContext
layoutGetContext (PangoLayout _ pl) = makeNewGObject mkPangoContext $ do
(\(PangoLayoutRaw arg1) -> withForeignPtr arg1 $ \argPtr1 ->pango_layout_get_context argPtr1) pl
layoutContextChanged :: PangoLayout -> IO ()
layoutContextChanged (PangoLayout _ pl) =
(\(PangoLayoutRaw arg1) -> withForeignPtr arg1 $ \argPtr1 ->pango_layout_context_changed argPtr1) pl
layoutSetText :: GlibString string => PangoLayout -> string -> IO ()
layoutSetText (PangoLayout psRef pl) txt = do
withUTFStringLen txt $ \(strPtr,len) ->
(\(PangoLayoutRaw arg1) arg2 arg3 -> withForeignPtr arg1 $ \argPtr1 ->pango_layout_set_text argPtr1 arg2 arg3) pl strPtr (fromIntegral len)
ps <- makeNewPangoString txt
writeIORef psRef ps
layoutGetText :: GlibString string => PangoLayout -> IO string
layoutGetText (PangoLayout _ pl) =
(\(PangoLayoutRaw arg1) -> withForeignPtr arg1 $ \argPtr1 ->pango_layout_get_text argPtr1) pl >>= peekUTFString
layoutSetMarkup :: (GlibString markup, GlibString string)
=> PangoLayout -> markup -> IO string
layoutSetMarkup pl@(PangoLayout psRef plr) txt = do
withUTFStringLen txt $ \(strPtr,len) ->
(\(PangoLayoutRaw arg1) arg2 arg3 -> withForeignPtr arg1 $ \argPtr1 ->pango_layout_set_markup argPtr1 arg2 arg3) plr strPtr (fromIntegral len)
txt' <- layoutGetText pl
ps <- makeNewPangoString txt'
writeIORef psRef ps
return txt'
escapeMarkup :: GlibString string => string -> string
escapeMarkup str = unsafePerformIO $ withUTFStringLen str $ \(strPtr,l) -> do
resPtr <- g_markup_escape_text strPtr (fromIntegral l)
res <- peekUTFString resPtr
g_free (castPtr resPtr)
return res
layoutSetMarkupWithAccel :: (GlibString markup, GlibString string)
=> PangoLayout -> markup -> IO (Char, string)
layoutSetMarkupWithAccel pl@(PangoLayout psRef plr) txt = do
modif <- alloca $ \chrPtr ->
withUTFStringLen txt $ \(strPtr,len) -> do
(\(PangoLayoutRaw arg1) arg2 arg3 arg4 arg5 -> withForeignPtr arg1 $ \argPtr1 ->pango_layout_set_markup_with_accel argPtr1 arg2 arg3 arg4 arg5) plr strPtr
(fromIntegral len) (fromIntegral (ord '_')) chrPtr
liftM (chr.fromIntegral) $ peek chrPtr
txt' <- layoutGetText pl
ps <- makeNewPangoString txt'
writeIORef psRef ps
return (modif, txt')
layoutSetAttributes :: PangoLayout -> [PangoAttribute] -> IO ()
layoutSetAttributes (PangoLayout psRef plr) attrs = do
ps <- readIORef psRef
withAttrList ps attrs $ \alPtr ->
(\(PangoLayoutRaw arg1) arg2 -> withForeignPtr arg1 $ \argPtr1 ->pango_layout_set_attributes argPtr1 arg2) plr alPtr
layoutGetAttributes :: PangoLayout -> IO [[PangoAttribute]]
layoutGetAttributes (PangoLayout psRef plr) = do
(PangoString correct _ _) <- readIORef psRef
attrListPtr <- (\(PangoLayoutRaw arg1) -> withForeignPtr arg1 $ \argPtr1 ->pango_layout_get_attributes argPtr1) plr
fromAttrList correct attrListPtr
layoutSetFontDescription :: PangoLayout -> Maybe FontDescription -> IO ()
layoutSetFontDescription (PangoLayout _ plr) (Just fd) =
(\(PangoLayoutRaw arg1) (FontDescription arg2) -> withForeignPtr arg1 $ \argPtr1 ->withForeignPtr arg2 $ \argPtr2 ->pango_layout_set_font_description argPtr1 argPtr2) plr fd
layoutSetFontDescription (PangoLayout _ (PangoLayoutRaw plr)) Nothing =
withForeignPtr plr $ \plrPtr ->
pango_layout_set_font_description plrPtr nullPtr
layoutGetFontDescription :: PangoLayout -> IO (Maybe FontDescription)
layoutGetFontDescription (PangoLayout _ plr) = do
fdPtr <- (\(PangoLayoutRaw arg1) -> withForeignPtr arg1 $ \argPtr1 ->pango_layout_get_font_description argPtr1) plr
if fdPtr==nullPtr then return Nothing else liftM Just $ do
fdPtr' <- font_description_copy fdPtr
makeNewFontDescription fdPtr'
foreign import ccall unsafe "pango_font_description_copy"
font_description_copy :: Ptr FontDescription -> IO (Ptr FontDescription)
layoutSetWidth :: PangoLayout -> Maybe Double -> IO ()
layoutSetWidth (PangoLayout _ pl) Nothing =
(\(PangoLayoutRaw arg1) arg2 -> withForeignPtr arg1 $ \argPtr1 ->pango_layout_set_width argPtr1 arg2) pl (-1)
layoutSetWidth (PangoLayout _ pl) (Just pu) =
(\(PangoLayoutRaw arg1) arg2 -> withForeignPtr arg1 $ \argPtr1 ->pango_layout_set_width argPtr1 arg2) pl (puToInt pu)
layoutGetWidth :: PangoLayout -> IO (Maybe Double)
layoutGetWidth (PangoLayout _ pl) = do
w <- (\(PangoLayoutRaw arg1) -> withForeignPtr arg1 $ \argPtr1 ->pango_layout_get_width argPtr1) pl
return (if w==(-1) then Nothing else Just (intToPu w))
data LayoutWrapMode = WrapWholeWords
| WrapAnywhere
| WrapPartialWords
deriving (Enum)
{-# LINE 364 "./Graphics/Rendering/Pango/Layout.chs" #-}
layoutSetWrap :: PangoLayout -> LayoutWrapMode -> IO ()
layoutSetWrap (PangoLayout _ pl) wm =
(\(PangoLayoutRaw arg1) arg2 -> withForeignPtr arg1 $ \argPtr1 ->pango_layout_set_wrap argPtr1 arg2) pl ((fromIntegral.fromEnum) wm)
layoutGetWrap :: PangoLayout -> IO LayoutWrapMode
layoutGetWrap (PangoLayout _ pl) = liftM (toEnum.fromIntegral) $
(\(PangoLayoutRaw arg1) -> withForeignPtr arg1 $ \argPtr1 ->pango_layout_get_wrap argPtr1) pl
layoutSetEllipsize :: PangoLayout -> EllipsizeMode -> IO ()
layoutSetEllipsize (PangoLayout _ pl) em =
(\(PangoLayoutRaw arg1) arg2 -> withForeignPtr arg1 $ \argPtr1 ->pango_layout_set_ellipsize argPtr1 arg2) pl ((fromIntegral.fromEnum) em)
layoutGetEllipsize :: PangoLayout -> IO EllipsizeMode
layoutGetEllipsize (PangoLayout _ pl) = liftM (toEnum.fromIntegral) $
(\(PangoLayoutRaw arg1) -> withForeignPtr arg1 $ \argPtr1 ->pango_layout_get_ellipsize argPtr1) pl
layoutSetIndent :: PangoLayout -> Double -> IO ()
layoutSetIndent (PangoLayout _ pl) indent =
(\(PangoLayoutRaw arg1) arg2 -> withForeignPtr arg1 $ \argPtr1 ->pango_layout_set_indent argPtr1 arg2) pl (puToInt indent)
layoutGetIndent :: PangoLayout -> IO Double
layoutGetIndent (PangoLayout _ pl) =
liftM intToPu $ (\(PangoLayoutRaw arg1) -> withForeignPtr arg1 $ \argPtr1 ->pango_layout_get_indent argPtr1) pl
layoutSetSpacing :: PangoLayout -> Double -> IO ()
layoutSetSpacing (PangoLayout _ pl) spacing =
(\(PangoLayoutRaw arg1) arg2 -> withForeignPtr arg1 $ \argPtr1 ->pango_layout_set_spacing argPtr1 arg2) pl (puToInt spacing)
layoutGetSpacing :: PangoLayout -> IO Double
layoutGetSpacing (PangoLayout _ pl) =
liftM intToPu $ (\(PangoLayoutRaw arg1) -> withForeignPtr arg1 $ \argPtr1 ->pango_layout_get_spacing argPtr1) pl
layoutSetJustify :: PangoLayout -> Bool -> IO ()
layoutSetJustify (PangoLayout _ pl) j =
(\(PangoLayoutRaw arg1) arg2 -> withForeignPtr arg1 $ \argPtr1 ->pango_layout_set_justify argPtr1 arg2) pl (fromBool j)
layoutGetJustify :: PangoLayout -> IO Bool
layoutGetJustify (PangoLayout _ pl) =
liftM toBool $ (\(PangoLayoutRaw arg1) -> withForeignPtr arg1 $ \argPtr1 ->pango_layout_get_justify argPtr1) pl
layoutSetAutoDir :: PangoLayout -> Bool -> IO ()
layoutSetAutoDir (PangoLayout _ pl) j =
(\(PangoLayoutRaw arg1) arg2 -> withForeignPtr arg1 $ \argPtr1 ->pango_layout_set_auto_dir argPtr1 arg2) pl (fromBool j)
layoutGetAutoDir :: PangoLayout -> IO Bool
layoutGetAutoDir (PangoLayout _ pl) =
liftM toBool $ (\(PangoLayoutRaw arg1) -> withForeignPtr arg1 $ \argPtr1 ->pango_layout_get_auto_dir argPtr1) pl
data LayoutAlignment = AlignLeft
| AlignCenter
| AlignRight
deriving (Enum)
{-# LINE 486 "./Graphics/Rendering/Pango/Layout.chs" #-}
layoutSetAlignment :: PangoLayout -> LayoutAlignment -> IO ()
layoutSetAlignment (PangoLayout _ pl) am =
(\(PangoLayoutRaw arg1) arg2 -> withForeignPtr arg1 $ \argPtr1 ->pango_layout_set_alignment argPtr1 arg2) pl ((fromIntegral.fromEnum) am)
layoutGetAlignment :: PangoLayout -> IO LayoutAlignment
layoutGetAlignment (PangoLayout _ pl) = liftM (toEnum.fromIntegral) $
(\(PangoLayoutRaw arg1) -> withForeignPtr arg1 $ \argPtr1 ->pango_layout_get_alignment argPtr1) pl
data TabAlign = TabLeft
deriving (Enum)
{-# LINE 508 "./Graphics/Rendering/Pango/Layout.chs" #-}
type TabPosition = (Double, TabAlign)
layoutSetTabs :: PangoLayout -> [TabPosition] -> IO ()
layoutSetTabs (PangoLayout _ pl) tabs = do
let len = fromIntegral (length tabs)
tabPtr <- pango_tab_array_new len (fromBool False)
mapM_ (\(idx, (pos, align)) ->
pango_tab_array_set_tab tabPtr idx
(fromIntegral (fromEnum align)) (puToInt pos)) (zip [0..] tabs)
(\(PangoLayoutRaw arg1) arg2 -> withForeignPtr arg1 $ \argPtr1 ->pango_layout_set_tabs argPtr1 arg2) pl tabPtr
pango_tab_array_free tabPtr
layoutResetTabs :: PangoLayout -> IO ()
layoutResetTabs (PangoLayout _ pl) = (\(PangoLayoutRaw arg1) arg2 -> withForeignPtr arg1 $ \argPtr1 ->pango_layout_set_tabs argPtr1 arg2) pl nullPtr
layoutGetTabs :: PangoLayout -> IO (Maybe [TabPosition])
layoutGetTabs (PangoLayout _ pl) = do
tabPtr <- (\(PangoLayoutRaw arg1) -> withForeignPtr arg1 $ \argPtr1 ->pango_layout_get_tabs argPtr1) pl
if tabPtr == nullPtr then return Nothing else liftM Just $ do
len <- pango_tab_array_get_size tabPtr
mapM (\idx -> alloca $ \posPtr -> alloca $ \alignPtr -> do
pango_tab_array_get_tab tabPtr idx alignPtr posPtr
align <- peek alignPtr
pos <- peek posPtr
return (intToPu pos, toEnum (fromIntegral align))) [0..len-1]
layoutSetSingleParagraphMode :: PangoLayout -> Bool -> IO ()
layoutSetSingleParagraphMode (PangoLayout _ pl) honor =
(\(PangoLayoutRaw arg1) arg2 -> withForeignPtr arg1 $ \argPtr1 ->pango_layout_set_single_paragraph_mode argPtr1 arg2) pl (fromBool honor)
layoutGetSingleParagraphMode :: PangoLayout -> IO Bool
layoutGetSingleParagraphMode (PangoLayout _ pl) =
liftM toBool $ (\(PangoLayoutRaw arg1) -> withForeignPtr arg1 $ \argPtr1 ->pango_layout_get_single_paragraph_mode argPtr1) pl
layoutXYToIndex :: PangoLayout -> Double
-> Double
-> IO (Bool, Int, Int)
layoutXYToIndex (PangoLayout psRef pl) x y =
alloca $ \idxPtr -> alloca $ \trailPtr -> do
res <- (\(PangoLayoutRaw arg1) arg2 arg3 arg4 arg5 -> withForeignPtr arg1 $ \argPtr1 ->pango_layout_xy_to_index argPtr1 arg2 arg3 arg4 arg5) pl (puToInt x) (puToInt y)
idxPtr trailPtr
idx <- peek idxPtr
trail <- peek trailPtr
(PangoString uc _ _) <- readIORef psRef
return (toBool res,
ofsFromUTF (fromIntegral idx) uc,
ofsFromUTF (fromIntegral trail) uc)
layoutIndexToPos :: PangoLayout -> Int -> IO PangoRectangle
layoutIndexToPos (PangoLayout psRef plr) pos = do
(PangoString uc _ _) <- readIORef psRef
alloca $ \rectPtr -> do
(\(PangoLayoutRaw arg1) arg2 arg3 -> withForeignPtr arg1 $ \argPtr1 ->pango_layout_index_to_pos argPtr1 arg2 arg3) plr (fromIntegral (ofsToUTF pos uc))
(castPtr rectPtr)
peek rectPtr
twoRect :: (Ptr () -> Ptr () -> IO ()) ->
IO (PangoRectangle, PangoRectangle)
twoRect f =
alloca $ \inkPtr -> alloca $ \logPtr -> do
f (castPtr inkPtr) (castPtr logPtr)
ink <- peek inkPtr
log <- peek logPtr
return (ink, log)
layoutGetCursorPos :: PangoLayout -> Int ->
IO (PangoRectangle, PangoRectangle)
layoutGetCursorPos (PangoLayout psRef plr) pos = do
(PangoString uc _ _) <- readIORef psRef
twoRect $ (\(PangoLayoutRaw arg1) arg2 arg3 arg4 -> withForeignPtr arg1 $ \argPtr1 ->pango_layout_get_cursor_pos argPtr1 arg2 arg3 arg4) plr (fromIntegral (ofsToUTF pos uc))
data CursorPos
= CursorPosPrevPara
| CursorPos Int Int
| CursorPosNextPara
layoutMoveCursorVisually :: PangoLayout
-> Bool
-> Int
-> Bool
-> IO CursorPos
layoutMoveCursorVisually (PangoLayout psRef plr) strong index dir = do
(PangoString uc _ _) <- readIORef psRef
alloca $ \idxPtr -> alloca $ \trailPtr -> do
(\(PangoLayoutRaw arg1) arg2 arg3 arg4 arg5 arg6 arg7 -> withForeignPtr arg1 $ \argPtr1 ->pango_layout_move_cursor_visually argPtr1 arg2 arg3 arg4 arg5 arg6 arg7) plr (fromBool strong)
(fromIntegral (ofsToUTF index uc)) 0
(if dir then 1 else (-1)) idxPtr trailPtr
idx <- peek idxPtr
trail <- peek trailPtr
return (if idx==(-1) then CursorPosPrevPara else
if idx==maxBound then CursorPosNextPara else
CursorPos (ofsFromUTF (fromIntegral idx) uc) (fromIntegral trail))
layoutGetExtents :: PangoLayout
-> IO (PangoRectangle, PangoRectangle)
layoutGetExtents (PangoLayout _ pl) =
twoRect $ (\(PangoLayoutRaw arg1) arg2 arg3 -> withForeignPtr arg1 $ \argPtr1 ->pango_layout_get_extents argPtr1 arg2 arg3) pl
layoutGetPixelExtents :: PangoLayout -> IO (Rectangle, Rectangle)
layoutGetPixelExtents (PangoLayout _ pl) =
alloca $ \inkPtr -> alloca $ \logPtr -> do
(\(PangoLayoutRaw arg1) arg2 arg3 -> withForeignPtr arg1 $ \argPtr1 ->pango_layout_get_pixel_extents argPtr1 arg2 arg3) pl (castPtr inkPtr) (castPtr logPtr)
ink <- peekIntPangoRectangle inkPtr
log <- peekIntPangoRectangle logPtr
return (ink,log)
layoutGetLineCount :: PangoLayout -> IO Int
layoutGetLineCount (PangoLayout _ pl) = liftM fromIntegral $
(\(PangoLayoutRaw arg1) -> withForeignPtr arg1 $ \argPtr1 ->pango_layout_get_line_count argPtr1) pl
layoutGetLine :: PangoLayout -> Int -> IO LayoutLine
layoutGetLine (PangoLayout psRef pl) idx = do
llPtr <-
(\(PangoLayoutRaw arg1) arg2 -> withForeignPtr arg1 $ \argPtr1 ->pango_layout_get_line_readonly argPtr1 arg2)
{-# LINE 747 "./Graphics/Rendering/Pango/Layout.chs" #-}
pl (fromIntegral idx)
if llPtr==nullPtr then
throwIO (IndexOutOfBounds
("Graphics.Rendering.Pango.Layout.layoutGetLine: "++
"no line at index "++show idx)) else do
ll <- makeNewLayoutLineRaw llPtr
(\(LayoutLineRaw arg1) -> withForeignPtr arg1 $ \argPtr1 ->pango_layout_line_ref argPtr1) ll
return (LayoutLine psRef ll)
layoutGetLines :: PangoLayout -> IO [LayoutLine]
layoutGetLines (PangoLayout psRef pl) = do
listPtr <-
(\(PangoLayoutRaw arg1) -> withForeignPtr arg1 $ \argPtr1 ->pango_layout_get_lines_readonly argPtr1)
{-# LINE 771 "./Graphics/Rendering/Pango/Layout.chs" #-}
pl
list <- readGSList listPtr
pls <- mapM makeNewLayoutLineRaw list
mapM_ (\(LayoutLineRaw arg1) -> withForeignPtr arg1 $ \argPtr1 ->pango_layout_line_ref argPtr1) pls
return (map (LayoutLine psRef) pls)
layoutGetIter :: PangoLayout -> IO LayoutIter
layoutGetIter (PangoLayout psRef pl) = do
iterPtr <- (\(PangoLayoutRaw arg1) -> withForeignPtr arg1 $ \argPtr1 ->pango_layout_get_iter argPtr1) pl
liftM (LayoutIter psRef) $ makeNewLayoutIterRaw iterPtr
layoutIterNextItem :: LayoutIter -> IO Bool
layoutIterNextItem (LayoutIter _ li) =
liftM toBool $ (\(LayoutIterRaw arg1) -> withForeignPtr arg1 $ \argPtr1 ->pango_layout_iter_next_run argPtr1) li
layoutIterNextChar :: LayoutIter -> IO Bool
layoutIterNextChar (LayoutIter _ li) =
liftM toBool $ (\(LayoutIterRaw arg1) -> withForeignPtr arg1 $ \argPtr1 ->pango_layout_iter_next_char argPtr1) li
layoutIterNextCluster :: LayoutIter -> IO Bool
layoutIterNextCluster (LayoutIter _ li) =
liftM toBool $ (\(LayoutIterRaw arg1) -> withForeignPtr arg1 $ \argPtr1 ->pango_layout_iter_next_cluster argPtr1) li
layoutIterNextLine :: LayoutIter -> IO Bool
layoutIterNextLine (LayoutIter _ li) =
liftM toBool $ (\(LayoutIterRaw arg1) -> withForeignPtr arg1 $ \argPtr1 ->pango_layout_iter_next_line argPtr1) li
layoutIterAtLastLine :: LayoutIter -> IO Bool
layoutIterAtLastLine (LayoutIter _ li) =
liftM toBool $ (\(LayoutIterRaw arg1) -> withForeignPtr arg1 $ \argPtr1 ->pango_layout_iter_at_last_line argPtr1) li
layoutIterGetIndex :: LayoutIter -> IO Int
layoutIterGetIndex (LayoutIter psRef li) = do
(PangoString uc _ _) <- readIORef psRef
idx <- (\(LayoutIterRaw arg1) -> withForeignPtr arg1 $ \argPtr1 ->pango_layout_iter_get_index argPtr1) li
return (ofsFromUTF (fromIntegral idx) uc)
layoutIterGetBaseline :: LayoutIter -> IO Double
layoutIterGetBaseline (LayoutIter _ li) =
liftM intToPu $ (\(LayoutIterRaw arg1) -> withForeignPtr arg1 $ \argPtr1 ->pango_layout_iter_get_baseline argPtr1) li
layoutIterGetItem :: LayoutIter -> IO (Maybe GlyphItem)
layoutIterGetItem (LayoutIter psRef li) = do
giPtr <- (\(LayoutIterRaw arg1) -> withForeignPtr arg1 $ \argPtr1 ->pango_layout_iter_get_run argPtr1) li
if giPtr==nullPtr then return Nothing else liftM Just $ do
(PangoString uc _ _) <- readIORef psRef
pirPtr <- (\ptr -> do {peekByteOff ptr 0 ::IO (Ptr PangoItemRaw)}) giPtr
gsrPtr <- (\ptr -> do {peekByteOff ptr 8 ::IO (Ptr GlyphStringRaw)}) giPtr
let dummy = (\(PangoItemRaw arg1) -> withForeignPtr arg1 $ \argPtr1 ->pango_item_copy argPtr1)
{-# LINE 865 "./Graphics/Rendering/Pango/Layout.chs" #-}
let dummy = (\(GlyphStringRaw arg1) -> withForeignPtr arg1 $ \argPtr1 ->pango_glyph_string_copy argPtr1)
{-# LINE 866 "./Graphics/Rendering/Pango/Layout.chs" #-}
pirPtr' <- pango_item_copy pirPtr
gsrPtr' <- pango_glyph_string_copy gsrPtr
pir <- makeNewPangoItemRaw pirPtr'
gsr <- makeNewGlyphStringRaw gsrPtr'
ps <- readIORef psRef
return (GlyphItem (PangoItem ps pir) gsr)
layoutIterGetLine :: LayoutIter -> IO (Maybe LayoutLine)
layoutIterGetLine (LayoutIter psRef li) = do
llPtr <- liftM castPtr $ (\(LayoutIterRaw arg1) -> withForeignPtr arg1 $ \argPtr1 ->pango_layout_iter_get_line argPtr1) li
if (llPtr==nullPtr) then return Nothing else do
ll <- makeNewLayoutLineRaw llPtr
(\(LayoutLineRaw arg1) -> withForeignPtr arg1 $ \argPtr1 ->pango_layout_line_ref argPtr1) ll
return (Just (LayoutLine psRef ll))
layoutIterGetCharExtents :: LayoutIter -> IO PangoRectangle
layoutIterGetCharExtents (LayoutIter _ li) = alloca $ \logPtr ->
(\(LayoutIterRaw arg1) arg2 -> withForeignPtr arg1 $ \argPtr1 ->pango_layout_iter_get_char_extents argPtr1 arg2) li (castPtr logPtr) >>
peek logPtr
layoutIterGetClusterExtents :: LayoutIter -> IO (PangoRectangle, PangoRectangle)
layoutIterGetClusterExtents (LayoutIter _ li) =
twoRect $ (\(LayoutIterRaw arg1) arg2 arg3 -> withForeignPtr arg1 $ \argPtr1 ->pango_layout_iter_get_cluster_extents argPtr1 arg2 arg3) li
layoutIterGetRunExtents :: LayoutIter -> IO (PangoRectangle, PangoRectangle)
layoutIterGetRunExtents (LayoutIter _ li) =
twoRect $ (\(LayoutIterRaw arg1) arg2 arg3 -> withForeignPtr arg1 $ \argPtr1 ->pango_layout_iter_get_run_extents argPtr1 arg2 arg3) li
layoutIterGetLineYRange :: LayoutIter -> IO (Double, Double)
layoutIterGetLineYRange (LayoutIter _ li) =
alloca $ \sPtr -> alloca $ \ePtr -> do
(\(LayoutIterRaw arg1) arg2 arg3 -> withForeignPtr arg1 $ \argPtr1 ->pango_layout_iter_get_line_extents argPtr1 arg2 arg3) li (castPtr sPtr) (castPtr ePtr)
start <- peek sPtr
end <- peek ePtr
return (intToPu start, intToPu end)
layoutIterGetLineExtents :: LayoutIter -> IO (PangoRectangle, PangoRectangle)
layoutIterGetLineExtents (LayoutIter _ li) =
twoRect $ (\(LayoutIterRaw arg1) arg2 arg3 -> withForeignPtr arg1 $ \argPtr1 ->pango_layout_iter_get_line_extents argPtr1 arg2 arg3) li
layoutLineGetExtents :: LayoutLine -> IO (PangoRectangle, PangoRectangle)
layoutLineGetExtents (LayoutLine _ ll) =
twoRect $ (\(LayoutLineRaw arg1) arg2 arg3 -> withForeignPtr arg1 $ \argPtr1 ->pango_layout_line_get_extents argPtr1 arg2 arg3) ll
layoutLineGetPixelExtents :: LayoutLine -> IO (Rectangle, Rectangle)
layoutLineGetPixelExtents (LayoutLine _ ll) =
alloca $ \inkPtr -> alloca $ \logPtr -> do
(\(LayoutLineRaw arg1) arg2 arg3 -> withForeignPtr arg1 $ \argPtr1 ->pango_layout_line_get_pixel_extents argPtr1 arg2 arg3) ll (castPtr inkPtr) (castPtr logPtr)
ink <- peekIntPangoRectangle inkPtr
log <- peekIntPangoRectangle logPtr
return (ink,log)
layoutLineIndexToX :: LayoutLine
-> Int
-> Bool
-> IO Double
layoutLineIndexToX (LayoutLine psRef ll) pos beg =
alloca $ \intPtr -> do
(PangoString uc _ _) <- readIORef psRef
(\(LayoutLineRaw arg1) arg2 arg3 arg4 -> withForeignPtr arg1 $ \argPtr1 ->pango_layout_line_index_to_x argPtr1 arg2 arg3 arg4) ll (fromIntegral (ofsToUTF pos uc))
(fromBool beg) intPtr
liftM intToPu $ peek intPtr
layoutLineXToIndex :: LayoutLine
-> Double
-> IO (Bool, Int, Int)
layoutLineXToIndex (LayoutLine psRef ll) pos =
alloca $ \idxPtr -> alloca $ \trailPtr -> do
(PangoString uc _ _) <- readIORef psRef
inside <- (\(LayoutLineRaw arg1) arg2 arg3 arg4 -> withForeignPtr arg1 $ \argPtr1 ->pango_layout_line_x_to_index argPtr1 arg2 arg3 arg4) ll
(puToInt pos) idxPtr trailPtr
idx <- peek idxPtr
trail <- peek trailPtr
return (toBool inside, ofsFromUTF (fromIntegral idx) uc,
fromIntegral trail)
layoutLineGetXRanges :: LayoutLine
-> Int
-> Int
-> IO [(Double, Double)]
layoutLineGetXRanges (LayoutLine psRef ll) start end = do
PangoString uc _ _ <- readIORef psRef
alloca $ \arrPtr -> alloca $ \szPtr -> do
(\(LayoutLineRaw arg1) arg2 arg3 arg4 arg5 -> withForeignPtr arg1 $ \argPtr1 ->pango_layout_line_get_x_ranges argPtr1 arg2 arg3 arg4 arg5) ll
(fromIntegral (ofsToUTF start uc))
(fromIntegral (ofsToUTF end uc))
arrPtr szPtr
sz <- peek szPtr
arr <- peek arrPtr
elems <- peekArray (2*fromIntegral sz) (castPtr arr:: Ptr (CInt))
g_free (castPtr arr)
let toRange (s:e:rs) = (intToPu s, intToPu e):toRange rs
toRange [] = []
return (toRange elems)
foreign import ccall unsafe "pango_layout_new"
pango_layout_new :: ((Ptr PangoContext) -> (IO (Ptr PangoLayoutRaw)))
foreign import ccall unsafe "pango_layout_set_text"
pango_layout_set_text :: ((Ptr PangoLayoutRaw) -> ((Ptr CChar) -> (CInt -> (IO ()))))
foreign import ccall unsafe "pango_layout_copy"
pango_layout_copy :: ((Ptr PangoLayoutRaw) -> (IO (Ptr PangoLayoutRaw)))
foreign import ccall unsafe "pango_layout_get_context"
pango_layout_get_context :: ((Ptr PangoLayoutRaw) -> (IO (Ptr PangoContext)))
foreign import ccall unsafe "pango_layout_context_changed"
pango_layout_context_changed :: ((Ptr PangoLayoutRaw) -> (IO ()))
foreign import ccall unsafe "pango_layout_get_text"
pango_layout_get_text :: ((Ptr PangoLayoutRaw) -> (IO (Ptr CChar)))
foreign import ccall unsafe "pango_layout_set_markup"
pango_layout_set_markup :: ((Ptr PangoLayoutRaw) -> ((Ptr CChar) -> (CInt -> (IO ()))))
foreign import ccall unsafe "g_markup_escape_text"
g_markup_escape_text :: ((Ptr CChar) -> (CLong -> (IO (Ptr CChar))))
foreign import ccall unsafe "g_free"
g_free :: ((Ptr ()) -> (IO ()))
foreign import ccall unsafe "pango_layout_set_markup_with_accel"
pango_layout_set_markup_with_accel :: ((Ptr PangoLayoutRaw) -> ((Ptr CChar) -> (CInt -> (CUInt -> ((Ptr CUInt) -> (IO ()))))))
foreign import ccall unsafe "pango_layout_set_attributes"
pango_layout_set_attributes :: ((Ptr PangoLayoutRaw) -> ((Ptr ()) -> (IO ())))
foreign import ccall unsafe "pango_layout_get_attributes"
pango_layout_get_attributes :: ((Ptr PangoLayoutRaw) -> (IO (Ptr ())))
foreign import ccall unsafe "pango_layout_set_font_description"
pango_layout_set_font_description :: ((Ptr PangoLayoutRaw) -> ((Ptr FontDescription) -> (IO ())))
foreign import ccall unsafe "pango_layout_get_font_description"
pango_layout_get_font_description :: ((Ptr PangoLayoutRaw) -> (IO (Ptr FontDescription)))
foreign import ccall unsafe "pango_layout_set_width"
pango_layout_set_width :: ((Ptr PangoLayoutRaw) -> (CInt -> (IO ())))
foreign import ccall unsafe "pango_layout_get_width"
pango_layout_get_width :: ((Ptr PangoLayoutRaw) -> (IO CInt))
foreign import ccall unsafe "pango_layout_set_wrap"
pango_layout_set_wrap :: ((Ptr PangoLayoutRaw) -> (CInt -> (IO ())))
foreign import ccall unsafe "pango_layout_get_wrap"
pango_layout_get_wrap :: ((Ptr PangoLayoutRaw) -> (IO CInt))
foreign import ccall unsafe "pango_layout_set_ellipsize"
pango_layout_set_ellipsize :: ((Ptr PangoLayoutRaw) -> (CInt -> (IO ())))
foreign import ccall unsafe "pango_layout_get_ellipsize"
pango_layout_get_ellipsize :: ((Ptr PangoLayoutRaw) -> (IO CInt))
foreign import ccall unsafe "pango_layout_set_indent"
pango_layout_set_indent :: ((Ptr PangoLayoutRaw) -> (CInt -> (IO ())))
foreign import ccall unsafe "pango_layout_get_indent"
pango_layout_get_indent :: ((Ptr PangoLayoutRaw) -> (IO CInt))
foreign import ccall unsafe "pango_layout_set_spacing"
pango_layout_set_spacing :: ((Ptr PangoLayoutRaw) -> (CInt -> (IO ())))
foreign import ccall unsafe "pango_layout_get_spacing"
pango_layout_get_spacing :: ((Ptr PangoLayoutRaw) -> (IO CInt))
foreign import ccall unsafe "pango_layout_set_justify"
pango_layout_set_justify :: ((Ptr PangoLayoutRaw) -> (CInt -> (IO ())))
foreign import ccall unsafe "pango_layout_get_justify"
pango_layout_get_justify :: ((Ptr PangoLayoutRaw) -> (IO CInt))
foreign import ccall unsafe "pango_layout_set_auto_dir"
pango_layout_set_auto_dir :: ((Ptr PangoLayoutRaw) -> (CInt -> (IO ())))
foreign import ccall unsafe "pango_layout_get_auto_dir"
pango_layout_get_auto_dir :: ((Ptr PangoLayoutRaw) -> (IO CInt))
foreign import ccall unsafe "pango_layout_set_alignment"
pango_layout_set_alignment :: ((Ptr PangoLayoutRaw) -> (CInt -> (IO ())))
foreign import ccall unsafe "pango_layout_get_alignment"
pango_layout_get_alignment :: ((Ptr PangoLayoutRaw) -> (IO CInt))
foreign import ccall unsafe "pango_tab_array_new"
pango_tab_array_new :: (CInt -> (CInt -> (IO (Ptr ()))))
foreign import ccall unsafe "pango_tab_array_set_tab"
pango_tab_array_set_tab :: ((Ptr ()) -> (CInt -> (CInt -> (CInt -> (IO ())))))
foreign import ccall unsafe "pango_layout_set_tabs"
pango_layout_set_tabs :: ((Ptr PangoLayoutRaw) -> ((Ptr ()) -> (IO ())))
foreign import ccall unsafe "pango_tab_array_free"
pango_tab_array_free :: ((Ptr ()) -> (IO ()))
foreign import ccall unsafe "pango_layout_get_tabs"
pango_layout_get_tabs :: ((Ptr PangoLayoutRaw) -> (IO (Ptr ())))
foreign import ccall unsafe "pango_tab_array_get_size"
pango_tab_array_get_size :: ((Ptr ()) -> (IO CInt))
foreign import ccall unsafe "pango_tab_array_get_tab"
pango_tab_array_get_tab :: ((Ptr ()) -> (CInt -> ((Ptr CInt) -> ((Ptr CInt) -> (IO ())))))
foreign import ccall unsafe "pango_layout_set_single_paragraph_mode"
pango_layout_set_single_paragraph_mode :: ((Ptr PangoLayoutRaw) -> (CInt -> (IO ())))
foreign import ccall unsafe "pango_layout_get_single_paragraph_mode"
pango_layout_get_single_paragraph_mode :: ((Ptr PangoLayoutRaw) -> (IO CInt))
foreign import ccall unsafe "pango_layout_xy_to_index"
pango_layout_xy_to_index :: ((Ptr PangoLayoutRaw) -> (CInt -> (CInt -> ((Ptr CInt) -> ((Ptr CInt) -> (IO CInt))))))
foreign import ccall unsafe "pango_layout_index_to_pos"
pango_layout_index_to_pos :: ((Ptr PangoLayoutRaw) -> (CInt -> ((Ptr ()) -> (IO ()))))
foreign import ccall unsafe "pango_layout_get_cursor_pos"
pango_layout_get_cursor_pos :: ((Ptr PangoLayoutRaw) -> (CInt -> ((Ptr ()) -> ((Ptr ()) -> (IO ())))))
foreign import ccall unsafe "pango_layout_move_cursor_visually"
pango_layout_move_cursor_visually :: ((Ptr PangoLayoutRaw) -> (CInt -> (CInt -> (CInt -> (CInt -> ((Ptr CInt) -> ((Ptr CInt) -> (IO ()))))))))
foreign import ccall unsafe "pango_layout_get_extents"
pango_layout_get_extents :: ((Ptr PangoLayoutRaw) -> ((Ptr ()) -> ((Ptr ()) -> (IO ()))))
foreign import ccall unsafe "pango_layout_get_pixel_extents"
pango_layout_get_pixel_extents :: ((Ptr PangoLayoutRaw) -> ((Ptr ()) -> ((Ptr ()) -> (IO ()))))
foreign import ccall unsafe "pango_layout_get_line_count"
pango_layout_get_line_count :: ((Ptr PangoLayoutRaw) -> (IO CInt))
foreign import ccall unsafe "pango_layout_get_line_readonly"
pango_layout_get_line_readonly :: ((Ptr PangoLayoutRaw) -> (CInt -> (IO (Ptr LayoutLineRaw))))
foreign import ccall unsafe "pango_layout_line_ref"
pango_layout_line_ref :: ((Ptr LayoutLineRaw) -> (IO (Ptr LayoutLineRaw)))
foreign import ccall unsafe "pango_layout_get_lines_readonly"
pango_layout_get_lines_readonly :: ((Ptr PangoLayoutRaw) -> (IO (Ptr ())))
foreign import ccall unsafe "pango_layout_get_iter"
pango_layout_get_iter :: ((Ptr PangoLayoutRaw) -> (IO (Ptr LayoutIterRaw)))
foreign import ccall unsafe "pango_layout_iter_next_run"
pango_layout_iter_next_run :: ((Ptr LayoutIterRaw) -> (IO CInt))
foreign import ccall unsafe "pango_layout_iter_next_char"
pango_layout_iter_next_char :: ((Ptr LayoutIterRaw) -> (IO CInt))
foreign import ccall unsafe "pango_layout_iter_next_cluster"
pango_layout_iter_next_cluster :: ((Ptr LayoutIterRaw) -> (IO CInt))
foreign import ccall unsafe "pango_layout_iter_next_line"
pango_layout_iter_next_line :: ((Ptr LayoutIterRaw) -> (IO CInt))
foreign import ccall unsafe "pango_layout_iter_at_last_line"
pango_layout_iter_at_last_line :: ((Ptr LayoutIterRaw) -> (IO CInt))
foreign import ccall unsafe "pango_layout_iter_get_index"
pango_layout_iter_get_index :: ((Ptr LayoutIterRaw) -> (IO CInt))
foreign import ccall unsafe "pango_layout_iter_get_baseline"
pango_layout_iter_get_baseline :: ((Ptr LayoutIterRaw) -> (IO CInt))
foreign import ccall unsafe "pango_layout_iter_get_run"
pango_layout_iter_get_run :: ((Ptr LayoutIterRaw) -> (IO (Ptr ())))
foreign import ccall unsafe "pango_item_copy"
pango_item_copy :: ((Ptr PangoItemRaw) -> (IO (Ptr PangoItemRaw)))
foreign import ccall unsafe "pango_glyph_string_copy"
pango_glyph_string_copy :: ((Ptr GlyphStringRaw) -> (IO (Ptr GlyphStringRaw)))
foreign import ccall unsafe "pango_layout_iter_get_line"
pango_layout_iter_get_line :: ((Ptr LayoutIterRaw) -> (IO (Ptr LayoutLineRaw)))
foreign import ccall unsafe "pango_layout_iter_get_char_extents"
pango_layout_iter_get_char_extents :: ((Ptr LayoutIterRaw) -> ((Ptr ()) -> (IO ())))
foreign import ccall unsafe "pango_layout_iter_get_cluster_extents"
pango_layout_iter_get_cluster_extents :: ((Ptr LayoutIterRaw) -> ((Ptr ()) -> ((Ptr ()) -> (IO ()))))
foreign import ccall unsafe "pango_layout_iter_get_run_extents"
pango_layout_iter_get_run_extents :: ((Ptr LayoutIterRaw) -> ((Ptr ()) -> ((Ptr ()) -> (IO ()))))
foreign import ccall unsafe "pango_layout_iter_get_line_extents"
pango_layout_iter_get_line_extents :: ((Ptr LayoutIterRaw) -> ((Ptr ()) -> ((Ptr ()) -> (IO ()))))
foreign import ccall unsafe "pango_layout_line_get_extents"
pango_layout_line_get_extents :: ((Ptr LayoutLineRaw) -> ((Ptr ()) -> ((Ptr ()) -> (IO ()))))
foreign import ccall unsafe "pango_layout_line_get_pixel_extents"
pango_layout_line_get_pixel_extents :: ((Ptr LayoutLineRaw) -> ((Ptr ()) -> ((Ptr ()) -> (IO ()))))
foreign import ccall unsafe "pango_layout_line_index_to_x"
pango_layout_line_index_to_x :: ((Ptr LayoutLineRaw) -> (CInt -> (CInt -> ((Ptr CInt) -> (IO ())))))
foreign import ccall unsafe "pango_layout_line_x_to_index"
pango_layout_line_x_to_index :: ((Ptr LayoutLineRaw) -> (CInt -> ((Ptr CInt) -> ((Ptr CInt) -> (IO CInt)))))
foreign import ccall unsafe "pango_layout_line_get_x_ranges"
pango_layout_line_get_x_ranges :: ((Ptr LayoutLineRaw) -> (CInt -> (CInt -> ((Ptr (Ptr CInt)) -> ((Ptr CInt) -> (IO ()))))))