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

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

module GI.PangoCairo.Functions
    (

 -- * Methods
-- ** contextGetFontOptions #method:contextGetFontOptions#

    contextGetFontOptions                   ,


-- ** contextGetResolution #method:contextGetResolution#

    contextGetResolution                    ,


-- ** contextSetFontOptions #method:contextSetFontOptions#

    contextSetFontOptions                   ,


-- ** contextSetResolution #method:contextSetResolution#

    contextSetResolution                    ,


-- ** contextSetShapeRenderer #method:contextSetShapeRenderer#

    contextSetShapeRenderer                 ,


-- ** createContext #method:createContext#

    createContext                           ,


-- ** createLayout #method:createLayout#

    createLayout                            ,


-- ** errorUnderlinePath #method:errorUnderlinePath#

    errorUnderlinePath                      ,


-- ** glyphStringPath #method:glyphStringPath#

    glyphStringPath                         ,


-- ** layoutLinePath #method:layoutLinePath#

    layoutLinePath                          ,


-- ** layoutPath #method:layoutPath#

    layoutPath                              ,


-- ** showErrorUnderline #method:showErrorUnderline#

    showErrorUnderline                      ,


-- ** showGlyphItem #method:showGlyphItem#

    showGlyphItem                           ,


-- ** showGlyphString #method:showGlyphString#

    showGlyphString                         ,


-- ** showLayout #method:showLayout#

    showLayout                              ,


-- ** showLayoutLine #method:showLayoutLine#

    showLayoutLine                          ,


-- ** updateContext #method:updateContext#

    updateContext                           ,


-- ** updateLayout #method:updateLayout#

    updateLayout                            ,




    ) 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 qualified GI.Cairo.Structs.Context as Cairo.Context
import qualified GI.Cairo.Structs.FontOptions as Cairo.FontOptions
import qualified GI.GLib.Callbacks as GLib.Callbacks
import qualified GI.Pango.Objects.Context as Pango.Context
import qualified GI.Pango.Objects.Font as Pango.Font
import qualified GI.Pango.Objects.Layout as Pango.Layout
import qualified GI.Pango.Structs.GlyphItem as Pango.GlyphItem
import qualified GI.Pango.Structs.GlyphString as Pango.GlyphString
import qualified GI.Pango.Structs.LayoutLine as Pango.LayoutLine
import qualified GI.PangoCairo.Callbacks as PangoCairo.Callbacks

