* src/BaseDoc.py: Support space above/below paragraph.

* src/StyleEditor.py: Support space above/below paragraph.
* src/gramps.glade: Support space above/below paragraph.


svn: r5384
This commit is contained in:
Alex Roitman 2005-11-09 21:55:29 +00:00
parent aaaed40342
commit 3a107558ee
4 changed files with 816 additions and 633 deletions

View File

@ -4,6 +4,9 @@
2005-11-09 Alex Roitman <shura@gramps-project.org> 2005-11-09 Alex Roitman <shura@gramps-project.org>
* src/docgen/LPRDoc.py: Use paragraph padding correctly. * 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 <Martin.Hawlisch@gmx.de> 2005-11-09 Martin Hawlisch <Martin.Hawlisch@gmx.de>
* src/DbPrompter.py (DbPrompter): Use Combo to list multiple rcecent files * src/DbPrompter.py (DbPrompter): Use Combo to list multiple rcecent files

View File

@ -499,8 +499,8 @@ class ParagraphStyle:
""" """
Defines the characteristics of a paragraph. The characteristics are: Defines the characteristics of a paragraph. The characteristics are:
font (a FontStyle instance), right margin, left margin, first indent, font (a FontStyle instance), right margin, left margin, first indent,
alignment, level, top border, bottom border, right border, left top margin, bottom margin, alignment, level, top border, bottom border,
border, padding, and background color. right border, left border, padding, and background color.
""" """
def __init__(self,source=None): def __init__(self,source=None):
@ -513,6 +513,8 @@ class ParagraphStyle:
self.rmargin = source.rmargin self.rmargin = source.rmargin
self.lmargin = source.lmargin self.lmargin = source.lmargin
self.first_indent = source.first_indent self.first_indent = source.first_indent
self.tmargin = source.tmargin
self.bmargin = source.bmargin
self.align = source.align self.align = source.align
self.level = source.level self.level = source.level
self.top_border = source.top_border self.top_border = source.top_border
@ -526,6 +528,8 @@ class ParagraphStyle:
self.font = FontStyle() self.font = FontStyle()
self.rmargin = 0 self.rmargin = 0
self.lmargin = 0 self.lmargin = 0
self.tmargin = 0
self.bmargin = 0
self.first_indent = 0 self.first_indent = 0
self.align = PARA_ALIGN_LEFT self.align = PARA_ALIGN_LEFT
self.level = 0 self.level = 0
@ -543,17 +547,19 @@ class ParagraphStyle:
def get_description(self): def get_description(self):
return self.description 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, tborder=None,bborder=None,rborder=None,lborder=None,pad=None,
bgcolor=None,font=None): bgcolor=None,font=None):
""" """
Allows the values of the object to be set. Allows the values of the object to be set.
@param rmargin: right margin in centimeters @param rmargin: right indent in centimeters
@param lmargin: left margin in centimeters @param lmargin: left indent in centimeters
@param first_indent: first line indent in centimeters @param first_indent: first line indent in centimeters
align - alignment type (PARA_ALIGN_LEFT, PARA_ALIGN_RIGHT, @param tmargin: space above paragraph in centimeters
PARA_ALIGN_CENTER, or PARA_ALIGN_JUSTIFY) @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 tborder: non zero indicates that a top border should be used
@param bborder: non zero indicates that a bottom 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 @param rborder: non zero indicates that a right border should be used
@ -584,6 +590,10 @@ class ParagraphStyle:
self.set_left_margin(lmargin) self.set_left_margin(lmargin)
if first_indent != None: if first_indent != None:
self.set_first_indent(first_indent) 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): def set_header_level(self,level):
""" """
@ -719,29 +729,45 @@ class ParagraphStyle:
return "unknown" return "unknown"
def set_left_margin(self,value): def set_left_margin(self,value):
"sets the left paragraph margin in centimeters" "sets the left indent in centimeters"
self.lmargin = value self.lmargin = value
def set_right_margin(self,value): def set_right_margin(self,value):
"sets the right paragraph margin in centimeters" "sets the right indent in centimeters"
self.rmargin = value self.rmargin = value
def set_first_indent(self,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 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): def get_left_margin(self):
"returns the left margin in centimeters" "returns the left indent in centimeters"
return self.lmargin return self.lmargin
def get_right_margin(self): def get_right_margin(self):
"returns the right margin in centimeters" "returns the right indent in centimeters"
return self.rmargin return self.rmargin
def get_first_indent(self): def get_first_indent(self):
"returns the first indent margin in centimeters" "returns the first line indent in centimeters"
return self.first_indent 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 # StyleSheetList
@ -832,10 +858,14 @@ class StyleSheetList:
rm = float(p.get_right_margin()) rm = float(p.get_right_margin())
lm = float(p.get_left_margin()) lm = float(p.get_left_margin())
fi = float(p.get_first_indent()) fi = float(p.get_first_indent())
tm = float(p.get_top_margin())
bm = float(p.get_bottom_margin())
pa = float(p.get_padding()) pa = float(p.get_padding())
f.write('rmargin="%s" ' % Utils.gformat(rm)) f.write('rmargin="%s" ' % Utils.gformat(rm))
f.write('lmargin="%s" ' % Utils.gformat(lm)) f.write('lmargin="%s" ' % Utils.gformat(lm))
f.write('first="%s" ' % Utils.gformat(fi)) 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('pad="%s" ' % Utils.gformat(pa))
f.write('bgcolor="#%02x%02x%02x" ' % p.get_background_color()) f.write('bgcolor="#%02x%02x%02x" ' % p.get_background_color())
f.write('level="%d" ' % p.get_header_level()) 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_right_margin(Utils.gfloat(attrs['rmargin']))
self.p.set_left_margin(Utils.gfloat(attrs['lmargin'])) self.p.set_left_margin(Utils.gfloat(attrs['lmargin']))
self.p.set_first_indent(Utils.gfloat(attrs['first'])) 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_padding(Utils.gfloat(attrs['pad']))
self.p.set_alignment(int(attrs['align'])) self.p.set_alignment(int(attrs['align']))
self.p.set_right_border(int(attrs['rborder'])) self.p.set_right_border(int(attrs['rborder']))

