home *** CD-ROM | disk | FTP | other *** search
/ PCGUIA 2010 Software/Programs / PCGuia_programas.iso / Swf / Produtividade.swf / scripts / __Packages / mx / controls / TextInput.as < prev    next >
Encoding:
Text File  |  2010-02-24  |  7.3 KB  |  311 lines

  1. class mx.controls.TextInput extends mx.core.UIComponent
  2. {
  3.    var owner;
  4.    var enterListener;
  5.    var label;
  6.    var focusTextField;
  7.    var _color;
  8.    var border_mc;
  9.    var tfx;
  10.    var tfy;
  11.    var tfw;
  12.    var tfh;
  13.    var bind;
  14.    var updateModel;
  15.    static var symbolName = "TextInput";
  16.    static var symbolOwner = mx.controls.TextInput;
  17.    static var version = "2.0.0.377";
  18.    var className = "TextInput";
  19.    var initializing = true;
  20.    var clipParameters = {text:1,editable:1,password:1,maxChars:1,restrict:1};
  21.    static var mergedClipParameters = mx.core.UIObject.mergeClipParameters(mx.controls.TextInput.prototype.clipParameters,mx.core.UIComponent.prototype.clipParameters);
  22.    var _maxWidth = mx.core.UIComponent.kStretch;
  23.    var __editable = true;
  24.    var initText = "";
  25.    function TextInput()
  26.    {
  27.       super();
  28.    }
  29.    function addEventListener(event, handler)
  30.    {
  31.       if(event == "enter")
  32.       {
  33.          this.addEnterEvents();
  34.       }
  35.       super.addEventListener(event,handler);
  36.    }
  37.    function enterOnKeyDown()
  38.    {
  39.       if(Key.getAscii() == 13)
  40.       {
  41.          this.owner.dispatchEvent({type:"enter"});
  42.       }
  43.    }
  44.    function addEnterEvents()
  45.    {
  46.       if(this.enterListener == undefined)
  47.       {
  48.          this.enterListener = new Object();
  49.          this.enterListener.owner = this;
  50.          this.enterListener.onKeyDown = this.enterOnKeyDown;
  51.       }
  52.    }
  53.    function init(Void)
  54.    {
  55.       super.init();
  56.       this.label.styleName = this;
  57.       this.tabChildren = true;
  58.       this.tabEnabled = false;
  59.       this.focusTextField = this.label;
  60.       this._color = mx.core.UIObject.textColorList;
  61.       this.label.onSetFocus = function()
  62.       {
  63.          this._parent.onSetFocus();
  64.       };
  65.       this.label.onKillFocus = function(n)
  66.       {
  67.          this._parent.onKillFocus(n);
  68.       };
  69.       this.label.drawFocus = function(b)
  70.       {
  71.          this._parent.drawFocus(b);
  72.       };
  73.       this.label.onChanged = this.onLabelChanged;
  74.    }
  75.    function setFocus()
  76.    {
  77.       Selection.setFocus(this.label);
  78.    }
  79.    function onLabelChanged(Void)
  80.    {
  81.       this._parent.dispatchEvent({type:"change"});
  82.       this._parent.dispatchValueChangedEvent(this.text);
  83.    }
  84.    function createChildren(Void)
  85.    {
  86.       super.createChildren();
  87.       if(this.border_mc == undefined)
  88.       {
  89.          this.createClassObject(_global.styles.rectBorderClass,"border_mc",0,{styleName:this});
  90.       }
  91.       this.border_mc.swapDepths(this.label);
  92.       this.label.autoSize = "none";
  93.    }
  94.    function get html()
  95.    {
  96.       return this.getHtml();
  97.    }
  98.    function set html(value)
  99.    {
  100.       this.setHtml(value);
  101.    }
  102.    function getHtml()
  103.    {
  104.       return this.label.html;
  105.    }
  106.    function setHtml(value)
  107.    {
  108.       if(value != this.label.html)
  109.       {
  110.          this.label.html = value;
  111.       }
  112.    }
  113.    function get text()
  114.    {
  115.       return this.getText();
  116.    }
  117.    function set text(t)
  118.    {
  119.       this.setText(t);
  120.    }
  121.    function getText()
  122.    {
  123.       if(this.initializing)
  124.       {
  125.          return this.initText;
  126.       }
  127.       if(this.label.html == true)
  128.       {
  129.          return this.label.htmlText;
  130.       }
  131.       return this.label.text;
  132.    }
  133.    function setText(t)
  134.    {
  135.       if(this.initializing)
  136.       {
  137.          this.initText = t;
  138.       }
  139.       else
  140.       {
  141.          var _loc2_ = this.label;
  142.          if(_loc2_.html == true)
  143.          {
  144.             _loc2_.htmlText = t;
  145.          }
  146.          else
  147.          {
  148.             _loc2_.text = t;
  149.          }
  150.       }
  151.       this.dispatchValueChangedEvent(t);
  152.    }
  153.    function size(Void)
  154.    {
  155.       this.border_mc.setSize(this.width,this.height);
  156.       var _loc2_ = this.border_mc.borderMetrics;
  157.       var _loc6_ = _loc2_.left + _loc2_.right;
  158.       var _loc3_ = _loc2_.top + _loc2_.bottom;
  159.       var _loc5_ = _loc2_.left;
  160.       var _loc4_ = _loc2_.top;
  161.       this.tfx = _loc5_;
  162.       this.tfy = _loc4_;
  163.       this.tfw = this.width - _loc6_;
  164.       this.tfh = this.height - _loc3_;
  165.       this.label.move(this.tfx,this.tfy);
  166.       this.label.setSize(this.tfw,this.tfh + 1);
  167.    }
  168.    function setEnabled(enable)
  169.    {
  170.       this.enabled = enable;
  171.       this.label.type = !(this.__editable == true || this.enabled == false) ? "dynamic" : "input";
  172.       this.label.selectable = this.enabled;
  173.       var _loc2_ = this.getStyle(!enable ? "disabledColor" : "color");
  174.       if(_loc2_ == undefined)
  175.       {
  176.          _loc2_ = !enable ? 8947848 : 0;
  177.       }
  178.       this.setColor(_loc2_);
  179.    }
  180.    function setColor(col)
  181.    {
  182.       this.label.textColor = col;
  183.    }
  184.    function onKillFocus(newFocus)
  185.    {
  186.       if(this.enterListener != undefined)
  187.       {
  188.          Key.removeListener(this.enterListener);
  189.       }
  190.       if(this.bind != undefined)
  191.       {
  192.          this.updateModel(this.text);
  193.       }
  194.       super.onKillFocus(newFocus);
  195.    }
  196.    function onSetFocus(oldFocus)
  197.    {
  198.       var f = Selection.getFocus();
  199.       var o = eval(f);
  200.       if(o != this.label)
  201.       {
  202.          Selection.setFocus(this.label);
  203.          return undefined;
  204.       }
  205.       if(this.enterListener != undefined)
  206.       {
  207.          Key.addListener(this.enterListener);
  208.       }
  209.       super.onSetFocus(oldFocus);
  210.    }
  211.    function draw(Void)
  212.    {
  213.       var _loc2_ = this.label;
  214.       var _loc4_ = this.getText();
  215.       if(this.initializing)
  216.       {
  217.          this.initializing = false;
  218.          delete this.initText;
  219.       }
  220.       var _loc3_ = this._getTextFormat();
  221.       _loc2_.embedFonts = _loc3_.embedFonts == true;
  222.       if(_loc3_ != undefined)
  223.       {
  224.          _loc2_.setTextFormat(_loc3_);
  225.          _loc2_.setNewTextFormat(_loc3_);
  226.       }
  227.       _loc2_.multiline = false;
  228.       _loc2_.wordWrap = false;
  229.       if(_loc2_.html == true)
  230.       {
  231.          _loc2_.setTextFormat(_loc3_);
  232.          _loc2_.htmlText = _loc4_;
  233.       }
  234.       else
  235.       {
  236.          _loc2_.text = _loc4_;
  237.       }
  238.       _loc2_.type = !(this.__editable == true || this.enabled == false) ? "dynamic" : "input";
  239.       this.size();
  240.    }
  241.    function setEditable(s)
  242.    {
  243.       this.__editable = s;
  244.       this.label.type = !s ? "dynamic" : "input";
  245.    }
  246.    function get maxChars()
  247.    {
  248.       return this.label.maxChars;
  249.    }
  250.    function set maxChars(w)
  251.    {
  252.       this.label.maxChars = w;
  253.    }
  254.    function get length()
  255.    {
  256.       return this.label.length;
  257.    }
  258.    function get restrict()
  259.    {
  260.       return this.label.restrict;
  261.    }
  262.    function set restrict(w)
  263.    {
  264.       this.label.restrict = w != "" ? w : null;
  265.    }
  266.    function get hPosition()
  267.    {
  268.       return this.label.hscroll;
  269.    }
  270.    function set hPosition(w)
  271.    {
  272.       this.label.hscroll = w;
  273.    }
  274.    function get maxHPosition()
  275.    {
  276.       return this.label.maxhscroll;
  277.    }
  278.    function get editable()
  279.    {
  280.       return this.__editable;
  281.    }
  282.    function set editable(w)
  283.    {
  284.       this.setEditable(w);
  285.    }
  286.    function get password()
  287.    {
  288.       return this.label.password;
  289.    }
  290.    function set password(w)
  291.    {
  292.       this.label.password = w;
  293.    }
  294.    function get tabIndex()
  295.    {
  296.       return this.label.tabIndex;
  297.    }
  298.    function set tabIndex(w)
  299.    {
  300.       this.label.tabIndex = w;
  301.    }
  302.    function set _accProps(val)
  303.    {
  304.       this.label._accProps = val;
  305.    }
  306.    function get _accProps()
  307.    {
  308.       return this.label._accProps;
  309.    }
  310. }
  311.