cifrado r79 - trunk/package/cifrado
- From: bersace svn gnome org
- To: svn-commits-list gnome org
- Subject: cifrado r79 - trunk/package/cifrado
- Date: Fri, 4 Apr 2008 14:52:36 +0100 (BST)
Author: bersace
Date: Fri Apr 4 14:52:36 2008
New Revision: 79
URL: http://svn.gnome.org/viewvc/cifrado?rev=79&view=rev
Log:
Factorisation de l'impression des messages.
Modified:
trunk/package/cifrado/cifrado.py
Modified: trunk/package/cifrado/cifrado.py
==============================================================================
--- trunk/package/cifrado/cifrado.py (original)
+++ trunk/package/cifrado/cifrado.py Fri Apr 4 14:52:36 2008
@@ -820,29 +820,17 @@
# identifiant pour la maÃtrise.
titre = "Message nÂ%i : ÂÂ%s de ÂÂ%s à ÂÂ%s ; DÃposer à %s ; %s"%(n,message.titre,message.exp.nom,dest.nom,
em.lieu.nom,msg.date)
- layout = contexte.create_pango_layout()
- layout.set_alignment(pango.ALIGN_LEFT)
- layout.set_wrap(pango.WRAP_WORD)
- layout.set_font_description(fd)
- layout.set_text(titre)
- w, hh = layout.get_size()
- cr.move_to(0, 0)
- cr.layout_path(layout)
- cr.fill()
+ w, hh = self.impr_text(contexte, titre, font='sans normal 9')
# on affiche uniquement l'identifiant pour les scouts
id = "%i"%(n)
- layout = contexte.create_pango_layout()
- layout.set_alignment(pango.ALIGN_RIGHT)
- layout.set_wrap(pango.WRAP_WORD)
- fd.set_size(7 * pango.SCALE)
- layout.set_font_description(fd)
- layout.set_text(id)
+ layout = self.layout_text(contexte, id,
+ font='sans normal 7',
+ align=pango.ALIGN_RIGHT)
w, h = layout.get_size()
- cr.move_to(contexte.get_width() - w/pango.SCALE, contexte.get_height() - h/pango.SCALE)
- cr.layout_path(layout)
- cr.fill()
-
+ self.impr_layout(contexte, layout,
+ x=contexte.get_width() - w/pango.SCALE,
+ y=contexte.get_height() - h/pango.SCALE)
# sÃparateur
cr.new_path()
@@ -859,34 +847,21 @@
# Original
- layout = contexte.create_pango_layout()
- layout.set_justify(True)
- layout.set_width(int(contexte.get_width()) * pango.SCALE)
- layout.set_wrap(pango.WRAP_WORD)
- layout.set_font_description(fd)
- layout.set_text(message.message)
- cr.move_to(0, int(1.5 * hh/pango.SCALE))
- cr.layout_path(layout)
- cr.fill()
+ self.impr_text(contexte, message.message,
+ y=int(1.5 * hh/pango.SCALE),
+ justify=True)
# ChiffrÃ
- layout = contexte.create_pango_layout()
- layout.set_justify(True)
- layout.set_width(int(contexte.get_width()) * pango.SCALE)
- layout.set_wrap(pango.WRAP_WORD)
- fd = pango.FontDescription(police)
- layout.set_font_description(fd)
- layout.set_text(em.convertir(message.message))
+ layout = self.layout_text(contexte, em.convertir(message.message),
+ font=police,
+ justify=True)
w,h = layout.get_size()
layout.set_spacing(int(dc.get_interligne()* h / layout.get_line_count()))
-
+ self.impr_layout(contexte, layout,
+ y=contexte.get_height()/division
+ +self.page_setup.get_bottom_margin(gtk.UNIT_POINTS)
+ +self.page_setup.get_top_margin(gtk.UNIT_POINTS))
- cr.move_to(0,
- contexte.get_height()/division
- +self.page_setup.get_bottom_margin(gtk.UNIT_POINTS)
- +self.page_setup.get_top_margin(gtk.UNIT_POINTS))
- cr.layout_path(layout)
- cr.fill()
def layout_text(self, contexte, text,
width=None,
@@ -905,21 +880,23 @@
layout.set_text(text)
return layout
- def impr_text(self, contexte, text, x=0, y=0,
- width=None,
- align=pango.ALIGN_LEFT,
- font='sans normal 9',
- justify=False):
- """return layout size in pango unit"""
+ def impr_layout(self, contexte, layout,x=0,y=0,width=None):
if width is None:
width = (contexte.get_width()-x) * pango.SCALE
- layout = self.layout_text(contexte, text, width, align, font, justify)
cr = contexte.get_cairo_context()
cr.move_to(x, y)
cr.layout_path(layout)
cr.fill()
return layout.get_size()
-
+
+ def impr_text(self, contexte, text, x=0, y=0,
+ width=None,
+ align=pango.ALIGN_LEFT,
+ font='sans normal 9',
+ justify=False):
+ """return layout size in pango unit"""
+ layout = self.layout_text(contexte, text, width, align, font, justify)
+ return self.impr_layout(contexte, layout,x,y,width)
def impr_page_chef(self, op, contexte, no):
cr = contexte.get_cairo_context()
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]