Label.lua 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  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 = Polycode.Label(unpack(arg))
  26. end
  27. end
  28. function Label:setText(text)
  29. local retVal = Polycode.Label_setText(self.__ptr, text)
  30. end
  31. function Label:getText()
  32. local retVal = Polycode.Label_getText(self.__ptr)
  33. return retVal
  34. end
  35. function Label:getTextWidthForString(text)
  36. local retVal = Polycode.Label_getTextWidthForString(self.__ptr, text)
  37. return retVal
  38. end
  39. function Label:getTextHeightForString(text)
  40. local retVal = Polycode.Label_getTextHeightForString(self.__ptr, text)
  41. return retVal
  42. end
  43. function Label:getTextWidth()
  44. local retVal = Polycode.Label_getTextWidth(self.__ptr)
  45. return retVal
  46. end
  47. function Label:getTextHeight()
  48. local retVal = Polycode.Label_getTextHeight(self.__ptr)
  49. return retVal
  50. end
  51. function Label:setColorForRange(color, rangeStart, rangeEnd)
  52. local retVal = Polycode.Label_setColorForRange(self.__ptr, color.__ptr, rangeStart, rangeEnd)
  53. end
  54. function Label:clearColors()
  55. local retVal = Polycode.Label_clearColors(self.__ptr)
  56. end
  57. function Label:getColorForIndex(index)
  58. local retVal = Polycode.Label_getColorForIndex(self.__ptr, index)
  59. if retVal == nil then return nil end
  60. local __c = _G["Color"]("__skip_ptr__")
  61. __c.__ptr = retVal
  62. return __c
  63. end
  64. function Label:getPremultiplyAlpha()
  65. local retVal = Polycode.Label_getPremultiplyAlpha(self.__ptr)
  66. return retVal
  67. end
  68. function Label:setPremultiplyAlpha(val)
  69. local retVal = Polycode.Label_setPremultiplyAlpha(self.__ptr, val)
  70. end
  71. function Label:setFont(newFont)
  72. local retVal = Polycode.Label_setFont(self.__ptr, newFont.__ptr)
  73. end
  74. function Label:getFont()
  75. local retVal = Polycode.Label_getFont(self.__ptr)
  76. if retVal == nil then return nil end
  77. local __c = _G["shared_ptr<Font>"]("__skip_ptr__")
  78. __c.__ptr = retVal
  79. return __c
  80. end
  81. function Label:setSize(newSize)
  82. local retVal = Polycode.Label_setSize(self.__ptr, newSize)
  83. end
  84. function Label:getSize()
  85. local retVal = Polycode.Label_getSize(self.__ptr)
  86. return retVal
  87. end
  88. function Label:getAntialiasMode()
  89. local retVal = Polycode.Label_getAntialiasMode(self.__ptr)
  90. return retVal
  91. end
  92. function Label:setAntialiasMode(newMode)
  93. local retVal = Polycode.Label_setAntialiasMode(self.__ptr, newMode)
  94. end
  95. function Label:getBaselineAdjust()
  96. local retVal = Polycode.Label_getBaselineAdjust(self.__ptr)
  97. return retVal
  98. end
  99. function Label:setBackgroundColor(color)
  100. local retVal = Polycode.Label_setBackgroundColor(self.__ptr, color.__ptr)
  101. end
  102. function Label:setForegroundColor(color)
  103. local retVal = Polycode.Label_setForegroundColor(self.__ptr, color.__ptr)
  104. end
  105. function Label:setColors(backgroundColor, foregroundColor)
  106. local retVal = Polycode.Label_setColors(self.__ptr, backgroundColor.__ptr, foregroundColor.__ptr)
  107. end
  108. function Label:getBackgroundColor()
  109. local retVal = Polycode.Label_getBackgroundColor(self.__ptr)
  110. if retVal == nil then return nil end
  111. local __c = _G["Color"]("__skip_ptr__")
  112. __c.__ptr = retVal
  113. return __c
  114. end
  115. function Label:getForegroundColor()
  116. local retVal = Polycode.Label_getForegroundColor(self.__ptr)
  117. if retVal == nil then return nil end
  118. local __c = _G["Color"]("__skip_ptr__")
  119. __c.__ptr = retVal
  120. return __c
  121. end
  122. function Label:optionsChanged()
  123. local retVal = Polycode.Label_optionsChanged(self.__ptr)
  124. return retVal
  125. end
  126. function Label:__delete()
  127. if self then Polycode.delete_Label(self.__ptr) end
  128. end