Label.js 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. require('Polycode/Image')
  2. function Label(font,text,size,antiAliasMode,premultiplyAlpha,backgroundColor,foregroundColor) {
  3. if(arguments[0] != "__skip_ptr__") {
  4. this.__ptr = Polycode.Label(font,text,size,antiAliasMode,premultiplyAlpha,backgroundColor,foregroundColor)
  5. }
  6. }
  7. Label.ANTIALIAS_FULL = 0
  8. Label.ANTIALIAS_NONE = 1
  9. Label.ANTIALIAS_STRONG = 2
  10. Label.ANTIALIAS_LCD = 3
  11. Label.ANTIALIAS_LCD_HINT = 4
  12. Label.ANTIALIAS_FULL_HINT = 5
  13. Label.prototype = Object.create(Image.prototype)
  14. Duktape.fin(Label.prototype, function (x) {
  15. if (x === Label.prototype) {
  16. return;
  17. }
  18. Polycode.Label__delete(x.__ptr)
  19. })
  20. Label.prototype.setText = function(text) {
  21. Polycode.Label_setText(this.__ptr, text)
  22. }
  23. Label.prototype.getText = function() {
  24. return Polycode.Label_getText(this.__ptr)
  25. }
  26. Label.prototype.getTextWidthForString = function(text) {
  27. return Polycode.Label_getTextWidthForString(this.__ptr, text)
  28. }
  29. Label.prototype.getTextHeightForString = function(text) {
  30. return Polycode.Label_getTextHeightForString(this.__ptr, text)
  31. }
  32. Label.prototype.getTextWidth = function() {
  33. return Polycode.Label_getTextWidth(this.__ptr)
  34. }
  35. Label.prototype.getTextHeight = function() {
  36. return Polycode.Label_getTextHeight(this.__ptr)
  37. }
  38. Label.prototype.setColorForRange = function(color,rangeStart,rangeEnd) {
  39. Polycode.Label_setColorForRange(this.__ptr, color, rangeStart, rangeEnd)
  40. }
  41. Label.prototype.clearColors = function() {
  42. Polycode.Label_clearColors(this.__ptr)
  43. }
  44. Label.prototype.getColorForIndex = function(index) {
  45. var retVal = new Color("__skip_ptr__")
  46. retVal.__ptr = Polycode.Label_getColorForIndex(this.__ptr, index)
  47. return retVal
  48. }
  49. Label.prototype.getPremultiplyAlpha = function() {
  50. return Polycode.Label_getPremultiplyAlpha(this.__ptr)
  51. }
  52. Label.prototype.setPremultiplyAlpha = function(val) {
  53. Polycode.Label_setPremultiplyAlpha(this.__ptr, val)
  54. }
  55. Label.prototype.setFont = function(newFont) {
  56. Polycode.Label_setFont(this.__ptr, newFont)
  57. }
  58. Label.prototype.getFont = function() {
  59. var retVal = new Font("__skip_ptr__")
  60. retVal.__ptr = Polycode.Label_getFont(this.__ptr)
  61. return retVal
  62. }
  63. Label.prototype.setSize = function(newSize) {
  64. Polycode.Label_setSize(this.__ptr, newSize)
  65. }
  66. Label.prototype.getSize = function() {
  67. return Polycode.Label_getSize(this.__ptr)
  68. }
  69. Label.prototype.getAntialiasMode = function() {
  70. return Polycode.Label_getAntialiasMode(this.__ptr)
  71. }
  72. Label.prototype.setAntialiasMode = function(newMode) {
  73. Polycode.Label_setAntialiasMode(this.__ptr, newMode)
  74. }
  75. Label.prototype.getBaselineAdjust = function() {
  76. return Polycode.Label_getBaselineAdjust(this.__ptr)
  77. }
  78. Label.prototype.setBackgroundColor = function(color) {
  79. Polycode.Label_setBackgroundColor(this.__ptr, color)
  80. }
  81. Label.prototype.setForegroundColor = function(color) {
  82. Polycode.Label_setForegroundColor(this.__ptr, color)
  83. }
  84. Label.prototype.setColors = function(backgroundColor,foregroundColor) {
  85. Polycode.Label_setColors(this.__ptr, backgroundColor, foregroundColor)
  86. }
  87. Label.prototype.getBackgroundColor = function() {
  88. var retVal = new Color("__skip_ptr__")
  89. retVal.__ptr = Polycode.Label_getBackgroundColor(this.__ptr)
  90. return retVal
  91. }
  92. Label.prototype.getForegroundColor = function() {
  93. var retVal = new Color("__skip_ptr__")
  94. retVal.__ptr = Polycode.Label_getForegroundColor(this.__ptr)
  95. return retVal
  96. }
  97. Label.prototype.optionsChanged = function() {
  98. return Polycode.Label_optionsChanged(this.__ptr)
  99. }