* src/Plugins.py: add GrampsBookFormatComboBox class

* src/Report.py: Roll common functions into Report class
* src/plugins/AncestorReport.py: Bring up to date with Report
* src/plugins/Ancestors.py: Bring up to date with Report
* src/plugins/BookReport.py: Bring up to date with Report,
incorporate new ComboBox
* src/plugins/DescendReport.py: Bring up to date with Report
* src/pulgins/FtmStyleAncestors.py: Bring up to date with Report
* src/pulgins/FtmStyleDescendants.py: Bring up to date
with Report
* src/plugins/IndivSummary.py: Bring up to date with Report
* src/plugins/TimeLine.py: Bring up to date with Report


svn: r3843
This commit is contained in:
Don Allingham 2004-12-30 00:21:49 +00:00
parent 76f8f4c013
commit 309b2c4842
11 changed files with 290 additions and 362 deletions

View File

@ -1,3 +1,17 @@
2004-12-29 Don Allingham <dallingham@users.sourceforge.net>
* src/Plugins.py: add GrampsBookFormatComboBox class
* src/Report.py: Roll common functions into Report class
* src/plugins/AncestorReport.py: Bring up to date with Report
* src/plugins/Ancestors.py: Bring up to date with Report
* src/plugins/BookReport.py: Bring up to date with Report,
incorporate new ComboBox
* src/plugins/DescendReport.py: Bring up to date with Report
* src/pulgins/FtmStyleAncestors.py: Bring up to date with Report
* src/pulgins/FtmStyleDescendants.py: Bring up to date
with Report
* src/plugins/IndivSummary.py: Bring up to date with Report
* src/plugins/TimeLine.py: Bring up to date with Report
2004-12-29 Alex Roitman <shura@alex.neuro.umn.edu>
* src/DisplayTrace.py: Typo in the debian version filename.
* src/plugins/Ancestors.py: Convert to new scheme.

View File

@ -936,48 +936,47 @@ class GrampsDrawFormatComboBox(gtk.ComboBox):
def get_printable(self):
return _drawdoc[self.get_active()][5]
#-------------------------------------------------------------------------
#
# get_book_menu
#
#-------------------------------------------------------------------------
def get_book_menu(main_menu,tables,callback,obj=None,active=None):
class GrampsBookFormatComboBox(gtk.ComboBox):
index = 0
myMenu = gtk.Menu()
_bookdoc.sort()
active_found = False
other_active = None
for item in _bookdoc:
if tables and item[2] == 0:
continue
name = item[0]
menuitem = gtk.MenuItem(name)
menuitem.set_data("name",item[1])
menuitem.set_data("label",name)
menuitem.set_data("styles",item[4])
menuitem.set_data("paper",item[3])
menuitem.set_data("ext",item[5])
menuitem.set_data("obj",obj)
if callback:
menuitem.connect("activate",callback)
menuitem.show()
myMenu.append(menuitem)
if name == active:
myMenu.set_active(index)
if callback:
callback(menuitem)
active_found = True
elif name == GrampsGconfKeys.get_output_preference():
other_active = index
other_item = menuitem
index = index + 1
def set(self,tables,callback,obj=None,active=None):
self.store = gtk.ListStore(str)
self.set_model(self.store)
cell = gtk.CellRendererText()
self.pack_start(cell,True)
self.add_attribute(cell,'text',0)
if other_active and not active_found:
myMenu.set_active(index)
if callback:
callback(other_item)
main_menu.set_menu(myMenu)
out_pref = GrampsGconfKeys.get_output_preference()
index = 0
_drawdoc.sort()
active_index = 0
self.data = []
for item in _bookdoc:
if tables and item[2] == 0:
continue
self.data.append(item)
name = item[0]
self.store.append(row=[name])
if name == active:
active_index = index
elif not active and name == out_pref:
active_index = index
index += 1
self.set_active(active_index)
def get_reference(self):
return self.data[self.get_active()][1]
def get_label(self):
return self.data[self.get_active()][0]
def get_paper(self):
return self.data[self.get_active()][3]
def get_ext(self):
return self.data[self.get_active()][5]
def get_printable(self):
return self.data[self.get_active()][6]
#-------------------------------------------------------------------------
#

View File

