2
0
mirror of https://github.com/koreader/koreader synced 2024-11-18 03:25:46 +00:00
koreader/frontend/ui/widget/fixedtextwidget.lua

30 lines
772 B
Lua
Raw Normal View History

2013-10-18 20:38:07 +00:00
local TextWidget = require("ui/widget/textwidget")
local RenderText = require("ui/rendertext")
local Geom = require("ui/geometry")
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,
self.fgcolor)
2013-10-18 20:38:07 +00:00
end
return FixedTextWidget