Label.lua 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. require "Polycode/Image"
  2. class "Label" (Image)
  3. Label.ANTIALIAS_FULL = 0
  4. Label.ANTIALIAS_NONE = 1
  5. Label.ANTIALIAS_STRONG = 2
  6. Label.ANTIALIAS_LCD = 3
  7. Label.ANTIALIAS_LCD_HINT = 4
  8. Label.ANTIALIAS_FULL_HINT = 5
  9. function Label:Label(...)
  10. local arg = {...}
  11. if type(arg[1]) == "table" and count(arg) == 1 then
  12. if ""..arg[1].__classname == "Image" then
  13. self.__ptr = arg[1].__ptr
  14. return
  15. end
  16. end
  17. for k,v in pairs(arg) do
  18. if type(v) == "table" then
  19. if v.__ptr ~= nil then
  20. arg[k] = v.__ptr
  21. end
  22. end
  23. end
  24. if self.__ptr == nil and arg[1] ~= "__skip_ptr__" then
  25. self.__ptr = Polycore.Label(unpack(arg))
  26. end
  27. end
  28. function Label:setText(text)
  29. local retVal = Polycore.Label_setText(self.__ptr, text)
  30. end
  31. function Label:getText()
  32. local retVal = Polycore.Label_getText(self.__ptr)
  33. if retVal == nil then return nil end
  34. local __c = _G["String"]("__skip_ptr__")
  35. __c.__ptr = retVal
  36. return __c
  37. end
  38. function Label:getTextWidthForString(text)
  39. local retVal = Polycore.Label_getTextWidthForString(self.__ptr, text)
  40. return retVal
  41. end
  42. function Label:getTextHeightForString(text)
  43. local retVal = Polycore.Label_getTextHeightForString(self.__ptr, text)
  44. return retVal
  45. end
  46. function Label:getTextWidth()
  47. local retVal = Polycore.Label_getTextWidth(self.__ptr)
  48. return retVal
  49. end
  50. function Label:getTextHeight()
  51. local retVal = Polycore.Label_getTextHeight(self.__ptr)
  52. return retVal
  53. end
  54. function Label:setColorForRange(color, rangeStart, rangeEnd)
  55. local retVal = Polycore.Label_setColorForRange(self.__ptr, color.__ptr, rangeStart, rangeEnd)
  56. end
  57. function Label:clearColors()
  58. local retVal = Polycore.Label_clearColors(self.__ptr)
  59. end
  60. function Label:getColorForIndex(index)
  61. local retVal = Polycore.Label_getColorForIndex(self.__ptr, index)
  62. if retVal == nil then return nil end
  63. local __c = _G["Color"]("__skip_ptr__")
  64. __c.__ptr = retVal
  65. return __c
  66. end
  67. function Label:getPremultiplyAlpha()
  68. local retVal = Polycore.Label_getPremultiplyAlpha(self.__ptr)
  69. return retVal
  70. end
  71. function Label:setPremultiplyAlpha(val)
  72. local retVal = Polycore.Label_setPremultiplyAlpha(self.__ptr, val)
  73. end
  74. function Label:setFont(newFont)
  75. local retVal = Polycore.Label_setFont(self.__ptr, newFont.__ptr)
  76. end
  77. function Label:getFont()
  78. local retVal = Polycore.Label_getFont(self.__ptr)
  79. if retVal == nil then return nil end
  80. local __c = _G["Font"]("__skip_ptr__")
  81. __c.__ptr = retVal
  82. return __c
  83. end
  84. function Label:setSize(newSize)
  85. local retVal = Polycore.Label_setSize(self.__ptr, newSize)
  86. end
  87. function Label:getSize()
  88. local retVal = Polycore.Label_getSize(self.__ptr)
  89. return retVal
  90. end
  91. function Label:getAntialiasMode()
  92. local retVal = Polycore.Label_getAntialiasMode(self.__ptr)
  93. return retVal
  94. end
  95. function Label:setAntialiasMode(newMode)
  96. local retVal = Polycore.Label_setAntialiasMode(self.__ptr, newMode)
  97. end
  98. function Label:getBaselineAdjust()
  99. local retVal = Polycore.Label_getBaselineAdjust(self.__ptr)
  100. return retVal
  101. end
  102. function Label:setBackgroundColor(color)
  103. local retVal = Polycore.Label_setBackgroundColor(self.__ptr, color.__ptr)
  104. end
  105. function Label:setForegroundColor(color)
  106. local retVal = Polycore.Label_setForegroundColor(self.__ptr, color.__ptr)
  107. end
  108. function Label:setColors(backgroundColor, foregroundColor)
  109. local retVal = Polycore.Label_setColors(self.__ptr, backgroundColor.__ptr, foregroundColor.__ptr)
  110. end
  111. function Label:getBackgroundColor()
  112. local retVal = Polycore.Label_getBackgroundColor(self.__ptr)
  113. if retVal == nil then return nil end
  114. local __c = _G["Color"]("__skip_ptr__")
  115. __c.__ptr = retVal
  116. return __c
  117. end
  118. function Label:getForegroundColor()
  119. local retVal = Polycore.Label_getForegroundColor(self.__ptr)
  120. if retVal == nil then return nil end
  121. local __c = _G["Color"]("__skip_ptr__")
  122. __c.__ptr = retVal
  123. return __c
  124. end
  125. function Label:optionsChanged()
  126. local retVal = Polycore.Label_optionsChanged(self.__ptr)
  127. return retVal
  128. end
  129. function Label:__delete()
  130. if self then Polycore.delete_Label(self.__ptr) end
  131. end