module Graphics.UI.Gtk.Printing.PaperSize (
PaperSize(..),
mkPaperSize,
Unit(..),
paperSizeNew,
paperSizeNewFromPpd,
paperSizeNewCustom,
paperSizeCopy,
paperSizeIsEqual,
paperSizeGetName,
paperSizeGetDisplayName,
paperSizeGetPpdName,
paperSizeGetWidth,
paperSizeGetHeight,
paperSizeIsCustom,
paperSizeSetSize,
paperSizeGetDefaultTopMargin,
paperSizeGetDefaultBottomMargin,
paperSizeGetDefaultLeftMargin,
paperSizeGetDefaultRightMargin,
paperSizeGetDefault,
paperSizeGetPaperSizes,
) where
import Control.Monad (liftM)
import System.Glib.FFI
import System.Glib.UTFString
import System.Glib.GList
newtype PaperSize = PaperSize (ForeignPtr (PaperSize))
data Unit = UnitNone
| UnitPoints
| UnitInch
| UnitMm
deriving (Enum,Bounded,Eq,Show)
mkPaperSize :: Ptr PaperSize -> IO PaperSize
mkPaperSize pPtr = do
size <- newForeignPtr pPtr paper_size_free
return (PaperSize size)
foreign import ccall unsafe ">k_paper_size_free"
paper_size_free :: FinalizerPtr PaperSize
paperSizeNew :: GlibString string
=> Maybe string
-> IO PaperSize
paperSizeNew name =
maybeWith withUTFString name $ \namePtr ->
gtk_paper_size_new
namePtr
>>= mkPaperSize
paperSizeNewFromPpd :: GlibString string
=> string
-> string
-> Double
-> Double
-> IO PaperSize
paperSizeNewFromPpd ppdName ppdDisplayName width height =
withUTFString ppdDisplayName $ \ppdDisplayNamePtr ->
withUTFString ppdName $ \ppdNamePtr ->
gtk_paper_size_new_from_ppd
ppdNamePtr
ppdDisplayNamePtr
(realToFrac width)
(realToFrac height)
>>= mkPaperSize
paperSizeNewCustom :: GlibString string
=> string
-> string
-> Double
-> Double
-> Unit
-> IO PaperSize
paperSizeNewCustom name displayName width height unit =
withUTFString displayName $ \displayNamePtr ->
withUTFString name $ \namePtr ->
gtk_paper_size_new_custom
namePtr
displayNamePtr
(realToFrac width)
(realToFrac height)
((fromIntegral . fromEnum) unit)
>>= mkPaperSize
paperSizeCopy :: PaperSize
-> IO PaperSize
paperSizeCopy self =
(\(PaperSize arg1) -> withForeignPtr arg1 $ \argPtr1 ->gtk_paper_size_copy argPtr1) self >>= mkPaperSize
paperSizeIsEqual :: PaperSize
-> PaperSize
-> IO Bool
paperSizeIsEqual self size2 =
liftM toBool $
(\(PaperSize arg1) (PaperSize arg2) -> withForeignPtr arg1 $ \argPtr1 ->withForeignPtr arg2 $ \argPtr2 ->gtk_paper_size_is_equal argPtr1 argPtr2)
self
size2
paperSizeGetName :: GlibString string => PaperSize
-> IO string
paperSizeGetName self =
(\(PaperSize arg1) -> withForeignPtr arg1 $ \argPtr1 ->gtk_paper_size_get_name argPtr1)
self
>>= peekUTFString
paperSizeGetDisplayName :: GlibString string => PaperSize
-> IO string
paperSizeGetDisplayName self =
(\(PaperSize arg1) -> withForeignPtr arg1 $ \argPtr1 ->gtk_paper_size_get_display_name argPtr1)
self
>>= peekUTFString
paperSizeGetPpdName :: GlibString string => PaperSize
-> IO (Maybe string)
paperSizeGetPpdName self =
(\(PaperSize arg1) -> withForeignPtr arg1 $ \argPtr1 ->gtk_paper_size_get_ppd_name argPtr1)
self
>>= maybePeekUTFString
paperSizeGetWidth :: PaperSize
-> Unit
-> IO Double
paperSizeGetWidth self unit =
liftM realToFrac $
(\(PaperSize arg1) arg2 -> withForeignPtr arg1 $ \argPtr1 ->gtk_paper_size_get_width argPtr1 arg2)
self
((fromIntegral . fromEnum) unit)
paperSizeGetHeight :: PaperSize
-> Unit
-> IO Double
paperSizeGetHeight self unit =
liftM realToFrac $
(\(PaperSize arg1) arg2 -> withForeignPtr arg1 $ \argPtr1 ->gtk_paper_size_get_height argPtr1 arg2)
self
((fromIntegral . fromEnum) unit)
paperSizeIsCustom :: PaperSize
-> IO Bool
paperSizeIsCustom self =
liftM toBool $
(\(PaperSize arg1) -> withForeignPtr arg1 $ \argPtr1 ->gtk_paper_size_is_custom argPtr1)
self
paperSizeSetSize :: PaperSize
-> Double
-> Double
-> Unit
-> IO ()
paperSizeSetSize self width height unit =
(\(PaperSize arg1) arg2 arg3 arg4 -> withForeignPtr arg1 $ \argPtr1 ->gtk_paper_size_set_size argPtr1 arg2 arg3 arg4)
self
(realToFrac width)
(realToFrac height)
((fromIntegral . fromEnum) unit)
paperSizeGetDefaultTopMargin :: PaperSize
-> Unit
-> IO Double
paperSizeGetDefaultTopMargin self unit =
liftM realToFrac $
(\(PaperSize arg1) arg2 -> withForeignPtr arg1 $ \argPtr1 ->gtk_paper_size_get_default_top_margin argPtr1 arg2)
self
((fromIntegral . fromEnum) unit)
paperSizeGetDefaultBottomMargin :: PaperSize
-> Unit
-> IO Double
paperSizeGetDefaultBottomMargin self unit =
liftM realToFrac $
(\(PaperSize arg1) arg2 -> withForeignPtr arg1 $ \argPtr1 ->gtk_paper_size_get_default_bottom_margin argPtr1 arg2)
self
((fromIntegral . fromEnum) unit)
paperSizeGetDefaultLeftMargin :: PaperSize
-> Unit
-> IO Double
paperSizeGetDefaultLeftMargin self unit =
liftM realToFrac $
(\(PaperSize arg1) arg2 -> withForeignPtr arg1 $ \argPtr1 ->gtk_paper_size_get_default_left_margin argPtr1 arg2)
self
((fromIntegral . fromEnum) unit)
paperSizeGetDefaultRightMargin :: PaperSize
-> Unit
-> IO Double
paperSizeGetDefaultRightMargin self unit =
liftM realToFrac $
(\(PaperSize arg1) arg2 -> withForeignPtr arg1 $ \argPtr1 ->gtk_paper_size_get_default_right_margin argPtr1 arg2)
self
((fromIntegral . fromEnum) unit)
paperSizeGetDefault :: GlibString string
=> IO string
paperSizeGetDefault =
gtk_paper_size_get_default
>>= peekUTFString
paperSizeGetPaperSizes ::
Bool
-> IO [PaperSize]
paperSizeGetPaperSizes includeCustom = do
glist <- gtk_paper_size_get_paper_sizes (fromBool includeCustom)
list <- fromGList glist
mapM mkPaperSize list
foreign import ccall safe "gtk_paper_size_new"
gtk_paper_size_new :: ((Ptr CChar) -> (IO (Ptr PaperSize)))
foreign import ccall safe "gtk_paper_size_new_from_ppd"
gtk_paper_size_new_from_ppd :: ((Ptr CChar) -> ((Ptr CChar) -> (CDouble -> (CDouble -> (IO (Ptr PaperSize))))))
foreign import ccall safe "gtk_paper_size_new_custom"
gtk_paper_size_new_custom :: ((Ptr CChar) -> ((Ptr CChar) -> (CDouble -> (CDouble -> (CInt -> (IO (Ptr PaperSize)))))))
foreign import ccall safe "gtk_paper_size_copy"
gtk_paper_size_copy :: ((Ptr PaperSize) -> (IO (Ptr PaperSize)))
foreign import ccall safe "gtk_paper_size_is_equal"
gtk_paper_size_is_equal :: ((Ptr PaperSize) -> ((Ptr PaperSize) -> (IO CInt)))
foreign import ccall safe "gtk_paper_size_get_name"
gtk_paper_size_get_name :: ((Ptr PaperSize) -> (IO (Ptr CChar)))
foreign import ccall safe "gtk_paper_size_get_display_name"
gtk_paper_size_get_display_name :: ((Ptr PaperSize) -> (IO (Ptr CChar)))
foreign import ccall safe "gtk_paper_size_get_ppd_name"
gtk_paper_size_get_ppd_name :: ((Ptr PaperSize) -> (IO (Ptr CChar)))
foreign import ccall safe "gtk_paper_size_get_width"
gtk_paper_size_get_width :: ((Ptr PaperSize) -> (CInt -> (IO CDouble)))
foreign import ccall safe "gtk_paper_size_get_height"
gtk_paper_size_get_height :: ((Ptr PaperSize) -> (CInt -> (IO CDouble)))
foreign import ccall safe "gtk_paper_size_is_custom"
gtk_paper_size_is_custom :: ((Ptr PaperSize) -> (IO CInt))
foreign import ccall safe "gtk_paper_size_set_size"
gtk_paper_size_set_size :: ((Ptr PaperSize) -> (CDouble -> (CDouble -> (CInt -> (IO ())))))
foreign import ccall safe "gtk_paper_size_get_default_top_margin"
gtk_paper_size_get_default_top_margin :: ((Ptr PaperSize) -> (CInt -> (IO CDouble)))
foreign import ccall safe "gtk_paper_size_get_default_bottom_margin"
gtk_paper_size_get_default_bottom_margin :: ((Ptr PaperSize) -> (CInt -> (IO CDouble)))
foreign import ccall safe "gtk_paper_size_get_default_left_margin"
gtk_paper_size_get_default_left_margin :: ((Ptr PaperSize) -> (CInt -> (IO CDouble)))
foreign import ccall safe "gtk_paper_size_get_default_right_margin"
gtk_paper_size_get_default_right_margin :: ((Ptr PaperSize) -> (CInt -> (IO CDouble)))
foreign import ccall safe "gtk_paper_size_get_default"
gtk_paper_size_get_default :: (IO (Ptr CChar))
foreign import ccall safe "gtk_paper_size_get_paper_sizes"
gtk_paper_size_get_paper_sizes :: (CInt -> (IO (Ptr ())))