cc-utilities/gfx/text.lua

41 lines
652 B
Lua

local Element = require("element")
local Text = Element:new{ text = "" }
function Text:new(o)
o.width = nil
o.height = nil
return Element.new(self, o)
end
function Text:setText(text)
self:setDirty()
self.text = text
end
function Text:draw()
Element.draw(self)
self.render.window.write(self.text)
end
function Text:getHeight()
return 1
end
function Text:getWidth()
return #self.text
end
function Text:setWidth()
error("Dimensions are derived from content")
end
function Text:setHeight()
error("Dimensions are derived from content")
end
function Text:resize()
error("Dimensions are derived from content")
end
return Text