View File

@ -27,6 +27,13 @@ Paragraph/Font style editor
__author__ = "Donald N. Allingham" __author__ = "Donald N. Allingham"
__version__ = "$Revision$" __version__ = "$Revision$"
#------------------------------------------------------------------------
#
# Python modules
#
#------------------------------------------------------------------------
from gettext import gettext as _
#------------------------------------------------------------------------ #------------------------------------------------------------------------
# #
# GNOME/GTK modules # GNOME/GTK modules
@ -43,9 +50,12 @@ import Utils
import const import const
import BaseDoc import BaseDoc
import ListModel import ListModel
import locale
from gettext import gettext as _
#------------------------------------------------------------------------
#
# StyleList class
#
#------------------------------------------------------------------------
class StyleListDisplay: class StyleListDisplay:
""" """
Shows the available paragraph/font styles. Allows the user to select, Shows the available paragraph/font styles. Allows the user to select,
@ -129,8 +139,8 @@ class StyleListDisplay:
def on_edit_clicked(self,obj): def on_edit_clicked(self,obj):
""" """
Called with the EDIT button is clicked. Calls the StyleEditor to edit the Called with the EDIT button is clicked.
selected style. Calls the StyleEditor to edit the selected style.
""" """
store,node = self.list.selection.get_selected() store,node = self.list.selection.get_selected()
if not node: if not node:
@ -149,10 +159,15 @@ class StyleListDisplay:
self.sheetlist.delete_style_sheet(name) self.sheetlist.delete_style_sheet(name)
self.redraw() self.redraw()
#------------------------------------------------------------------------
#
# StyleEditor class
#
#------------------------------------------------------------------------
class StyleEditor: class StyleEditor:
""" """
Edits the current style definition. Presents a dialog allowing the values of Edits the current style definition. Presents a dialog allowing the values
the paragraphs in the style to be altered. of the paragraphs in the style to be altered.
""" """
def __init__(self,name,style,parent): def __init__(self,name,style,parent):
@ -227,10 +242,12 @@ class StyleEditor:
self.top.get_widget("calign").set_active(1) self.top.get_widget("calign").set_active(1)
else: else:
self.top.get_widget("jalign").set_active(1) 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("rmargin").set_value(p.get_right_margin())
self.top.get_widget("lmargin").set_text(locale.str(p.get_left_margin())) self.top.get_widget("lmargin").set_value(p.get_left_margin())
self.top.get_widget("pad").set_text(locale.str(p.get_padding())) self.top.get_widget("pad").set_value(p.get_padding())
self.top.get_widget("indent").set_text(locale.str(p.get_first_indent())) 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("tborder").set_active(p.get_top_border())
self.top.get_widget("lborder").set_active(p.get_left_border()) self.top.get_widget("lborder").set_active(p.get_left_border())
self.top.get_widget("rborder").set_active(p.get_right_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""" """Saves the current paragraph displayed on the dialog"""
font = p.get_font() 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(): if self.top.get_widget("roman").get_active():
font.set_type_face(BaseDoc.FONT_SERIF) font.set_type_face(BaseDoc.FONT_SERIF)
@ -274,10 +291,12 @@ class StyleEditor:
else: else:
p.set_alignment(BaseDoc.PARA_ALIGN_JUSTIFY) p.set_alignment(BaseDoc.PARA_ALIGN_JUSTIFY)
p.set_right_margin(Utils.gfloat(self.top.get_widget("rmargin").get_text())) p.set_right_margin(self.top.get_widget("rmargin").get_value())
p.set_left_margin(Utils.gfloat(self.top.get_widget("lmargin").get_text())) p.set_left_margin(self.top.get_widget("lmargin").get_value())
p.set_padding(Utils.gfloat(self.top.get_widget("pad").get_text())) p.set_top_margin(self.top.get_widget("tmargin").get_value())
p.set_first_indent(Utils.gfloat(self.top.get_widget("indent").get_text())) 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_top_border(self.top.get_widget("tborder").get_active())
p.set_left_border(self.top.get_widget("lborder").get_active()) p.set_left_border(self.top.get_widget("lborder").get_active())
p.set_right_border(self.top.get_widget("rborder").get_active()) p.set_right_border(self.top.get_widget("rborder").get_active())

File diff suppressed because it is too large Load Diff