class AncestorTreeOptions(MenuReportOptions): """ Defines options and provides handling interface. """ def __init__(self, name, dbase): MenuReportOptions.__init__(self, name, dbase) def add_menu_options(self, menu): ################## category_name = _("Tree Options") pid = PersonOption(_("Center Person")) pid.set_help(_("The center person for the tree")) menu.add_option(category_name, "pid", pid) self.max_gen = NumberOption(_("Generations"), 10, 1, 50) self.max_gen.set_help( _("The number of generations to include " "in the tree")) menu.add_option(category_name, "maxgen", self.max_gen) self.fillout = EnumeratedListOption(_("Display unknown\ngenerations"), 0) self.fillout.set_help( _("The number of generations of empty " "boxes that will be displayed")) menu.add_option(category_name, "fill_out", self.fillout) self.max_gen.connect('value-changed', self.__fillout_vals) self.__fillout_vals() compress = BooleanOption(_('Co_mpress tree'), True) compress.set_help( _("Whether to remove any extra blank spaces set " "aside for people that are unknown")) menu.add_option(category_name, "compress_tree", compress) #better to 'Show siblings of\nthe center person #Spouse_disp = EnumeratedListOption(_("Show spouses of\nthe center " # "person"), 0) #Spouse_disp.add_item( 0, _("No. Do not show Spouses")) #Spouse_disp.add_item( 1, _("Yes, and use the the Main Display Format")) #Spouse_disp.add_item( 2, _("Yes, and use the the Secondary " # "Display Format")) #Spouse_disp.set_help(_("Show spouses of the center person?")) #menu.add_option(category_name, "Spouse_disp", Spouse_disp) centerDisp = EnumeratedListOption( _("Center person uses\n" "which format"), 0) centerDisp.add_item(0, _("Use Fathers Display format")) centerDisp.add_item(1, _("Use Mothers display format")) centerDisp.set_help(_("Which Display format to use the center person")) menu.add_option(category_name, "center_uses", centerDisp) ################## category_name = _("Display") disp = TextOption( _("Father\nDisplay Format"), ["$n", "%s $b" % _BORN, "{%s $d}" % _DIED]) disp.set_help(_("Display format for the fathers box.")) menu.add_option(category_name, "father_disp", disp) #Will add when libsubstkeyword supports it. #missing = EnumeratedListOption(_("Replace missing\nplaces\\dates \ # with"), 0) #missing.add_item( 0, _("Does not display anything")) #missing.add_item( 1, _("Displays '_____'")) #missing.set_help(_("What will print when information is not known")) #menu.add_option(category_name, "miss_val", missing) #category_name = _("Secondary") dispMom = TextOption( _("Mother\nDisplay Format"), ["$n", "%s $b" % _BORN, "%s $m" % _MARR, "{%s $d}" % _DIED]) dispMom.set_help(_("Display format for the mothers box.")) menu.add_option(category_name, "mother_disp", dispMom) incmarr = BooleanOption(_('Include Marriage box'), False) incmarr.set_help( _("Whether to include a separate marital box in the report")) menu.add_option(category_name, "inc_marr", incmarr) marrdisp = StringOption(_("Marriage\nDisplay Format"), "%s $m" % _MARR) marrdisp.set_help(_("Display format for the marital box.")) menu.add_option(category_name, "marr_disp", marrdisp) ################## category_name = _("Size") self.scale = EnumeratedListOption(_("Scale tree to fit"), 0) self.scale.add_item(0, _("Do not scale tree")) self.scale.add_item(1, _("Scale tree to fit page width only")) self.scale.add_item(2, _("Scale tree to fit the size of the page")) self.scale.set_help( _("Whether to scale the tree to fit a specific paper size")) menu.add_option(category_name, "scale_tree", self.scale) self.scale.connect('value-changed', self.__check_blank) if "BKI" not in self.name.split(","): self.__onepage = BooleanOption( _("Resize Page to Fit Tree size\n" "\n" "Note: Overrides options in the 'Paper Option' tab"), False) self.__onepage.set_help( _("Whether to resize the page to fit the size \n" "of the tree. Note: the page will have a \n" "non standard size.\n" "\n" "With this option selected, the following will happen:\n" "\n" "With the 'Do not scale tree' option the page\n" " is resized to the height/width of the tree\n" "\n" "With 'Scale tree to fit page width only' the height of\n" " the page is resized to the height of the tree\n" "\n" "With 'Scale tree to fit the size of the page' the page\n" " is resized to remove any gap in either height or width")) menu.add_option(category_name, "resize_page", self.__onepage) self.__onepage.connect('value-changed', self.__check_blank) else: self.__onepage = None ################## category_name = _("Include") self.title = EnumeratedListOption(_("Report Title"), 0) self.title.add_item(0, _("Do not include a title")) self.title.add_item(1, _("Include Report Title")) self.title.set_help(_("Choose a title for the report")) menu.add_option(category_name, "report_title", self.title) border = BooleanOption(_('Include a border'), False) border.set_help(_("Whether to make a border around the report.")) menu.add_option(category_name, "inc_border", border) prnnum = BooleanOption(_('Include Page Numbers'), False) prnnum.set_help(_("Whether to print page numbers on each page.")) menu.add_option(category_name, "inc_pagenum", prnnum) self.__blank = BooleanOption(_('Include Blank Pages'), True) self.__blank.set_help(_("Whether to include pages that are blank.")) menu.add_option(category_name, "inc_blank", self.__blank) self.__check_blank() #category_name = _("Notes") self.usenote = BooleanOption(_('Include a note'), False) self.usenote.set_help(_("Whether to include a note on " "the report.")) menu.add_option(category_name, "inc_note", self.usenote) self.notedisp = TextOption(_("Note"), []) self.notedisp.set_help(_("Add a note\n\n" "$T inserts today's date")) menu.add_option(category_name, "note_disp", self.notedisp) locales = NoteType(0, 1) self.notelocal = EnumeratedListOption(_("Note Location"), 0) for num, text in locales.note_locals(): self.notelocal.add_item(num, text) self.notelocal.set_help(_("Where to place the note.")) menu.add_option(category_name, "note_place", self.notelocal) def __check_blank(self): if self.__onepage: value = not self.__onepage.get_value() else: value = True off = value and (self.scale.get_value() != 2) self.__blank.set_available(off) def __fillout_vals(self): max_gen = self.max_gen.get_value() old_val = self.fillout.get_value() item_list = [] item_list.append( [0, _("No generations of empty boxes " "for unknown ancestors")]) if max_gen > 1: item_list.append([ 1, _("One Generation of empty boxes " "for unknown ancestors") ]) item_list.extend([ itr, str(itr) + _(" Generations of empty boxes for unknown ancestors") ] for itr in range(2, max_gen)) self.fillout.set_items(item_list) if old_val + 2 > len(item_list): self.fillout.set_value(len(item_list) - 2) def make_default_style(self, default_style): """Make the default output style for the Ancestor Tree.""" from gen.plug.docgen import (FontStyle, ParagraphStyle, GraphicsStyle, FONT_SANS_SERIF, PARA_ALIGN_CENTER) ## Paragraph Styles: font = FontStyle() font.set_size(9) font.set_type_face(FONT_SANS_SERIF) para_style = ParagraphStyle() para_style.set_font(font) para_style.set_description( _('The basic style used for the ' 'text display.')) default_style.add_paragraph_style("AC2-Normal", para_style) box_shadow = PT2CM(font.get_size()) * .6 font = FontStyle() font.set_size(16) font.set_type_face(FONT_SANS_SERIF) para_style = ParagraphStyle() para_style.set_font(font) para_style.set_alignment(PARA_ALIGN_CENTER) para_style.set_description( _('The basic style used for the ' 'title display.')) default_style.add_paragraph_style("AC2-Title", para_style) ## Draw styles graph_style = GraphicsStyle() graph_style.set_paragraph_style("AC2-Normal") graph_style.set_shadow(1, box_shadow) #shadow set by text size graph_style.set_fill_color((255, 255, 255)) default_style.add_draw_style("AC2-box", graph_style) graph_style = GraphicsStyle() graph_style.set_paragraph_style("AC2-Normal") #graph_style.set_shadow(0, PT2CM(9)) #shadow set by text size graph_style.set_fill_color((255, 255, 255)) default_style.add_draw_style("AC2-fam-box", graph_style) graph_style = GraphicsStyle() graph_style.set_paragraph_style("AC2-Title") graph_style.set_color((0, 0, 0)) graph_style.set_fill_color((255, 255, 255)) graph_style.set_line_width(0) default_style.add_draw_style("AC2-Title", graph_style) graph_style = GraphicsStyle() default_style.add_draw_style("AC2-line", graph_style)
class FamilyLinesOptions(MenuReportOptions): """ Defines all of the controls necessary to configure the FamilyLines reports. """ def __init__(self, name, dbase): self.limit_parents = None self.max_parents = None self.limit_children = None self.max_children = None self.include_images = None self.image_location = None MenuReportOptions.__init__(self, name, dbase) def add_menu_options(self, menu): # -------------------------------- add_option = partial(menu.add_option, _('People of Interest')) # -------------------------------- person_list = PersonListOption(_('People of interest')) person_list.set_help( _('People of interest are used as a starting ' 'point when determining "family lines".')) add_option('gidlist', person_list) followpar = BooleanOption( _('Follow parents to determine family lines'), True) followpar.set_help( _('Parents and their ancestors will be ' 'considered when determining "family lines".')) add_option('followpar', followpar) followchild = BooleanOption( _('Follow children to determine ' '"family lines"'), True) followchild.set_help( _('Children will be considered when ' 'determining "family lines".')) add_option('followchild', followchild) remove_extra_people = BooleanOption( _('Try to remove extra people and families'), True) remove_extra_people.set_help( _('People and families not directly ' 'related to people of interest will ' 'be removed when determining ' '"family lines".')) add_option('removeextra', remove_extra_people) # ---------------------------- add_option = partial(menu.add_option, _('Family Colours')) # ---------------------------- surname_color = SurnameColorOption(_('Family colours')) surname_color.set_help(_('Colours to use for various family lines.')) add_option('surnamecolors', surname_color) # ------------------------- add_option = partial(menu.add_option, _('Individuals')) # ------------------------- color_males = ColorOption(_('Males'), '#e0e0ff') color_males.set_help(_('The colour to use to display men.')) add_option('colormales', color_males) color_females = ColorOption(_('Females'), '#ffe0e0') color_females.set_help(_('The colour to use to display women.')) add_option('colorfemales', color_females) color_unknown = ColorOption(_('Unknown'), '#e0e0e0') color_unknown.set_help( _('The colour to use ' 'when the gender is unknown.')) add_option('colorunknown', color_unknown) color_family = ColorOption(_('Families'), '#ffffe0') color_family.set_help(_('The colour to use to display families.')) add_option('colorfamilies', color_family) self.limit_parents = BooleanOption(_('Limit the number of ancestors'), False) self.limit_parents.set_help( _('Whether to ' 'limit the number of ancestors.')) add_option('limitparents', self.limit_parents) self.limit_parents.connect('value-changed', self.limit_changed) self.max_parents = NumberOption('', 50, 10, 9999) self.max_parents.set_help( _('The maximum number ' 'of ancestors to include.')) add_option('maxparents', self.max_parents) self.limit_children = BooleanOption( _('Limit the number ' 'of descendants'), False) self.limit_children.set_help( _('Whether to ' 'limit the number of descendants.')) add_option('limitchildren', self.limit_children) self.limit_children.connect('value-changed', self.limit_changed) self.max_children = NumberOption('', 50, 10, 9999) self.max_children.set_help( _('The maximum number ' 'of descendants to include.')) add_option('maxchildren', self.max_children) # -------------------- add_option = partial(menu.add_option, _('Images')) # -------------------- self.include_images = BooleanOption( _('Include ' 'thumbnail images of people'), True) self.include_images.set_help( _('Whether to ' 'include thumbnail images of people.')) add_option('incimages', self.include_images) self.include_images.connect('value-changed', self.images_changed) self.image_location = EnumeratedListOption(_('Thumbnail location'), 0) self.image_location.add_item(0, _('Above the name')) self.image_location.add_item(1, _('Beside the name')) self.image_location.set_help( _('Where the thumbnail image ' 'should appear relative to the name')) add_option('imageonside', self.image_location) # --------------------- add_option = partial(menu.add_option, _('Options')) # --------------------- color = EnumeratedListOption(_("Graph coloring"), "filled") for i in range(len(_COLORS)): color.add_item(_COLORS[i]["value"], _COLORS[i]["name"]) color.set_help( _("Males will be shown with blue, females " "with red, unless otherwise set above for filled. " "If the sex of an individual " "is unknown it will be shown with gray.")) add_option("color", color) use_roundedcorners = BooleanOption(_('Use rounded corners'), False) use_roundedcorners.set_help( _('Use rounded corners to differentiate ' 'between women and men.')) add_option("useroundedcorners", use_roundedcorners) self.include_dates = BooleanOption(_('Include dates'), True) self.include_dates.set_help( _('Whether to include dates for people ' 'and families.')) add_option('incdates', self.include_dates) self.include_dates.connect('value-changed', self.include_dates_changed) self.justyears = BooleanOption(_("Limit dates to years only"), False) self.justyears.set_help( _("Prints just dates' year, neither " "month or day nor date approximation " "or interval are shown.")) add_option("justyears", self.justyears) include_places = BooleanOption(_('Include places'), True) include_places.set_help( _('Whether to include placenames for people ' 'and families.')) add_option('incplaces', include_places) include_num_children = BooleanOption( _('Include the number of children'), True) include_num_children.set_help( _('Whether to include the number of ' 'children for families with more ' 'than 1 child.')) add_option('incchildcnt', include_num_children) include_private = BooleanOption(_('Include private records'), False) include_private.set_help( _('Whether to include names, dates, and ' 'families that are marked as private.')) add_option('incprivate', include_private) self.limit_changed() self.images_changed() def limit_changed(self): """ Handle the change of limiting parents and children. """ self.max_parents.set_available(self.limit_parents.get_value()) self.max_children.set_available(self.limit_children.get_value()) def images_changed(self): """ Handle the change of including images. """ self.image_location.set_available(self.include_images.get_value()) def include_dates_changed(self): """ Enable/disable menu items if dates are required """ if self.include_dates.get_value(): self.justyears.set_available(True) else: self.justyears.set_available(False)
class RelGraphOptions(MenuReportOptions): """ Defines options and provides handling interface. """ def __init__(self, name, dbase): self.__pid = None self.__filter = None self.__show_relships = None self.__show_GaGb = None self.__include_images = None self.__image_on_side = None self.__db = dbase MenuReportOptions.__init__(self, name, dbase) def add_menu_options(self, menu): ################################ add_option = partial(menu.add_option, _("Report Options")) ################################ self.__filter = FilterOption(_("Filter"), 0) self.__filter.set_help( _("Determines what people are included in the graph")) add_option("filter", self.__filter) self.__filter.connect('value-changed', self.__filter_changed) self.__pid = PersonOption(_("Center Person")) self.__pid.set_help(_("The center person for the report")) add_option("pid", self.__pid) self.__pid.connect('value-changed', self.__update_filters) self.__update_filters() self.incdate = BooleanOption( _("Include Birth, Marriage and Death dates"), True) self.incdate.set_help( _("Include the dates that the individual was " "born, got married and/or died in the graph labels.")) add_option("incdate", self.incdate) self.incdate.connect('value-changed', self.__include_dates_changed) self.justyears = BooleanOption(_("Limit dates to years only"), False) self.justyears.set_help( _("Prints just dates' year, neither " "month or day nor date approximation " "or interval are shown.")) add_option("justyears", self.justyears) use_place = BooleanOption(_("Use place when no date"), True) use_place.set_help( _("When no birth, marriage, or death date is " "available, the correspondent place field " "will be used.")) add_option("use_place", use_place) url = BooleanOption(_("Include URLs"), False) url.set_help( _("Include a URL in each graph node so " "that PDF and imagemap files can be " "generated that contain active links " "to the files generated by the 'Narrated " "Web Site' report.")) add_option("url", url) incid = BooleanOption(_("Include IDs"), False) incid.set_help(_("Include individual and family IDs.")) add_option("incid", incid) self.__show_relships = BooleanOption( _("Include relationship to center person"), False) self.__show_relships.set_help( _("Whether to show every " "person's relationship to the center person")) add_option("increlname", self.__show_relships) self.__show_relships.connect('value-changed', self.__show_relships_changed) if __debug__: self.__show_GaGb = BooleanOption( _("Include relationship " "debugging numbers also"), False) self.__show_GaGb.set_help( _("Whether to include 'Ga' and 'Gb' " "also, to debug the relationship calculator")) add_option("advrelinfo", self.__show_GaGb) self.__include_images = BooleanOption( _('Include thumbnail images of people'), False) self.__include_images.set_help( _("Whether to include thumbnails of people.")) add_option("includeImages", self.__include_images) self.__include_images.connect('value-changed', self.__image_changed) self.__image_on_side = EnumeratedListOption(_("Thumbnail Location"), 0) self.__image_on_side.add_item(0, _('Above the name')) self.__image_on_side.add_item(1, _('Beside the name')) self.__image_on_side.set_help( _("Where the thumbnail image should appear " "relative to the name")) add_option("imageOnTheSide", self.__image_on_side) ################################ add_option = partial(menu.add_option, _("Graph Style")) ################################ color = EnumeratedListOption(_("Graph coloring"), 'filled') for i in range(0, len(_COLORS)): color.add_item(_COLORS[i]["value"], _COLORS[i]["name"]) color.set_help( _("Males will be shown with blue, females " "with red. If the sex of an individual " "is unknown it will be shown with gray.")) add_option("color", color) color_males = ColorOption(_('Males'), '#e0e0ff') color_males.set_help(_('The colour to use to display men.')) add_option('colormales', color_males) color_females = ColorOption(_('Females'), '#ffe0e0') color_females.set_help(_('The colour to use to display women.')) add_option('colorfemales', color_females) color_unknown = ColorOption(_('Unknown'), '#e0e0e0') color_unknown.set_help( _('The colour to use when the gender is unknown.')) add_option('colorunknown', color_unknown) color_family = ColorOption(_('Families'), '#ffffe0') color_family.set_help(_('The colour to use to display families.')) add_option('colorfamilies', color_family) arrow = EnumeratedListOption(_("Arrowhead direction"), 'd') for i in range(0, len(_ARROWS)): arrow.add_item(_ARROWS[i]["value"], _ARROWS[i]["name"]) arrow.set_help(_("Choose the direction that the arrows point.")) add_option("arrow", arrow) roundedcorners = BooleanOption( # see bug report #2180 _("Use rounded corners"), False) roundedcorners.set_help( _("Use rounded corners to differentiate " "between women and men.")) add_option("useroundedcorners", roundedcorners) dashed = BooleanOption( _("Indicate non-birth relationships with dotted lines"), True) dashed.set_help( _("Non-birth relationships will show up " "as dotted lines in the graph.")) add_option("dashed", dashed) showfamily = BooleanOption(_("Show family nodes"), True) showfamily.set_help( _("Families will show up as ellipses, linked " "to parents and children.")) add_option("showfamily", showfamily) def __update_filters(self): """ Update the filter list based on the selected person """ gid = self.__pid.get_value() person = self.__db.get_person_from_gramps_id(gid) filter_list = ReportUtils.get_person_filters(person, False) self.__filter.set_filters(filter_list) def __include_dates_changed(self): """ Enable/disable menu items if dates are required """ if self.incdate.get_value(): self.justyears.set_available(True) else: self.justyears.set_available(False) def __filter_changed(self): """ Handle filter change. If the filter is not specific to a person, disable the person option """ filter_value = self.__filter.get_value() if filter_value in [1, 2, 3, 4]: # Filters 1, 2, 3 and 4 rely on the center person self.__pid.set_available(True) elif self.__show_relships and self.__show_relships.get_value(): self.__pid.set_available(True) else: # The rest don't self.__pid.set_available(False) def __image_changed(self): """ Handle thumbnail change. If the image is not to be included, make the image location option unavailable. """ self.__image_on_side.set_available(self.__include_images.get_value()) def __show_relships_changed(self): """ Enable/disable menu items if relationships are required """ if self.__show_GaGb: self.__show_GaGb.set_available(self.__show_relships.get_value()) self.__filter_changed()