示例#1
0
 def add_menu_options(self, menu):
     """Add the menu options for the tool."""
     if self.__is_db_empty():
         txt = [_("The Tool requires at least one tag to execute.")]
         self.empty = TextOption(_("ERROR"), txt)
         self.empty.set_available(False)
         menu.add_option(_("ERROR"), "empty", self.empty)
         return  # stop other menu option creation
     else:
         self.__general_options(menu)
         self.__filter_options(menu)
示例#2
0
    def add_menu_options(self, menu):

        category_name = _("Text")

        self.__top = TextOption(_("Initial Text"), [""])
        self.__top.set_help(_("Text to display at the top"))
        menu.add_option(category_name, "top", self.__top)

        self.__mid = TextOption(_("Middle Text"), [""])
        self.__mid.set_help(_("Text to display in the middle"))
        menu.add_option(category_name, "mid", self.__mid)

        self.__bot = TextOption(_("Final Text"), [""])
        self.__bot.set_help(_("Text to display at the bottom"))
        menu.add_option(category_name, "bot", self.__bot)
示例#3
0
    def add_menu_options(self, menu):

        category_name = _("Text")

        top = TextOption(_("Initial Text"), [""] )
        top.set_help(_("Text to display at the top."))
        menu.add_option(category_name, "top", top)

        mid = TextOption(_("Middle Text"), [""] )
        mid.set_help(_("Text to display in the middle"))
        menu.add_option(category_name, "mid", mid)

        bot = TextOption(_("Final Text"), [""] )
        bot.set_help(_("Text to display last."))
        menu.add_option(category_name, "bot", bot)
    def add_menu_options(self, menu):
        """
        Add the menu options for the Remove Tag Tool.
        """
        if self.is_db_empty():
            txt = [
                _("The Remove Tag Tool requires at least "
                  "one person, family and tag to execute.")
            ]
            self.empty = TextOption(_("ERROR"), txt)
            menu.add_option(_("ERROR"), "empty", self.empty)
        else:
            self.__add_tag_category_options(menu)
            self.__add_person_options(menu)
            self.__add_family_options(menu)

            self.filter_dict = {}
            lst = [("events", _("Event Filter"), "event_filter", 'Event',
                    _("All Events")),
                   ("places", _("Place Filter"), "place_filter", 'Place',
                    _("All Places")),
                   ("sources", _("Source Filter"), "scource_filter", 'Source',
                    _("All Sources")),
                   ("citations", _("Citation Filter"), "cit_filter",
                    'Citation', _("All Citations")),
                   ("repositories", _("Repository Filter"), "repo_filter",
                    'Repository', _("All Repositories")),
                   ("media", _("Media Filter"), "media_filter", 'Media',
                    _("All Media")),
                   ("notes", _("Note Filter"), "note_filter", 'Note',
                    _("All Notes"))]

            for entry in lst:
                filter_name = FilterOption(entry[1], 0)
                filter_name.set_help(
                    _("Select filter to restrict {}".format(entry[0])))
                menu.add_option(_("Option 2"), entry[2], filter_name)
                self.filter_dict[entry[3]] = filter_name

                filter_list = CustomFilters.get_filters(entry[3])
                GenericFilter = GenericFilterFactory(entry[3])
                all_filter = GenericFilter()
                all_filter.set_name(entry[4])
                all_filter.add_rule(rules.event.AllEvents([]))
                all_filter_in_list = False
                for fltr in filter_list:
                    if fltr.get_name() == all_filter.get_name():
                        all_filter_in_list = True
                if not all_filter_in_list:
                    filter_list.insert(0, all_filter)
                self.filter_dict[entry[3]].set_filters(filter_list)
示例#5
0
    def add_menu_options(self, menu):

        category_name = _("Text")

        self.__top = TextOption(_("Initial Text"), [""])
        self.__top.set_help(_("Text to display at the top."))
        menu.add_option(category_name, "top", self.__top)

        self.__mid = TextOption(_("Middle Text"), [""])
        self.__mid.set_help(_("Text to display in the middle"))
        menu.add_option(category_name, "mid", self.__mid)

        self.__bot = TextOption(_("Final Text"), [""])
        self.__bot.set_help(_("Text to display last."))
        menu.add_option(category_name, "bot", self.__bot)
