commit-gnue
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[gnue] r8898 - in trunk/gnue-forms/src/uidrivers/win32: . widgets/form


From: btami
Subject: [gnue] r8898 - in trunk/gnue-forms/src/uidrivers/win32: . widgets/form
Date: Sat, 21 Oct 2006 14:02:16 -0500 (CDT)

Author: btami
Date: 2006-10-21 14:02:16 -0500 (Sat, 21 Oct 2006)
New Revision: 8898

Removed:
   trunk/gnue-forms/src/uidrivers/win32/PrintForm.py
Modified:
   trunk/gnue-forms/src/uidrivers/win32/widgets/form/widget.py
Log:
moved ui printout code to it's place

Deleted: trunk/gnue-forms/src/uidrivers/win32/PrintForm.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/win32/PrintForm.py   2006-10-21 18:35:04 UTC 
(rev 8897)
+++ trunk/gnue-forms/src/uidrivers/win32/PrintForm.py   2006-10-21 19:02:16 UTC 
(rev 8898)
@@ -1,102 +0,0 @@
-# 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.
-#
-# Copyright 2001-2006 Free Software Foundation
-#
-# $Id$
-#
-# DESCRIPTION:
-# Handles the default "Print" option for the win32 client
-#
-
-__all__ = ['printForm']
-
-import win32ui
-import win32gui
-import win32con
-import win32print
-
-from PIL import Image, ImageWin, ImageGrab
-
-import time
-from gnue.forms import VERSION
-
-# Constants for GetDeviceCaps
-HORZRES = 8
-VERTRES = 10
-
-
-def printForm(form, driver):
-  print 'PrintForm start...'
-  # Get a suitable title for the print job
-  # We default to either "Form Name" or "Form Name" + "Page Name"
-  # depending on if the page has a caption or not.
-  subtitle = ""
-  try:
-    title = form.title
-  except AttributeError:
-    title = 'Untitled Form'
-  try:
-    if form._currentPage.caption:
-      subtitle = ' (' + form._currentPage.caption + ')'
-  except AttributeError:
-    pass
-
-  window = driver._gfObjToUIWidget[form].mainWindow
-  l,t,r,b = win32gui.GetWindowRect(window.GetHwnd())
-  image = ImageGrab.grab((l+2, t+2, r-2, b-2))
-  image.save("tmp.bmp")
-
-  # Open the bitmap
-  bmp = Image.open ("tmp.bmp")
-  print "original bitmap size =", bmp.size
-
-
-  printer = win32print.GetDefaultPrinter()
-  print printer
-  phandle = win32print.OpenPrinter(printer)
-
-  # Find the printer resolution to scale to
-  hDC = win32ui.CreateDC ()
-  hDC.CreatePrinterDC () # can optionally put a printer name in here
-  printer_resolution = hDC.GetDeviceCaps (HORZRES), hDC.GetDeviceCaps (VERTRES)
-  print "printer resolution =", printer_resolution
-
-  # Resize the image to fit the page but not to overflow
-  ratios = [printer_resolution[0] / bmp.size[0], printer_resolution[1] / 
bmp.size[1]]
-  print "ratios =", ratios
-  scale = min (ratios)
-  print "scale =", scale
-
-  # Create the printer document and send the page
-  hDC.StartDoc ("GNUe PrintForm")
-  hDC.StartPage ()
-
-  dib = ImageWin.Dib (bmp)
-  scaled_size = [scale * i for i in bmp.size]
-  print "scaled bitmap size =", scaled_size
-  dib.draw (hDC.GetHandleOutput (), [0, 0] + scaled_size)
-
-  hDC.EndPage ()
-  hDC.EndDoc ()
-
-  win32print.ClosePrinter(phandle)
-  del hDC
-  del bmp
-  os.remove("tmp.bmp")
-
-  print 'PrintForm end.'

Modified: trunk/gnue-forms/src/uidrivers/win32/widgets/form/widget.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/win32/widgets/form/widget.py 2006-10-21 
18:35:04 UTC (rev 8897)
+++ trunk/gnue-forms/src/uidrivers/win32/widgets/form/widget.py 2006-10-21 
19:02:16 UTC (rev 8898)
@@ -32,13 +32,20 @@
 import win32gui
 import win32con
 import commctrl
-
+import win32print
+
+from PIL import Image, ImageWin, ImageGrab
+
 from gnue.forms.uidrivers.win32 import dialogs
 from gnue.forms.uidrivers.win32.common import *
 from gnue.forms.uidrivers.win32.widgets._base import UIHelper, Win32Window
 from gnue.forms.uidrivers.win32.MenuBar import MenuBar
 from gnue.forms.uidrivers.win32.ToolBar import ToolBar
 import wrappers
+
+# Constants for GetDeviceCaps
+HORZRES = 8
+VERTRES = 10
 
 _MBOX_KIND = {'Info'    : {'type'   : _('Info'),
                            'icon'   : win32con.MB_ICONINFORMATION,
@@ -284,7 +291,52 @@
 
   def _ui_printout_(self, title, subtitle, user):
 
-    pass
+    print 'PrintForm start...'
+
+    window = self.mainWindow
+    l,t,r,b = win32gui.GetWindowRect(window.GetHwnd())
+    image = ImageGrab.grab((l+2, t+2, r-2, b-2))
+    image.save("tmp.bmp")
+
+    # Open the bitmap
+    bmp = Image.open ("tmp.bmp")
+    print "original bitmap size =", bmp.size
+
+
+    printer = win32print.GetDefaultPrinter()
+    print printer
+    phandle = win32print.OpenPrinter(printer)
+
+    # Find the printer resolution to scale to
+    hDC = win32ui.CreateDC ()
+    hDC.CreatePrinterDC () # can optionally put a printer name in here
+    printer_resolution = hDC.GetDeviceCaps (HORZRES), hDC.GetDeviceCaps 
(VERTRES)
+    print "printer resolution =", printer_resolution
+
+    # Resize the image to fit the page but not to overflow
+    ratios = [printer_resolution[0] / bmp.size[0], printer_resolution[1] / 
bmp.size[1]]
+    print "ratios =", ratios
+    scale = min (ratios)
+    print "scale =", scale
+
+    # Create the printer document and send the page
+    hDC.StartDoc ("GNUe PrintForm")
+    hDC.StartPage ()
+
+    dib = ImageWin.Dib (bmp)
+    scaled_size = [scale * i for i in bmp.size]
+    print "scaled bitmap size =", scaled_size
+    dib.draw (hDC.GetHandleOutput (), [0, 0] + scaled_size)
+
+    hDC.EndPage ()
+    hDC.EndDoc ()
+
+    win32print.ClosePrinter(phandle)
+    del hDC
+    del bmp
+    os.remove("tmp.bmp")
+
+    print 'PrintForm end.'
 
 
   # ---------------------------------------------------------------------------





reply via email to

[Prev in Thread] Current Thread [Next in Thread]