8 PURPOSE: Print context and utility functions for printing
9 contents of map display window.
11 AUTHORS: The GRASS Development Team
12 Michael Barton (Arizona State University)
13 Based on generic example code from wxPython
14 demo program by Robin Dunn
16 COPYRIGHT: (C) 2007 by the GRASS Development Team
17 This program is free software under the GNU General Public
18 License (>=v2). Read the file COPYING that comes with GRASS
28 wx.Printout.__init__(self)
60 maxX, maxY = self.canvas.GetSize()
67 maxX = maxX + (2 * marginX)
68 maxY = maxY + (2 * marginY)
71 (w, h) = dc.GetSizeTuple()
74 scaleX = float(w) / maxX
75 scaleY = float(h) / maxY
78 actualScale =
min(scaleX, scaleY)
81 posX = (w - (self.canvas.GetSize()[0] * actualScale)) / 2.0
82 posY = (h - (self.canvas.GetSize()[1] * actualScale)) / 2.0
85 dc.SetUserScale(actualScale, actualScale)
86 dc.SetDeviceOrigin(int(posX), int(posY))
90 self.canvas.pdc.DrawToDC(dc)
111 self.printData.SetPaperId(wx.PAPER_LETTER)
112 self.printData.SetPrintMode(wx.PRINT_MODE_PRINTER)
116 psdd = wx.PageSetupDialogData(self.
printData)
117 psdd.CalculatePaperSizeFromId()
118 dlg = wx.PageSetupDialog(self.
mapwin, psdd)
124 self.
printData = wx.PrintData( dlg.GetPageSetupData().GetPrintData() )
130 data = wx.PrintDialogData(self.
printData)
133 self.
preview = wx.PrintPreview(printout, printout2, data)
135 if not self.preview.Ok():
136 wx.MessageBox(
"There was a problem printing this display\n", wx.OK)
142 pfrm.SetPosition(self.mapframe.GetPosition())
143 pfrm.SetSize(self.mapframe.GetClientSize())
151 printer = wx.Printer(pdd)
154 if not printer.Print(self.
mapframe, printout,
True):
155 wx.MessageBox(
"There was a problem printing.\nPerhaps your current printer is not set correctly?",
"Printing", wx.OK)
157 self.
printData = wx.PrintData( printer.GetPrintDialogData().GetPrintData() )