From d7d7ed340bddf8e00685aa670b59a2ab07b55994 Mon Sep 17 00:00:00 2001 From: Brian Matherly Date: Tue, 27 Feb 2007 04:10:43 +0000 Subject: [PATCH] * src/BaseDoc.py: * src/docgen/PSDrawDoc.py: * src/docgen/SvgDrawDoc.py: * src/docgen/PdfDoc.py: * src/docgen/OpenOfficeDoc.py: * src/docgen/GtkPrint.py: * src/docgen/LPRDoc.py: * src/docgen/ODFDoc.py: * src/plugins/StatisticsChart.py: * src/plugins/Calendar.py: * src/ReportBase/_ReportUtils.py: Remove draw_bar function svn: r8254 --- ChangeLog | 14 ++++++++++++++ src/BaseDoc.py | 3 --- src/ReportBase/_ReportUtils.py | 6 +++--- src/docgen/GtkPrint.py | 5 +---- src/docgen/LPRDoc.py | 25 +++--------------------- src/docgen/ODFDoc.py | 16 ++-------------- src/docgen/OpenOfficeDoc.py | 16 ++-------------- src/docgen/PSDrawDoc.py | 35 +++++++++------------------------- src/docgen/PdfDoc.py | 26 ++++--------------------- src/docgen/SvgDrawDoc.py | 21 +++----------------- src/plugins/Calendar.py | 2 +- src/plugins/StatisticsChart.py | 6 +----- 12 files changed, 43 insertions(+), 132 deletions(-) diff --git a/ChangeLog b/ChangeLog index 4794a1a08..3726677e0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,17 @@ +2007-02-26 Brian Matherly + * src/BaseDoc.py: + * src/docgen/PSDrawDoc.py: + * src/docgen/SvgDrawDoc.py: + * src/docgen/PdfDoc.py: + * src/docgen/OpenOfficeDoc.py: + * src/docgen/GtkPrint.py: + * src/docgen/LPRDoc.py: + * src/docgen/ODFDoc.py: + * src/plugins/StatisticsChart.py: + * src/plugins/Calendar.py: + * src/ReportBase/_ReportUtils.py: + Remove draw_bar function + 2007-02-26 Brian Matherly * src/plugins/WritePkg.py: Fix crash on gpkg export in Windows diff --git a/src/BaseDoc.py b/src/BaseDoc.py index e515a57d0..c7fbd731a 100644 --- a/src/BaseDoc.py +++ b/src/BaseDoc.py @@ -1441,9 +1441,6 @@ class BaseDoc: def draw_box(self, style, text, x, y, w, h): pass - def draw_bar(self, style, x1, y1, x2, y2): - pass - def draw_text(self, style, text, x1, y1): pass diff --git a/src/ReportBase/_ReportUtils.py b/src/ReportBase/_ReportUtils.py index 8d8e7ab4c..8ffc42afa 100644 --- a/src/ReportBase/_ReportUtils.py +++ b/src/ReportBase/_ReportUtils.py @@ -988,7 +988,7 @@ def draw_legend(doc, start_x, start_y, data, title, label_style): gstyle = doc.get_draw_style(format) pstyle = gstyle.get_paragraph_style() size = pt2cm(doc.get_style(pstyle).get_font().get_size()) - doc.draw_bar(format, start_x, start_y, start_x + (2*size), start_y + size) + doc.draw_box(format, "", start_x, start_y, (2*size), size) doc.draw_text(label_style, legend, start_x + (3*size), start_y - (size*0.25)) start_y += size * 1.3 @@ -1027,13 +1027,13 @@ def draw_vertical_bar_graph(doc, format, start_x, start_y, height, width, data): scale = float(height)/float(largest) units = len(data) box_width = (float(width) / (units*3.0+1.0))*2 - + box_height = float(height) bottom = float(start_y)+float(height) start = 0.5*box_width + start_x for index in range(units): size = float(data[index][1]) * scale - doc.draw_bar(data[index][0],start,bottom-size,start+box_width,bottom) + doc.draw_box(data[index][0],"",start,bottom-size,box_width,box_height) start += box_width * 1.5 diff --git a/src/docgen/GtkPrint.py b/src/docgen/GtkPrint.py index 4ff41cb54..93ccee188 100644 --- a/src/docgen/GtkPrint.py +++ b/src/docgen/GtkPrint.py @@ -411,10 +411,7 @@ class GtkDoc(BaseDoc.BaseDoc): def draw_line(self,style,x1,y1,x2,y2): pass - - def draw_bar(self, style, x1, y1, x2, y2): - pass - + def draw_path(self,style,path): pass diff --git a/src/docgen/LPRDoc.py b/src/docgen/LPRDoc.py index 8c7545751..460d156d8 100644 --- a/src/docgen/LPRDoc.py +++ b/src/docgen/LPRDoc.py @@ -1064,9 +1064,6 @@ class LPRDoc(BaseDoc.BaseDoc): y = self.top_margin - cm2u(y) box_style = self.draw_styles[style] - para_name = box_style.get_paragraph_style() - para_style = self.style_list[para_name] - fontstyle = para_style.get_font() bh = cm2u(h) bw = cm2u(w) @@ -1090,6 +1087,9 @@ class LPRDoc(BaseDoc.BaseDoc): self.gpc.rect_stroked(x,y,bw,-bh) if text: + para_name = box_style.get_paragraph_style() + para_style = self.style_list[para_name] + fontstyle = para_style.get_font() lines = text.split('\n') start_x = x + 0.5 * fontstyle.get_size() start_y = y - fontstyle.get_size() * _EXTRA_SPACING_FACTOR @@ -1101,25 +1101,6 @@ class LPRDoc(BaseDoc.BaseDoc): self.gpc.show(line) start_y -= fontstyle.get_size() * _EXTRA_SPACING_FACTOR - def draw_bar(self, style, x1, y1, x2, y2): - self.brand_new_page = 0 - - stype = self.draw_styles[style] - self.gpc.setlinewidth(stype.get_line_width()) - 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) - bh = cm2u(y2-y1) - bw = cm2u(x2-x1) - - self.gpc.setrgbcolor(fill_color[0],fill_color[1],fill_color[2]) - self.gpc.rect_filled(x,y,bw,-bh) - self.gpc.setrgbcolor(color[0],color[1],color[2]) - self.gpc.rect_stroked(x,y,bw,-bh) - self.gpc.setrgbcolor(0,0,0) - def draw_text(self,style,text,x,y): self.brand_new_page = 0 box_style = self.draw_styles[style] diff --git a/src/docgen/ODFDoc.py b/src/docgen/ODFDoc.py index 9e88a37aa..93b410e25 100644 --- a/src/docgen/ODFDoc.py +++ b/src/docgen/ODFDoc.py @@ -1070,18 +1070,6 @@ class ODFDoc(BaseDoc.BaseDoc): self.cntnt.write('\n') self.cntnt.write('\n') - def draw_bar(self,style,x,y,x2,y2): - box_style = self.draw_styles[style] - - self.cntnt.write('' % float(y)) - self.cntnt.write('\n') - def draw_box(self,style,text,x,y, w, h): box_style = self.draw_styles[style] para_name = box_style.get_paragraph_style() @@ -1120,11 +1108,11 @@ class ODFDoc(BaseDoc.BaseDoc): pstyle = self.style_list[para_name] font = pstyle.get_font() - size = 1.2*(FontScale.string_width(font,text)/72.0) * 2.54 + size = (FontScale.string_width(font,text)/72.0) * 2.54 self.cntnt.write('') self.cntnt.write('\n') - def draw_bar(self,style,x,y,x2,y2): - box_style = self.draw_styles[style] - - self.cntnt.write('' % float(y)) - self.cntnt.write('\n') - def draw_box(self,style,text,x,y, w, h): box_style = self.draw_styles[style] para_name = box_style.get_paragraph_style() @@ -965,11 +953,11 @@ class OpenOfficeDoc(BaseDoc.BaseDoc): pstyle = self.style_list[para_name] font = pstyle.get_font() - size = 1.1*(FontScale.string_width(font,text)/72.0) * 2.54 + size = (FontScale.string_width(font,text)/72.0) * 2.54 self.cntnt.write('\n') - - def draw_bar(self,style,x1,y1,x2,y2): - x1 = x1 + self.paper.get_left_margin() - x2 = x2 + self.paper.get_left_margin() - y1 = y1 + self.paper.get_top_margin() - y2 = y2 + self.paper.get_top_margin() - s = self.draw_styles[style] - self.f.write('\n' % s.get_line_width()) - def draw_box(self,style,text,x,y, w, h): x = x + self.paper.get_left_margin() y = y + self.paper.get_top_margin() box_style = self.draw_styles[style] - para_name = box_style.get_paragraph_style() - p = self.style_list[para_name] if box_style.get_shadow(): self.f.write('\n' % box_style.get_line_width()) if text != "": + para_name = box_style.get_paragraph_style() + assert( para_name != '' ) + p = self.style_list[para_name] font = p.get_font() font_size = font.get_size() lines = text.split('\n') diff --git a/src/plugins/Calendar.py b/src/plugins/Calendar.py index a22a79437..f7be4ad88 100644 --- a/src/plugins/Calendar.py +++ b/src/plugins/Calendar.py @@ -199,7 +199,7 @@ class Calendar(Report): height = self.doc.get_usable_height() header = 2.54 # one inch self.draw_rectangle("CAL-Border", 0, 0, width, height) - self.doc.draw_bar("CAL-Title", 0, 0, width, header) + self.doc.draw_box("CAL-Title", "", 0, 0, width, header) self.doc.draw_line("CAL-Border", 0, header, width, header) year = self["year"] title = "%s %d" % (GrampsLocale.long_months[month], year) diff --git a/src/plugins/StatisticsChart.py b/src/plugins/StatisticsChart.py index 558b3c7f6..dc1fbc0d5 100644 --- a/src/plugins/StatisticsChart.py +++ b/src/plugins/StatisticsChart.py @@ -737,11 +737,7 @@ class StatisticsChart(Report): # right align bar to the text value = data[key] startx = stopx - (maxsize * value / max_value) - path = ((startx, yoffset), - (stopx, yoffset), - (stopx, yoffset + row_h), - (startx, yoffset + row_h)) - self.doc.draw_path('SC-bar', path) + self.doc.draw_box('SC-bar',"",startx,yoffset,stopx-startx,row_h) # text after bar text = "%s (%d)" % (key, data[key]) self.doc.draw_text('SC-text', text, textx, yoffset)