Mercurial > fife-parpg
annotate engine/extensions/pychan/widgets/buttons.py @ 334:a9482d3d989e
PyChan fixes:
* DummyImage is gone for good.
* Renamed GuiImage.source annotation used in PyChan.
* Fixed a bug in an error path.
author | phoku@33b003aa-7bff-0310-803a-e67f0ece8222 |
---|---|
date | Mon, 24 Aug 2009 14:47:23 +0000 |
parents | 457e626296ba |
children | dfd48d49c044 |
rev | line source |
---|---|
331
48c99636453e
Added Licence header to all pypthon modules in extension/
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
255
diff
changeset
|
1 #!/usr/bin/env python |
248
a2d5e2721489
widgets.py split up.
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
2 # -*- coding: utf-8 -*- |
a2d5e2721489
widgets.py split up.
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
3 |
331
48c99636453e
Added Licence header to all pypthon modules in extension/
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
255
diff
changeset
|
4 # #################################################################### |
48c99636453e
Added Licence header to all pypthon modules in extension/
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
255
diff
changeset
|
5 # 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
|
6 # http://www.fifengine.de |
48c99636453e
Added Licence header to all pypthon modules in extension/
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
255
diff
changeset
|
7 # 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
|
8 # |
48c99636453e
Added Licence header to all pypthon modules in extension/
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
255
diff
changeset
|
9 # 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
|
10 # 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
|
11 # 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
|
12 # 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
|
13 # |
48c99636453e
Added Licence header to all pypthon modules in extension/
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
255
diff
changeset
|
14 # 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
|
15 # 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
|
16 # 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
|
17 # 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
|
18 # |
48c99636453e
Added Licence header to all pypthon modules in extension/
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
255
diff
changeset
|
19 # 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
|
20 # 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
|
21 # Free Software Foundation, Inc., |
48c99636453e
Added Licence header to all pypthon modules in extension/
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
255
diff
changeset
|
22 # 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
|
23 # #################################################################### |
48c99636453e
Added Licence header to all pypthon modules in extension/
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
255
diff
changeset
|
24 |
248
a2d5e2721489
widgets.py split up.
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
25 from common import * |
a2d5e2721489
widgets.py split up.
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
26 from basictextwidget import BasicTextWidget |
332
457e626296ba
Working on the XXX_image attributes to force consistent
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
331
diff
changeset
|
27 from pychan.properties import ImageProperty |
248
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 class Button(BasicTextWidget): |
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 A basic push button. |
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 def __init__(self,**kwargs): |
a2d5e2721489
widgets.py split up.
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
34 self.real_widget = fife.Button("") |
a2d5e2721489
widgets.py split up.
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
35 super(Button,self).__init__(**kwargs) |
a2d5e2721489
widgets.py split up.
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
36 |
a2d5e2721489
widgets.py split up.
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
37 class ImageButton(BasicTextWidget): |
a2d5e2721489
widgets.py split up.
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
38 """ |
a2d5e2721489
widgets.py split up.
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
39 A basic push button with three different images for the up, down and hover state. |
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 B{Work in progress.} |
a2d5e2721489
widgets.py split up.
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
42 |
a2d5e2721489
widgets.py split up.
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
43 New Attributes |
a2d5e2721489
widgets.py split up.
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
44 ============== |
a2d5e2721489
widgets.py split up.
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
45 |
a2d5e2721489
widgets.py split up.
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
46 - up_image: String: The source location of the Image for the B{unpressed} state. |
a2d5e2721489
widgets.py split up.
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
47 - down_image: String: The source location of the Image for the B{pressed} state. |
a2d5e2721489
widgets.py split up.
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
48 - hover_image: String: The source location of the Image for the B{unpressed hovered} state. |
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 |
a2d5e2721489
widgets.py split up.
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
51 ATTRIBUTES = BasicTextWidget.ATTRIBUTES + [Attr('up_image'),Attr('down_image'),PointAttr('offset'),Attr('hover_image')] |
a2d5e2721489
widgets.py split up.
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
52 |
a2d5e2721489
widgets.py split up.
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
53 def __init__(self,up_image="",down_image="",hover_image="",offset=(0,0),**kwargs): |
332
457e626296ba
Working on the XXX_image attributes to force consistent
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
331
diff
changeset
|
54 self.real_widget = kwargs.get("real_widget", fife.TwoButton()) |
248
a2d5e2721489
widgets.py split up.
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
55 super(ImageButton,self).__init__(**kwargs) |
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 self.up_image = up_image |
a2d5e2721489
widgets.py split up.
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
58 self.down_image = down_image |
a2d5e2721489
widgets.py split up.
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
59 self.hover_image = hover_image |
a2d5e2721489
widgets.py split up.
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
60 self.offset = offset |
a2d5e2721489
widgets.py split up.
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
61 |
332
457e626296ba
Working on the XXX_image attributes to force consistent
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
331
diff
changeset
|
62 up_image = ImageProperty("UpImage") |
457e626296ba
Working on the XXX_image attributes to force consistent
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
331
diff
changeset
|
63 down_image = ImageProperty("DownImage") |
457e626296ba
Working on the XXX_image attributes to force consistent
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
331
diff
changeset
|
64 hover_image = ImageProperty("HoverImage") |
248
a2d5e2721489
widgets.py split up.
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
65 |
a2d5e2721489
widgets.py split up.
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
66 def _setOffset(self, offset): |
a2d5e2721489
widgets.py split up.
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
67 self.real_widget.setDownOffset(offset[0], offset[1]) |
a2d5e2721489
widgets.py split up.
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
68 def _getOffset(self): |
a2d5e2721489
widgets.py split up.
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
69 return (self.real_widget.getDownXOffset(), self.real_widget.getDownYOffset()) |
a2d5e2721489
widgets.py split up.
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
70 offset = property(_getOffset,_setOffset) |
a2d5e2721489
widgets.py split up.
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
71 |
255
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
248
diff
changeset
|
72 def resizeToContent(self, recurse=True): |
332
457e626296ba
Working on the XXX_image attributes to force consistent
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
331
diff
changeset
|
73 th, tw = 0, 0 |
457e626296ba
Working on the XXX_image attributes to force consistent
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
331
diff
changeset
|
74 if self.text: |
457e626296ba
Working on the XXX_image attributes to force consistent
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
331
diff
changeset
|
75 th = self.real_font.getHeight()#+self.real_font.getSpacing() |
457e626296ba
Working on the XXX_image attributes to force consistent
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
331
diff
changeset
|
76 tw = self.real_font.getWidth(text2gui(self.text))#+self.real_font.getSpacing() |
457e626296ba
Working on the XXX_image attributes to force consistent
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
331
diff
changeset
|
77 self.height = max( |
457e626296ba
Working on the XXX_image attributes to force consistent
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
331
diff
changeset
|
78 self._prop_upimage["image"].getHeight(), |
457e626296ba
Working on the XXX_image attributes to force consistent
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
331
diff
changeset
|
79 self._prop_downimage["image"].getHeight(), |
457e626296ba
Working on the XXX_image attributes to force consistent
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
331
diff
changeset
|
80 self._prop_hoverimage["image"].getHeight(), |
457e626296ba
Working on the XXX_image attributes to force consistent
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
331
diff
changeset
|
81 th) + self.margins[1]*2 |
457e626296ba
Working on the XXX_image attributes to force consistent
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
331
diff
changeset
|
82 self.width = max( |
457e626296ba
Working on the XXX_image attributes to force consistent
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
331
diff
changeset
|
83 self._prop_upimage["image"].getWidth(), |
457e626296ba
Working on the XXX_image attributes to force consistent
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
331
diff
changeset
|
84 self._prop_downimage["image"].getWidth(), |
457e626296ba
Working on the XXX_image attributes to force consistent
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
331
diff
changeset
|
85 self._prop_hoverimage["image"].getWidth(), |
457e626296ba
Working on the XXX_image attributes to force consistent
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
331
diff
changeset
|
86 tw) + self.margins[0]*2 |
248
a2d5e2721489
widgets.py split up.
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
87 |
332
457e626296ba
Working on the XXX_image attributes to force consistent
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
331
diff
changeset
|
88 class ToggleButton(ImageButton): |
248
a2d5e2721489
widgets.py split up.
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
89 """ |
a2d5e2721489
widgets.py split up.
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
90 A basic push button that can be toggled. |
a2d5e2721489
widgets.py split up.
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
91 |
a2d5e2721489
widgets.py split up.
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
92 Unfortunately a bit of code duplication from ImageButton. |
a2d5e2721489
widgets.py split up.
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
93 |
a2d5e2721489
widgets.py split up.
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
94 New Attributes |
a2d5e2721489
widgets.py split up.
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
95 ============== |
a2d5e2721489
widgets.py split up.
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
96 |
a2d5e2721489
widgets.py split up.
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
97 - group: String: The group the button belongs to. Only one button in each group will be toggled at one time. |
a2d5e2721489
widgets.py split up.
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
98 - toggled: Boolean: Whether the button is toggled or not. |
a2d5e2721489
widgets.py split up.
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
99 """ |
a2d5e2721489
widgets.py split up.
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
100 |
a2d5e2721489
widgets.py split up.
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
101 ATTRIBUTES = BasicTextWidget.ATTRIBUTES + [ |
a2d5e2721489
widgets.py split up.
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
102 Attr('up_image'),Attr('down_image'),Attr('hover_image'), |
a2d5e2721489
widgets.py split up.
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
103 PointAttr('offset'),Attr('group') |
a2d5e2721489
widgets.py split up.
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
104 ] |
a2d5e2721489
widgets.py split up.
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
105 |
332
457e626296ba
Working on the XXX_image attributes to force consistent
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
331
diff
changeset
|
106 def __init__(self,group="",**kwargs): |
248
a2d5e2721489
widgets.py split up.
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
107 |
332
457e626296ba
Working on the XXX_image attributes to force consistent
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
331
diff
changeset
|
108 super(ToggleButton,self).__init__(real_widget = fife.ToggleButton(), **kwargs) |
248
a2d5e2721489
widgets.py split up.
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
109 self.group = group |
a2d5e2721489
widgets.py split up.
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
110 |
a2d5e2721489
widgets.py split up.
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
111 def _setGroup(self,group): |
a2d5e2721489
widgets.py split up.
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
112 self.real_widget.setGroup( group ) |
a2d5e2721489
widgets.py split up.
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
113 |
a2d5e2721489
widgets.py split up.
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
114 def _getGroup(self): |
a2d5e2721489
widgets.py split up.
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
115 return self.real_widget.getGroup() |
a2d5e2721489
widgets.py split up.
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
116 group = property(_getGroup,_setGroup) |
a2d5e2721489
widgets.py split up.
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
117 |
a2d5e2721489
widgets.py split up.
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
118 def _setToggled(self, toggled): |
a2d5e2721489
widgets.py split up.
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
119 self.real_widget.setToggled( toggled ) |
a2d5e2721489
widgets.py split up.
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
120 |
a2d5e2721489
widgets.py split up.
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
121 def _isToggled(self): |
a2d5e2721489
widgets.py split up.
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
122 return self.real_widget.isToggled() |
a2d5e2721489
widgets.py split up.
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
123 toggled = property(_isToggled, _setToggled) |
a2d5e2721489
widgets.py split up.
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
124 |
255
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
248
diff
changeset
|
125 def resizeToContent(self, recurse=True): |
332
457e626296ba
Working on the XXX_image attributes to force consistent
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
331
diff
changeset
|
126 # NOTE: Figure out how the spacing comes into play |
457e626296ba
Working on the XXX_image attributes to force consistent
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
331
diff
changeset
|
127 tw, th = 0, 0 |
457e626296ba
Working on the XXX_image attributes to force consistent
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
331
diff
changeset
|
128 if self.text: |
457e626296ba
Working on the XXX_image attributes to force consistent
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
331
diff
changeset
|
129 th = self.real_font.getHeight() + self.real_widget.getSpacing() |
457e626296ba
Working on the XXX_image attributes to force consistent
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
331
diff
changeset
|
130 tw = self.real_font.getWidth(text2gui(self.text)) + self.real_widget.getSpacing() |
457e626296ba
Working on the XXX_image attributes to force consistent
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
331
diff
changeset
|
131 self.height = max( |
457e626296ba
Working on the XXX_image attributes to force consistent
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
331
diff
changeset
|
132 self._prop_upimage["image"].getHeight(), |
457e626296ba
Working on the XXX_image attributes to force consistent
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
331
diff
changeset
|
133 self._prop_downimage["image"].getHeight(), |
457e626296ba
Working on the XXX_image attributes to force consistent
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
331
diff
changeset
|
134 self._prop_hoverimage["image"].getHeight(), |
457e626296ba
Working on the XXX_image attributes to force consistent
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
331
diff
changeset
|
135 th) + self.margins[1]*2 |
457e626296ba
Working on the XXX_image attributes to force consistent
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
331
diff
changeset
|
136 self.width = max( |
457e626296ba
Working on the XXX_image attributes to force consistent
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
331
diff
changeset
|
137 self._prop_upimage["image"].getWidth(), |
457e626296ba
Working on the XXX_image attributes to force consistent
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
331
diff
changeset
|
138 self._prop_downimage["image"].getWidth(), |
457e626296ba
Working on the XXX_image attributes to force consistent
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
331
diff
changeset
|
139 self._prop_hoverimage["image"].getWidth(), |
457e626296ba
Working on the XXX_image attributes to force consistent
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
331
diff
changeset
|
140 tw) + self.margins[0]*2 |