2007-09-08 Don Allingham <don@gramps-project.org>

* src/ViewManager.py: code cleanup
	* src/FontScale.py: code cleanup
	* src/GrampsWidgets.py: code cleanup
	* src/ExportOptions.py: code cleanup
	* src/GrampsDisplay.py: code cleanup
	* src/DateEdit.py: code cleanup
	* src/DbLoader.py: code cleanup



svn: r8951
This commit is contained in:
Don Allingham
2007-09-09 05:24:15 +00:00
parent 651e29ead4
commit 6d9dbfee49
8 changed files with 593 additions and 501 deletions

View File

@@ -17,7 +17,12 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
_swiss = [
"""
Provides a rough estimate of the width of a text string.
"""
SWISS = [
0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000,
0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000,
0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000,
@@ -45,7 +50,7 @@ _swiss = [
0.556, 0.556, 0.556, 0.556, 0.556, 0.556, 0.556, 0.584, 0.611, 0.556,
0.556, 0.556, 0.556, 0.500, 0.556, 0.500]
_swiss_b = [
SWISS_B = [
0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000,
0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000,
0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000,
@@ -73,7 +78,7 @@ _swiss_b = [
0.611, 0.611, 0.611, 0.611, 0.611, 0.611, 0.611, 0.584, 0.611, 0.611,
0.611, 0.611, 0.611, 0.556, 0.611, 0.556]
_swiss_i = [
SWISS_I = [
0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000,
0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000,
0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000,
@@ -101,7 +106,7 @@ _swiss_i = [
0.556, 0.556, 0.556, 0.556, 0.556, 0.556, 0.556, 0.584, 0.611, 0.556,
0.556, 0.556, 0.556, 0.500, 0.556, 0.500]
_swiss_bi = [
SWISS_BI = [
0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000,
0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000,
0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000,
@@ -129,7 +134,7 @@ _swiss_bi = [
0.611, 0.611, 0.611, 0.611, 0.611, 0.611, 0.611, 0.584, 0.611, 0.611,
0.611, 0.611, 0.611, 0.556, 0.611, 0.556]
_roman = [
ROMAN = [
0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000,
0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000,
0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000,
@@ -157,7 +162,7 @@ _roman = [
0.500, 0.500, 0.500, 0.500, 0.500, 0.500, 0.500, 0.564, 0.500, 0.500,
0.500, 0.500, 0.500, 0.500, 0.500, 0.500]
_roman_b = [
ROMAN_B = [
0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000,
0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000,
0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000,
@@ -185,7 +190,7 @@ _roman_b = [
0.500, 0.556, 0.500, 0.500, 0.500, 0.500, 0.500, 0.570, 0.500, 0.556,
0.556, 0.556, 0.556, 0.500, 0.556, 0.500]
_roman_i = [
ROMAN_I = [
0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000,
0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000,
0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000,
@@ -213,7 +218,7 @@ _roman_i = [
0.500, 0.500, 0.500, 0.500, 0.500, 0.500, 0.500, 0.675, 0.500, 0.500,
0.500, 0.500, 0.500, 0.444, 0.500, 0.444]
_roman_bi = [
ROMAN_BI = [
0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000,
0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000,
0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000,
@@ -241,19 +246,22 @@ _roman_bi = [
0.500, 0.556, 0.500, 0.500, 0.500, 0.500, 0.500, 0.570, 0.500, 0.556,
0.556, 0.556, 0.556, 0.444, 0.500, 0.444]
_font_array = [ [_swiss, _swiss_b, _swiss_i, _swiss_bi ],
[_roman, _roman_b, _roman_i, _roman_bi ] ]
FONT_ARRAY = [ [SWISS, SWISS_B, SWISS_I, SWISS_BI ],
[ROMAN, ROMAN_B, ROMAN_I, ROMAN_BI ] ]
#-------------------------------------------------------------------------
#
#
# string_width
#
#-------------------------------------------------------------------------
def string_width(font,text):
def string_width(font, text):
"""
returns with width of a string in the specified font
"""
i = font.get_type_face()
j = font.get_bold() + font.get_italic()*2
s = font.get_size()
l = _font_array[i][j]
l = FONT_ARRAY[i][j]
r = 0
for c in text:
try:
@@ -270,7 +278,7 @@ def string_trim(font, text, width, ellipses = "..."):
i = font.get_type_face()
j = font.get_bold() + font.get_italic()*2
s = font.get_size()
l = _font_array[i][j]
l = FONT_ARRAY[i][j]
ellipses_length = 0
# get length of each letter
for c in ellipses: