2 @package mapdisp.gprint
4 @brief Print context and utility functions for printing
5 contents of map display window.
11 (C) 2007-2011 by the GRASS Development Team
13 This program is free software under the GNU General Public License
14 (>=v2). Read the file COPYING that comes with GRASS for details.
16 @author Michael Barton (Arizona State University)
25 wx.Printout.__init__(self)
57 maxX, maxY = self.canvas.GetSize()
64 maxX = maxX + (2 * marginX)
65 maxY = maxY + (2 * marginY)
68 (w, h) = dc.GetSizeTuple()
71 scaleX = float(w) / maxX
72 scaleY = float(h) / maxY
75 actualScale =
min(scaleX, scaleY)
78 posX = (w - (self.canvas.GetSize()[0] * actualScale)) / 2.0
79 posY = (h - (self.canvas.GetSize()[1] * actualScale)) / 2.0
82 dc.SetUserScale(actualScale, actualScale)
83 dc.SetDeviceOrigin(int(posX), int(posY))
87 self.canvas.pdc.DrawToDC(dc)
108 self.printData.SetPaperId(wx.PAPER_LETTER)
109 self.printData.SetPrintMode(wx.PRINT_MODE_PRINTER)
113 psdd = wx.PageSetupDialogData(self.
printData)
114 psdd.CalculatePaperSizeFromId()
115 dlg = wx.PageSetupDialog(self.
mapwin, psdd)
121 self.
printData = wx.PrintData( dlg.GetPageSetupData().GetPrintData() )
127 data = wx.PrintDialogData(self.
printData)
130 self.
preview = wx.PrintPreview(printout, printout2, data)
132 if not self.preview.Ok():
133 wx.MessageBox(
"There was a problem printing this display\n", wx.OK)
139 pfrm.SetPosition(self.mapframe.GetPosition())
140 pfrm.SetSize(self.mapframe.GetClientSize())
148 printer = wx.Printer(pdd)
151 if not printer.Print(self.
mapframe, printout,
True):
152 wx.MessageBox(
"There was a problem printing.\nPerhaps your current printer is not set correctly?",
"Printing", wx.OK)
154 self.
printData = wx.PrintData( printer.GetPrintDialogData().GetPrintData() )
158 wx.Printout.__init__(self)
190 maxX, maxY = self.canvas.GetSize()
197 maxX = maxX + (2 * marginX)
198 maxY = maxY + (2 * marginY)
201 (w, h) = dc.GetSizeTuple()
204 scaleX = float(w) / maxX
205 scaleY = float(h) / maxY
208 actualScale =
min(scaleX, scaleY)
211 posX = (w - (self.canvas.GetSize()[0] * actualScale)) / 2.0
212 posY = (h - (self.canvas.GetSize()[1] * actualScale)) / 2.0
215 dc.SetUserScale(actualScale, actualScale)
216 dc.SetDeviceOrigin(int(posX), int(posY))
220 self.canvas.pdc.DrawToDC(dc)
241 self.printData.SetPaperId(wx.PAPER_LETTER)
242 self.printData.SetPrintMode(wx.PRINT_MODE_PRINTER)
246 psdd = wx.PageSetupDialogData(self.
printData)
247 psdd.CalculatePaperSizeFromId()
248 dlg = wx.PageSetupDialog(self.
mapwin, psdd)
254 self.
printData = wx.PrintData( dlg.GetPageSetupData().GetPrintData() )
260 data = wx.PrintDialogData(self.
printData)
263 self.
preview = wx.PrintPreview(printout, printout2, data)
265 if not self.preview.Ok():
266 wx.MessageBox(
"There was a problem printing this display\n", wx.OK)
272 pfrm.SetPosition(self.mapframe.GetPosition())
273 pfrm.SetSize(self.mapframe.GetClientSize())
281 printer = wx.Printer(pdd)
284 if not printer.Print(self.
mapframe, printout,
True):
285 GMessage(_(
"There was a problem printing.\n"
286 "Perhaps your current printer is not set correctly?"))
288 self.
printData = wx.PrintData( printer.GetPrintDialogData().GetPrintData() )