module Graphics.UI.Gtk.Printing.PrintContext (
PrintContext,
PrintContextClass,
castToPrintContext,
toPrintContext,
printContextGetCairoContext,
printContextSetCairoContext,
printContextGetPageSetup,
printContextGetWidth,
printContextGetHeight,
printContextGetDpiX,
printContextGetDpiY,
printContextGetPangoFontmap,
printContextCreatePangoContext,
printContextCreatePangoLayout,
printContextGetHardMargins,
) where
import Control.Monad (liftM)
import Data.IORef (newIORef)
import System.Glib.FFI
import System.Glib.UTFString
import Graphics.UI.Gtk.Types
import Graphics.Rendering.Pango.Types
import Graphics.Rendering.Pango.BasicTypes
import Graphics.Rendering.Cairo.Types
printContextGetCairoContext :: PrintContextClass self => self
-> IO Cairo
printContextGetCairoContext self =
liftM Cairo $
(\(PrintContext arg1) -> withForeignPtr arg1 $ \argPtr1 ->gtk_print_context_get_cairo_context argPtr1) (toPrintContext self)
printContextSetCairoContext :: PrintContextClass self => self
-> Cairo
-> Double
-> Double
-> IO ()
printContextSetCairoContext self cr dpiX dpiY =
(\(PrintContext arg1) (Cairo arg2) arg3 arg4 -> withForeignPtr arg1 $ \argPtr1 ->gtk_print_context_set_cairo_context argPtr1 arg2 arg3 arg4)
(toPrintContext self)
cr
(realToFrac dpiX)
(realToFrac dpiY)
printContextGetPageSetup :: PrintContextClass self => self
-> IO PageSetup
printContextGetPageSetup self =
makeNewGObject mkPageSetup $
(\(PrintContext arg1) -> withForeignPtr arg1 $ \argPtr1 ->gtk_print_context_get_page_setup argPtr1)
(toPrintContext self)
printContextGetWidth :: PrintContextClass self => self
-> IO Double
printContextGetWidth self =
liftM realToFrac $
(\(PrintContext arg1) -> withForeignPtr arg1 $ \argPtr1 ->gtk_print_context_get_width argPtr1)
(toPrintContext self)
printContextGetHeight :: PrintContextClass self => self
-> IO Double
printContextGetHeight self =
liftM realToFrac $
(\(PrintContext arg1) -> withForeignPtr arg1 $ \argPtr1 ->gtk_print_context_get_height argPtr1)
(toPrintContext self)
printContextGetDpiX :: PrintContextClass self => self
-> IO Double
printContextGetDpiX self =
liftM realToFrac $
(\(PrintContext arg1) -> withForeignPtr arg1 $ \argPtr1 ->gtk_print_context_get_dpi_x argPtr1)
(toPrintContext self)
printContextGetDpiY :: PrintContextClass self => self
-> IO Double
printContextGetDpiY self =
liftM realToFrac $
(\(PrintContext arg1) -> withForeignPtr arg1 $ \argPtr1 ->gtk_print_context_get_dpi_y argPtr1)
(toPrintContext self)
printContextGetPangoFontmap :: PrintContextClass self => self
-> IO FontMap
printContextGetPangoFontmap self =
makeNewGObject mkFontMap $
(\(PrintContext arg1) -> withForeignPtr arg1 $ \argPtr1 ->gtk_print_context_get_pango_fontmap argPtr1)
(toPrintContext self)
printContextCreatePangoContext :: PrintContextClass self => self
-> IO PangoContext
printContextCreatePangoContext self =
wrapNewGObject mkPangoContext $
(\(PrintContext arg1) -> withForeignPtr arg1 $ \argPtr1 ->gtk_print_context_create_pango_context argPtr1)
(toPrintContext self)
printContextCreatePangoLayout :: PrintContextClass self => self
-> IO PangoLayout
printContextCreatePangoLayout self = do
pl <- wrapNewGObject mkPangoLayoutRaw $
(\(PrintContext arg1) -> withForeignPtr arg1 $ \argPtr1 ->gtk_print_context_create_pango_layout argPtr1)
(toPrintContext self)
ps <- makeNewPangoString (""::DefaultGlibString)
psRef <- newIORef ps
return (PangoLayout psRef pl)
printContextGetHardMargins :: PrintContextClass self => self
-> IO (Maybe (Double, Double, Double, Double))
printContextGetHardMargins self =
alloca $ \ topPtr ->
alloca $ \ bottomPtr ->
alloca $ \ leftPtr ->
alloca $ \ rightPtr -> do
success <- liftM toBool $ (\(PrintContext arg1) arg2 arg3 arg4 arg5 -> withForeignPtr arg1 $ \argPtr1 ->gtk_print_context_get_hard_margins argPtr1 arg2 arg3 arg4 arg5)
(toPrintContext self)
topPtr
bottomPtr
leftPtr
rightPtr
if success
then do
top <- liftM realToFrac $ peek topPtr
bottom <- liftM realToFrac $ peek bottomPtr
left <- liftM realToFrac $ peek leftPtr
right <- liftM realToFrac $ peek rightPtr
return $ Just (top, bottom, left, right)
else return Nothing
foreign import ccall safe "gtk_print_context_get_cairo_context"
gtk_print_context_get_cairo_context :: ((Ptr PrintContext) -> (IO (Ptr Cairo)))
foreign import ccall safe "gtk_print_context_set_cairo_context"
gtk_print_context_set_cairo_context :: ((Ptr PrintContext) -> ((Ptr Cairo) -> (CDouble -> (CDouble -> (IO ())))))
foreign import ccall safe "gtk_print_context_get_page_setup"
gtk_print_context_get_page_setup :: ((Ptr PrintContext) -> (IO (Ptr PageSetup)))
foreign import ccall safe "gtk_print_context_get_width"
gtk_print_context_get_width :: ((Ptr PrintContext) -> (IO CDouble))
foreign import ccall safe "gtk_print_context_get_height"
gtk_print_context_get_height :: ((Ptr PrintContext) -> (IO CDouble))
foreign import ccall safe "gtk_print_context_get_dpi_x"
gtk_print_context_get_dpi_x :: ((Ptr PrintContext) -> (IO CDouble))
foreign import ccall safe "gtk_print_context_get_dpi_y"
gtk_print_context_get_dpi_y :: ((Ptr PrintContext) -> (IO CDouble))
foreign import ccall safe "gtk_print_context_get_pango_fontmap"
gtk_print_context_get_pango_fontmap :: ((Ptr PrintContext) -> (IO (Ptr FontMap)))
foreign import ccall safe "gtk_print_context_create_pango_context"
gtk_print_context_create_pango_context :: ((Ptr PrintContext) -> (IO (Ptr PangoContext)))
foreign import ccall safe "gtk_print_context_create_pango_layout"
gtk_print_context_create_pango_layout :: ((Ptr PrintContext) -> (IO (Ptr PangoLayoutRaw)))
foreign import ccall safe "gtk_print_context_get_hard_margins"
gtk_print_context_get_hard_margins :: ((Ptr PrintContext) -> ((Ptr CDouble) -> ((Ptr CDouble) -> ((Ptr CDouble) -> ((Ptr CDouble) -> (IO CInt))))))