1 |
# Copyright (c) 2001, 2002 by Intevation GmbH |
2 |
# Authors: |
3 |
# Bernhard Herzog <[email protected]> |
4 |
# |
5 |
# This program is free software under the GPL (>=v2) |
6 |
# Read the file COPYING coming with Thuban for details. |
7 |
|
8 |
__version__ = "$Revision$" |
9 |
|
10 |
from messages import CHANGED |
11 |
|
12 |
from base import TitledObject, Modifiable |
13 |
|
14 |
ALIGN_CENTER = "center" |
15 |
ALIGN_TOP = "top" |
16 |
ALIGN_BOTTOM = "bottom" |
17 |
ALIGN_LEFT = "left" |
18 |
ALIGN_RIGHT = "right" |
19 |
ALIGN_BASELINE = "baseline" |
20 |
|
21 |
class Label: |
22 |
|
23 |
def __init__(self, x, y, text, halign, valign): |
24 |
self.x = x |
25 |
self.y = y |
26 |
self.text = text |
27 |
self.halign = halign |
28 |
self.valign = valign |
29 |
|
30 |
|
31 |
class LabelLayer(TitledObject, Modifiable): |
32 |
|
33 |
def __init__(self, title): |
34 |
TitledObject.__init__(self, title) |
35 |
Modifiable.__init__(self) |
36 |
self.labels = [] |
37 |
|
38 |
def Labels(self): |
39 |
return self.labels |
40 |
|
41 |
def AddLabel(self, x, y, text, halign = "left", valign="center"): |
42 |
self.labels.append(Label(x, y, text, halign, valign)) |
43 |
self.changed(CHANGED) |
44 |
|
45 |
def RemoveLabel(self, index): |
46 |
del self.labels[index] |
47 |
self.changed(CHANGED) |
48 |
|
49 |
def ClearLabels(self): |
50 |
"""Remove all labels""" |
51 |
del self.labels[:] |
52 |
self.changed(CHANGED) |