Mercurial > fife-parpg
comparison engine/python/fife/extensions/pychan/widgets/label.py @ 378:64738befdf3b
bringing in the changes from the build_system_rework branch in preparation for the 0.3.0 release. This commit will require the Jan2010 devkit. Clients will also need to be modified to the new way to import fife.
author | vtchill@33b003aa-7bff-0310-803a-e67f0ece8222 |
---|---|
date | Mon, 11 Jan 2010 23:34:52 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
377:fe6fb0e0ed23 | 378:64738befdf3b |
---|---|
1 # -*- coding: utf-8 -*- | |
2 | |
3 # #################################################################### | |
4 # Copyright (C) 2005-2009 by the FIFE team | |
5 # http://www.fifengine.de | |
6 # This file is part of FIFE. | |
7 # | |
8 # FIFE is free software; you can redistribute it and/or | |
9 # modify it under the terms of the GNU Lesser General Public | |
10 # License as published by the Free Software Foundation; either | |
11 # version 2.1 of the License, or (at your option) any later version. | |
12 # | |
13 # This library is distributed in the hope that it will be useful, | |
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
16 # Lesser General Public License for more details. | |
17 # | |
18 # You should have received a copy of the GNU Lesser General Public | |
19 # License along with this library; if not, write to the | |
20 # Free Software Foundation, Inc., | |
21 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | |
22 # #################################################################### | |
23 | |
24 from common import * | |
25 from basictextwidget import BasicTextWidget | |
26 | |
27 class Label(BasicTextWidget): | |
28 """ | |
29 A basic label - displaying a string. | |
30 | |
31 Also allows text wrapping and onMouse hover callbacks. | |
32 | |
33 New Attributes | |
34 ============== | |
35 | |
36 - wrap_text: Boolean: Enable/Disable automatic text wrapping. Disabled by default. | |
37 Currently to actually see text wrapping you have to explicitly set a max_size with | |
38 the desired width of the text, as the layout engine is not capable of deriving | |
39 the maximum width from a parent container. | |
40 | |
41 """ | |
42 | |
43 ATTRIBUTES = BasicTextWidget.ATTRIBUTES + [BoolAttr('wrap_text')] | |
44 | |
45 def __init__(self,wrap_text=False,**kwargs): | |
46 self.real_widget = fife.Label("") | |
47 self.wrap_text = wrap_text | |
48 super(Label,self).__init__(**kwargs) | |
49 | |
50 def resizeToContent(self, recurse=True): | |
51 self.real_widget.setWidth( self.max_size[0] ) | |
52 self.real_widget.adjustSize() | |
53 self.height = self.real_widget.getHeight() + self.margins[1]*2 | |
54 self.width = self.real_widget.getWidth() + self.margins[0]*2 | |
55 #print self.width,self.max_size[0] | |
56 | |
57 def _setTextWrapping(self,wrapping): self.real_widget.setTextWrapping(wrapping) | |
58 def _getTextWrapping(self): self.real_widget.isTextWrapping() | |
59 wrap_text = property(_getTextWrapping,_setTextWrapping) | |
60 | |
61 class ClickLabel(Label): | |
62 """ | |
63 Deprecated - use L{Label} instead. | |
64 """ | |
65 __init__ = tools.this_is_deprecated(Label.__init__,message = "ClickLabel - Use Label instead") |