Author: btami Date: 2008-03-18 07:47:09 -0500 (Tue, 18 Mar 2008) New Revision: 9859
Added: trunk/gnue-forms/src/uidrivers/win32/PrintDialog.py Modified: trunk/gnue-reports/src/adapters/destinations/printer/gdi.py trunk/gnue-reports/src/adapters/destinations/printer/win32raw.py Log: removed PrintDialog to gnue-forms uidriver Added: trunk/gnue-forms/src/uidrivers/win32/PrintDialog.py =================================================================== --- trunk/gnue-forms/src/uidrivers/win32/PrintDialog.py (rev 0) +++ trunk/gnue-forms/src/uidrivers/win32/PrintDialog.py 2008-03-18 12:47:09 UTC (rev 9859) @@ -0,0 +1,46 @@ +# +# Copyright 2002-2008 Free Software Foundation +# +# This file is part of GNU Enterprise. +# +# GNU Enterprise is free software; you can redistribute it +# and/or modify it under the terms of the GNU General Public +# License as published by the Free Software Foundation; either +# version 2, or (at your option) any later version. +# +# GNU Enterprise is distributed in the hope that it will be +# useful, but WITHOUT ANY WARRANTY; without even the implied +# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +# PURPOSE. See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public +# License along with program; see the file COPYING. If not, +# write to the Free Software Foundation, Inc., 59 Temple Place +# - Suite 330, Boston, MA 02111-1307, USA. +# +# $Id:$ + +import win32ui +from pywin.mfc import window, dialog + +PRINTDLGORD = 1538 +PRINTER = 1139 + +class PrintDialog(dialog.Dialog): + def __init__(self, dlgID=PRINTDLGORD, dllid=None): + printSetupOnly = 0 + flags=(win32ui.PD_ALLPAGES| + win32ui.PD_USEDEVMODECOPIES| + win32ui.PD_NOPAGENUMS| + win32ui.PD_HIDEPRINTTOFILE| + win32ui.PD_NOSELECTION) + + parent=None + dlg = win32ui.CreatePrintDialog(dlgID, printSetupOnly, flags, parent, dllid) + window.Wnd.__init__(self, dlg) + self.HookCommands() + self.bHaveInit = None + + def OnOK(self): + self._obj_.OnOK() + self['deviceName'] = self.GetDlgItem(PRINTER).GetWindowText() Modified: trunk/gnue-reports/src/adapters/destinations/printer/gdi.py =================================================================== --- trunk/gnue-reports/src/adapters/destinations/printer/gdi.py 2008-03-18 12:41:18 UTC (rev 9858) +++ trunk/gnue-reports/src/adapters/destinations/printer/gdi.py 2008-03-18 12:47:09 UTC (rev 9859) @@ -19,44 +19,22 @@ # - Suite 330, Boston, MA 02111-1307, USA. # # $Id$ - -""" -Basic destination adapter for writing xml data + +""" +Basic destination adapter for writing xml data based on Char layout to win32 GDI printers """ - + import xml.sax -import win32ui, win32con -import math, string, sys, os -from pywin.mfc import window, dialog - +import math, string, sys, os + +import win32ui, win32con + from gnue.reports.base.GROutputAdapter import DestinationAdapter as Base from gnue.common.apps import GDebug - -PRINTDLGORD = 1538 -PRINTER = 1139 - +from gnue.forms.uidrivers.win32 import PrintDialog -class PrintDialog(dialog.Dialog): - def __init__(self, dlgID, dllid=None): - printSetupOnly = 0 - flags=(win32ui.PD_ALLPAGES| - win32ui.PD_USEDEVMODECOPIES| - win32ui.PD_NOPAGENUMS| - win32ui.PD_HIDEPRINTTOFILE| - win32ui.PD_NOSELECTION) - parent=None - dlg = win32ui.CreatePrintDialog(dlgID, printSetupOnly, flags, parent, dllid) - window.Wnd.__init__(self, dlg) - self.HookCommands() - self.bHaveInit = None - - def OnOK(self): - self._obj_.OnOK() - self['deviceName'] = self.GetDlgItem(PRINTER).GetWindowText() - - class DestinationAdapter(Base, xml.sax.ContentHandler): # @@ -93,7 +71,7 @@ print_to = string.replace(string.replace(self.destination, "`",""),';','') if print_to == '-': - pDialog = PrintDialog(PRINTDLGORD) + pDialog = PrintDialog() pDialog.DoModal() try: # OK selected @@ -102,99 +80,99 @@ # Cancel selected self.deleteTempFile(self.tempfile) return - - self.setup(print_to) - + + self.setup(print_to) + infile = open(file, 'r') - + # Create a parser parser = xml.sax.make_parser() # Tell the parser to use our handler parser.setContentHandler(self) parser.parse(infile) - + infile.close() - + self.deleteTempFile(self.tempfile) - - + + # XML handling stuff def startElement(self, name, attrs): if name == "report": - self.dc.StartDoc(name) + self.dc.StartDoc(name) elif name == "page": - self.dc.StartPage() - + self.dc.StartPage() + elif name == "line": - self._y = int(attrs['y']) - + self._y = int(attrs['y']) + elif name == "label": - self._attrs = attrs - self.dc.SelectObject(FONTS['normal']) - + self._attrs = attrs + self.dc.SelectObject(FONTS['normal']) + elif name == "b": - self.dc.SelectObject(FONTS['bold']) - + self.dc.SelectObject(FONTS['bold']) + elif name == "i": - self.dc.SelectObject(FONTS['italic']) - + self.dc.SelectObject(FONTS['italic']) + self._text = '' - - + + def characters(self, text): self._text += text def endElement(self, name): if name == "report": - self.dc.EndDoc() + self.dc.EndDoc() elif name == "page": - self.dc.EndPage() - + self.dc.EndPage() + elif name == "label": - h = self.metrics['height'] - w = self.metrics['width'] - self.dc.TextOut(int(w * int(self._attrs['x'])), - int( - h * 1.3 * self._y), - self._text.encode(_encoding, 'replace')) - - def setup(self, printer): - self.dc = win32ui.CreateDC() - self.dc.CreatePrinterDC(printer) - self.dc.SetMapMode(win32con.MM_TWIPS) - - self.dc.SelectObject(FONTS['normal']) - m = self.dc.GetTextMetrics() - - self.metrics = {} - self.metrics['width'] = m['tmAveCharWidth'] - self.metrics['height'] = m['tmHeight'] - - -def createFonts(): - fonts = {} - font_specs = { - 'normal' : { - 'name': 'Courier New', - 'size': 12, - 'weight': 400}, - 'bold' : { - 'name': 'Courier New', - 'size': 12, - 'weight': 800}, - 'italic' : { - 'name': 'Courier New', - 'size': 12, - 'weight': 400, - 'italic': 1} - } - for spec in ['normal', 'bold', 'italic']: - fonts[spec] = win32ui.CreateFont(font_specs[spec]) - return fonts - -FONTS = createFonts() - + h = self.metrics['height'] + w = self.metrics['width'] + self.dc.TextOut(int(w * int(self._attrs['x'])), + int( - h * 1.3 * self._y), + self._text.encode(_encoding, 'replace')) + + def setup(self, printer): + self.dc = win32ui.CreateDC() + self.dc.CreatePrinterDC(printer) + self.dc.SetMapMode(win32con.MM_TWIPS) + + self.dc.SelectObject(FONTS['normal']) + m = self.dc.GetTextMetrics() + + self.metrics = {} + self.metrics['width'] = m['tmAveCharWidth'] + self.metrics['height'] = m['tmHeight'] + + +def createFonts(): + fonts = {} + font_specs = { + 'normal' : { + 'name': 'Courier New', + 'size': 12, + 'weight': 400}, + 'bold' : { + 'name': 'Courier New', + 'size': 12, + 'weight': 800}, + 'italic' : { + 'name': 'Courier New', + 'size': 12, + 'weight': 400, + 'italic': 1} + } + for spec in ['normal', 'bold', 'italic']: + fonts[spec] = win32ui.CreateFont(font_specs[spec]) + return fonts + +FONTS = createFonts() + _encoding = gConfig('textEncoding') \ No newline at end of file Modified: trunk/gnue-reports/src/adapters/destinations/printer/win32raw.py =================================================================== --- trunk/gnue-reports/src/adapters/destinations/printer/win32raw.py 2008-03-18 12:41:18 UTC (rev 9858) +++ trunk/gnue-reports/src/adapters/destinations/printer/win32raw.py 2008-03-18 12:47:09 UTC (rev 9859) @@ -18,43 +18,22 @@ # write to the Free Software Foundation, Inc., 59 Temple Place # - Suite 330, Boston, MA 02111-1307, USA. # -# $Id$ +# $Id$ -""" -Basic destination adapter for writing raw data +""" +Basic destination adapter for writing raw data (text/ps/pcl/esc-p) to win32 printers """ +import sys, os, string + +import win32print + from gnue.reports import VERSION from gnue.reports.base.GROutputAdapter import DestinationAdapter as Base from gnue.common.apps import GDebug -import sys, os, string -import win32print, win32ui -from pywin.mfc import window, dialog +from gnue.forms.uidrivers.win32 import PrintDialog -PRINTDLGORD = 1538 -PRINTER = 1139 - -class PrintDialog(dialog.Dialog): - def __init__(self, dlgID, dllid=None): - printSetupOnly = 0 - flags=(win32ui.PD_ALLPAGES| - win32ui.PD_USEDEVMODECOPIES| - win32ui.PD_NOPAGENUMS| - win32ui.PD_HIDEPRINTTOFILE| - win32ui.PD_NOSELECTION) - - parent=None - dlg = win32ui.CreatePrintDialog(dlgID, printSetupOnly, flags, parent, dllid) - window.Wnd.__init__(self, dlg) - self.HookCommands() - self.bHaveInit = None - - def OnOK(self): - self._obj_.OnOK() - self['deviceName'] = self.GetDlgItem(PRINTER).GetWindowText() - - class DestinationAdapter(Base): # @@ -91,7 +70,7 @@ print_to = string.replace(string.replace(self.destination, "`",""),';','') if print_to == '-': - pDialog = PrintDialog(PRINTDLGORD) + pDialog = PrintDialog() pDialog.DoModal() try: # OK selected _______________________________________________ commit-gnue mailing list commit-gnue@gnu.org http://lists.gnu.org/mailman/listinfo/commit-gnue