home *** CD-ROM | disk | FTP | other *** search
/ ftp.novell.com / 2014.06.ftp.novell.com.tar / ftp.novell.com / forge / camtasia.msi / Cabs.w1.cab / fp8_controller.swf2202 / scripts / __Packages / mx / controls / TextArea.as < prev    next >
Text File  |  2009-08-19  |  14KB  |  520 lines

  1. class mx.controls.TextArea extends mx.core.ScrollView
  2. {
  3.    static var symbolName = "TextArea";
  4.    static var symbolOwner = mx.controls.TextArea;
  5.    static var version = "2.0.2.126";
  6.    var className = "TextArea";
  7.    var initializing = true;
  8.    var clipParameters = {text:1,wordWrap:1,editable:1,maxChars:1,restrict:1,html:1,password:1};
  9.    static var mergedClipParameters = mx.core.UIObject.mergeClipParameters(mx.controls.TextArea.prototype.clipParameters,mx.core.ScrollView.prototype.clipParameters);
  10.    var __vScrollPolicy = "auto";
  11.    var __hScrollPolicy = "auto";
  12.    var __editable = true;
  13.    function TextArea()
  14.    {
  15.       super();
  16.    }
  17.    function get maxChars()
  18.    {
  19.       return this.label.maxChars;
  20.    }
  21.    function set maxChars(x)
  22.    {
  23.       this.label.maxChars = x;
  24.    }
  25.    function get length()
  26.    {
  27.       return this.label.length;
  28.    }
  29.    function get restrict()
  30.    {
  31.       return this.label.restrict;
  32.    }
  33.    function set restrict(s)
  34.    {
  35.       this.label.restrict = s != "" ? s : null;
  36.    }
  37.    function get wordWrap()
  38.    {
  39.       return this.label.wordWrap;
  40.    }
  41.    function set wordWrap(s)
  42.    {
  43.       this.label.wordWrap = s;
  44.       this.invalidate();
  45.    }
  46.    function get editable()
  47.    {
  48.       return this.__editable;
  49.    }
  50.    function set editable(x)
  51.    {
  52.       this.__editable = x;
  53.       this.label.type = !x ? "dynamic" : "input";
  54.    }
  55.    function get password()
  56.    {
  57.       return this.label.password;
  58.    }
  59.    function set password(s)
  60.    {
  61.       this.label.password = s;
  62.    }
  63.    function get html()
  64.    {
  65.       return this.getHtml();
  66.    }
  67.    function set html(value)
  68.    {
  69.       this.setHtml(value);
  70.    }
  71.    function getHtml()
  72.    {
  73.       return this.label.html;
  74.    }
  75.    function setHtml(value)
  76.    {
  77.       if(value != this.label.html)
  78.       {
  79.          this.label.html = value;
  80.       }
  81.    }
  82.    function get text()
  83.    {
  84.       return this.getText();
  85.    }
  86.    function set text(t)
  87.    {
  88.       this.setText(t);
  89.    }
  90.    function getText()
  91.    {
  92.       if(this.initializing)
  93.       {
  94.          return this.initText;
  95.       }
  96.       var _loc2_ = this.label;
  97.       if(_loc2_.html == true)
  98.       {
  99.          return _loc2_.htmlText;
  100.       }
  101.       return _loc2_.text;
  102.    }
  103.    function setText(t)
  104.    {
  105.       if(this.initializing)
  106.       {
  107.          this.initText = t;
  108.       }
  109.       else
  110.       {
  111.          var _loc2_ = this.label;
  112.          if(_loc2_.html == true)
  113.          {
  114.             _loc2_.htmlText = t;
  115.          }
  116.          else
  117.          {
  118.             _loc2_.text = t;
  119.          }
  120.          this.invalidate();
  121.       }
  122.       this.dispatchValueChangedEvent(t);
  123.    }
  124.    function get hPosition()
  125.    {
  126.       return this.getHPosition();
  127.    }
  128.    function set hPosition(pos)
  129.    {
  130.       this.setHPosition(pos);
  131.       this.label.hscroll = pos;
  132.       this.label.background = false;
  133.    }
  134.    function get vPosition()
  135.    {
  136.       return this.getVPosition();
  137.    }
  138.    function set vPosition(pos)
  139.    {
  140.       this.setVPosition(pos);
  141.       this.label.scroll = pos + 1;
  142.       this.label.background = false;
  143.    }
  144.    function get maxVPosition()
  145.    {
  146.       var _loc2_ = this.label.maxscroll - 1;
  147.       return _loc2_ != undefined ? _loc2_ : 0;
  148.    }
  149.    function get maxHPosition()
  150.    {
  151.       var _loc2_ = this.label.maxhscroll;
  152.       return _loc2_ != undefined ? _loc2_ : 0;
  153.    }
  154.    function init(Void)
  155.    {
  156.       super.init();
  157.       this.label.styleName = this;
  158.       this._color = mx.core.UIObject.textColorList;
  159.       this.focusTextField = this.label;
  160.       this.label.owner = this;
  161.       this.label.onSetFocus = function(x)
  162.       {
  163.          this._parent.onSetFocus(x);
  164.       };
  165.       this.label.onKillFocus = function(x)
  166.       {
  167.          this._parent.onKillFocus(x);
  168.       };
  169.       this.label.drawFocus = function(b)
  170.       {
  171.          this._parent.drawFocus(b);
  172.       };
  173.       this.label.onChanged = function()
  174.       {
  175.          this.owner.adjustScrollBars();
  176.          this.owner.dispatchEvent({type:"change"});
  177.          this.owner.dispatchValueChangedEvent(this.owner.text);
  178.       };
  179.       this.label.onScroller = function()
  180.       {
  181.          this.owner.hPosition = this.hscroll;
  182.          this.owner.vPosition = this.scroll - 1;
  183.       };
  184.       if(this.__get__text() == undefined)
  185.       {
  186.          this.__set__text("");
  187.       }
  188.    }
  189.    function createChildren(Void)
  190.    {
  191.       super.createChildren();
  192.       this.label.autoSize = "none";
  193.    }
  194.    function layoutContent(x, y, totalW, totalH, displayW, displayH)
  195.    {
  196.       var _loc2_ = this.label;
  197.       if(this.tfx != x || this.tfy != y || this.tfw != displayW || this.tfh != displayH)
  198.       {
  199.          this.tfx = x;
  200.          this.tfy = y;
  201.          this.tfw = displayW;
  202.          this.tfh = displayH;
  203.          _loc2_.move(this.tfx,this.tfy);
  204.          _loc2_.setSize(this.tfw,this.tfh);
  205.          this.doLater(this,"adjustScrollBars");
  206.       }
  207.    }
  208.    function scrollChanged(Void)
  209.    {
  210.       var _loc2_ = Selection;
  211.       if(_loc2_.lastBeginIndex != undefined)
  212.       {
  213.          this.restoreSelection();
  214.       }
  215.       this.label.background = false;
  216.    }
  217.    function onScroll(docObj)
  218.    {
  219.       var _loc3_ = this.label;
  220.       super.onScroll(docObj);
  221.       _loc3_.hscroll = this.__get__hPosition() + 0;
  222.       _loc3_.scroll = this.__get__vPosition() + 1;
  223.       this._vpos = _loc3_.scroll;
  224.       this._hpos = _loc3_.hscroll;
  225.       _loc3_.background = false;
  226.       if(this.hookedV != true)
  227.       {
  228.          this.vScroller.addEventListener("scrollChanged",this);
  229.          this.hookedV = true;
  230.       }
  231.       if(this.hookedH != true)
  232.       {
  233.          this.hScroller.addEventListener("scrollChanged",this);
  234.          this.hookedH = true;
  235.       }
  236.    }
  237.    function size(Void)
  238.    {
  239.       var _loc3_ = this.getViewMetrics();
  240.       var _loc7_ = _loc3_.left + _loc3_.right;
  241.       var _loc4_ = _loc3_.top + _loc3_.bottom;
  242.       var _loc6_ = _loc3_.left;
  243.       var _loc5_ = _loc3_.top;
  244.       this.tfx = _loc6_;
  245.       this.tfy = _loc5_;
  246.       this.tfw = this.__get__width() - _loc7_;
  247.       this.tfh = this.__get__height() - _loc4_;
  248.       super.size();
  249.       this.label.move(this.tfx,this.tfy);
  250.       this.label.setSize(this.tfw,this.tfh);
  251.       if(this.__get__height() <= 40)
  252.       {
  253.          this.hScrollPolicy = "off";
  254.          this.vScrollPolicy = "off";
  255.       }
  256.       this.doLater(this,"adjustScrollBars");
  257.    }
  258.    function setEnabled(enable)
  259.    {
  260.       this.vScroller.enabled = enable;
  261.       this.hScroller.enabled = enable;
  262.       this.label.type = !(this.__get__editable() == false || enable == false) ? "input" : "dynamic";
  263.       this.label.selectable = enable;
  264.       var _loc3_ = this.getStyle(!enable ? "disabledColor" : "color");
  265.       if(_loc3_ == undefined)
  266.       {
  267.          _loc3_ = !enable ? 8947848 : 0;
  268.       }
  269.       this.setColor(_loc3_);
  270.    }
  271.    function setColor(col)
  272.    {
  273.       this.label.textColor = col;
  274.    }
  275.    function setFocus(Void)
  276.    {
  277.       Selection.setFocus(this.label);
  278.    }
  279.    function onSetFocus(x)
  280.    {
  281.       var f = Selection.getFocus();
  282.       var o = eval(f);
  283.       if(o != this.label)
  284.       {
  285.          Selection.setFocus(this.label);
  286.          return undefined;
  287.       }
  288.       this.getFocusManager().defaultPushButtonEnabled = false;
  289.       this.addEventListener("keyDown",this);
  290.       super.onSetFocus(x);
  291.    }
  292.    function onKillFocus(x)
  293.    {
  294.       this.getFocusManager().defaultPushButtonEnabled = true;
  295.       this.removeEventListener("keyDown",this);
  296.       super.onKillFocus(x);
  297.    }
  298.    function restoreSelection(x)
  299.    {
  300.       var _loc2_ = Selection;
  301.       Selection.setSelection(_loc2_.lastBeginIndex,_loc2_.lastEndIndex);
  302.       this.label.scroll = this._vpos;
  303.       this.label.hscroll = this._hpos;
  304.    }
  305.    function getLineOffsets(Void)
  306.    {
  307.       var _loc16_ = this._getTextFormat();
  308.       var _loc18_ = _loc16_.getTextExtent2(this.label.text);
  309.       var _loc5_ = _root._getTextExtent;
  310.       _loc5_.setNewTextFormat(TextFormat(_loc16_));
  311.       var _loc14_ = this.label.wordWrap;
  312.       var _loc9_ = 0;
  313.       var _loc7_ = this.label._width - 2 - 2;
  314.       var _loc12_ = new Array();
  315.       var _loc17_ = new String(this.label.text);
  316.       var _loc15_ = _loc17_.split("\r");
  317.       var _loc11_ = 0;
  318.       while(_loc11_ < _loc15_.length)
  319.       {
  320.          _loc12_.push(_loc9_);
  321.          var _loc4_ = _loc15_[_loc11_];
  322.          _loc5_.text = _loc4_;
  323.          var _loc13_ = Math.ceil(_loc5_.textWidth / _loc7_);
  324.          var _loc10_ = Math.floor(_loc4_.length / _loc13_);
  325.          var _loc3_ = undefined;
  326.          while(_loc14_ && _loc5_.textWidth > _loc7_)
  327.          {
  328.             _loc3_ = _loc4_.indexOf(" ",_loc10_);
  329.             var _loc6_ = undefined;
  330.             if(_loc3_ == -1)
  331.             {
  332.                _loc3_ = _loc4_.lastIndexOf(" ");
  333.                if(_loc3_ == -1)
  334.                {
  335.                   _loc3_ = _loc10_;
  336.                }
  337.             }
  338.             _loc6_ = _loc4_.substr(0,_loc3_);
  339.             _loc5_.text = _loc6_;
  340.             if(_loc5_.textWidth > _loc7_)
  341.             {
  342.                while(_loc5_.textWidth > _loc7_)
  343.                {
  344.                   var _loc8_ = _loc3_;
  345.                   _loc3_ = _loc4_.lastIndexOf(" ",_loc3_ - 1);
  346.                   if(_loc3_ == -1)
  347.                   {
  348.                      _loc3_ = _loc8_ - 1;
  349.                   }
  350.                   _loc6_ = _loc4_.substr(0,_loc3_);
  351.                   _loc5_.text = _loc6_;
  352.                }
  353.             }
  354.             else if(_loc5_.textWidth < _loc7_)
  355.             {
  356.                _loc8_ = _loc3_;
  357.                while(_loc5_.textWidth < _loc7_)
  358.                {
  359.                   _loc8_ = _loc3_;
  360.                   _loc3_ = _loc4_.indexOf(" ",_loc3_ + 1);
  361.                   if(_loc3_ == -1)
  362.                   {
  363.                      if(_loc4_.indexOf(" ",0) != -1)
  364.                      {
  365.                         break;
  366.                      }
  367.                      _loc3_ = _loc8_ + 1;
  368.                   }
  369.                   _loc6_ = _loc4_.substr(0,_loc3_);
  370.                   _loc5_.text = _loc6_;
  371.                }
  372.                _loc3_ = _loc8_;
  373.             }
  374.             _loc9_ += _loc3_;
  375.             _loc12_.push(_loc9_ + 1);
  376.             _loc4_ = _loc4_.substr(_loc3_);
  377.             if(_loc4_.charAt(0) == " ")
  378.             {
  379.                _loc4_ = _loc4_.substr(1,_loc4_.length - 1);
  380.                _loc9_ += 1;
  381.             }
  382.             _loc5_.text = _loc4_;
  383.          }
  384.          _loc9_ += _loc4_.length + 1;
  385.          _loc11_ = _loc11_ + 1;
  386.       }
  387.       return _loc12_;
  388.    }
  389.    function keyDown(e)
  390.    {
  391.       var _loc5_ = e.code;
  392.       if(_loc5_ == 34)
  393.       {
  394.          var _loc6_ = this.label.bottomScroll - this.label.scroll + 1;
  395.          var _loc3_ = this.getLineOffsets();
  396.          var _loc2_ = Math.min(this.label.bottomScroll + 1,this.label.maxscroll);
  397.          if(_loc2_ == this.label.maxscroll)
  398.          {
  399.             var _loc4_ = this.label.length;
  400.             Selection.setSelection(_loc4_,_loc4_);
  401.          }
  402.          else
  403.          {
  404.             this.label.scroll = _loc2_;
  405.             Selection.setSelection(_loc3_[_loc2_ - 1],_loc3_[_loc2_ - 1]);
  406.          }
  407.       }
  408.       else if(_loc5_ == 33)
  409.       {
  410.          _loc6_ = this.label.bottomScroll - this.label.scroll + 1;
  411.          _loc3_ = this.getLineOffsets();
  412.          _loc2_ = this.label.scroll - 1;
  413.          if(_loc2_ < 1)
  414.          {
  415.             Selection.setSelection(0,0);
  416.          }
  417.          else
  418.          {
  419.             Selection.setSelection(_loc3_[_loc2_ - 1],_loc3_[_loc2_ - 1]);
  420.             this.label.scroll = Math.max(_loc2_ - _loc6_,1);
  421.          }
  422.       }
  423.    }
  424.    function draw(Void)
  425.    {
  426.       var _loc2_ = this.label;
  427.       var _loc4_ = this.getText();
  428.       if(this.initializing)
  429.       {
  430.          this.initializing = false;
  431.          delete this.initText;
  432.       }
  433.       var _loc3_ = this._getTextFormat();
  434.       _loc2_.embedFonts = _loc3_.embedFonts == true;
  435.       if(_loc3_ != undefined)
  436.       {
  437.          _loc2_.setTextFormat(_loc3_);
  438.          _loc2_.setNewTextFormat(_loc3_);
  439.       }
  440.       _loc2_.multiline = true;
  441.       _loc2_.wordWrap = this.__get__wordWrap() == true;
  442.       if(_loc2_.html == true)
  443.       {
  444.          _loc2_.setTextFormat(_loc3_);
  445.          _loc2_.htmlText = _loc4_;
  446.       }
  447.       else
  448.       {
  449.          _loc2_.text = _loc4_;
  450.       }
  451.       _loc2_.type = this.__get__editable() != true ? "dynamic" : "input";
  452.       this.size();
  453.       _loc2_.background = false;
  454.    }
  455.    function adjustScrollBars()
  456.    {
  457.       var _loc2_ = this.label;
  458.       var _loc4_ = _loc2_.bottomScroll - _loc2_.scroll + 1;
  459.       var _loc3_ = _loc4_ + _loc2_.maxscroll - 1;
  460.       if(_loc3_ < 1)
  461.       {
  462.          _loc3_ = 1;
  463.       }
  464.       var _loc5_ = 0;
  465.       if(_loc2_.textWidth + 5 > _loc2_._width)
  466.       {
  467.          if(!_loc2_.wordWrap)
  468.          {
  469.             _loc5_ = _loc2_._width + _loc2_.maxhscroll;
  470.          }
  471.       }
  472.       else
  473.       {
  474.          _loc2_.hscroll = 0;
  475.          _loc2_.background = false;
  476.       }
  477.       if(_loc2_.height / _loc4_ != Math.round(_loc2_.height / _loc4_))
  478.       {
  479.          _loc3_ = _loc3_ - 1;
  480.       }
  481.       this.setScrollProperties(_loc5_,1,_loc3_,_loc2_.height / _loc4_);
  482.    }
  483.    function setScrollProperties(colCount, colWidth, rwCount, rwHeight, hPadding, wPadding)
  484.    {
  485.       super.setScrollProperties(colCount,colWidth,rwCount,rwHeight,hPadding,wPadding);
  486.       if(this.vScroller == undefined)
  487.       {
  488.          this.hookedV = false;
  489.       }
  490.       if(this.hScroller == undefined)
  491.       {
  492.          this.hookedH = false;
  493.       }
  494.    }
  495.    function get tabIndex()
  496.    {
  497.       return this.label.tabIndex;
  498.    }
  499.    function set tabIndex(w)
  500.    {
  501.       this.label.tabIndex = w;
  502.    }
  503.    function set _accProps(val)
  504.    {
  505.       this.label._accProps = val;
  506.    }
  507.    function get _accProps()
  508.    {
  509.       return this.label._accProps;
  510.    }
  511.    function get styleSheet()
  512.    {
  513.       return this.label.styleSheet;
  514.    }
  515.    function set styleSheet(v)
  516.    {
  517.       this.label.styleSheet = v;
  518.    }
  519. }
  520.