UNPKG

starling-framework

Version:

A fast, productive library for 2D cross-platform development.

244 lines (227 loc) 7.73 kB
// Class: starling.text.TextFormat var $global = typeof window != "undefined" ? window : typeof global != "undefined" ? global : typeof self != "undefined" ? self : this $global.Object.defineProperty(exports, "__esModule", {value: true}); var __map_reserved = {}; // Imports var $hxClasses = require("./../../hxClasses_stub").default; var $hxEnums = require("./../../hxEnums_stub").default; var $import = require("./../../import_stub").default; var $extend = require("./../../extend_stub").default; function starling_events_EventDispatcher() {return require("./../../starling/events/EventDispatcher");} function openfl_text_TextFormat() {return $import(require("openfl/text/TextFormat"));} function Std() {return require("./../../Std");} function starling_utils_Align() {return require("./../../starling/utils/Align");} function js__$Boot_HaxeError() {return require("./../../js/_Boot/HaxeError");} function openfl_errors_ArgumentError() {return $import(require("openfl/errors/ArgumentError"));} // Constructor var TextFormat = function(font,size,color,horizontalAlign,verticalAlign) { if(verticalAlign == null) { verticalAlign = "center"; } if(horizontalAlign == null) { horizontalAlign = "center"; } if(color == null) { color = 0; } if(size == null) { size = 12; } if(font == null) { font = "Verdana"; } (starling_events_EventDispatcher().default).call(this); this.__font = font; this.__size = size; this.__color = color; this.__horizontalAlign = horizontalAlign; this.__verticalAlign = verticalAlign; this.__kerning = true; this.__letterSpacing = this.__leading = 0.0; } // Meta TextFormat.__name__ = "starling.text.TextFormat"; TextFormat.__isInterface__ = false; TextFormat.__super__ = (starling_events_EventDispatcher().default); TextFormat.prototype = $extend((starling_events_EventDispatcher().default).prototype, { copyFrom: function(format) { this.__font = format.__font; this.__size = format.__size; this.__color = format.__color; this.__bold = format.__bold; this.__italic = format.__italic; this.__underline = format.__underline; this.__horizontalAlign = format.__horizontalAlign; this.__verticalAlign = format.__verticalAlign; this.__kerning = format.__kerning; this.__leading = format.__leading; this.__letterSpacing = format.__letterSpacing; this.dispatchEventWith("change"); }, clone: function() { var clone = new TextFormat(); clone.copyFrom(this); return clone; }, setTo: function(font,size,color,horizontalAlign,verticalAlign) { if(verticalAlign == null) { verticalAlign = "center"; } if(horizontalAlign == null) { horizontalAlign = "center"; } if(color == null) { color = 0; } if(size == null) { size = 12; } if(font == null) { font = "Verdana"; } this.__font = font; this.__size = size; this.__color = color; this.__horizontalAlign = horizontalAlign; this.__verticalAlign = verticalAlign; this.dispatchEventWith("change"); }, toNativeFormat: function(out) { if(out == null) { out = new (openfl_text_TextFormat().default)(); } out.font = this.__font; out.size = (Std().default).int(this.__size); out.color = this.__color; out.bold = this.__bold; out.italic = this.__italic; out.underline = this.__underline; out.align = this.__horizontalAlign; out.kerning = this.__kerning; out.leading = (Std().default).int(this.__leading); out.letterSpacing = this.__letterSpacing; return out; }, get_font: function() { return this.__font; }, set_font: function(value) { if(value != this.__font) { this.__font = value; this.dispatchEventWith("change"); } return value; }, get_size: function() { return this.__size; }, set_size: function(value) { if(value != this.__size) { this.__size = value; this.dispatchEventWith("change"); } return value; }, get_color: function() { return this.__color; }, set_color: function(value) { if(value != this.__color) { this.__color = value; this.dispatchEventWith("change"); } return value; }, get_bold: function() { return this.__bold; }, set_bold: function(value) { if(value != this.__bold) { this.__bold = value; this.dispatchEventWith("change"); } return value; }, get_italic: function() { return this.__italic; }, set_italic: function(value) { if(value != this.__italic) { this.__italic = value; this.dispatchEventWith("change"); } return value; }, get_underline: function() { return this.__underline; }, set_underline: function(value) { if(value != this.__underline) { this.__underline = value; this.dispatchEventWith("change"); } return value; }, get_horizontalAlign: function() { return this.__horizontalAlign; }, set_horizontalAlign: function(value) { if(!(starling_utils_Align().default).isValidHorizontal(value)) { throw new (js__$Boot_HaxeError().default)(new (openfl_errors_ArgumentError().default)("Invalid horizontal alignment")); } if(value != this.__horizontalAlign) { this.__horizontalAlign = value; this.dispatchEventWith("change"); } return value; }, get_verticalAlign: function() { return this.__verticalAlign; }, set_verticalAlign: function(value) { if(!(starling_utils_Align().default).isValidVertical(value)) { throw new (js__$Boot_HaxeError().default)(new (openfl_errors_ArgumentError().default)("Invalid vertical alignment")); } if(value != this.__verticalAlign) { this.__verticalAlign = value; this.dispatchEventWith("change"); } return value; }, get_kerning: function() { return this.__kerning; }, set_kerning: function(value) { if(value != this.__kerning) { this.__kerning = value; this.dispatchEventWith("change"); } return value; }, get_leading: function() { return this.__leading; }, set_leading: function(value) { if(value != this.__leading) { this.__leading = value; this.dispatchEventWith("change"); } return value; }, get_letterSpacing: function() { return this.__letterSpacing; }, set_letterSpacing: function(value) { if(value != this.__letterSpacing) { this.__letterSpacing = value; this.dispatchEventWith("change"); } return value; } }); TextFormat.prototype.__class__ = TextFormat.prototype.constructor = $hxClasses["starling.text.TextFormat"] = TextFormat; // Init Object.defineProperties(TextFormat.prototype,{ font : { get : function () { return this.get_font (); }, set : function (v) { return this.set_font (v); }}, size : { get : function () { return this.get_size (); }, set : function (v) { return this.set_size (v); }}, color : { get : function () { return this.get_color (); }, set : function (v) { return this.set_color (v); }}, bold : { get : function () { return this.get_bold (); }, set : function (v) { return this.set_bold (v); }}, italic : { get : function () { return this.get_italic (); }, set : function (v) { return this.set_italic (v); }}, underline : { get : function () { return this.get_underline (); }, set : function (v) { return this.set_underline (v); }}, horizontalAlign : { get : function () { return this.get_horizontalAlign (); }, set : function (v) { return this.set_horizontalAlign (v); }}, verticalAlign : { get : function () { return this.get_verticalAlign (); }, set : function (v) { return this.set_verticalAlign (v); }}, kerning : { get : function () { return this.get_kerning (); }, set : function (v) { return this.set_kerning (v); }}, leading : { get : function () { return this.get_leading (); }, set : function (v) { return this.set_leading (v); }}, letterSpacing : { get : function () { return this.get_letterSpacing (); }, set : function (v) { return this.set_letterSpacing (v); }}}); // Statics // Export exports.default = TextFormat;