示例#6
0
    def add_menu_options(self, menu):

        ##################
        category_name = _("Tree Options")

        self.__pid = PersonOption(_("Center Person"))
        self.__pid.set_help(_("The center person for the tree"))
        menu.add_option(category_name, "pid", self.__pid)

        stdoptions.add_name_format_option(menu, category_name)

        stdoptions.add_living_people_option(menu, category_name)

        stdoptions.add_private_data_option(menu, category_name)

        siblings = BooleanOption(_('Include siblings of the center person'),
                                 False)
        siblings.set_help(
            _("Whether to only display the center person or all "
              "of his/her siblings too"))
        menu.add_option(category_name, "inc_siblings", siblings)

        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(_('Compress 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 Main Display Format"))
        #Spouse_disp.add_item(2, _("Yes, and use the Secondary "
        #                           "Display Format"))
        #Spouse_disp.set_help(_("Show spouses of the center person?"))
        #menu.add_option(category_name, "Spouse_disp", Spouse_disp)

        ##################
        category_name = _("Report Options")

        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)

        stdoptions.add_localization_option(menu, category_name)

        ##################
        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")

        disp_mom = TextOption(
            _("Mother\nDisplay Format"),
            ["$n", "%s $b" % _BORN,
             "%s $m" % _MARR,
             "-{%s $d}" % _DIED])
        disp_mom.set_help(_("Display format for the mothers box."))
        menu.add_option(category_name, "mother_disp", disp_mom)

        center_disp = EnumeratedListOption(
            _("Center person uses\n"
              "which format"), 0)
        center_disp.add_item(0, _("Use Fathers Display format"))
        center_disp.add_item(1, _("Use Mothers display format"))
        center_disp.set_help(
            _("Which Display format to use the center person"))
        menu.add_option(category_name, "center_uses", center_disp)

        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

        self.box_Y_sf = NumberOption(_("inter-box scale factor"), 1.00, 0.10,
                                     2.00, 0.01)
        self.box_Y_sf.set_help(
            _("Make the inter-box spacing bigger or smaller"))
        menu.add_option(category_name, "box_Yscale", self.box_Y_sf)

        self.box_shadow_sf = NumberOption(_("box shadow scale factor"), 1.00,
                                          0.00, 2.00, 0.01)  # down to 0
        self.box_shadow_sf.set_help(_("Make the box shadow bigger or smaller"))
        menu.add_option(category_name, "shadowscale", self.box_shadow_sf)

        ##################
        category_name = _("Replace")

        repldisp = TextOption(
            _("Replace Display Format:\n'Replace this'/' with this'"), [])
        repldisp.set_help(_("i.e.\nUnited States of America/U.S.A"))
        menu.add_option(category_name, "replace_list", repldisp)

        ##################
        category_name = _("Include")

        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()

        # TODO this code is never used and so I conclude it is for future use
        # self.__include_images = BooleanOption(
        #                       _('Include thumbnail images of people'), False)
        # self.__include_images.set_help(
        #                       _("Whether to include thumbnails of people."))
        # menu.add_option(category_name, "includeImages", self.__include_images)

        #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)
示例#7
0
class AncestorTreeOptions(MenuReportOptions):
    """
    Defines options and provides handling interface.
    """
    def __init__(self, name, dbase):
        self.__db = dbase
        self.__pid = None
        self.box_Y_sf = None
        self.box_shadow_sf = None
        MenuReportOptions.__init__(self, name, dbase)

    def get_subject(self):
        """ Return a string that describes the subject of the report. """
        gid = self.__pid.get_value()
        person = self.__db.get_person_from_gramps_id(gid)
        return _nd.display(person)

    def add_menu_options(self, menu):

        ##################
        category_name = _("Tree Options")

        self.__pid = PersonOption(_("Center Person"))
        self.__pid.set_help(_("The center person for the tree"))
        menu.add_option(category_name, "pid", self.__pid)

        stdoptions.add_name_format_option(menu, category_name)

        stdoptions.add_living_people_option(menu, category_name)

        stdoptions.add_private_data_option(menu, category_name)

        siblings = BooleanOption(_('Include siblings of the center person'),
                                 False)
        siblings.set_help(
            _("Whether to only display the center person or all "
              "of his/her siblings too"))
        menu.add_option(category_name, "inc_siblings", siblings)

        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(_('Compress 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 Main Display Format"))
        #Spouse_disp.add_item(2, _("Yes, and use the Secondary "
        #                           "Display Format"))
        #Spouse_disp.set_help(_("Show spouses of the center person?"))
        #menu.add_option(category_name, "Spouse_disp", Spouse_disp)

        ##################
        category_name = _("Report Options")

        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)

        stdoptions.add_localization_option(menu, category_name)

        ##################
        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")

        disp_mom = TextOption(
            _("Mother\nDisplay Format"),
            ["$n", "%s $b" % _BORN,
             "%s $m" % _MARR,
             "-{%s $d}" % _DIED])
        disp_mom.set_help(_("Display format for the mothers box."))
        menu.add_option(category_name, "mother_disp", disp_mom)

        center_disp = EnumeratedListOption(
            _("Center person uses\n"
              "which format"), 0)
        center_disp.add_item(0, _("Use Fathers Display format"))
        center_disp.add_item(1, _("Use Mothers display format"))
        center_disp.set_help(
            _("Which Display format to use the center person"))
        menu.add_option(category_name, "center_uses", center_disp)

        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

        self.box_Y_sf = NumberOption(_("inter-box scale factor"), 1.00, 0.10,
                                     2.00, 0.01)
        self.box_Y_sf.set_help(
            _("Make the inter-box spacing bigger or smaller"))
        menu.add_option(category_name, "box_Yscale", self.box_Y_sf)

        self.box_shadow_sf = NumberOption(_("box shadow scale factor"), 1.00,
                                          0.00, 2.00, 0.01)  # down to 0
        self.box_shadow_sf.set_help(_("Make the box shadow bigger or smaller"))
        menu.add_option(category_name, "shadowscale", self.box_shadow_sf)

        ##################
        category_name = _("Replace")

        repldisp = TextOption(
            _("Replace Display Format:\n'Replace this'/' with this'"), [])
        repldisp.set_help(_("i.e.\nUnited States of America/U.S.A"))
        menu.add_option(category_name, "replace_list", repldisp)

        ##################
        category_name = _("Include")

        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()

        # TODO this code is never used and so I conclude it is for future use
        # self.__include_images = BooleanOption(
        #                       _('Include thumbnail images of people'), False)
        # self.__include_images.set_help(
        #                       _("Whether to include thumbnails of people."))
        # menu.add_option(category_name, "includeImages", self.__include_images)

        #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."""

        ## 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(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 '
              'note display.'))
        default_style.add_paragraph_style("AC2-Note", para_style)

        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-Note")
        graph_style.set_fill_color((255, 255, 255))
        default_style.add_draw_style("AC2-note-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)
示例#8
0
class RemoveTagOptions(MenuToolOptions):
    """Class for creating menu options."""
    def __init__(self, name, person_id=None, dbstate=None):
        self.db = dbstate.get_database()
        MenuToolOptions.__init__(self, name, person_id, dbstate)

    def add_menu_options(self, menu):
        """Add the menu options for the tool."""
        if self.__is_db_empty():
            txt = [_("The Tool requires at least one tag to execute.")]
            self.empty = TextOption(_("ERROR"), txt)
            self.empty.set_available(False)
            menu.add_option(_("ERROR"), "empty", self.empty)
            return  # stop other menu option creation
        else:
            self.__general_options(menu)
            self.__filter_options(menu)

    def __enum_tag_list(self):
        """Return an enumerated tag name list."""
        tag_list = list(self.db.iter_tags())
        if tag_list:
            L = list(map(lambda x: x.get_name(), tag_list))
            return list(enumerate(L))

    def __is_db_empty(self):
        """Check if database has at least one tag."""
        try:
            next(self.db.iter_tag_handles())
        except StopIteration:
            # StopIteration is raised when the category has no objects
            return True  # Empty
        return False  # Not empty

    def __general_options(self, menu):
        """Menu Options for general option tab."""
        # Add or remove tags menu option
        self.add_remove = FilterOption(_("Add/Remove"), 0)
        self.add_remove.set_help(_("Add or remove tags from objects."))
        self.add_remove.set_items([(0, _("Add Tags")), (1, _("Remove Tags"))])
        menu.add_option(_("General options"), "add_remove", self.add_remove)

        # category menu option
        lst = [
            _("People"),
            _("Families"),
            _("Events"),
            _("Places"),
            _("Sources"),
            _("Citations"),
            _("Repositories"),
            _("Media"),
            _("Notes")
        ]
        category_list = list(enumerate(lst))
        self.tag_category = FilterOption(_("Category"), 0)
        self.tag_category.set_help(_("Choose a category."))
        menu.add_option(_("General options"), "category", self.tag_category)
        self.tag_category.set_items(category_list)
        self.tag_category.connect('value-changed', self.__update_options)

        # tag name list menu option
        tag_list = self.__enum_tag_list()
        self.tag_name = FilterOption(_("Choose Tag"), 0)
        self.tag_name.set_help(_("Choose a tag to remove."))
        menu.add_option(_("General options"), "tag_name", self.tag_name)
        self.tag_name.set_items(tag_list)

    def __filter_options(self, menu):
        """Menu Options for filter option tab."""
        self.filter_dict = {}

        # get all filter rules, used for generic filters
        all_persons = rules.person.Everyone([])
        all_families = rules.family.AllFamilies([])
        all_events = rules.event.AllEvents([])
        all_places = rules.place.AllPlaces([])
        all_sources = rules.source.AllSources([])
        all_cits = rules.citation.AllCitations([])
        all_repos = rules.repository.AllRepos([])
        all_media = rules.media.AllMedia([])
        all_notes = rules.note.AllNotes([])

        # create a list used for menu filter option creation later
        lst = [(_("Person Filter"), 'Person', _("Persons"), all_persons),
               (_("Family Filter"), 'Family', _("Families"), all_families),
               (_("Event Filter"), 'Event', _("Events"), all_events),
               (_("Place Filter"), 'Place', _("Places"), all_places),
               (_("Source Filter"), 'Source', _("Sources"), all_sources),
               (_("Citation Filter"), 'Citation', _("Citations"), all_cits),
               (_("Repository Filter"), 'Repository',
                _("Repositories"), all_repos),
               (_("Media Filter"), 'Media', _("Media"), all_media),
               (_("Note Filter"), 'Note', _("Notes"), all_notes)]

        for entry in lst:
            # create a filter option for each category e.g. person, events
            # filter option is a combination of custom filters and
            # a generic filter for all objects of one category
            filter_name = FilterOption(entry[0], 0)
            menu.add_option(_("Filter options"), entry[1].lower(), filter_name)
            self.filter_dict[entry[1]] = filter_name

            # custom filter:
            filter_list = CustomFilters.get_filters(entry[1])

            # generic filter:
            GenericFilter = GenericFilterFactory(entry[1])
            all_filter = GenericFilter()
            all_filter.set_name(_("All %s") % (entry[2]))
            all_filter.add_rule(entry[3])

            # only add the generic filter if it isn't already in the menu
            all_filter_in_list = False
            for fltr in filter_list:
                if fltr.get_name() == all_filter.get_name():
                    all_filter_in_list = True
            if not all_filter_in_list:
                filter_list.insert(0, all_filter)

            # add the list of custom and generic filters
            # to the filter option
            self.filter_dict[entry[1]].set_filters(filter_list)

    def __update_options(self):
        """Turn availability on and off depending on user selection."""
        lst = [
            'Person', 'Family', 'Event', 'Place', 'Source', 'Citation',
            'Repository', 'Media', 'Note'
        ]
        for entry in lst:
            self.filter_dict[entry].set_available(False)
        value = self.tag_category.get_value()
        self.filter_dict[lst[value]].set_available(True)
示例#9
0
class CustomTextOptions(MenuReportOptions):

    """
    Defines options and provides handling interface.
    """

    def __init__(self, name, dbase):
        self.__top = None
        self.__mid = None
        self.__bot = None
        MenuReportOptions.__init__(self, name, dbase)

    def add_menu_options(self, menu):

        category_name = _("Text")

        self.__top = TextOption(_("Initial Text"), [""])
        self.__top.set_help(_("Text to display at the top"))
        menu.add_option(category_name, "top", self.__top)

        self.__mid = TextOption(_("Middle Text"), [""])
        self.__mid.set_help(_("Text to display in the middle"))
        menu.add_option(category_name, "mid", self.__mid)

        self.__bot = TextOption(_("Final Text"), [""])
        self.__bot.set_help(_("Text to display at the bottom"))
        menu.add_option(category_name, "bot", self.__bot)

    def get_subject(self):
        """ Return a string that describes the subject of the report. """
        if len(self.__top.get_value()[0]) > 0:
            return self.__top.get_value()[0]
        if len(self.__mid.get_value()[0]) > 0:
            return self.__mid.get_value()[0]
        if len(self.__bot.get_value()[0]) > 0:
            return self.__bot.get_value()[0]
        return ""

    def make_default_style(self, default_style):
        """Make the default output style for the Custom Text report."""
        font = FontStyle()
        font.set(face=FONT_SANS_SERIF, size=12, bold=0, italic=0)
        para = ParagraphStyle()
        para.set_font(font)
        para.set_alignment(PARA_ALIGN_CENTER)
        para.set(pad=0.5)
        para.set_description(_('Text to display at the top'))
        default_style.add_paragraph_style("CBT-Initial", para)

        font = FontStyle()
        font.set(face=FONT_SANS_SERIF, size=12, bold=0, italic=0)
        para = ParagraphStyle()
        para.set_font(font)
        para.set(pad=0.5)
        para.set_alignment(PARA_ALIGN_CENTER)
        para.set_description(_('Text to display in the middle'))
        default_style.add_paragraph_style("CBT-Middle", para)

        font = FontStyle()
        font.set(face=FONT_SANS_SERIF, size=12, bold=0, italic=0)
        para = ParagraphStyle()
        para.set_font(font)
        para.set_alignment(PARA_ALIGN_CENTER)
        para.set(pad=0.5)
        para.set_description(_('Text to display at the bottom'))
        default_style.add_paragraph_style("CBT-Final", para)
示例#10
0
    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)

        siblings = BooleanOption(_('Include siblings of the center person'), False)
        siblings.set_help(_("Whether to only display the center person or all "
            "of his/her siblings too"))
        menu.add_option(category_name, "inc_siblings", siblings)

        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(_('Compress 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 Main Display Format"))
        #Spouse_disp.add_item( 2, _("Yes, and use the Secondary "
        #                           "Display Format"))
        #Spouse_disp.set_help(_("Show spouses of the center person?"))
        #menu.add_option(category_name, "Spouse_disp", Spouse_disp)

        ##################
        category_name = _("Report Options")

        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)

        stdoptions.add_private_data_option(menu, category_name)

        stdoptions.add_name_format_option(menu, category_name)

        stdoptions.add_localization_option(menu, category_name)

        ##################
        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)

        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)

        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

        self.box_Y_sf = NumberOption(_("inter-box scale factor"),
                                     1.00, 0.10, 2.00, 0.01)
        self.box_Y_sf.set_help(_("Make the inter-box spacing bigger or smaller"))
        menu.add_option(category_name, "box_Yscale", self.box_Y_sf)

        self.box_shadow_sf = NumberOption(_("box shadow scale factor"),
                                          1.00, 0.00, 2.00, 0.01) # down to 0
        self.box_shadow_sf.set_help(_("Make the box shadow bigger or smaller"))
        menu.add_option(category_name, "shadowscale", self.box_shadow_sf)


        ##################
        category_name = _("Replace")

        repldisp = TextOption(
            _("Replace Display Format:\n'Replace this'/' with this'"),
            [])
        repldisp.set_help(_("i.e.\nUnited States of America/U.S.A"))
        menu.add_option(category_name, "replace_list", repldisp)


        ##################
        category_name = _("Include")

        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()

        self.__include_images = BooleanOption(
                                 _('Include thumbnail images of people'), False)
        self.__include_images.set_help(
                                 _("Whether to include thumbnails of people."))
        menu.add_option(category_name, "includeImages", self.__include_images)

        #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)
