-
Notifications
You must be signed in to change notification settings - Fork 2
/
Layout.py
executable file
·139 lines (137 loc) · 4.77 KB
/
Layout.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
# verwaltet Farbe, Schriftgroesse, Style, usw. der Sequenz, der Nummerierung und der Features
# bis jetzt nur ansatzweise
import wx
import wx.richtext as rt
import random
from Observable import Observable
class Layout(Observable):
"""contains layout data"""
seqSize=0
numSize=0
seqColor=wx.Color(0,0,0) #black
numColor=wx.Color(0,0,0) #black
colorList=[]
#Listen-Iterator, der ueber die Farbliste iteriert
colListIter=iter(colorList)
typeColDict={}
leftIndent=0
lineSpacing=0
seqStyle=wx.NORMAL
seqWeight=wx.BOLD
upperCase = True
charsPerLine=0
# constructor
def __init__(self, initial_seqSize=10, initial_numSize=8, initial_seqColor=wx.Color(0,0,0), initial_numColor=wx.Color(0,0,0), initial_leftIndent=50, initial_lineSpacing=20, initial_charsPerLine=50):
self.seqSize=initial_seqSize
self.numSize=initial_numSize
self.seqColor=initial_seqColor
self.numColor=initial_numColor
self.colorList=initial_colorList=[wx.Color(139 ,0, 0), wx.Color(0, 0, 255), wx.Color(84, 139, 84),wx.Color(0, 0, 139)]
self.colListIter=iter(self.colorList)
self.typeColDict={}
self.leftIndent=initial_leftIndent
self.lineSpacing=initial_lineSpacing
self.seqStyle=wx.NORMAL
self.seqWeight=wx.BOLD
self.upperCase = True
self.charsPerLine=initial_charsPerLine
def setSeqSize(self,n):
self.seqSize=n
self.setChanged()
def getSeqSize(self):
return self.seqSize
def setNumSize(self,n):
self.numSize=n
self.setChanged()
def getNumSize(self):
return self.numSize
def setSeqColor(self, color):
self.seqColor=color
self.setChanged()
def getSeqColor(self):
return self.seqColor
def setNumColor(self, color):
self.numColor=color
self.setChanged()
def getNumColor(self):
return self.numColor
def getFeatureListColor(self, i):
return self.colorList[i]
def getLeftIndent(self):
return self.leftIndent
def setLeftIndent(self, int):
self.leftIndent=int
self.setChanged()
def getLineSpacing(self):
return self.lineSpacing
def setLineSpacing(self, int):
self.lineSpacing=int
self.setChanged()
def getSeqStyle(self):
return self.seqStyle
def setSeqStyle(self, style):
self.seqStyle=style
self.setChanged()
def getSeqWeight(self):
return self.seqWeight
def setSeqWeight(self, weight):
self.seqWeight=weight
self.setChanged()
def getUpperCase(self):
return self.upperCase
def setUpperCase(self, bool):
self.upperCase=bool
self.setChanged()
def getSeqFont(self):
#return wx.Font(self.seqSize, wx.MODERN, wx.NORMAL, self.seqWeight)
return wx.Font(self.seqSize, wx.MODERN, self.seqStyle, self.seqWeight)
def setSeqFont(self, size, style, weight):
self.seqSize=size
self.seqStyle=style
self.seqWeight=weight
self.setChanged()
def getNumFont(self):
return wx.Font(self.numSize, wx.MODERN, wx.NORMAL, wx.BOLD)
def getCharWidth(self):
print "IsFixedWidth: ", self.getSeqFont().IsFixedWidth()
print "IsUsingSizeInPixels: ", self.getSeqFont().IsUsingSizeInPixels()
print "GetPixelSize: ", self.getSeqFont().GetPixelSize()
def setNumFont(self, size):
self.numSize=size
self.setChanged()
def getSeqTextAttrEx(self):
rta = rt.RichTextAttr()
rta.SetFont(self.getSeqFont())
rta.SetTextColour(self.seqColor)
# leftindent und linespacing wird nicht angezeigt
rta.SetLeftIndent(self.leftIndent)
return rta
def getNumTextAttrEx(self):
rta = rt.RichTextAttr()
rta.SetFont(self.getNumFont())
rta.SetTextColour(self.numColor)
rta.SetLineSpacing(self.lineSpacing)
return rta
# weist einem Typ eine Farbe zu, falls dieser noch nicht im Dictionary vorhanden
def addTypeColDict(self, type):
if not self.typeColDict.has_key(type):
try:
self.typeColDict[type]=self.colListIter.next()
#print self.typeColDict
except StopIteration:
r=random.randint(0, 255)
g=random.randint(0, 255)
b=random.randint(0, 255)
#print r, g, b
newcolor=wx.Color(r,g,b)
self.typeColDict[type]=newcolor
#print self.typeColDict
def getTypeColDict(self, key):
return self.typeColDict.get(key)
def getTypeDict(self):
return self.typeColDict
def getCharsPerLine(self):
return self.charsPerLine
def setCharsPerLine(self, n):
self.charsPerLine=n
self.setChanged()