-
Notifications
You must be signed in to change notification settings - Fork 0
/
fielditem.py
61 lines (30 loc) · 1.19 KB
/
fielditem.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
from debug import *
from vector import *
from matrix import TransformMatrix
class FieldItem:
def __init__( self ):
# Position of Element on Field
self.position = TransformMatrix()
self.position.setTranspose( 0,0, 1 ) # Default Position
self.transform = None
def refreshTransform( self ):
pass
class TextItem( FieldItem ):
def __init__( self, text ):
FieldItem.__init__( self )
self.refreshTransform()
self.text = text
self.fontsize = 14
def copy( self ):
copy = TextItem( self.text )
copy.position = self.position.copy()
copy.refreshTransform()
return copy
def refreshTransform( self ):
self.transform = self.position
def pick( self, font, matrix, pos ):
vector = matrix * Vector((0,0,1,1))
x,y,s,_ = vector
sx,sy = font.size( self.text )
return x < pos.x < x+sx and \
y < pos.y < y+sy