wxcore-0.92.2.0: wxHaskell core

Copyright(c) Daan Leijen 2003
LicensewxWindows
Maintainerwxhaskell-devel@lists.sourceforge.net
Stabilityprovisional
Portabilityportable
Safe HaskellNone
LanguageHaskell98

Graphics.UI.WXCore.Print

Contents

Description

Printer abstraction layer. See samples/wx/Print.hs for a demo.

The application should create a pageSetupDialog to hold the printer settings of the user.

f <- frame [text := "Print demo"]                               

-- Create a pageSetup dialog with an initial margin of 25 mm.
pageSetup <- pageSetupDialog f 25

The dialog can be shown using pageSetupShowModal. Furthermore, the function printDialog and printPreview can be used to show a print dialog and preview window.

mprint   <- menuItem file 
               [ text := "&Print..."
               , help := "Print a test"
               , on command := printDialog pageSetup "Test"  pageFun printFun
               ]
mpreview <- menuItem file 
               [ text := "&Print preview"
               , help := "Print preview"
               , on command := printPreview pageSetup "Test" pageFun printFun 

Those functions take a PageFunction and PrintFunction respectively that get called to determine the number of needed pages and to draw on the printer DC respectively. The framework takes automatic care of printer margins, preview scaling etc.

Synopsis

Printing

pageSetupDialog :: Frame a -> Int -> IO (PageSetupDialog ()) Source

Create a (hidden) page setup dialog that remembers printer settings. It is a parameter to the functions printDialog and printPreview. The creation function takes a parent frame and the initial page margins (in millimeters) as an argument.

pageSetupShowModal :: PageSetupDialog a -> IO () Source

Show the page setup dialog

printDialog :: PageSetupDialog a -> String -> PageFunction -> PrintFunction -> IO () Source

Show a print dialog.

printPreview :: PageSetupDialog a -> String -> PageFunction -> PrintFunction -> IO () Source

Show a preview window

Callbacks

type PageFunction = PageInfo -> PrintInfo -> Size -> (Int, Int) Source

Return a page range given page info, print info, and the printable size. The printable size is the number of pixels available for printing without the page margins.

type PrintFunction = PageInfo -> PrintInfo -> Size -> DC () -> Int -> IO () Source

Print a page given page info, print info, the printable size, the printer device context and the current page. The printable size is the number of pixels available for printing without the page margins

Page and printer info

data PageInfo Source

Information from the page setup dialog. All measurements are in millimeters.

Constructors

PageInfo 

Fields

pageSize :: Size

The page size (in millimeters)

pageArea :: Rect

The available page area (=margins) (in millimeters)

Instances

data PrintInfo Source

Printer information.

Constructors

PrintInfo 

Fields

screenPPI :: Size

screen pixels per inch

printerPPI :: Size

printer pixels per inch

printPageSize :: Size

printable area (in pixels) = PageInfo pageSize minus printer margins

Instances

Internal

printOutGetPrintInfo :: Printout a -> IO PrintInfo Source

Extract print info

pageSetupDialogGetFrame :: PageSetupDialog a -> IO (Frame ()) Source

Get the parent frame of a PageSetupDialog.