Mercurial > fife-parpg
annotate engine/extensions/pychan/widgets/textfield.py @ 354:dfd48d49c044
* Removed shebang and svn:executable for python files which are not meant to be executed directly
* Made sure all executable files with shebang has svn:executable
author | cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222 |
---|---|
date | Mon, 21 Sep 2009 19:48:00 +0000 |
parents | 48c99636453e |
children |
rev | line source |
---|---|
248
a2d5e2721489
widgets.py split up.
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
1 # -*- coding: utf-8 -*- |
a2d5e2721489
widgets.py split up.
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
2 |
331
48c99636453e
Added Licence header to all pypthon modules in extension/
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
255
diff
changeset
|
3 # #################################################################### |
48c99636453e
Added Licence header to all pypthon modules in extension/
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
255
diff
changeset
|
4 # Copyright (C) 2005-2009 by the FIFE team |
48c99636453e
Added Licence header to all pypthon modules in extension/
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
255
diff
changeset
|
5 # http://www.fifengine.de |
48c99636453e
Added Licence header to all pypthon modules in extension/
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
255
diff
changeset
|
6 # This file is part of FIFE. |
48c99636453e
Added Licence header to all pypthon modules in extension/
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
255
diff
changeset
|
7 # |
48c99636453e
Added Licence header to all pypthon modules in extension/
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
255
diff
changeset
|
8 # FIFE is free software; you can redistribute it and/or |
48c99636453e
Added Licence header to all pypthon modules in extension/
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
255
diff
changeset
|
9 # modify it under the terms of the GNU Lesser General Public |
48c99636453e
Added Licence header to all pypthon modules in extension/
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
255
diff
changeset
|
10 # License as published by the Free Software Foundation; either |
48c99636453e
Added Licence header to all pypthon modules in extension/
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
255
diff
changeset
|
11 # version 2.1 of the License, or (at your option) any later version. |
48c99636453e
Added Licence header to all pypthon modules in extension/
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
255
diff
changeset
|
12 # |
48c99636453e
Added Licence header to all pypthon modules in extension/
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
255
diff
changeset
|
13 # This library is distributed in the hope that it will be useful, |
48c99636453e
Added Licence header to all pypthon modules in extension/
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
255
diff
changeset
|
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of |
48c99636453e
Added Licence header to all pypthon modules in extension/
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
255
diff
changeset
|
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
48c99636453e
Added Licence header to all pypthon modules in extension/
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
255
diff
changeset
|
16 # Lesser General Public License for more details. |
48c99636453e
Added Licence header to all pypthon modules in extension/
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
255
diff
changeset
|
17 # |
48c99636453e
Added Licence header to all pypthon modules in extension/
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
255
diff
changeset
|
18 # You should have received a copy of the GNU Lesser General Public |
48c99636453e
Added Licence header to all pypthon modules in extension/
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
255
diff
changeset
|
19 # License along with this library; if not, write to the |
48c99636453e
Added Licence header to all pypthon modules in extension/
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
255
diff
changeset
|
20 # Free Software Foundation, Inc., |
48c99636453e
Added Licence header to all pypthon modules in extension/
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
255
diff
changeset
|
21 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
48c99636453e
Added Licence header to all pypthon modules in extension/
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
255
diff
changeset
|
22 # #################################################################### |
48c99636453e
Added Licence header to all pypthon modules in extension/
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
255
diff
changeset
|
23 |
248
a2d5e2721489
widgets.py split up.
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
24 from common import * |
a2d5e2721489
widgets.py split up.
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
25 from widget import Widget |
a2d5e2721489
widgets.py split up.
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
26 |
a2d5e2721489
widgets.py split up.
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
27 class TextField(Widget): |
a2d5e2721489
widgets.py split up.
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
28 """ |
a2d5e2721489
widgets.py split up.
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
29 An editable B{single line} text edit widget. |
a2d5e2721489
widgets.py split up.
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
30 |
a2d5e2721489
widgets.py split up.
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
31 New Attributes |
a2d5e2721489
widgets.py split up.
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
32 ============== |
a2d5e2721489
widgets.py split up.
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
33 |
a2d5e2721489
widgets.py split up.
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
34 - text: The text in the TextBox. |
a2d5e2721489
widgets.py split up.
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
35 |
a2d5e2721489
widgets.py split up.
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
36 Data |
a2d5e2721489
widgets.py split up.
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
37 ==== |
a2d5e2721489
widgets.py split up.
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
38 The text can be read and set via L{distributeData} and L{collectData}. |
a2d5e2721489
widgets.py split up.
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
39 """ |
a2d5e2721489
widgets.py split up.
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
40 |
a2d5e2721489
widgets.py split up.
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
41 ATTRIBUTES = Widget.ATTRIBUTES + [UnicodeAttr('text')] |
255
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
248
diff
changeset
|
42 DEFAULT_HEXPAND = 1 |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
248
diff
changeset
|
43 DEFAULT_VEXPAND = 0 |
248
a2d5e2721489
widgets.py split up.
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
44 |
255
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
248
diff
changeset
|
45 def __init__(self,text=u"",**kwargs): |
248
a2d5e2721489
widgets.py split up.
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
46 self.real_widget = fife.TextField() |
a2d5e2721489
widgets.py split up.
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
47 self.text = text |
a2d5e2721489
widgets.py split up.
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
48 super(TextField,self).__init__(**kwargs) |
a2d5e2721489
widgets.py split up.
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
49 |
a2d5e2721489
widgets.py split up.
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
50 # Prepare Data collection framework |
a2d5e2721489
widgets.py split up.
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
51 self.accepts_data = True |
a2d5e2721489
widgets.py split up.
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
52 self.accepts_inital_data = True |
a2d5e2721489
widgets.py split up.
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
53 self._realSetInitialData = self._setText |
a2d5e2721489
widgets.py split up.
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
54 self._realSetData = self._setText |
a2d5e2721489
widgets.py split up.
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
55 self._realGetData = self._getText |
a2d5e2721489
widgets.py split up.
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
56 |
a2d5e2721489
widgets.py split up.
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
57 def resizeToContent(self,recurse=True): |
a2d5e2721489
widgets.py split up.
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
58 max_w = self.real_font.getWidth(text2gui(self.text)) |
a2d5e2721489
widgets.py split up.
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
59 self.width = max_w |
a2d5e2721489
widgets.py split up.
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
60 self.height = (self.real_font.getHeight() + 2) |
a2d5e2721489
widgets.py split up.
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
61 def _getText(self): return gui2text(self.real_widget.getText()) |
a2d5e2721489
widgets.py split up.
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
62 def _setText(self,text): self.real_widget.setText(text2gui(text)) |
a2d5e2721489
widgets.py split up.
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
63 text = property(_getText,_setText) |
a2d5e2721489
widgets.py split up.
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
64 |
a2d5e2721489
widgets.py split up.
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
65 def _setOpaque(self,opaque): self.real_widget.setOpaque(opaque) |
a2d5e2721489
widgets.py split up.
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
66 def _getOpaque(self): return self.real_widget.isOpaque() |
a2d5e2721489
widgets.py split up.
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
67 opaque = property(_getOpaque,_setOpaque) |