[tekui-devel] tekui: Text, CheckMark, MenuItem: improved setup and cleanup of ...
Timm S. Mueller
tmueller at neoscientists.org
Fri Apr 18 02:51:53 CEST 2008
details: http://hg.teklib.org/tekui/rev/e3cdbeb32cda
changeset: 430:e3cdbeb32cda
user: Timm S. Mueller <tmueller at neoscientists.org>
date: Tue Apr 15 21:56:38 2008 +0200
description:
Text, CheckMark, MenuItem: improved setup and cleanup of multiple texts;
Layouter: askMinMax() was invoked with nil arguments, fixed; small
improvements in examples
diffs (truncated from 382 to 100 lines):
diff -r e1e5ed2d583b -r e3cdbeb32cda tek/app/ui/tekui.lua
--- a/tek/app/ui/tekui.lua Tue Apr 15 18:35:59 2008 +0200
+++ b/tek/app/ui/tekui.lua Tue Apr 15 21:56:38 2008 +0200
@@ -379,7 +379,7 @@ ui.application:new
},
},
ui.text:new { Mode = "button", Label = "Open", VAlign = "center", Width = "auto" },
- ui.text:new { Label = "Hello\nWorld", TextVAlign = "top" },
+ ui.text:new { Label = "Hello,\nWorld!", Height = "fill" },
ui.text:new
{
Width = "auto",
diff -r e1e5ed2d583b -r e3cdbeb32cda tek/app/ui/weight.lua
--- a/tek/app/ui/weight.lua Tue Apr 15 18:35:59 2008 +0200
+++ b/tek/app/ui/weight.lua Tue Apr 15 21:56:38 2008 +0200
@@ -6,18 +6,8 @@ local mybutton = ui.text:newClass()
local mybutton = ui.text:newClass()
function mybutton:draw()
- ui.frame.draw(self)
- local Label = tostring(self.Rect[3] - self.Rect[1] - 1)
- local d = self.Drawable
- local p1, p2, p3, p4 = unpack(self.PaddingAndBorder)
- local w = self.Rect[3] - self.Rect[1] + 1 - p1 - p3
- local h = self.Rect[4] - self.Rect[2] + 1 - p2 - p4
- local tpen = self.Drawable.Pens[ui.PEN_BUTTONTEXT]
- d:setFont(self.Font)
- local tw, th = d:textSize(Label)
- d:drawText(
- self.Rect[1] + p1 + w / 2 - tw / 2,
- self.Rect[2] + p2 + (h - th) / 2, Label, tpen)
+ self:setLabel(tostring(self.Rect[3] - self.Rect[1] + 1))
+ ui.text.draw(self)
end
ui.application:new
diff -r e1e5ed2d583b -r e3cdbeb32cda tek/class/ui/checkmark.lua
--- a/tek/class/ui/checkmark.lua Tue Apr 15 18:35:59 2008 +0200
+++ b/tek/class/ui/checkmark.lua Tue Apr 15 21:56:38 2008 +0200
@@ -15,7 +15,7 @@ local max = math.max
local max = math.max
module("tek.class.ui.checkmark", tek.class.ui.text)
-_VERSION = "CheckMark 2.9"
+_VERSION = "CheckMark 2.10"
-------------------------------------------------------------------------------
-- Constants & Class data:
@@ -83,6 +83,7 @@ function CheckMark.new(class, self)
self.ImageRect = { 0, 0, 0, 0 }
return Text.new(class, self)
end
+
function CheckMark.init(self)
self.Image = self.Image or CheckImage1
self.AltImage = self.AltImage or CheckImage2
@@ -90,18 +91,8 @@ function CheckMark.init(self)
self.ImageMinHeight = self.ImageMinHeight or DEF_IMAGEMINHEIGHT
self.ImageWidth = false
self.ImageHeight = false
- self.TextRecords =
- {
- {
- self.Label,
- "",
- "left",
- "center",
- 0, 0, 0, 0,
- 0, 0, 0, 0,
- false,
- }
- }
+ self.TextRecords = self.TextRecords or { false }
+ self.TextHAlign = self.TextHAlign or "left"
return Text.init(self)
end
@@ -127,7 +118,19 @@ function CheckMark:setupDisplay(display,
self.IBorderStyle = self.IBorderStyle or theme.CheckMarkIBorderStyle or
DEF_IBORDERSTYLE
- return Text.setupDisplay(self, display, drawable)
+ if Text.setupDisplay(self, display, drawable) then
+ self.TextRecords[1] = self:newTextRecord(self.Label, self.FontSpec)
+ return true
+ end
+end
+
+-------------------------------------------------------------------------------
+-- cleanupDisplay:
+-------------------------------------------------------------------------------
+
+function CheckMark:cleanupDisplay()
+ self.TextRecords[1] = false
+ Text.cleanupDisplay(self)
end
-------------------------------------------------------------------------------
@@ -144,7 +147,7 @@ end
More information about the tekui-devel
mailing list