summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>1991-08-16 13:04:40 (GMT)
committerGuido van Rossum <guido@python.org>1991-08-16 13:04:40 (GMT)
commit1e5ad4e9bb769ab4a055c4eaf02db8c3b9a29467 (patch)
tree03d67dfece1332f81d35922a38fef6f5a26fdf70 /Lib
parente6afe6a46840dde13b1f9d7847a289fd18be723a (diff)
downloadcpython-1e5ad4e9bb769ab4a055c4eaf02db8c3b9a29467.zip
cpython-1e5ad4e9bb769ab4a055c4eaf02db8c3b9a29467.tar.gz
cpython-1e5ad4e9bb769ab4a055c4eaf02db8c3b9a29467.tar.bz2
Added class StrutAppearance (a label with with 0).
Changed minsize to getminsize.
Diffstat (limited to 'Lib')
-rw-r--r--Lib/lib-stdwin/Buttons.py30
-rwxr-xr-xLib/stdwin/Buttons.py30
2 files changed, 42 insertions, 18 deletions
diff --git a/Lib/lib-stdwin/Buttons.py b/Lib/lib-stdwin/Buttons.py
index d991c96..a218a99 100644
--- a/Lib/lib-stdwin/Buttons.py
+++ b/Lib/lib-stdwin/Buttons.py
@@ -35,12 +35,10 @@ class LabelAppearance():
#
# Size enquiry
#
- def minsize(self, m):
- try:
- self.text = self.text
- except NameError:
- self.text = ''
- return m.textwidth(self.text) + 6, m.lineheight() + 6
+ def getminsize(self, (m, (width, height))):
+ width = max(width, m.textwidth(self.text) + 6)
+ height = max(height, m.lineheight() + 6)
+ return width, height
#
def getbounds(self):
return self.bounds
@@ -143,6 +141,16 @@ class LabelAppearance():
d.invert(self.hilitebounds)
+# A Strut is a label with no width of its own.
+
+class StrutAppearance() = LabelAppearance():
+ #
+ def getminsize(self, (m, (width, height))):
+ height = max(height, m.lineheight() + 6)
+ return width, height
+ #
+
+
# ButtonAppearance displays a centered string in a box.
# selected --> bold border
# disabled --> crossed out
@@ -167,9 +175,12 @@ class ButtonAppearance() = LabelAppearance():
#
class CheckAppearance() = LabelAppearance():
#
- def minsize(self, m):
- width, height = m.textwidth(self.text) + 6, m.lineheight() + 6
- return width + height + m.textwidth(' '), height
+ def getminsize(self, (m, (width, height))):
+ minwidth = m.textwidth(self.text) + 6
+ minheight = m.lineheight() + 6
+ width = max(width, minwidth + minheight + m.textwidth(' '))
+ height = max(height, minheight)
+ return width, height
#
def drawpict(self, d):
d.box(self.boxbounds)
@@ -393,6 +404,7 @@ def _xorcross(d, bounds):
# Ready-made button classes.
#
class Label() = NoReactivity(), LabelAppearance(), Define(): pass
+class Strut() = NoReactivity(), StrutAppearance(), Define(): pass
class PushButton() = TriggerReactivity(), ButtonAppearance(), Define(): pass
class CheckButton() = CheckReactivity(), CheckAppearance(), Define(): pass
class RadioButton() = RadioReactivity(), RadioAppearance(), Define(): pass
diff --git a/Lib/stdwin/Buttons.py b/Lib/stdwin/Buttons.py
index d991c96..a218a99 100755
--- a/Lib/stdwin/Buttons.py
+++ b/Lib/stdwin/Buttons.py
@@ -35,12 +35,10 @@ class LabelAppearance():
#
# Size enquiry
#
- def minsize(self, m):
- try:
- self.text = self.text
- except NameError:
- self.text = ''
- return m.textwidth(self.text) + 6, m.lineheight() + 6
+ def getminsize(self, (m, (width, height))):
+ width = max(width, m.textwidth(self.text) + 6)
+ height = max(height, m.lineheight() + 6)
+ return width, height
#
def getbounds(self):
return self.bounds
@@ -143,6 +141,16 @@ class LabelAppearance():
d.invert(self.hilitebounds)
+# A Strut is a label with no width of its own.
+
+class StrutAppearance() = LabelAppearance():
+ #
+ def getminsize(self, (m, (width, height))):
+ height = max(height, m.lineheight() + 6)
+ return width, height
+ #
+
+
# ButtonAppearance displays a centered string in a box.
# selected --> bold border
# disabled --> crossed out
@@ -167,9 +175,12 @@ class ButtonAppearance() = LabelAppearance():
#
class CheckAppearance() = LabelAppearance():
#
- def minsize(self, m):
- width, height = m.textwidth(self.text) + 6, m.lineheight() + 6
- return width + height + m.textwidth(' '), height
+ def getminsize(self, (m, (width, height))):
+ minwidth = m.textwidth(self.text) + 6
+ minheight = m.lineheight() + 6
+ width = max(width, minwidth + minheight + m.textwidth(' '))
+ height = max(height, minheight)
+ return width, height
#
def drawpict(self, d):
d.box(self.boxbounds)
@@ -393,6 +404,7 @@ def _xorcross(d, bounds):
# Ready-made button classes.
#
class Label() = NoReactivity(), LabelAppearance(), Define(): pass
+class Strut() = NoReactivity(), StrutAppearance(), Define(): pass
class PushButton() = TriggerReactivity(), ButtonAppearance(), Define(): pass
class CheckButton() = CheckReactivity(), CheckAppearance(), Define(): pass
class RadioButton() = RadioReactivity(), RadioAppearance(), Define(): pass