@ -201,6 +201,34 @@ class Report:
29: _("Twenty-ninth")
}
def __init__(self, database, person, options_class):
self.database = database
self.start_person = person
self.options_class = options_class
self.doc = options_class.get_document()
creator = database.get_researcher().get_name()
self.doc.creator(creator)
if options_class.get_output():
self.standalone = True
self.doc.open(output)
self.doc.init()
else:
self.standalone = False
def begin_report(self):
if self.options_class.get_newpage():
self.doc.page_break()
def write_report(self):
pass
def finish_report(self):
if self.standalone:
self.doc.close()
def get_progressbar_data(self):
"""The window title for this dialog, and the header line to
put at the top of the contents of the dialog box."""
@ -1232,7 +1260,7 @@ class ReportDialog(BareReportDialog):
self.template_combo.append_text(template)
self.template_combo.append_text(_user_template)
self.template_combo.set_active(0)
self.template_combo.set_active(False)
self.template_combo.connect('changed',self.html_file_enable)
self.html_table.attach(self.template_combo,2,3,1,2)
@ -1242,7 +1270,7 @@ class ReportDialog(BareReportDialog):
self.html_fileentry = gnome.ui.FileEntry("HTML_Template",
_("Choose File"))
self.html_fileentry.set_modal(True)
self.html_fileentry.set_sensitive(0)
self.html_fileentry.set_sensitive(False)
user_template = ''
if os.path.isfile(user_template):
self.html_fileentry.set_filename(user_template)
@ -1711,7 +1739,9 @@ def report(database,person,report_class,options_class,translated_name,name,categ
if response == True:
try:
MyReport = report_class(dialog.db,dialog.person,dialog.options)
MyReport.begin_report()
MyReport.write_report()
MyReport.end_report()
except Errors.FilterError, msg:
(m1,m2) = msg.messages()
ErrorDialog(m1,m2)

View File

@ -78,26 +78,13 @@ class AncestorReport(Report.Report):
newpage - if True, newpage is made before writing a report
"""
self.database = database
self.start = person
self.options_class = options_class
Report.Report.__init__(self,database,person,options_class)
self.map = {}
(self.max_generations,self.pgbrk) \
= options_class.get_report_generations()
self.doc = options_class.get_document()
output = options_class.get_output()
self.newpage = options_class.get_newpage()
if output:
self.standalone = 1
self.doc.open(output)
self.doc.init()
else:
self.standalone = 0
def filter(self,person_handle,index,generation=1):
if not person_handle or generation >= self.max_generations:
return
@ -112,12 +99,9 @@ class AncestorReport(Report.Report):
def write_report(self):
if self.newpage:
self.doc.page_break()
self.filter(self.start_person.get_handle(),1)
self.filter(self.start.get_handle(),1)
name = self.start.get_primary_name().get_regular_name()
name = self.start_person.get_primary_name().get_regular_name()
self.doc.start_paragraph("AHN-Title")
title = _("Ahnentafel Report for %s") % name
self.doc.write_text(title)
@ -268,9 +252,6 @@ class AncestorReport(Report.Report):
self.doc.write_text(".")
self.doc.end_paragraph()
if self.standalone:
self.doc.close()
#------------------------------------------------------------------------
#

View File

@ -61,9 +61,7 @@ class ComprehensiveAncestorsReport (Report.Report):
def __init__(self,database,person,options_class):
#,max,pgbrk,cite,doc,output,newpage=0):
self.database = database
self.start = person
self.options_class = options_class
Report.Report.__init__(self,database,person,options_class)
self.map = {}
@ -72,7 +70,6 @@ class ComprehensiveAncestorsReport (Report.Report):
#self.opt_cite = cite
self.opt_cite = options_class.handler.options_dict['cites']
self.doc = options_class.get_document()
self.output = options_class.get_output()
self.newpage = options_class.get_newpage()
@ -126,19 +123,10 @@ class ComprehensiveAncestorsReport (Report.Report):
cell.set_padding (0.1)
self.doc.add_cell_style ("AR-Entry", cell)
if self.output:
self.standalone = 1
self.doc.open(self.output)
self.doc.init()
else:
self.standalone = 0
def write_report(self):
if self.newpage:
self.doc.page_break()
self.sources = []
name = self.person_name (self.start.get_handle())
name = self.person_name (self.start_person.get_handle())
self.doc.start_paragraph("AR-Title")
title = _("Ancestors of %s") % name
self.doc.write_text(title)
@ -148,11 +136,13 @@ class ComprehensiveAncestorsReport (Report.Report):
self.doc.write_text (_("Generation 1"))
self.doc.end_paragraph ()
self.write_paragraphs (self.person (self.start.get_handle(), suppress_children = 1,
self.write_paragraphs (self.person (self.start_person.get_handle(),
suppress_children = 1,
needs_name = 1))
family_handles = [self.start.get_main_parents_family_handle ()]
family_handles = [self.start_person.get_main_parents_family_handle ()]
if len (family_handles) > 0:
self.generation (self.max_generations, family_handles, [], [self.start.get_handle()])
self.generation (self.max_generations, family_handles, [],
[self.start_person.get_handle()])
if len (self.sources) > 0:
self.doc.start_paragraph ("AR-Heading")
@ -182,8 +172,6 @@ class ComprehensiveAncestorsReport (Report.Report):
i += 1
if self.standalone:
self.doc.close()
return
def write_paragraphs (self, paragraphs):
@ -255,10 +243,10 @@ class ComprehensiveAncestorsReport (Report.Report):
if self.gp:
break
relstring = self.relationship.get_grandparents_string (self.start,
relstring = self.relationship.get_grandparents_string (self.start_person,
self.database.get_person_from_handle(self.gp))[0]
heading = _("%(name)s's maternal %(grandparents)s") % \
{ 'name': self.first_name_or_nick (self.start),
{ 'name': self.first_name_or_nick (self.start_person),
'grandparents': relstring }
people.append ((self.doc.start_paragraph, ['AR-Heading']))
people.append ((self.doc.write_text, [heading]))
@ -280,15 +268,15 @@ class ComprehensiveAncestorsReport (Report.Report):
if paternal_known:
self.doc.start_paragraph ("AR-Heading")
relstring = self.relationship.get_grandparents_string (self.start,
relstring = self.relationship.get_grandparents_string (self.start_person,
self.database.get_person_from_handle(self.gp))[0]
if thisgen == 2:
heading = _("%(name)s's %(parents)s") % \
{ 'name': self.first_name_or_nick (self.start),
{ 'name': self.first_name_or_nick (self.start_person),
'parents': relstring }
else:
heading = _("%(name)s's paternal %(grandparents)s") % \
{ 'name': self.first_name_or_nick (self.start),
{ 'name': self.first_name_or_nick (self.start_person),
'grandparents': relstring }
self.doc.write_text (heading)

View File

@ -913,7 +913,8 @@ class BookItemDialog(Report.BareReportDialog):
self.option_class = option_class
self.person = self.database.get_person_from_gramps_id(self.option_class.handler.get_person_id())
self.new_person = None
Report.BareReportDialog.__init__(self,database,self.person,option_class,name,translated_name)
Report.BareReportDialog.__init__(self,database,self.person,
option_class,name,translated_name)
def on_ok_clicked(self, obj):
"""The user is satisfied with the dialog choices. Parse all options
@ -1001,8 +1002,9 @@ class BookReportDialog(Report.ReportDialog):
"""Build a menu of document types that are appropriate for
this text report. This menu will be generated based upon
whether the document requires table support, etc."""
Plugins.get_book_menu(self.format_menu, self.doc_uses_tables(),
self.doc_type_changed,None,active)
self.format_menu = Plugins.GrampsBookFormatComboBox()
self.format_menu.set(self.doc_uses_tables(),
self.doc_type_changed, None, active)
def make_document(self):
"""Create a document of the type requested by the user."""

View File

@ -58,7 +58,7 @@ _DIED = _('d.')
# DescendantReport
#
#------------------------------------------------------------------------
class DescendantReport:
class DescendantReport(Report.Report):
def __init__(self,database,person,options_class):
"""
@ -84,24 +84,11 @@ class DescendantReport:
newpage - if True, newpage is made before writing a report
"""
self.database = database
self.creator = database.get_researcher().get_name()
self.person = person
self.options_class = options_class
Report.Report.__init__(self,database,person,options_class)
(self.max_generations,self.pgbrk) \
= options_class.get_report_generations()
self.doc = options_class.get_document()
output = options_class.get_output()
self.newpage = options_class.get_newpage()
if output:
self.standalone = 1
self.doc.open(output)
self.doc.init()
else:
self.standalone = 0
sort = Sort.Sort(self.database)
self.by_birthdate = sort.by_birthdate
@ -131,16 +118,12 @@ class DescendantReport:
self.doc.write_text(')')
def write_report(self):
if self.newpage:
self.doc.page_break()
self.doc.start_paragraph("DR-Title")
name = self.person.get_primary_name().get_regular_name()
name = self.start_person.get_primary_name().get_regular_name()
self.doc.write_text(_("Descendants of %s") % name)
self.dump_dates(self.person)
self.dump_dates(self.start_person)
self.doc.end_paragraph()
self.dump(0,self.person)
if self.standalone:
self.doc.close()
self.dump(0,self.start_person)
def dump(self,level,person):

View File

@ -81,25 +81,13 @@ class FtmAncestorReport(Report.Report):
newpage - if True, newpage is made before writing a report
"""
self.database = database
self.start = person
self.options_class = options_class
Report.Report.__init__(self,database,person,options_class)
self.map = {}
(self.max_generations,self.pgbrk) \
= options_class.get_report_generations()
self.doc = options_class.get_document()
output = options_class.get_output()
self.newpage = options_class.get_newpage()
if output:
self.standalone = 1
self.doc.open(output)
self.doc.init()
else:
self.standalone = 0
self.sref_map = {}
self.sref_index = 0
@ -117,12 +105,9 @@ class FtmAncestorReport(Report.Report):
def write_report(self):
if self.newpage:
self.doc.page_break()
self.apply_filter(self.start.get_handle(),1)
self.apply_filter(self.start_person.get_handle(),1)
name = self.start.get_primary_name().get_regular_name()
name = self.start_person.get_primary_name().get_regular_name()
self.doc.start_paragraph("FTA-Title")
title = _("Ancestors of %s") % name
self.doc.write_text(title)
@ -472,8 +457,6 @@ class FtmAncestorReport(Report.Report):
self.print_more_about(person)
self.write_endnotes()
if self.standalone:
self.doc.close()
def write_endnotes(self):
keys = self.sref_map.keys()

View File

@ -86,9 +86,7 @@ class FtmDescendantReport(Report.Report):
"""
self.database = database
self.start = person
self.options_class = options_class
Report.Report.__init__(self,database,person,options_class)
self.anc_map = {}
self.gen_map = {}
@ -96,18 +94,8 @@ class FtmDescendantReport(Report.Report):
(self.max_generations,self.pgbrk) \
= options_class.get_report_generations()
self.doc = options_class.get_document()
output = options_class.get_output()
self.newpage = options_class.get_newpage()
self.setup()
if output:
self.standalone = 1
self.doc.open(output)
self.doc.init()
else:
self.standalone = 0
self.sref_map = {}
self.sref_index = 0
@ -145,12 +133,9 @@ class FtmDescendantReport(Report.Report):
def write_report(self):
if self.newpage:
self.doc.page_break()
self.apply_filter(self.start.get_handle(),1)
self.apply_filter(self.start_person.get_handle(),1)
name = self.start.get_primary_name().get_regular_name()
name = self.start_person.get_primary_name().get_regular_name()
self.doc.start_paragraph("FTD-Title")
title = _("Descendants of %s") % name
self.doc.write_text(title)
@ -498,8 +483,6 @@ class FtmDescendantReport(Report.Report):
self.print_children(person)
self.write_endnotes()
if self.standalone:
self.doc.close()
def write_endnotes(self):
keys = self.sref_map.keys()

View File

@ -81,25 +81,11 @@ class IndivSummary(Report.Report):
newpage - if True, newpage is made before writing a report
"""
self.database = database
self.person = person
self.options_class = options_class
Report.Report.__init__(self,database,person,options_class)
self.d = options_class.get_document()
self.output = options_class.get_output()
self.newpage = options_class.get_newpage()
c = database.get_researcher().get_name()
self.d.creator(c)
self.map = {}
self.setup()
if self.output:
self.standalone = 1
self.d.open(self.output)
self.d.init()
else:
self.standalone = 0
def setup(self):
tbl = BaseDoc.TableStyle()
@ -107,23 +93,19 @@ class IndivSummary(Report.Report):
tbl.set_columns(2)
tbl.set_column_width(0,20)
tbl.set_column_width(1,80)
self.d.add_table_style("IVS-IndTable",tbl)
self.doc.add_table_style("IVS-IndTable",tbl)
cell = BaseDoc.TableCellStyle()
cell.set_top_border(1)
cell.set_bottom_border(1)
self.d.add_cell_style("IVS-TableHead",cell)
self.doc.add_cell_style("IVS-TableHead",cell)
cell = BaseDoc.TableCellStyle()
self.d.add_cell_style("IVS-NormalCell",cell)
self.doc.add_cell_style("IVS-NormalCell",cell)
cell = BaseDoc.TableCellStyle()
cell.set_longlist(1)
self.d.add_cell_style("IVS-ListCell",cell)
def end(self):
if self.standalone:
self.d.close()
self.doc.add_cell_style("IVS-ListCell",cell)
def write_fact(self,event):
if event == None:
@ -151,19 +133,19 @@ class IndivSummary(Report.Report):
'place' : place }
text = '%s %s' % (text,description)
self.d.start_row()
self.d.start_cell("IVS-NormalCell")
self.d.start_paragraph("IVS-Normal")
self.d.write_text(name)
self.d.end_paragraph()
self.d.end_cell()
self.doc.start_row()
self.doc.start_cell("IVS-NormalCell")
self.doc.start_paragraph("IVS-Normal")
self.doc.write_text(name)
self.doc.end_paragraph()
self.doc.end_cell()
self.d.start_cell("IVS-NormalCell")
self.d.start_paragraph("IVS-Normal")
self.d.write_text(text)
self.d.end_paragraph()
self.d.end_cell()
self.d.end_row()
self.doc.start_cell("IVS-NormalCell")
self.doc.start_paragraph("IVS-Normal")
self.doc.write_text(text)
self.doc.end_paragraph()
self.doc.end_cell()
self.doc.end_row()
#--------------------------------------------------------------------
#
@ -172,35 +154,35 @@ class IndivSummary(Report.Report):
#--------------------------------------------------------------------
def write_families(self):
self.d.start_paragraph("IVS-Normal")
self.d.end_paragraph()
self.d.start_table("three","IVS-IndTable")
self.d.start_row()
self.d.start_cell("IVS-TableHead",2)
self.d.start_paragraph("IVS-TableTitle")
self.d.write_text(_("Marriages/Children"))
self.d.end_paragraph()
self.d.end_cell()
self.d.end_row()
self.doc.start_paragraph("IVS-Normal")
self.doc.end_paragraph()
self.doc.start_table("three","IVS-IndTable")
self.doc.start_row()
self.doc.start_cell("IVS-TableHead",2)
self.doc.start_paragraph("IVS-TableTitle")
self.doc.write_text(_("Marriages/Children"))
self.doc.end_paragraph()
self.doc.end_cell()
self.doc.end_row()
for family_handle in self.person.get_family_handle_list():
for family_handle in self.start_person.get_family_handle_list():
family = self.database.get_family_from_handle(family_handle)
if self.person.get_handle() == family.get_father_handle():
if self.start_person.get_handle() == family.get_father_handle():
spouse_id = family.get_mother_handle()
else:
spouse_id = family.get_father_handle()
self.d.start_row()
self.d.start_cell("IVS-NormalCell",2)
self.d.start_paragraph("IVS-Spouse")
self.doc.start_row()
self.doc.start_cell("IVS-NormalCell",2)
self.doc.start_paragraph("IVS-Spouse")
if spouse_id:
spouse = self.database.get_person_from_handle(spouse_id)
self.d.write_text(spouse.get_primary_name().get_regular_name())
self.doc.write_text(spouse.get_primary_name().get_regular_name())
else:
self.d.write_text(_("unknown"))
self.d.end_paragraph()
self.d.end_cell()
self.d.end_row()
self.doc.write_text(_("unknown"))
self.doc.end_paragraph()
self.doc.end_cell()
self.doc.end_row()
for event_handle in family.get_event_list():
event = self.database.get_event_from_handle(event_handle)
@ -208,87 +190,84 @@ class IndivSummary(Report.Report):
child_list = family.get_child_handle_list()
if len(child_list):
self.d.start_row()
self.d.start_cell("IVS-NormalCell")
self.d.start_paragraph("IVS-Normal")
self.d.write_text(_("Children"))
self.d.end_paragraph()
self.d.end_cell()
self.doc.start_row()
self.doc.start_cell("IVS-NormalCell")
self.doc.start_paragraph("IVS-Normal")
self.doc.write_text(_("Children"))
self.doc.end_paragraph()
self.doc.end_cell()
self.d.start_cell("IVS-ListCell")
self.d.start_paragraph("IVS-Normal")
self.doc.start_cell("IVS-ListCell")
self.doc.start_paragraph("IVS-Normal")
first = 1
for child_handle in child_list:
if first == 1:
first = 0
else:
self.d.write_text('\n')
self.doc.write_text('\n')
child = self.database.get_person_from_handle(child_handle)
self.d.write_text(child.get_primary_name().get_regular_name())
self.d.end_paragraph()
self.d.end_cell()
self.d.end_row()
self.d.end_table()
self.doc.write_text(child.get_primary_name().get_regular_name())
self.doc.end_paragraph()
self.doc.end_cell()
self.doc.end_row()
self.doc.end_table()
def write_report(self):
if self.newpage:
self.d.page_break()
media_list = self.start_person.get_media_list()
media_list = self.person.get_media_list()
name = self.start_person.get_primary_name().get_regular_name()
self.doc.start_paragraph("IVS-Title")
self.doc.write_text(_("Summary of %s") % name)
self.doc.end_paragraph()
name = self.person.get_primary_name().get_regular_name()
self.d.start_paragraph("IVS-Title")
self.d.write_text(_("Summary of %s") % name)
self.d.end_paragraph()
self.d.start_paragraph("IVS-Normal")
self.d.end_paragraph()
self.doc.start_paragraph("IVS-Normal")
self.doc.end_paragraph()
if len(media_list) > 0:
object_handle = media_list[0].get_reference_handle()
object = self.database.get_object_from_handle(object_handle)
if object.get_mime_type()[0:5] == "image":
file = object.get_path()
self.d.start_paragraph("IVS-Normal")
self.d.add_media_object(file,"row",4.0,4.0)
self.d.end_paragraph()
self.doc.start_paragraph("IVS-Normal")
self.doc.add_media_object(file,"row",4.0,4.0)
self.doc.end_paragraph()
self.d.start_table("one","IVS-IndTable")
self.doc.start_table("one","IVS-IndTable")
self.d.start_row()
self.d.start_cell("IVS-NormalCell")
self.d.start_paragraph("IVS-Normal")
self.d.write_text("%s:" % _("Name"))
self.d.end_paragraph()
self.d.end_cell()
self.doc.start_row()
self.doc.start_cell("IVS-NormalCell")
self.doc.start_paragraph("IVS-Normal")
self.doc.write_text("%s:" % _("Name"))
self.doc.end_paragraph()
self.doc.end_cell()
self.d.start_cell("IVS-NormalCell")
self.d.start_paragraph("IVS-Normal")
self.d.write_text(self.person.get_primary_name().get_regular_name())
self.d.end_paragraph()
self.d.end_cell()
self.d.end_row()
self.doc.start_cell("IVS-NormalCell")
self.doc.start_paragraph("IVS-Normal")
self.doc.write_text(self.start_person.get_primary_name().get_regular_name())
self.doc.end_paragraph()
self.doc.end_cell()
self.doc.end_row()
self.d.start_row()
self.d.start_cell("IVS-NormalCell")
self.d.start_paragraph("IVS-Normal")
self.d.write_text("%s:" % _("Gender"))
self.d.end_paragraph()
self.d.end_cell()
self.doc.start_row()
self.doc.start_cell("IVS-NormalCell")
self.doc.start_paragraph("IVS-Normal")
self.doc.write_text("%s:" % _("Gender"))
self.doc.end_paragraph()
self.doc.end_cell()
self.d.start_cell("IVS-NormalCell")
self.d.start_paragraph("IVS-Normal")
if self.person.get_gender() == RelLib.Person.male:
self.d.write_text(_("Male"))
self.doc.start_cell("IVS-NormalCell")
self.doc.start_paragraph("IVS-Normal")
if self.start_person.get_gender() == RelLib.Person.male:
self.doc.write_text(_("Male"))
else:
self.d.write_text(_("Female"))
self.d.end_paragraph()
self.d.end_cell()
self.d.end_row()
self.doc.write_text(_("Female"))
self.doc.end_paragraph()
self.doc.end_cell()
self.doc.end_row()
fam_id = self.person.get_main_parents_family_handle()
fam_id = self.start_person.get_main_parents_family_handle()
if fam_id:
family = self.database.get_family_from_handle(fam_id)
father_handle = family.get_father_handle()
@ -307,57 +286,57 @@ class IndivSummary(Report.Report):
father = ""
mother = ""
self.d.start_row()
self.d.start_cell("IVS-NormalCell")
self.d.start_paragraph("IVS-Normal")
self.d.write_text("%s:" % _("Father"))
self.d.end_paragraph()
self.d.end_cell()
self.doc.start_row()
self.doc.start_cell("IVS-NormalCell")
self.doc.start_paragraph("IVS-Normal")
self.doc.write_text("%s:" % _("Father"))
self.doc.end_paragraph()
self.doc.end_cell()
self.d.start_cell("IVS-NormalCell")
self.d.start_paragraph("IVS-Normal")
self.d.write_text(father)
self.d.end_paragraph()
self.d.end_cell()
self.d.end_row()
self.doc.start_cell("IVS-NormalCell")
self.doc.start_paragraph("IVS-Normal")
self.doc.write_text(father)
self.doc.end_paragraph()
self.doc.end_cell()
self.doc.end_row()
self.d.start_row()
self.d.start_cell("IVS-NormalCell")
self.d.start_paragraph("IVS-Normal")
self.d.write_text("%s:" % _("Mother"))
self.d.end_paragraph()
self.d.end_cell()
self.doc.start_row()
self.doc.start_cell("IVS-NormalCell")
self.doc.start_paragraph("IVS-Normal")
self.doc.write_text("%s:" % _("Mother"))
self.doc.end_paragraph()
self.doc.end_cell()
self.d.start_cell("IVS-NormalCell")
self.d.start_paragraph("IVS-Normal")
self.d.write_text(mother)
self.d.end_paragraph()
self.d.end_cell()
self.d.end_row()
self.d.end_table()
self.doc.start_cell("IVS-NormalCell")
self.doc.start_paragraph("IVS-Normal")
self.doc.write_text(mother)
self.doc.end_paragraph()
self.doc.end_cell()
self.doc.end_row()
self.doc.end_table()
self.d.start_paragraph("IVS-Normal")
self.d.end_paragraph()
self.doc.start_paragraph("IVS-Normal")
self.doc.end_paragraph()
self.d.start_table("two","IVS-IndTable")
self.d.start_row()
self.d.start_cell("IVS-TableHead",2)
self.d.start_paragraph("IVS-TableTitle")
self.d.write_text(_("Individual Facts"))
self.d.end_paragraph()
self.d.end_cell()
self.d.end_row()
self.doc.start_table("two","IVS-IndTable")
self.doc.start_row()
self.doc.start_cell("IVS-TableHead",2)
self.doc.start_paragraph("IVS-TableTitle")
self.doc.write_text(_("Individual Facts"))
self.doc.end_paragraph()
self.doc.end_cell()
self.doc.end_row()
event_list = [ self.person.get_birth_handle(), self.person.get_death_handle() ]
event_list = event_list + self.person.get_event_list()
event_list = [ self.start_person.get_birth_handle(),
self.start_person.get_death_handle() ]
event_list = event_list + self.start_person.get_event_list()
for event_handle in event_list:
if event_handle:
event = self.database.get_event_from_handle(event_handle)
self.write_fact(event)
self.d.end_table()
self.doc.end_table()
self.write_families()
self.end()
#------------------------------------------------------------------------
#

View File

@ -60,7 +60,7 @@ import const
# TimeLine
#
#------------------------------------------------------------------------
class TimeLine:
class TimeLine(Report.Report):
def __init__(self,database,person,options_class):
"""
@ -93,9 +93,7 @@ class TimeLine:
"""
self.db = database
self.person = person
self.options_class = options_class
Report.Report.__init__(self,database,person,options_class)
filter_num = options_class.get_filter_number()
filters = options_class.get_report_filters(person)
@ -107,17 +105,7 @@ class TimeLine:
sort_functions = options_class.get_sort_functions(Sort.Sort(database))
self.sort_func = sort_functions[sort_func_num][1]
self.d = options_class.get_document()
self.output = options_class.get_output()
self.newpage = options_class.get_newpage()
self.setup()
if self.output:
self.standalone = 1
self.d.open(self.output)
self.d.init()
else:
self.standalone = 0
def setup(self):
"""
@ -140,47 +128,47 @@ class TimeLine:
g = BaseDoc.GraphicsStyle()
g.set_line_width(0.5)
g.set_color((0,0,0))
self.d.add_draw_style("TLG-line",g)
self.doc.add_draw_style("TLG-line",g)
g = BaseDoc.GraphicsStyle()
g.set_line_width(0.5)
g.set_color((0,0,0))
g.set_fill_color((0,0,0))
self.d.add_draw_style("TLG-solid",g)
self.doc.add_draw_style("TLG-solid",g)
g = BaseDoc.GraphicsStyle()
g.set_line_width(0.5)
g.set_color((0,0,0))
g.set_fill_color((255,255,255))
self.d.add_draw_style("open",g)
self.doc.add_draw_style("open",g)
g = BaseDoc.GraphicsStyle()
g.set_line_width(0.5)
g.set_line_style(BaseDoc.DASHED)
g.set_color((0,0,0))
self.d.add_draw_style("TLG-grid",g)
self.doc.add_draw_style("TLG-grid",g)
g = BaseDoc.GraphicsStyle()
g.set_paragraph_style("TLG-Name")
g.set_color((255,255,255))
g.set_fill_color((255,255,255))
g.set_line_width(0)
self.d.add_draw_style("TLG-text",g)
self.doc.add_draw_style("TLG-text",g)
g = BaseDoc.GraphicsStyle()
g.set_paragraph_style("TLG-Title")
g.set_color((255,255,255))
g.set_fill_color((255,255,255))
g.set_line_width(0)
g.set_width(self.d.get_usable_width())
self.d.add_draw_style("TLG-title",g)
g.set_width(self.doc.get_usable_width())
self.doc.add_draw_style("TLG-title",g)
g = BaseDoc.GraphicsStyle()
g.set_paragraph_style("TLG-Label")
g.set_color((255,255,255))
g.set_fill_color((255,255,255))
g.set_line_width(0)
self.d.add_draw_style("TLG-label",g)
self.doc.add_draw_style("TLG-label",g)
def write_report(self):
@ -188,14 +176,14 @@ class TimeLine:
if low == high:
if self.standalone:
self.d.close()
self.doc.close()
ErrorDialog(_("Report could not be created"),
_("The range of dates chosen was not valid"))
return
st_size = self.name_size()
font = self.d.style_list['TLG-Name'].get_font()
font = self.doc.style_list['TLG-Name'].get_font()
incr = Utils.pt2cm(font.get_size())
pad = incr*.75
@ -203,13 +191,11 @@ class TimeLine:
x1,x2,y1,y2 = (0,0,0,0)
start = st_size+0.5
stop = self.d.get_usable_width()-0.5
stop = self.doc.get_usable_width()-0.5
size = (stop-start)
self.header = 2.0
if self.newpage:
self.d.page_break()
self.d.start_page()
self.doc.start_page()
index = 1
current = 1;
@ -219,21 +205,21 @@ class TimeLine:
self.plist.sort(self.sort_func)
for p_id in self.plist:
p = self.db.get_person_from_handle(p_id)
p = self.database.get_person_from_handle(p_id)
b_id = p.get_birth_handle()
if b_id:
b = self.db.get_event_from_handle(b_id).get_date_object().get_year()
b = self.database.get_event_from_handle(b_id).get_date_object().get_year()
else:
b = None
d_id = p.get_death_handle()
if d_id:
d = self.db.get_event_from_handle(d_id).get_date_object().get_year()
d = self.database.get_event_from_handle(d_id).get_date_object().get_year()
else:
d = None
n = p.get_primary_name().get_name()
self.d.draw_text('TLG-text',n,incr+pad,self.header + (incr+pad)*index)
self.doc.draw_text('TLG-text',n,incr+pad,self.header + (incr+pad)*index)
y1 = self.header + (pad+incr)*index
y2 = self.header + ((pad+incr)*index)+incr
@ -244,13 +230,13 @@ class TimeLine:
start_offset = ((float(b-low)/float(high-low)) * (size))
x1 = start+start_offset
path = [(x1,y1),(x1+w,y3),(x1,y2),(x1-w,y3)]
self.d.draw_path('TLG-line',path)
self.doc.draw_path('TLG-line',path)
if d:
start_offset = ((float(d-low)/float(high-low)) * (size))
x1 = start+start_offset
path = [(x1,y1),(x1+w,y3),(x1,y2),(x1-w,y3)]
self.d.draw_path('TLG-solid',path)
self.doc.draw_path('TLG-solid',path)
if b and d:
start_offset = ((float(b-low)/float(high-low)) * size) + w
@ -258,13 +244,13 @@ class TimeLine:
x1 = start+start_offset
x2 = start+stop_offset
self.d.draw_line('open',x1,y3,x2,y3)
self.doc.draw_line('open',x1,y3,x2,y3)
if (y2 + incr) >= self.d.get_usable_height():
if (y2 + incr) >= self.doc.get_usable_height():
if current != length:
self.build_grid(low,high,start,stop)
self.d.end_page()
self.d.start_page()
self.doc.end_page()
self.doc.start_page()
self.build_grid(low,high,start,stop)
index = 1
x1,x2,y1,y2 = (0,0,0,0)
@ -273,9 +259,7 @@ class TimeLine:
current += 1
self.build_grid(low,high,start,stop)
self.d.end_page()
if self.standalone:
self.d.close()
self.doc.end_page()
def build_grid(self,year_low,year_high,start_pos,stop_pos):
"""
@ -288,17 +272,17 @@ class TimeLine:
start_pos - x position of the lowest leftmost grid line
stop_pos - x position of the rightmost grid line
"""
width = self.d.get_usable_width()
width = self.doc.get_usable_width()
title_font = self.d.style_list['TLG-Title'].get_font()
normal_font = self.d.style_list['TLG-Name'].get_font()
label_font = self.d.style_list['TLG-Label'].get_font()
title_font = self.doc.style_list['TLG-Title'].get_font()
normal_font = self.doc.style_list['TLG-Name'].get_font()
label_font = self.doc.style_list['TLG-Label'].get_font()
self.d.center_text('TLG-title',self.title,width/2.0,0)
self.doc.center_text('TLG-title',self.title,width/2.0,0)
label_y = self.header - (Utils.pt2cm(normal_font.get_size())*1.2)
top_y = self.header
bottom_y = self.d.get_usable_height()
bottom_y = self.doc.get_usable_height()
incr = (year_high - year_low)/5
delta = (stop_pos - start_pos)/ 5
@ -307,26 +291,27 @@ class TimeLine:
year_str = str(year_low + (incr*val))
xpos = start_pos+(val*delta)
self.d.center_text('TLG-label', year_str, xpos, label_y)
self.d.draw_line('TLG-grid', xpos, top_y, xpos, bottom_y)
self.doc.center_text('TLG-label', year_str, xpos, label_y)
self.doc.draw_line('TLG-grid', xpos, top_y, xpos, bottom_y)
def find_year_range(self):
low = 999999
high = -999999
self.plist = self.filter.apply(self.db,self.db.get_person_handles(sort_handles=False))
self.plist = self.filter.apply(self.database,
self.database.get_person_handles(sort_handles=False))
for p_id in self.plist:
p = self.db.get_person_from_handle(p_id)
p = self.database.get_person_from_handle(p_id)
b_id = p.get_birth_handle()
if b_id:
b = self.db.get_event_from_handle(b_id).get_date_object().get_year()
b = self.database.get_event_from_handle(b_id).get_date_object().get_year()
else:
b = None
d_id = p.get_death_handle()
if d_id:
d = self.db.get_event_from_handle(d_id).get_date_object().get_year()
d = self.database.get_event_from_handle(d_id).get_date_object().get_year()
else:
d = None
@ -349,16 +334,17 @@ class TimeLine:
return (low,high)
def name_size(self):
self.plist = self.filter.apply(self.db,self.db.get_person_handles(sort_handles=False))
self.plist = self.filter.apply(self.database,
self.database.get_person_handles(sort_handles=False))
style_name = self.d.draw_styles['TLG-text'].get_paragraph_style()
font = self.d.style_list[style_name].get_font()
style_name = self.doc.draw_styles['TLG-text'].get_paragraph_style()
font = self.doc.style_list[style_name].get_font()
size = 0
for p_id in self.plist:
p = self.db.get_person_from_handle(p_id)
p = self.database.get_person_from_handle(p_id)
n = p.get_primary_name().get_name()
size = max(self.d.string_width(font,n),size)
size = max(self.doc.string_width(font,n),size)
return Utils.pt2cm(size)
#------------------------------------------------------------------------