Label.js 3.1 KB

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