2013-10-18 20:38:07 +00:00
|
|
|
local TextWidget = require("ui/widget/textwidget")
|
|
|
|
local RenderText = require("ui/rendertext")
|
|
|
|
local Geom = require("ui/geometry")
|
2014-10-30 18:42:18 +00:00
|
|
|
local Screen = require("device").screen
|
2013-10-18 20:38:07 +00:00
|
|
|
|
|
|
|
--[[
|
|
|
|
FixedTextWidget
|
|
|
|
--]]
|
|
|
|
local FixedTextWidget = TextWidget:new{}
|
|
|
|
|
|
|
|
function FixedTextWidget:getSize()
|
2014-03-13 13:52:43 +00:00
|
|
|
local tsize = RenderText:sizeUtf8Text(0, Screen:getWidth(), self.face, self.text, true, self.bold)
|
|
|
|
if not tsize then
|
|
|
|
return Geom:new{}
|
|
|
|
end
|
|
|
|
self._length = tsize.x
|
|
|
|
self._height = self.face.size
|
|
|
|
return Geom:new{
|
|
|
|
w = self._length,
|
|
|
|
h = self._height,
|
|
|
|
}
|
2013-10-18 20:38:07 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
function FixedTextWidget:paintTo(bb, x, y)
|
2014-03-13 13:52:43 +00:00
|
|
|
RenderText:renderUtf8Text(bb, x, y+self._height, self.face, self.text, true, self.bold,
|
2014-10-04 13:53:30 +00:00
|
|
|
self.fgcolor)
|
2013-10-18 20:38:07 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
return FixedTextWidget
|