diff --git a/gramps2/ChangeLog b/gramps2/ChangeLog index 29280c5eb..c51ddcbbd 100644 --- a/gramps2/ChangeLog +++ b/gramps2/ChangeLog @@ -4,6 +4,9 @@ 2005-11-09 Alex Roitman * src/docgen/LPRDoc.py: Use paragraph padding correctly. + * src/BaseDoc.py: Support space above/below paragraph. + * src/StyleEditor.py: Support space above/below paragraph. + * src/gramps.glade: Support space above/below paragraph. 2005-11-09 Martin Hawlisch * src/DbPrompter.py (DbPrompter): Use Combo to list multiple rcecent files diff --git a/gramps2/src/BaseDoc.py b/gramps2/src/BaseDoc.py index 7f99aaf8c..de4823b9b 100644 --- a/gramps2/src/BaseDoc.py +++ b/gramps2/src/BaseDoc.py @@ -499,8 +499,8 @@ class ParagraphStyle: """ Defines the characteristics of a paragraph. The characteristics are: font (a FontStyle instance), right margin, left margin, first indent, - alignment, level, top border, bottom border, right border, left - border, padding, and background color. + top margin, bottom margin, alignment, level, top border, bottom border, + right border, left border, padding, and background color. """ def __init__(self,source=None): @@ -513,6 +513,8 @@ class ParagraphStyle: self.rmargin = source.rmargin self.lmargin = source.lmargin self.first_indent = source.first_indent + self.tmargin = source.tmargin + self.bmargin = source.bmargin self.align = source.align self.level = source.level self.top_border = source.top_border @@ -526,6 +528,8 @@ class ParagraphStyle: self.font = FontStyle() self.rmargin = 0 self.lmargin = 0 + self.tmargin = 0 + self.bmargin = 0 self.first_indent = 0 self.align = PARA_ALIGN_LEFT self.level = 0 @@ -543,17 +547,19 @@ class ParagraphStyle: def get_description(self): return self.description - def set(self,rmargin=None,lmargin=None,first_indent=None,align=None, + def set(self,rmargin=None,lmargin=None,first_indent=None, + tmargin=None,bmargin=None,align=None, tborder=None,bborder=None,rborder=None,lborder=None,pad=None, bgcolor=None,font=None): """ Allows the values of the object to be set. - @param rmargin: right margin in centimeters - @param lmargin: left margin in centimeters + @param rmargin: right indent in centimeters + @param lmargin: left indent in centimeters @param first_indent: first line indent in centimeters - align - alignment type (PARA_ALIGN_LEFT, PARA_ALIGN_RIGHT, - PARA_ALIGN_CENTER, or PARA_ALIGN_JUSTIFY) + @param tmargin: space above paragraph in centimeters + @param bmargin: space below paragraph in centimeters + @param align: alignment type (PARA_ALIGN_LEFT, PARA_ALIGN_RIGHT, PARA_ALIGN_CENTER, or PARA_ALIGN_JUSTIFY) @param tborder: non zero indicates that a top border should be used @param bborder: non zero indicates that a bottom border should be used @param rborder: non zero indicates that a right border should be used @@ -584,6 +590,10 @@ class ParagraphStyle: self.set_left_margin(lmargin) if first_indent != None: self.set_first_indent(first_indent) + if tmargin != None: + self.set_top_margin(tmargin) + if bmargin != None: + self.set_bottom_margin(bmargin) def set_header_level(self,level): """ @@ -719,29 +729,45 @@ class ParagraphStyle: return "unknown" def set_left_margin(self,value): - "sets the left paragraph margin in centimeters" + "sets the left indent in centimeters" self.lmargin = value def set_right_margin(self,value): - "sets the right paragraph margin in centimeters" + "sets the right indent in centimeters" self.rmargin = value def set_first_indent(self,value): - "sets the first indent margin in centimeters" + "sets the first line indent in centimeters" self.first_indent = value + def set_top_margin(self,value): + "sets the space above paragraph in centimeters" + self.tmargin = value + + def set_bottom_margin(self,value): + "sets the space below paragraph in centimeters" + self.bmargin = value + def get_left_margin(self): - "returns the left margin in centimeters" + "returns the left indent in centimeters" return self.lmargin def get_right_margin(self): - "returns the right margin in centimeters" + "returns the right indent in centimeters" return self.rmargin def get_first_indent(self): - "returns the first indent margin in centimeters" + "returns the first line indent in centimeters" return self.first_indent + def get_top_margin(self): + "returns the space above paragraph in centimeters" + return self.tmargin + + def get_bottom_margin(self): + "returns the space below paragraph in centimeters" + return self.bmargin + #------------------------------------------------------------------------ # # StyleSheetList @@ -832,10 +858,14 @@ class StyleSheetList: rm = float(p.get_right_margin()) lm = float(p.get_left_margin()) fi = float(p.get_first_indent()) + tm = float(p.get_top_margin()) + bm = float(p.get_bottom_margin()) pa = float(p.get_padding()) f.write('rmargin="%s" ' % Utils.gformat(rm)) f.write('lmargin="%s" ' % Utils.gformat(lm)) f.write('first="%s" ' % Utils.gformat(fi)) + f.write('tmargin="%s" ' % Utils.gformat(tm)) + f.write('bmargin="%s" ' % Utils.gformat(bm)) f.write('pad="%s" ' % Utils.gformat(pa)) f.write('bgcolor="#%02x%02x%02x" ' % p.get_background_color()) f.write('level="%d" ' % p.get_header_level()) @@ -963,6 +993,8 @@ class SheetParser(handler.ContentHandler): self.p.set_right_margin(Utils.gfloat(attrs['rmargin'])) self.p.set_left_margin(Utils.gfloat(attrs['lmargin'])) self.p.set_first_indent(Utils.gfloat(attrs['first'])) + self.p.set_top_margin(Utils.gfloat(attrs['tmargin'])) + self.p.set_bottom_margin(Utils.gfloat(attrs['bmargin'])) self.p.set_padding(Utils.gfloat(attrs['pad'])) self.p.set_alignment(int(attrs['align'])) self.p.set_right_border(int(attrs['rborder'])) diff --git a/gramps2/src/StyleEditor.py b/gramps2/src/StyleEditor.py index 14545139b..a283824d0 100644 --- a/gramps2/src/StyleEditor.py +++ b/gramps2/src/StyleEditor.py @@ -27,6 +27,13 @@ Paragraph/Font style editor __author__ = "Donald N. Allingham" __version__ = "$Revision$" +#------------------------------------------------------------------------ +# +# Python modules +# +#------------------------------------------------------------------------ +from gettext import gettext as _ + #------------------------------------------------------------------------ # # GNOME/GTK modules @@ -43,9 +50,12 @@ import Utils import const import BaseDoc import ListModel -import locale -from gettext import gettext as _ +#------------------------------------------------------------------------ +# +# StyleList class +# +#------------------------------------------------------------------------ class StyleListDisplay: """ Shows the available paragraph/font styles. Allows the user to select, @@ -129,8 +139,8 @@ class StyleListDisplay: def on_edit_clicked(self,obj): """ - Called with the EDIT button is clicked. Calls the StyleEditor to edit the - selected style. + Called with the EDIT button is clicked. + Calls the StyleEditor to edit the selected style. """ store,node = self.list.selection.get_selected() if not node: @@ -149,10 +159,15 @@ class StyleListDisplay: self.sheetlist.delete_style_sheet(name) self.redraw() +#------------------------------------------------------------------------ +# +# StyleEditor class +# +#------------------------------------------------------------------------ class StyleEditor: """ - Edits the current style definition. Presents a dialog allowing the values of - the paragraphs in the style to be altered. + Edits the current style definition. Presents a dialog allowing the values + of the paragraphs in the style to be altered. """ def __init__(self,name,style,parent): @@ -227,10 +242,12 @@ class StyleEditor: self.top.get_widget("calign").set_active(1) else: self.top.get_widget("jalign").set_active(1) - self.top.get_widget("rmargin").set_text(locale.str(p.get_right_margin())) - self.top.get_widget("lmargin").set_text(locale.str(p.get_left_margin())) - self.top.get_widget("pad").set_text(locale.str(p.get_padding())) - self.top.get_widget("indent").set_text(locale.str(p.get_first_indent())) + self.top.get_widget("rmargin").set_value(p.get_right_margin()) + self.top.get_widget("lmargin").set_value(p.get_left_margin()) + self.top.get_widget("pad").set_value(p.get_padding()) + self.top.get_widget("tmargin").set_value(p.get_top_margin()) + self.top.get_widget("bmargin").set_value(p.get_bottom_margin()) + self.top.get_widget("indent").set_value(p.get_first_indent()) self.top.get_widget("tborder").set_active(p.get_top_border()) self.top.get_widget("lborder").set_active(p.get_left_border()) self.top.get_widget("rborder").set_active(p.get_right_border()) @@ -255,7 +272,7 @@ class StyleEditor: """Saves the current paragraph displayed on the dialog""" font = p.get_font() - font.set_size(int(self.top.get_widget("size").get_value())) + font.set_size(self.top.get_widget("size").get_value_as_int()) if self.top.get_widget("roman").get_active(): font.set_type_face(BaseDoc.FONT_SERIF) @@ -274,10 +291,12 @@ class StyleEditor: else: p.set_alignment(BaseDoc.PARA_ALIGN_JUSTIFY) - p.set_right_margin(Utils.gfloat(self.top.get_widget("rmargin").get_text())) - p.set_left_margin(Utils.gfloat(self.top.get_widget("lmargin").get_text())) - p.set_padding(Utils.gfloat(self.top.get_widget("pad").get_text())) - p.set_first_indent(Utils.gfloat(self.top.get_widget("indent").get_text())) + p.set_right_margin(self.top.get_widget("rmargin").get_value()) + p.set_left_margin(self.top.get_widget("lmargin").get_value()) + p.set_top_margin(self.top.get_widget("tmargin").get_value()) + p.set_bottom_margin(self.top.get_widget("bmargin").get_value()) + p.set_padding(self.top.get_widget("pad").get_value()) + p.set_first_indent(self.top.get_widget("indent").get_value()) p.set_top_border(self.top.get_widget("tborder").get_active()) p.set_left_border(self.top.get_widget("lborder").get_active()) p.set_right_border(self.top.get_widget("rborder").get_active()) diff --git a/gramps2/src/gramps.glade b/gramps2/src/gramps.glade index 66fd6afb4..8afc7e935 100644 --- a/gramps2/src/gramps.glade +++ b/gramps2/src/gramps.glade @@ -5735,8 +5735,6 @@ Other True - False - True 0 @@ -19668,7 +19666,7 @@ Very High True - Style _name: + Style n_ame: True False GTK_JUSTIFY_CENTER @@ -19846,143 +19844,12 @@ Very High 12 True - 14 - 5 + 11 + 4 False 6 12 - - - True - pt - False - False - GTK_JUSTIFY_CENTER - False - False - 0 - 0.5 - 0 - 0 - - - 3 - 4 - 5 - 6 - fill - - - - - - - True - True - True - False - Pick a color - True - - - 1 - 2 - 8 - 9 - fill - - - - - - - True - True - 1 - 0 - False - GTK_UPDATE_ALWAYS - False - False - 0 0 100 1 10 10 - - - 1 - 3 - 5 - 6 - fill - - - - - - - True - True - _Bold - True - GTK_RELIEF_NORMAL - True - False - False - True - - - 1 - 3 - 11 - 12 - fill - - - - - - - True - True - _Italic - True - GTK_RELIEF_NORMAL - True - False - False - True - - - 1 - 3 - 12 - 13 - fill - - - - - - - True - True - _Underline - True - GTK_RELIEF_NORMAL - True - False - False - True - - - 1 - 3 - 13 - 14 - fill - - - - True @@ -19995,7 +19862,7 @@ Very High 0 0 0 - 0 + 3 0 @@ -20007,103 +19874,6 @@ Very High - - - True - <b>Size</b> - False - True - GTK_JUSTIFY_CENTER - False - False - 0 - 0.5 - 0 - 0 - - - 0 - 4 - 4 - 5 - fill - - - - - - - True - <b>Color</b> - False - True - GTK_JUSTIFY_CENTER - False - False - 0 - 0.5 - 0 - 0 - - - 0 - 4 - 7 - 8 - fill - - - - - - - True - <b>Options</b> - False - True - GTK_JUSTIFY_CENTER - False - False - 0 - 0 - 0 - 0 - - - 0 - 4 - 10 - 11 - fill - fill - - - - - - True - True - - False - False - GTK_JUSTIFY_LEFT - False - True - 0 - 0.5 - 0 - 0 - - - 2 - 3 - 8 - 9 - fill - - - - True @@ -20148,6 +19918,234 @@ Very High + + + + True + <b>Size</b> + False + True + GTK_JUSTIFY_CENTER + False + False + 0 + 0.5 + 0 + 3 + + + 0 + 4 + 3 + 4 + fill + + + + + + + True + True + 1 + 0 + True + GTK_UPDATE_ALWAYS + False + False + 0 0 100 1 10 10 + + + 1 + 3 + 4 + 5 + fill + + + + + + + True + pt + False + False + GTK_JUSTIFY_CENTER + False + False + 0 + 0.5 + 0 + 0 + + + 3 + 4 + 4 + 5 + fill + + + + + + + True + <b>Color</b> + False + True + GTK_JUSTIFY_CENTER + False + False + 0 + 0.5 + 0 + 3 + + + 0 + 4 + 5 + 6 + fill + + + + + + + True + True + True + False + Pick a color + True + + + 1 + 2 + 6 + 7 + fill + + + + + + + True + <b>Options</b> + False + True + GTK_JUSTIFY_CENTER + False + False + 0 + 0 + 0 + 3 + + + 0 + 4 + 7 + 8 + fill + fill + + + + + + True + True + _Bold + True + GTK_RELIEF_NORMAL + True + False + False + True + + + 1 + 4 + 8 + 9 + fill + + + + + + + True + True + _Italic + True + GTK_RELIEF_NORMAL + True + False + False + True + + + 1 + 4 + 9 + 10 + fill + + + + + + + True + True + _Underline + True + GTK_RELIEF_NORMAL + True + False + False + True + + + 1 + 4 + 10 + 11 + fill + + + + + + + True + True + + False + False + GTK_JUSTIFY_LEFT + False + True + 0 + 0.5 + 0 + 0 + + + 2 + 3 + 6 + 7 + fill + + + False @@ -20178,250 +20176,12 @@ Very High 12 True - 15 - 6 + 14 + 5 False 6 12 - - - True - True - True - False - Pick a color - True - - - 1 - 2 - 4 - 5 - fill - - - - - - - True - R_ight: - True - False - GTK_JUSTIFY_CENTER - False - False - 0 - 0.5 - 0 - 0 - rmargin - - - - - - 1 - 2 - 7 - 8 - fill - - - - - - - True - L_eft: - True - False - GTK_JUSTIFY_CENTER - False - False - 0 - 0.5 - 0 - 0 - lmargin - - - - - - 1 - 2 - 8 - 9 - fill - - - - - - - True - _Padding: - True - False - GTK_JUSTIFY_CENTER - False - False - 0 - 0.5 - 0 - 0 - pad - - - - - - 1 - 2 - 9 - 10 - fill - - - - - - - True - cm - False - False - GTK_JUSTIFY_CENTER - False - False - 0 - 0.5 - 0 - 0 - - - 4 - 5 - 7 - 8 - fill - - - - - - - True - cm - False - False - GTK_JUSTIFY_CENTER - False - False - 0 - 0.5 - 0 - 0 - - - 4 - 5 - 8 - 9 - fill - - - - - - - True - cm - False - False - GTK_JUSTIFY_CENTER - False - False - 0 - 0.5 - 0 - 0 - - - 4 - 5 - 9 - 10 - fill - - - - - - - True - True - True - True - 0 - - True - * - False - - - 2 - 4 - 7 - 8 - - - - - - - True - True - True - True - 0 - - True - * - False - - - 2 - 4 - 8 - 9 - - - - - - - True - True - True - True - 0 - - True - * - False - - - 2 - 4 - 9 - 10 - - - - True @@ -20513,79 +20273,6 @@ Very High - - - True - <b>Background</b> - False - True - GTK_JUSTIFY_CENTER - False - False - 0 - 0.5 - 0 - 0 - - - 0 - 6 - 3 - 4 - fill - - - - - - - True - <b>Margins</b> - False - True - GTK_JUSTIFY_LEFT - False - False - 0 - 0.5 - 0 - 0 - - - 0 - 6 - 6 - 7 - fill - - - - - - - True - True - - False - False - GTK_JUSTIFY_LEFT - False - True - 0 - 0.5 - 0 - 0 - - - 2 - 3 - 4 - 5 - fill - - - - True @@ -20598,11 +20285,11 @@ Very High 0 0 0 - 0 + 3 0 - 6 + 5 0 1 fill @@ -20610,6 +20297,318 @@ Very High + + + True + <b>Background color</b> + False + True + GTK_JUSTIFY_CENTER + False + False + 0 + 0.5 + 0 + 3 + + + 0 + 5 + 2 + 3 + fill + + + + + + + True + True + True + False + Pick a color + True + + + 1 + 2 + 3 + 4 + fill + + + + + + + True + First li_ne: + True + False + GTK_JUSTIFY_CENTER + False + False + 0 + 0.5 + 0 + 0 + indent + + + 1 + 2 + 7 + 8 + fill + + + + + + + True + cm + False + False + GTK_JUSTIFY_CENTER + False + False + 0 + 0.5 + 0 + 0 + + + 4 + 5 + 5 + 6 + fill + + + + + + + True + cm + False + False + GTK_JUSTIFY_CENTER + False + False + 0 + 0.5 + 0 + 0 + + + 4 + 5 + 6 + 7 + fill + + + + + + + True + cm + False + False + GTK_JUSTIFY_CENTER + False + False + 0 + 0.5 + 0 + 0 + + + 4 + 5 + 7 + 8 + fill + + + + + + + True + R_ight: + True + False + GTK_JUSTIFY_CENTER + False + False + 0 + 0.5 + 0 + 0 + rmargin + + + 1 + 2 + 6 + 7 + fill + + + + + + + True + L_eft: + True + False + GTK_JUSTIFY_CENTER + False + False + 0 + 0.5 + 0 + 0 + lmargin + + + 1 + 2 + 5 + 6 + fill + + + + + + + True + <b>Spacing</b> + False + True + GTK_JUSTIFY_CENTER + False + False + 0 + 0 + 0 + 3 + + + 0 + 5 + 8 + 9 + fill + + + + + + + True + Abo_ve: + True + False + GTK_JUSTIFY_CENTER + False + False + 0 + 0.5 + 0 + 0 + tmargin + + + 1 + 2 + 9 + 10 + fill + + + + + + + True + Belo_w: + True + False + GTK_JUSTIFY_CENTER + False + False + 0 + 0.5 + 0 + 0 + bmargin + + + 1 + 2 + 10 + 11 + fill + + + + + + + True + cm + False + False + GTK_JUSTIFY_CENTER + False + False + 0 + 0.5 + 0 + 0 + + + 4 + 5 + 9 + 10 + fill + + + + + + + True + cm + False + False + GTK_JUSTIFY_CENTER + False + False + 0 + 0.5 + 0 + 0 + + + 4 + 5 + 10 + 11 + fill + + + + True @@ -20622,18 +20621,123 @@ Very High 0 0 0 - 0 + 3 0 - 6 - 13 - 14 + 5 + 11 + 12 fill + + + True + True + 1 + 2 + True + GTK_UPDATE_ALWAYS + False + False + 0 -100 100 0.1 1 10 + + + 2 + 4 + 6 + 7 + + + + + + + True + True + 1 + 2 + True + GTK_UPDATE_ALWAYS + False + False + 2 -100 100 0.1 1 10 + + + 2 + 4 + 7 + 8 + + + + + + + True + True + 1 + 2 + True + GTK_UPDATE_ALWAYS + False + False + 0 -100 100 0.1 1 10 + + + 2 + 4 + 5 + 6 + + + + + + + True + True + 1 + 2 + True + GTK_UPDATE_ALWAYS + False + False + 0 -100 100 0.1 1 10 + + + 2 + 4 + 9 + 10 + + + + + + + True + True + 1 + 2 + True + GTK_UPDATE_ALWAYS + False + False + 0 -100 100 0.1 1 10 + + + 2 + 4 + 10 + 11 + + + + True @@ -20649,8 +20753,8 @@ Very High 1 2 - 14 - 15 + 13 + 14 fill @@ -20671,8 +20775,8 @@ Very High 2 3 - 14 - 15 + 13 + 14 fill @@ -20693,70 +20797,49 @@ Very High 3 4 - 14 - 15 + 13 + 14 fill - + True - True - _Bottom + _Padding: True - GTK_RELIEF_NORMAL - True - False - False - True - - - 4 - 5 - 14 - 15 - fill - - - - - - - True - <b>First line</b> - False - True + False GTK_JUSTIFY_CENTER False False 0 - 0 + 0.5 0 0 + pad - 0 - 6 - 11 - 12 + 1 + 2 + 12 + 13 fill - + True True - True - True - 0 - - True - * - False + 1 + 2 + True + GTK_UPDATE_ALWAYS + False + False + 0.2 0 100 0.1 1 10 2 @@ -20792,25 +20875,71 @@ Very High - + True - I_ndent: + True + _Bottom True + GTK_RELIEF_NORMAL + True + False + False + True + + + 4 + 5 + 13 + 14 + fill + + + + + + + True + True + + False False - GTK_JUSTIFY_CENTER + GTK_JUSTIFY_LEFT + False + True + 0 + 0.5 + 0 + 0 + + + 2 + 3 + 3 + 4 + fill + + + + + + + True + <b>Indentation</b> + False + True + GTK_JUSTIFY_LEFT False False 0 0.5 0 0 - pad - 1 - 2 - 12 - 13 + 0 + 5 + 4 + 5 fill