From ac6ccd0adc61473d7877acc5dcd0d80368196de6 Mon Sep 17 00:00:00 2001 From: Alex Roitman Date: Tue, 22 Feb 2005 01:59:28 +0000 Subject: [PATCH] * src/docgen/PSDrawDoc.py (rgb_color): Remove function, import it from ReportUtils instead. * src/ReportUtils.py (rgb_color): Add function. * src/docgen/PdfDoc.py: Use rgb_color from ReportUtils. * src/docgen/LPRDoc.py: Use rgb_color from ReportUtils. svn: r4070 --- gramps2/ChangeLog | 6 ++++++ gramps2/src/ReportUtils.py | 6 ++++++ gramps2/src/docgen/LPRDoc.py | 11 ++++++----- gramps2/src/docgen/PSDrawDoc.py | 10 +++------- gramps2/src/docgen/PdfDoc.py | 11 +++++++++-- 5 files changed, 30 insertions(+), 14 deletions(-) diff --git a/gramps2/ChangeLog b/gramps2/ChangeLog index 32c0a60b3..20af2ceb6 100644 --- a/gramps2/ChangeLog +++ b/gramps2/ChangeLog @@ -8,6 +8,12 @@ * src/docgen/PSDrawDoc.py (draw_text,write_at): Attempt latin1 encoding. + * src/docgen/PSDrawDoc.py (rgb_color): Remove function, import it + from ReportUtils instead. + * src/ReportUtils.py (rgb_color): Add function. + * src/docgen/PdfDoc.py: Use rgb_color from ReportUtils. + * src/docgen/LPRDoc.py: Use rgb_color from ReportUtils. + 2005-02-20 Alex Roitman * src/docgen/LPRDoc.py (draw_path,draw_bar): Set proper linewidth. * doc/gramps-manual/C/usage.xml: Update. diff --git a/gramps2/src/ReportUtils.py b/gramps2/src/ReportUtils.py index 4258d8885..c608be775 100644 --- a/gramps2/src/ReportUtils.py +++ b/gramps2/src/ReportUtils.py @@ -62,6 +62,12 @@ def cm2pt(cm): """ return cm*182.88 +def rgb_color(color): + r = float(color[0])/255.0 + g = float(color[1])/255.0 + b = float(color[2])/255.0 + return (r,g,b) + def draw_pie_chart(doc, center_x, center_y, radius, data, start=0): """ Draws a pie chart in the specified document. The data passed is plotted as diff --git a/gramps2/src/docgen/LPRDoc.py b/gramps2/src/docgen/LPRDoc.py index 5dabfc944..1a054f537 100644 --- a/gramps2/src/docgen/LPRDoc.py +++ b/gramps2/src/docgen/LPRDoc.py @@ -62,6 +62,7 @@ else: #------------------------------------------------------------------------ import BaseDoc import PluginMgr +from ReportUtils import rgb_color #------------------------------------------------------------------------ # @@ -991,8 +992,8 @@ class LPRDoc(BaseDoc.BaseDoc): self.brand_new_page = 0 stype = self.draw_styles[style] self.gpc.setlinewidth(stype.get_line_width()) - fill_color = [ val/255.0 for val in stype.get_fill_color()] - color = [ val/255.0 for val in stype.get_color()] + fill_color = rgb_color(stype.get_fill_color()) + color = rgb_color(stype.get_color()) point = path[0] x = cm2u(point[0]) + self.left_margin @@ -1040,7 +1041,7 @@ class LPRDoc(BaseDoc.BaseDoc): if box_style.get_shadow(): ss = cm2u(box_style.get_shadow_space()) - color = [ val/255.0 for val in _SHADOW_COLOR ] + color = rgb_color(_SHADOW_COLOR) path = ( (x+ss,y-bh), (x+ss,y-bh-ss), (x+bw+ss,y-bh-ss), (x+bw+ss,y-ss), (x+bw,y-ss), (x+bw,y-bh), (x+ss,y-bh), @@ -1085,8 +1086,8 @@ class LPRDoc(BaseDoc.BaseDoc): stype = self.draw_styles[style] self.gpc.setlinewidth(stype.get_line_width()) - fill_color = [ val/255.0 for val in stype.get_fill_color() ] - color = [ val/255.0 for val in stype.get_color() ] + fill_color = rgb_color(stype.get_fill_color()) + color = rgb_color(stype.get_color()) x = self.left_margin + cm2u(x1) y = self.top_margin - cm2u(y1) diff --git a/gramps2/src/docgen/PSDrawDoc.py b/gramps2/src/docgen/PSDrawDoc.py index 099855988..f1ae63573 100644 --- a/gramps2/src/docgen/PSDrawDoc.py +++ b/gramps2/src/docgen/PSDrawDoc.py @@ -18,6 +18,8 @@ # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # +# $Id$ + #------------------------------------------------------------------------- # # python modules @@ -35,7 +37,7 @@ import PluginMgr import Errors import BaseDoc from Report import run_print_dialog -from ReportUtils import pt2cm +from ReportUtils import pt2cm, rgb_color #------------------------------------------------------------------------- # @@ -404,11 +406,5 @@ class PSDrawDoc(BaseDoc.BaseDoc): self.f.write("(%s) show\n" % lines[i]) self.f.write('grestore\n') -def rgb_color(color): - r = float(color[0])/255.0 - g = float(color[1])/255.0 - b = float(color[2])/255.0 - return (r,g,b) - PluginMgr.register_draw_doc(_("PostScript"),PSDrawDoc,1,1,".ps", _("Print a copy")); diff --git a/gramps2/src/docgen/PdfDoc.py b/gramps2/src/docgen/PdfDoc.py index 6db367115..f4a0b5565 100644 --- a/gramps2/src/docgen/PdfDoc.py +++ b/gramps2/src/docgen/PdfDoc.py @@ -20,6 +20,13 @@ # $Id$ +#------------------------------------------------------------------------ +# +# Python modules +# +#------------------------------------------------------------------------ +from gettext import gettext as _ + #------------------------------------------------------------------------ # # gramps modules @@ -30,7 +37,7 @@ import PluginMgr import Errors import ImgManip import GrampsMime -from gettext import gettext as _ +from ReportUtils import rgb_color _H = 'Helvetica' _HB = 'Helvetica-Bold' @@ -611,7 +618,7 @@ class PdfDoc(BaseDoc.BaseDoc): # #------------------------------------------------------------------------ def make_color(c): - return Color(float(c[0])/255.0, float(c[1])/255.0, float(c[2])/255.0) + return Color(rgb_color(c)) #------------------------------------------------------------------------ #