-- function pango_cairo_update_layout
-- Args : [Arg {argCName = "cr", argType = TInterface (Name {namespace = "cairo", name = "Context"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a Cairo context", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "layout", argType = TInterface (Name {namespace = "Pango", name = "Layout"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #PangoLayout, from pango_cairo_create_layout()", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "pango_cairo_update_layout" pango_cairo_update_layout ::
    Ptr Cairo.Context.Context ->            -- cr : TInterface (Name {namespace = "cairo", name = "Context"})
    Ptr Pango.Layout.Layout ->              -- layout : TInterface (Name {namespace = "Pango", name = "Layout"})
    IO ()

{- |
Updates the private 'GI.Pango.Objects.Context.Context' of a 'GI.Pango.Objects.Layout.Layout' created with
'GI.PangoCairo.Functions.createLayout' to match the current transformation
and target surface of a Cairo context.

/Since: 1.10/
-}
updateLayout ::
    (B.CallStack.HasCallStack, MonadIO m, Pango.Layout.IsLayout a) =>
    Cairo.Context.Context
    {- ^ /@cr@/: a Cairo context -}
    -> a
    {- ^ /@layout@/: a 'GI.Pango.Objects.Layout.Layout', from 'GI.PangoCairo.Functions.createLayout' -}
    -> m ()
updateLayout cr layout = liftIO $ do
    cr' <- unsafeManagedPtrGetPtr cr
    layout' <- unsafeManagedPtrCastPtr layout
    pango_cairo_update_layout cr' layout'
    touchManagedPtr cr
    touchManagedPtr layout
    return ()


-- function pango_cairo_update_context
-- Args : [Arg {argCName = "cr", argType = TInterface (Name {namespace = "cairo", name = "Context"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a Cairo context", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "context", argType = TInterface (Name {namespace = "Pango", name = "Context"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #PangoContext, from a pangocairo font map", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "pango_cairo_update_context" pango_cairo_update_context ::
    Ptr Cairo.Context.Context ->            -- cr : TInterface (Name {namespace = "cairo", name = "Context"})
    Ptr Pango.Context.Context ->            -- context : TInterface (Name {namespace = "Pango", name = "Context"})
    IO ()

{- |
Updates a 'GI.Pango.Objects.Context.Context' previously created for use with Cairo to
match the current transformation and target surface of a Cairo
context. If any layouts have been created for the context,
it\'s necessary to call 'GI.Pango.Objects.Layout.layoutContextChanged' on those
layouts.

/Since: 1.10/
-}
updateContext ::
    (B.CallStack.HasCallStack, MonadIO m, Pango.Context.IsContext a) =>
    Cairo.Context.Context
    {- ^ /@cr@/: a Cairo context -}
    -> a
    {- ^ /@context@/: a 'GI.Pango.Objects.Context.Context', from a pangocairo font map -}
    -> m ()
updateContext cr context = liftIO $ do
    cr' <- unsafeManagedPtrGetPtr cr
    context' <- unsafeManagedPtrCastPtr context
    pango_cairo_update_context cr' context'
    touchManagedPtr cr
    touchManagedPtr context
    return ()


-- function pango_cairo_show_layout_line
-- Args : [Arg {argCName = "cr", argType = TInterface (Name {namespace = "cairo", name = "Context"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a Cairo context", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "line", argType = TInterface (Name {namespace = "Pango", name = "LayoutLine"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #PangoLayoutLine", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "pango_cairo_show_layout_line" pango_cairo_show_layout_line ::
    Ptr Cairo.Context.Context ->            -- cr : TInterface (Name {namespace = "cairo", name = "Context"})
    Ptr Pango.LayoutLine.LayoutLine ->      -- line : TInterface (Name {namespace = "Pango", name = "LayoutLine"})
    IO ()

{- |
Draws a 'GI.Pango.Structs.LayoutLine.LayoutLine' in the specified cairo context.
The origin of the glyphs (the left edge of the line) will
be drawn at the current point of the cairo context.

/Since: 1.10/
-}
showLayoutLine ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Cairo.Context.Context
    {- ^ /@cr@/: a Cairo context -}
    -> Pango.LayoutLine.LayoutLine
    {- ^ /@line@/: a 'GI.Pango.Structs.LayoutLine.LayoutLine' -}
    -> m ()
showLayoutLine cr line = liftIO $ do
    cr' <- unsafeManagedPtrGetPtr cr
    line' <- unsafeManagedPtrGetPtr line
    pango_cairo_show_layout_line cr' line'
    touchManagedPtr cr
    touchManagedPtr line
    return ()


-- function pango_cairo_show_layout
-- Args : [Arg {argCName = "cr", argType = TInterface (Name {namespace = "cairo", name = "Context"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a Cairo context", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "layout", argType = TInterface (Name {namespace = "Pango", name = "Layout"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a Pango layout", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "pango_cairo_show_layout" pango_cairo_show_layout ::
    Ptr Cairo.Context.Context ->            -- cr : TInterface (Name {namespace = "cairo", name = "Context"})
    Ptr Pango.Layout.Layout ->              -- layout : TInterface (Name {namespace = "Pango", name = "Layout"})
    IO ()

{- |
Draws a 'GI.Pango.Objects.Layout.Layout' in the specified cairo context.
The top-left corner of the 'GI.Pango.Objects.Layout.Layout' will be drawn
at the current point of the cairo context.

/Since: 1.10/
-}
showLayout ::
    (B.CallStack.HasCallStack, MonadIO m, Pango.Layout.IsLayout a) =>
    Cairo.Context.Context
    {- ^ /@cr@/: a Cairo context -}
    -> a
    {- ^ /@layout@/: a Pango layout -}
    -> m ()
showLayout cr layout = liftIO $ do
    cr' <- unsafeManagedPtrGetPtr cr
    layout' <- unsafeManagedPtrCastPtr layout
    pango_cairo_show_layout cr' layout'
    touchManagedPtr cr
    touchManagedPtr layout
    return ()


-- function pango_cairo_show_glyph_string
-- Args : [Arg {argCName = "cr", argType = TInterface (Name {namespace = "cairo", name = "Context"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a Cairo context", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "font", argType = TInterface (Name {namespace = "Pango", name = "Font"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #PangoFont from a #PangoCairoFontMap", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "glyphs", argType = TInterface (Name {namespace = "Pango", name = "GlyphString"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #PangoGlyphString", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "pango_cairo_show_glyph_string" pango_cairo_show_glyph_string ::
    Ptr Cairo.Context.Context ->            -- cr : TInterface (Name {namespace = "cairo", name = "Context"})
    Ptr Pango.Font.Font ->                  -- font : TInterface (Name {namespace = "Pango", name = "Font"})
    Ptr Pango.GlyphString.GlyphString ->    -- glyphs : TInterface (Name {namespace = "Pango", name = "GlyphString"})
    IO ()

{- |
Draws the glyphs in /@glyphs@/ in the specified cairo context.
The origin of the glyphs (the left edge of the baseline) will
be drawn at the current point of the cairo context.

/Since: 1.10/
-}
showGlyphString ::
    (B.CallStack.HasCallStack, MonadIO m, Pango.Font.IsFont a) =>
    Cairo.Context.Context
    {- ^ /@cr@/: a Cairo context -}
    -> a
    {- ^ /@font@/: a 'GI.Pango.Objects.Font.Font' from a 'GI.PangoCairo.Interfaces.FontMap.FontMap' -}
    -> Pango.GlyphString.GlyphString
    {- ^ /@glyphs@/: a 'GI.Pango.Structs.GlyphString.GlyphString' -}
    -> m ()
showGlyphString cr font glyphs = liftIO $ do
    cr' <- unsafeManagedPtrGetPtr cr
    font' <- unsafeManagedPtrCastPtr font
    glyphs' <- unsafeManagedPtrGetPtr glyphs
    pango_cairo_show_glyph_string cr' font' glyphs'
    touchManagedPtr cr
    touchManagedPtr font
    touchManagedPtr glyphs
    return ()


-- function pango_cairo_show_glyph_item
-- Args : [Arg {argCName = "cr", argType = TInterface (Name {namespace = "cairo", name = "Context"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a Cairo context", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "text", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the UTF-8 text that @glyph_item refers to", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "glyph_item", argType = TInterface (Name {namespace = "Pango", name = "GlyphItem"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #PangoGlyphItem", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "pango_cairo_show_glyph_item" pango_cairo_show_glyph_item ::
    Ptr Cairo.Context.Context ->            -- cr : TInterface (Name {namespace = "cairo", name = "Context"})
    CString ->                              -- text : TBasicType TUTF8
    Ptr Pango.GlyphItem.GlyphItem ->        -- glyph_item : TInterface (Name {namespace = "Pango", name = "GlyphItem"})
    IO ()

{- |
Draws the glyphs in /@glyphItem@/ in the specified cairo context,
embedding the text associated with the glyphs in the output if the
output format supports it (PDF for example), otherwise it acts
similar to 'GI.PangoCairo.Functions.showGlyphString'.

The origin of the glyphs (the left edge of the baseline) will
be drawn at the current point of the cairo context.

Note that /@text@/ is the start of the text for layout, which is then
indexed by \<literal>/@glyphItem@/->item->offset\<\/literal>.

/Since: 1.22/
-}
showGlyphItem ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Cairo.Context.Context
    {- ^ /@cr@/: a Cairo context -}
    -> T.Text
    {- ^ /@text@/: the UTF-8 text that /@glyphItem@/ refers to -}
    -> Pango.GlyphItem.GlyphItem
    {- ^ /@glyphItem@/: a 'GI.Pango.Structs.GlyphItem.GlyphItem' -}
    -> m ()
showGlyphItem cr text glyphItem = liftIO $ do
    cr' <- unsafeManagedPtrGetPtr cr
    text' <- textToCString text
    glyphItem' <- unsafeManagedPtrGetPtr glyphItem
    pango_cairo_show_glyph_item cr' text' glyphItem'
    touchManagedPtr cr
    touchManagedPtr glyphItem
    freeMem text'
    return ()


-- function pango_cairo_show_error_underline
-- Args : [Arg {argCName = "cr", argType = TInterface (Name {namespace = "cairo", name = "Context"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a Cairo context", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "x", argType = TBasicType TDouble, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "The X coordinate of one corner of the rectangle", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "y", argType = TBasicType TDouble, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "The Y coordinate of one corner of the rectangle", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "width", argType = TBasicType TDouble, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "Non-negative width of the rectangle", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "height", argType = TBasicType TDouble, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "Non-negative height of the rectangle", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "pango_cairo_show_error_underline" pango_cairo_show_error_underline ::
    Ptr Cairo.Context.Context ->            -- cr : TInterface (Name {namespace = "cairo", name = "Context"})
    CDouble ->                              -- x : TBasicType TDouble
    CDouble ->                              -- y : TBasicType TDouble
    CDouble ->                              -- width : TBasicType TDouble
    CDouble ->                              -- height : TBasicType TDouble
    IO ()

{- |
Draw a squiggly line in the specified cairo context that approximately
covers the given rectangle in the style of an underline used to indicate a
spelling error.  (The width of the underline is rounded to an integer
number of up\/down segments and the resulting rectangle is centered in the
original rectangle)

/Since: 1.14/
-}
showErrorUnderline ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Cairo.Context.Context
    {- ^ /@cr@/: a Cairo context -}
    -> Double
    {- ^ /@x@/: The X coordinate of one corner of the rectangle -}
    -> Double
    {- ^ /@y@/: The Y coordinate of one corner of the rectangle -}
    -> Double
    {- ^ /@width@/: Non-negative width of the rectangle -}
    -> Double
    {- ^ /@height@/: Non-negative height of the rectangle -}
    -> m ()
showErrorUnderline cr x y width height = liftIO $ do
    cr' <- unsafeManagedPtrGetPtr cr
    let x' = realToFrac x
    let y' = realToFrac y
    let width' = realToFrac width
    let height' = realToFrac height
    pango_cairo_show_error_underline cr' x' y' width' height'
    touchManagedPtr cr
    return ()


-- function pango_cairo_layout_path
-- Args : [Arg {argCName = "cr", argType = TInterface (Name {namespace = "cairo", name = "Context"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a Cairo context", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "layout", argType = TInterface (Name {namespace = "Pango", name = "Layout"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a Pango layout", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "pango_cairo_layout_path" pango_cairo_layout_path ::
    Ptr Cairo.Context.Context ->            -- cr : TInterface (Name {namespace = "cairo", name = "Context"})
    Ptr Pango.Layout.Layout ->              -- layout : TInterface (Name {namespace = "Pango", name = "Layout"})
    IO ()

{- |
Adds the text in a 'GI.Pango.Objects.Layout.Layout' to the current path in the
specified cairo context.  The top-left corner of the 'GI.Pango.Objects.Layout.Layout'
will be at the current point of the cairo context.

/Since: 1.10/
-}
layoutPath ::
    (B.CallStack.HasCallStack, MonadIO m, Pango.Layout.IsLayout a) =>
    Cairo.Context.Context
    {- ^ /@cr@/: a Cairo context -}
    -> a
    {- ^ /@layout@/: a Pango layout -}
    -> m ()
layoutPath cr layout = liftIO $ do
    cr' <- unsafeManagedPtrGetPtr cr
    layout' <- unsafeManagedPtrCastPtr layout
    pango_cairo_layout_path cr' layout'
    touchManagedPtr cr
    touchManagedPtr layout
    return ()


-- function pango_cairo_layout_line_path
-- Args : [Arg {argCName = "cr", argType = TInterface (Name {namespace = "cairo", name = "Context"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a Cairo context", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "line", argType = TInterface (Name {namespace = "Pango", name = "LayoutLine"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #PangoLayoutLine", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "pango_cairo_layout_line_path" pango_cairo_layout_line_path ::
    Ptr Cairo.Context.Context ->            -- cr : TInterface (Name {namespace = "cairo", name = "Context"})
    Ptr Pango.LayoutLine.LayoutLine ->      -- line : TInterface (Name {namespace = "Pango", name = "LayoutLine"})
    IO ()

{- |
Adds the text in 'GI.Pango.Structs.LayoutLine.LayoutLine' to the current path in the
specified cairo context.  The origin of the glyphs (the left edge
of the line) will be at the current point of the cairo context.

/Since: 1.10/
-}
layoutLinePath ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Cairo.Context.Context
    {- ^ /@cr@/: a Cairo context -}
    -> Pango.LayoutLine.LayoutLine
    {- ^ /@line@/: a 'GI.Pango.Structs.LayoutLine.LayoutLine' -}
    -> m ()
layoutLinePath cr line = liftIO $ do
    cr' <- unsafeManagedPtrGetPtr cr
    line' <- unsafeManagedPtrGetPtr line
    pango_cairo_layout_line_path cr' line'
    touchManagedPtr cr
    touchManagedPtr line
    return ()


-- function pango_cairo_glyph_string_path
-- Args : [Arg {argCName = "cr", argType = TInterface (Name {namespace = "cairo", name = "Context"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a Cairo context", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "font", argType = TInterface (Name {namespace = "Pango", name = "Font"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #PangoFont from a #PangoCairoFontMap", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "glyphs", argType = TInterface (Name {namespace = "Pango", name = "GlyphString"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #PangoGlyphString", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "pango_cairo_glyph_string_path" pango_cairo_glyph_string_path ::
    Ptr Cairo.Context.Context ->            -- cr : TInterface (Name {namespace = "cairo", name = "Context"})
    Ptr Pango.Font.Font ->                  -- font : TInterface (Name {namespace = "Pango", name = "Font"})
    Ptr Pango.GlyphString.GlyphString ->    -- glyphs : TInterface (Name {namespace = "Pango", name = "GlyphString"})
    IO ()

{- |
Adds the glyphs in /@glyphs@/ to the current path in the specified
cairo context. The origin of the glyphs (the left edge of the baseline)
will be at the current point of the cairo context.

/Since: 1.10/
-}
glyphStringPath ::
    (B.CallStack.HasCallStack, MonadIO m, Pango.Font.IsFont a) =>
    Cairo.Context.Context
    {- ^ /@cr@/: a Cairo context -}
    -> a
    {- ^ /@font@/: a 'GI.Pango.Objects.Font.Font' from a 'GI.PangoCairo.Interfaces.FontMap.FontMap' -}
    -> Pango.GlyphString.GlyphString
    {- ^ /@glyphs@/: a 'GI.Pango.Structs.GlyphString.GlyphString' -}
    -> m ()
glyphStringPath cr font glyphs = liftIO $ do
    cr' <- unsafeManagedPtrGetPtr cr
    font' <- unsafeManagedPtrCastPtr font
    glyphs' <- unsafeManagedPtrGetPtr glyphs
    pango_cairo_glyph_string_path cr' font' glyphs'
    touchManagedPtr cr
    touchManagedPtr font
    touchManagedPtr glyphs
    return ()


-- function pango_cairo_error_underline_path
-- Args : [Arg {argCName = "cr", argType = TInterface (Name {namespace = "cairo", name = "Context"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a Cairo context", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "x", argType = TBasicType TDouble, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "The X coordinate of one corner of the rectangle", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "y", argType = TBasicType TDouble, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "The Y coordinate of one corner of the rectangle", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "width", argType = TBasicType TDouble, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "Non-negative width of the rectangle", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "height", argType = TBasicType TDouble, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "Non-negative height of the rectangle", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "pango_cairo_error_underline_path" pango_cairo_error_underline_path ::
    Ptr Cairo.Context.Context ->            -- cr : TInterface (Name {namespace = "cairo", name = "Context"})
    CDouble ->                              -- x : TBasicType TDouble
    CDouble ->                              -- y : TBasicType TDouble
    CDouble ->                              -- width : TBasicType TDouble
    CDouble ->                              -- height : TBasicType TDouble
    IO ()

{- |
Add a squiggly line to the current path in the specified cairo context that
approximately covers the given rectangle in the style of an underline used
to indicate a spelling error.  (The width of the underline is rounded to an
integer number of up\/down segments and the resulting rectangle is centered
in the original rectangle)

/Since: 1.14/
-}
errorUnderlinePath ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Cairo.Context.Context
    {- ^ /@cr@/: a Cairo context -}
    -> Double
    {- ^ /@x@/: The X coordinate of one corner of the rectangle -}
    -> Double
    {- ^ /@y@/: The Y coordinate of one corner of the rectangle -}
    -> Double
    {- ^ /@width@/: Non-negative width of the rectangle -}
    -> Double
    {- ^ /@height@/: Non-negative height of the rectangle -}
    -> m ()
errorUnderlinePath cr x y width height = liftIO $ do
    cr' <- unsafeManagedPtrGetPtr cr
    let x' = realToFrac x
    let y' = realToFrac y
    let width' = realToFrac width
    let height' = realToFrac height
    pango_cairo_error_underline_path cr' x' y' width' height'
    touchManagedPtr cr
    return ()


-- function pango_cairo_create_layout
-- Args : [Arg {argCName = "cr", argType = TInterface (Name {namespace = "cairo", name = "Context"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a Cairo context", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "Pango", name = "Layout"}))
-- throws : False
-- Skip return : False

foreign import ccall "pango_cairo_create_layout" pango_cairo_create_layout ::
    Ptr Cairo.Context.Context ->            -- cr : TInterface (Name {namespace = "cairo", name = "Context"})
    IO (Ptr Pango.Layout.Layout)

{- |
Creates a layout object set up to match the current transformation
and target surface of the Cairo context.  This layout can then be
used for text measurement with functions like
'GI.Pango.Objects.Layout.layoutGetSize' or drawing with functions like
'GI.PangoCairo.Functions.showLayout'. If you change the transformation
or target surface for /@cr@/, you need to call 'GI.PangoCairo.Functions.updateLayout'

This function is the most convenient way to use Cairo with Pango,
however it is slightly inefficient since it creates a separate
'GI.Pango.Objects.Context.Context' object for each layout. This might matter in an
application that was laying out large amounts of text.

/Since: 1.10/
-}
createLayout ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Cairo.Context.Context
    {- ^ /@cr@/: a Cairo context -}
    -> m Pango.Layout.Layout
    {- ^ __Returns:__ the newly created 'GI.Pango.Objects.Layout.Layout'. Free with
  'GI.GObject.Objects.Object.objectUnref'. -}
createLayout cr = liftIO $ do
    cr' <- unsafeManagedPtrGetPtr cr
    result <- pango_cairo_create_layout cr'
    checkUnexpectedReturnNULL "createLayout" result
    result' <- (wrapObject Pango.Layout.Layout) result
    touchManagedPtr cr
    return result'


-- function pango_cairo_create_context
-- Args : [Arg {argCName = "cr", argType = TInterface (Name {namespace = "cairo", name = "Context"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a Cairo context", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "Pango", name = "Context"}))
-- throws : False
-- Skip return : False

foreign import ccall "pango_cairo_create_context" pango_cairo_create_context ::
    Ptr Cairo.Context.Context ->            -- cr : TInterface (Name {namespace = "cairo", name = "Context"})
    IO (Ptr Pango.Context.Context)

{- |
Creates a context object set up to match the current transformation
and target surface of the Cairo context.  This context can then be
used to create a layout using 'GI.Pango.Objects.Layout.layoutNew'.

This function is a convenience function that creates a context using
the default font map, then updates it to /@cr@/.  If you just need to
create a layout for use with /@cr@/ and do not need to access 'GI.Pango.Objects.Context.Context'
directly, you can use 'GI.PangoCairo.Functions.createLayout' instead.

/Since: 1.22/
-}
createContext ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Cairo.Context.Context
    {- ^ /@cr@/: a Cairo context -}
    -> m Pango.Context.Context
    {- ^ __Returns:__ the newly created 'GI.Pango.Objects.Context.Context'. Free with
  'GI.GObject.Objects.Object.objectUnref'. -}
createContext cr = liftIO $ do
    cr' <- unsafeManagedPtrGetPtr cr
    result <- pango_cairo_create_context cr'
    checkUnexpectedReturnNULL "createContext" result
    result' <- (wrapObject Pango.Context.Context) result
    touchManagedPtr cr
    return result'


-- function pango_cairo_context_set_shape_renderer
-- Args : [Arg {argCName = "context", argType = TInterface (Name {namespace = "Pango", name = "Context"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #PangoContext, from a pangocairo font map", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "func", argType = TInterface (Name {namespace = "PangoCairo", name = "ShapeRendererFunc"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "Callback function for rendering attributes of\n       type %PANGO_ATTR_SHAPE, or %NULL to disable shape rendering.", sinceVersion = Nothing}, argScope = ScopeTypeNotified, argClosure = 2, argDestroy = 3, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "data", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "User data that will be passed to @func.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "dnotify", argType = TInterface (Name {namespace = "GLib", name = "DestroyNotify"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "Callback that will be called when the\n          context is freed to release @data, or %NULL.", sinceVersion = Nothing}, argScope = ScopeTypeAsync, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "pango_cairo_context_set_shape_renderer" pango_cairo_context_set_shape_renderer ::
    Ptr Pango.Context.Context ->            -- context : TInterface (Name {namespace = "Pango", name = "Context"})
    FunPtr PangoCairo.Callbacks.C_ShapeRendererFunc -> -- func : TInterface (Name {namespace = "PangoCairo", name = "ShapeRendererFunc"})
    Ptr () ->                               -- data : TBasicType TPtr
    FunPtr GLib.Callbacks.C_DestroyNotify -> -- dnotify : TInterface (Name {namespace = "GLib", name = "DestroyNotify"})
    IO ()

{- |
Sets callback function for context to use for rendering attributes
of type 'GI.Pango.Enums.AttrTypeShape'.  See 'GI.PangoCairo.Callbacks.ShapeRendererFunc' for
details.

/Since: 1.18/
-}
contextSetShapeRenderer ::
    (B.CallStack.HasCallStack, MonadIO m, Pango.Context.IsContext a) =>
    a
    {- ^ /@context@/: a 'GI.Pango.Objects.Context.Context', from a pangocairo font map -}
    -> Maybe (PangoCairo.Callbacks.ShapeRendererFunc)
    {- ^ /@func@/: Callback function for rendering attributes of
       type 'GI.Pango.Enums.AttrTypeShape', or 'Nothing' to disable shape rendering. -}
    -> m ()
contextSetShapeRenderer context func = liftIO $ do
    context' <- unsafeManagedPtrCastPtr context
    maybeFunc <- case func of
        Nothing -> return (castPtrToFunPtr nullPtr)
        Just jFunc -> do
            jFunc' <- PangoCairo.Callbacks.mk_ShapeRendererFunc (PangoCairo.Callbacks.wrap_ShapeRendererFunc Nothing jFunc)
            return jFunc'
    let data_ = castFunPtrToPtr maybeFunc
    let dnotify = safeFreeFunPtrPtr
    pango_cairo_context_set_shape_renderer context' maybeFunc data_ dnotify
    touchManagedPtr context
    return ()


-- function pango_cairo_context_set_resolution
-- Args : [Arg {argCName = "context", argType = TInterface (Name {namespace = "Pango", name = "Context"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #PangoContext, from a pangocairo font map", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "dpi", argType = TBasicType TDouble, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the resolution in \"dots per inch\". (Physical inches aren't actually\n  involved; the terminology is conventional.) A 0 or negative value\n  means to use the resolution from the font map.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "pango_cairo_context_set_resolution" pango_cairo_context_set_resolution ::
    Ptr Pango.Context.Context ->            -- context : TInterface (Name {namespace = "Pango", name = "Context"})
    CDouble ->                              -- dpi : TBasicType TDouble
    IO ()

{- |
Sets the resolution for the context. This is a scale factor between
points specified in a 'GI.Pango.Structs.FontDescription.FontDescription' and Cairo units. The
default value is 96, meaning that a 10 point font will be 13
units high. (10 * 96. \/ 72. = 13.3).

/Since: 1.10/
-}
contextSetResolution ::
    (B.CallStack.HasCallStack, MonadIO m, Pango.Context.IsContext a) =>
    a
    {- ^ /@context@/: a 'GI.Pango.Objects.Context.Context', from a pangocairo font map -}
    -> Double
    {- ^ /@dpi@/: the resolution in \"dots per inch\". (Physical inches aren\'t actually
  involved; the terminology is conventional.) A 0 or negative value
  means to use the resolution from the font map. -}
    -> m ()
contextSetResolution context dpi = liftIO $ do
    context' <- unsafeManagedPtrCastPtr context
    let dpi' = realToFrac dpi
    pango_cairo_context_set_resolution context' dpi'
    touchManagedPtr context
    return ()


-- function pango_cairo_context_set_font_options
-- Args : [Arg {argCName = "context", argType = TInterface (Name {namespace = "Pango", name = "Context"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #PangoContext, from a pangocairo font map", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "options", argType = TInterface (Name {namespace = "cairo", name = "FontOptions"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "a #cairo_font_options_t, or %NULL to unset\n          any previously set options. A copy is made.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "pango_cairo_context_set_font_options" pango_cairo_context_set_font_options ::
    Ptr Pango.Context.Context ->            -- context : TInterface (Name {namespace = "Pango", name = "Context"})
    Ptr Cairo.FontOptions.FontOptions ->    -- options : TInterface (Name {namespace = "cairo", name = "FontOptions"})
    IO ()

{- |
Sets the font options used when rendering text with this context.
These options override any options that 'GI.PangoCairo.Functions.updateContext'
derives from the target surface.

/Since: 1.10/
-}
contextSetFontOptions ::
    (B.CallStack.HasCallStack, MonadIO m, Pango.Context.IsContext a) =>
    a
    {- ^ /@context@/: a 'GI.Pango.Objects.Context.Context', from a pangocairo font map -}
    -> Maybe (Cairo.FontOptions.FontOptions)
    {- ^ /@options@/: a 'GI.Cairo.Structs.FontOptions.FontOptions', or 'Nothing' to unset
          any previously set options. A copy is made. -}
    -> m ()
contextSetFontOptions context options = liftIO $ do
    context' <- unsafeManagedPtrCastPtr context
    maybeOptions <- case options of
        Nothing -> return nullPtr
        Just jOptions -> do
            jOptions' <- unsafeManagedPtrGetPtr jOptions
            return jOptions'
    pango_cairo_context_set_font_options context' maybeOptions
    touchManagedPtr context
    whenJust options touchManagedPtr
    return ()


-- function pango_cairo_context_get_resolution
-- Args : [Arg {argCName = "context", argType = TInterface (Name {namespace = "Pango", name = "Context"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #PangoContext, from a pangocairo font map", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TDouble)
-- throws : False
-- Skip return : False

foreign import ccall "pango_cairo_context_get_resolution" pango_cairo_context_get_resolution ::
    Ptr Pango.Context.Context ->            -- context : TInterface (Name {namespace = "Pango", name = "Context"})
    IO CDouble

{- |
Gets the resolution for the context. See 'GI.PangoCairo.Functions.contextSetResolution'

/Since: 1.10/
-}
contextGetResolution ::
    (B.CallStack.HasCallStack, MonadIO m, Pango.Context.IsContext a) =>
    a
    {- ^ /@context@/: a 'GI.Pango.Objects.Context.Context', from a pangocairo font map -}
    -> m Double
    {- ^ __Returns:__ the resolution in \"dots per inch\". A negative value will
 be returned if no resolution has previously been set. -}
contextGetResolution context = liftIO $ do
    context' <- unsafeManagedPtrCastPtr context
    result <- pango_cairo_context_get_resolution context'
    let result' = realToFrac result
    touchManagedPtr context
    return result'


-- function pango_cairo_context_get_font_options
-- Args : [Arg {argCName = "context", argType = TInterface (Name {namespace = "Pango", name = "Context"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #PangoContext, from a pangocairo font map", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "cairo", name = "FontOptions"}))
-- throws : False
-- Skip return : False

foreign import ccall "pango_cairo_context_get_font_options" pango_cairo_context_get_font_options ::
    Ptr Pango.Context.Context ->            -- context : TInterface (Name {namespace = "Pango", name = "Context"})
    IO (Ptr Cairo.FontOptions.FontOptions)

{- |
Retrieves any font rendering options previously set with
'GI.PangoCairo.Functions.contextSetFontOptions'. This function does not report options
that are derived from the target surface by 'GI.PangoCairo.Functions.updateContext'

/Since: 1.10/
-}
contextGetFontOptions ::
    (B.CallStack.HasCallStack, MonadIO m, Pango.Context.IsContext a) =>
    a
    {- ^ /@context@/: a 'GI.Pango.Objects.Context.Context', from a pangocairo font map -}
    -> m (Maybe Cairo.FontOptions.FontOptions)
    {- ^ __Returns:__ the font options previously set on the
  context, or 'Nothing' if no options have been set. This value is
  owned by the context and must not be modified or freed. -}
contextGetFontOptions context = liftIO $ do
    context' <- unsafeManagedPtrCastPtr context
    result <- pango_cairo_context_get_font_options context'
    maybeResult <- convertIfNonNull result $ \result' -> do
        result'' <- (newBoxed Cairo.FontOptions.FontOptions) result'
        return result''
    touchManagedPtr context
    return maybeResult