Label.lua 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. require "Polycode/Image"
  2. class "Label" (Image)
  3. ANTIALIAS_FULL = 0
  4. ANTIALIAS_NONE = 1
  5. function Label:Label(...)
  6. for k,v in pairs(arg) do
  7. if type(v) == "table" then
  8. if v.__ptr ~= nil then
  9. arg[k] = v.__ptr
  10. end
  11. end
  12. end
  13. if self.__ptr == nil and arg[1] ~= "__skip_ptr__" then
  14. self.__ptr = Polycore.Label(unpack(arg))
  15. end
  16. end
  17. function Label:setText(text)
  18. local retVal = Polycore.Label_setText(self.__ptr, text)
  19. end
  20. function Label:getText()
  21. local retVal = Polycore.Label_getText(self.__ptr)
  22. return retVal
  23. end
  24. function Label:getTextWidth(font, text, size)
  25. local retVal = Polycore.Label_getTextWidth(self.__ptr, font.__ptr, text, size)
  26. return retVal
  27. end
  28. function Label:getTextHeight(font, text, size)
  29. local retVal = Polycore.Label_getTextHeight(self.__ptr, font.__ptr, text, size)
  30. return retVal
  31. end
  32. function Label:getFont()
  33. local retVal = Polycore.Label_getFont(self.__ptr)
  34. if Polycore.__ptr_lookup[retVal] ~= nil then
  35. return Polycore.__ptr_lookup[retVal]
  36. else
  37. Polycore.__ptr_lookup[retVal] = Font("__skip_ptr__")
  38. Polycore.__ptr_lookup[retVal].__ptr = retVal
  39. return Polycore.__ptr_lookup[retVal]
  40. end
  41. end