示例#11
0
class AncestorTreeOptions(MenuReportOptions):

    """
    Defines options and provides handling interface.
    """

    def __init__(self, name, dbase):
        self.box_Y_sf = None
        self.box_shadow_sf = None
        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)

        siblings = BooleanOption(_('Include siblings of the center person'), False)
        siblings.set_help(_("Whether to only display the center person or all "
            "of his/her siblings too"))
        menu.add_option(category_name, "inc_siblings", siblings)

        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(_('Compress 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 Main Display Format"))
        #Spouse_disp.add_item( 2, _("Yes, and use the Secondary "
        #                           "Display Format"))
        #Spouse_disp.set_help(_("Show spouses of the center person?"))
        #menu.add_option(category_name, "Spouse_disp", Spouse_disp)

        ##################
        category_name = _("Report Options")

        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)

        stdoptions.add_private_data_option(menu, category_name)

        stdoptions.add_name_format_option(menu, category_name)

        stdoptions.add_localization_option(menu, category_name)

        ##################
        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)

        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)

        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

        self.box_Y_sf = NumberOption(_("inter-box scale factor"),
                                     1.00, 0.10, 2.00, 0.01)
        self.box_Y_sf.set_help(_("Make the inter-box spacing bigger or smaller"))
        menu.add_option(category_name, "box_Yscale", self.box_Y_sf)

        self.box_shadow_sf = NumberOption(_("box shadow scale factor"),
                                          1.00, 0.00, 2.00, 0.01) # down to 0
        self.box_shadow_sf.set_help(_("Make the box shadow bigger or smaller"))
        menu.add_option(category_name, "shadowscale", self.box_shadow_sf)


        ##################
        category_name = _("Replace")

        repldisp = TextOption(
            _("Replace Display Format:\n'Replace this'/' with this'"),
            [])
        repldisp.set_help(_("i.e.\nUnited States of America/U.S.A"))
        menu.add_option(category_name, "replace_list", repldisp)


        ##################
        category_name = _("Include")

        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()

        self.__include_images = BooleanOption(
                                 _('Include thumbnail images of people'), False)
        self.__include_images.set_help(
                                 _("Whether to include thumbnails of people."))
        menu.add_option(category_name, "includeImages", self.__include_images)

        #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."""

        ## 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(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 '
                                     'note display.'))
        default_style.add_paragraph_style("AC2-Note", para_style)

        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-Note")
        graph_style.set_fill_color((255, 255, 255))
        default_style.add_draw_style("AC2-note-box", graph_style)

        # TODO - Why is this here twice?
        #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)
