Package Simple :: Module _SimpleDoc
[frames] | no frames]

Source Code for Module Simple._SimpleDoc

  1  # 
  2  # Gramps - a GTK+/GNOME based genealogy program 
  3  # 
  4  # Copyright (C) 2007  Donald N. Allingham 
  5  # 
  6  # This program is free software; you can redistribute it and/or modify 
  7  # it under the terms of the GNU General Public License as published by 
  8  # the Free Software Foundation; either version 2 of the License, or 
  9  # (at your option) any later version. 
 10  # 
 11  # This program is distributed in the hope that it will be useful, 
 12  # but WITHOUT ANY WARRANTY; without even the implied warranty of 
 13  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
 14  # GNU General Public License for more details. 
 15  # 
 16  # You should have received a copy of the GNU General Public License 
 17  # along with this program; if not, write to the Free Software 
 18  # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA 
 19  # 
 20   
 21  """ 
 22  Provide a simplified database access interface to the GRAMPS database. 
 23  """ 
 24  import BaseDoc 
 25   
26 -class SimpleDoc:
27 """ 28 Provide a simplified database access interface to the GRAMPS database. 29 """ 30
31 - def __init__(self, doc):
32 """ 33 Initialize the class with the real document 34 """ 35 self.doc = doc
36
37 - def __write(self, format, text):
38 """ 39 Writes a paragraph using the specified format to the BaseDoc 40 """ 41 self.doc.start_paragraph(format) 42 self.doc.write_text(text) 43 self.doc.end_paragraph()
44
45 - def title(self, text):
46 """ 47 Writes the Title using the Title paragraph 48 """ 49 self.__write('Title', text)
50
51 - def header1(self, text):
52 """ 53 Writes the first level header using the Header1 paragraph 54 """ 55 self.__write('Header1', text)
56
57 - def header2(self, text):
58 """ 59 Writes the second level header using the Header2 paragraph 60 """ 61 self.__write('Header2', text)
62
63 - def header3(self, text):
64 """ 65 Writes the third level header using the Header3 paragraph 66 """ 67 self.__write('Header3', text)
68
69 - def paragraph(self, text):
70 """ 71 Writes a paragraph using the Normal format 72 """ 73 self.__write('Normal', text)
74
75 -def make_basic_stylesheet():
76 """ 77 Create the basic style sheet for the SimpleDoc class 78 """ 79 sheet = BaseDoc.StyleSheet() 80 81 pstyle = BaseDoc.ParagraphStyle() 82 fstyle = pstyle.get_font() 83 fstyle.set_type_face(BaseDoc.FONT_SANS_SERIF) 84 fstyle.set_size(14) 85 fstyle.set_bold(True) 86 pstyle.set_font(fstyle) 87 pstyle.set_alignment(BaseDoc.PARA_ALIGN_LEFT) 88 sheet.add_paragraph_style('Title', pstyle) 89 90 pstyle = BaseDoc.ParagraphStyle() 91 fstyle = pstyle.get_font() 92 fstyle.set_type_face(BaseDoc.FONT_SANS_SERIF) 93 fstyle.set_size(12) 94 fstyle.set_bold(True) 95 pstyle.set_font(fstyle) 96 pstyle.set_alignment(BaseDoc.PARA_ALIGN_LEFT) 97 pstyle.set_tabs([4, 8, 12, 16]) 98 sheet.add_paragraph_style('Header1', pstyle) 99 100 pstyle = BaseDoc.ParagraphStyle() 101 fstyle = pstyle.get_font() 102 fstyle.set_type_face(BaseDoc.FONT_SANS_SERIF) 103 fstyle.set_size(10) 104 fstyle.set_bold(True) 105 pstyle.set_font(fstyle) 106 pstyle.set_alignment(BaseDoc.PARA_ALIGN_LEFT) 107 pstyle.set_tabs([4, 8, 12, 16]) 108 sheet.add_paragraph_style('Header2', pstyle) 109 110 pstyle = BaseDoc.ParagraphStyle() 111 fstyle = pstyle.get_font() 112 fstyle.set_type_face(BaseDoc.FONT_SANS_SERIF) 113 fstyle.set_size(10) 114 fstyle.set_bold(True) 115 fstyle.set_italic(True) 116 pstyle.set_font(fstyle) 117 pstyle.set_alignment(BaseDoc.PARA_ALIGN_LEFT) 118 pstyle.set_tabs([4, 8, 12, 16]) 119 sheet.add_paragraph_style('Header3', pstyle) 120 121 pstyle = BaseDoc.ParagraphStyle() 122 pstyle.set_tabs([4, 8, 12, 16]) 123 sheet.add_paragraph_style('Normal', pstyle) 124 125 # Styles for tables: 126 tbl = BaseDoc.TableStyle() 127 tbl.set_width(100) 128 tbl.set_columns(2) 129 tbl.set_column_width(0,20) 130 tbl.set_column_width(1,80) 131 sheet.add_table_style("Table",tbl) 132 133 cell = BaseDoc.TableCellStyle() 134 cell.set_top_border(1) 135 cell.set_bottom_border(1) 136 sheet.add_cell_style("TableHead",cell) 137 138 cell = BaseDoc.TableCellStyle() 139 sheet.add_cell_style("TableNormalCell",cell) 140 141 cell = BaseDoc.TableCellStyle() 142 cell.set_longlist(1) 143 sheet.add_cell_style("TableListCell",cell) 144 145 return sheet
146