示例#12
0
class CustomTextOptions(MenuReportOptions):
    """
    Defines options and provides handling interface.
    """
    def __init__(self, name, dbase):
        self.__top = None
        self.__mid = None
        self.__bot = None
        MenuReportOptions.__init__(self, name, dbase)

    def add_menu_options(self, menu):

        category_name = _("Text")

        self.__top = TextOption(_("Initial Text"), [""])
        self.__top.set_help(_("Text to display at the top."))
        menu.add_option(category_name, "top", self.__top)

        self.__mid = TextOption(_("Middle Text"), [""])
        self.__mid.set_help(_("Text to display in the middle"))
        menu.add_option(category_name, "mid", self.__mid)

        self.__bot = TextOption(_("Final Text"), [""])
        self.__bot.set_help(_("Text to display last."))
        menu.add_option(category_name, "bot", self.__bot)

    def get_subject(self):
        """ Return a string that describes the subject of the report. """
        if len(self.__top.get_value()[0]) > 0:
            return self.__top.get_value()[0]
        if len(self.__mid.get_value()[0]) > 0:
            return self.__mid.get_value()[0]
        if len(self.__bot.get_value()[0]) > 0:
            return self.__bot.get_value()[0]
        return ""

    def make_default_style(self, default_style):
        """Make the default output style for the Custom Text report."""
        font = FontStyle()
        font.set(face=FONT_SANS_SERIF, size=12, bold=0, italic=0)
        para = ParagraphStyle()
        para.set_font(font)
        para.set_alignment(PARA_ALIGN_CENTER)
        para.set(pad=0.5)
        para.set_description(
            _('The style used for the first portion of the custom text.'))
        default_style.add_paragraph_style("CBT-Initial", para)

        font = FontStyle()
        font.set(face=FONT_SANS_SERIF, size=12, bold=0, italic=0)
        para = ParagraphStyle()
        para.set_font(font)
        para.set(pad=0.5)
        para.set_alignment(PARA_ALIGN_CENTER)
        para.set_description(
            _('The style used for the middle portion of the custom text.'))
        default_style.add_paragraph_style("CBT-Middle", para)

        font = FontStyle()
        font.set(face=FONT_SANS_SERIF, size=12, bold=0, italic=0)
        para = ParagraphStyle()
        para.set_font(font)
        para.set_alignment(PARA_ALIGN_CENTER)
        para.set(pad=0.5)
        para.set_description(
            _('The style used for the last portion of the custom text.'))
        default_style.add_paragraph_style("CBT-Final", para)