home *** CD-ROM | disk | FTP | other *** search
/ i·claim - visualizing argument / ICLAIM.ISO / mac / intro.swf / scripts / __Packages / mx / controls / UIScrollBar.as < prev    next >
Text File  |  2005-02-26  |  7KB  |  243 lines

  1. class mx.controls.UIScrollBar extends mx.controls.scrollClasses.ScrollBar
  2. {
  3.    static var symbolName = "UIScrollBar";
  4.    static var symbolOwner = mx.controls.UIScrollBar;
  5.    var className = "UIScrollBar";
  6.    var clipParameters = {_targetInstanceName:1,horizontal:1};
  7.    static var mergedClipParameters = mx.core.UIObject.mergeClipParameters(mx.controls.UIScrollBar.prototype.clipParameters);
  8.    static var version = "2.0.1.78";
  9.    function UIScrollBar()
  10.    {
  11.       super();
  12.    }
  13.    function init(Void)
  14.    {
  15.       super.init();
  16.       this.textField.owner = this;
  17.       this.__set__horizontal(this.wasHorizontal);
  18.       if(this.__get__horizontal())
  19.       {
  20.          this.textField == undefined ? super.setSize(this.__width,this.__height) : super.setSize(this.textField._width,16);
  21.       }
  22.       else
  23.       {
  24.          this.textField == undefined ? super.setSize(this.__width,this.__height) : super.setSize(16,this.textField._height);
  25.       }
  26.       if(this.__get__horizontal())
  27.       {
  28.          var _loc3_ = this.__width;
  29.          this.__height = this.__width;
  30.          this.width = _loc3_;
  31.          this.__width = 16;
  32.       }
  33.       this.textField.onScroller = function()
  34.       {
  35.          this.hPosition = this.hscroll;
  36.          this.vPosition = this.scroll - 1;
  37.       };
  38.       if(this.__get___targetInstanceName() != undefined)
  39.       {
  40.          this.setScrollTarget(this.__get___targetInstanceName());
  41.          this._targetInstanceName.addListener(this);
  42.       }
  43.    }
  44.    function get _targetInstanceName()
  45.    {
  46.       return this.textField;
  47.    }
  48.    function get height()
  49.    {
  50.       if(this.wasHorizontal)
  51.       {
  52.          return this.__width;
  53.       }
  54.       return this.__height;
  55.    }
  56.    function get width()
  57.    {
  58.       if(this.wasHorizontal)
  59.       {
  60.          return this.__height;
  61.       }
  62.       return this.__width;
  63.    }
  64.    function size(Void)
  65.    {
  66.       super.size();
  67.       this.onTextChanged();
  68.    }
  69.    function draw()
  70.    {
  71.       super.draw();
  72.    }
  73.    function set _targetInstanceName(t)
  74.    {
  75.       if(t == undefined)
  76.       {
  77.          this.textField.removeListener(this);
  78.          delete this.textField[!this.__get__horizontal() ? "vScroller" : "hScroller"];
  79.          if(this.textField.hScroller != undefined && this.textField.vScroller != undefined)
  80.          {
  81.             this.textField.unwatch("text");
  82.             this.textField.unwatch("htmltext");
  83.          }
  84.       }
  85.       var _loc3_ = this._parent[t];
  86.       this.textField = this._parent[t];
  87.       this.onTextChanged();
  88.    }
  89.    function setSize(w, h)
  90.    {
  91.       if(this.__get__horizontal())
  92.       {
  93.          super.setSize(h,w);
  94.       }
  95.       else
  96.       {
  97.          super.setSize(w,h);
  98.       }
  99.    }
  100.    function onTextChanged(Void)
  101.    {
  102.       if(this.textField == undefined)
  103.       {
  104.          return undefined;
  105.       }
  106.       clearInterval(this.synchScroll);
  107.       if(this.__get__horizontal())
  108.       {
  109.          var _loc2_ = this.textField.hscroll;
  110.          this.setScrollProperties(this.textField._width,0,this.textField.maxhscroll);
  111.          this.__set__scrollPosition(Math.min(_loc2_,this.textField.maxhscroll));
  112.       }
  113.       else
  114.       {
  115.          _loc2_ = this.textField.scroll;
  116.          var _loc3_ = this.textField.bottomScroll - this.textField.scroll;
  117.          this.setScrollProperties(_loc3_,1,this.textField.maxscroll);
  118.          this.__set__scrollPosition(Math.min(_loc2_,this.textField.maxscroll));
  119.       }
  120.    }
  121.    function get horizontal()
  122.    {
  123.       return this.wasHorizontal;
  124.    }
  125.    function set horizontal(v)
  126.    {
  127.       this.wasHorizontal = v;
  128.       if(v and this.initializing)
  129.       {
  130.          if(this._rotation == 90)
  131.          {
  132.             return undefined;
  133.          }
  134.          this._xscale = -100;
  135.          this._rotation = -90;
  136.       }
  137.       if(!this.initializing)
  138.       {
  139.          if(v)
  140.          {
  141.             if(this._rotation == 0)
  142.             {
  143.                this._rotation = -90;
  144.                this._xscale = -100;
  145.             }
  146.          }
  147.          else if(this._rotation == -90)
  148.          {
  149.             this._rotation = 0;
  150.             this._xscale = 100;
  151.          }
  152.       }
  153.    }
  154.    function callback(prop, oldval, newval)
  155.    {
  156.       clearInterval(this.hScroller.synchScroll);
  157.       clearInterval(this.vScroller.synchScroll);
  158.       this.hScroller.synchScroll = setInterval(this.hScroller,"onTextChanged",50);
  159.       this.vScroller.synchScroll = setInterval(this.vScroller,"onTextChanged",50);
  160.       return newval;
  161.    }
  162.    function setScrollTarget(tF)
  163.    {
  164.       if(tF == undefined)
  165.       {
  166.          this.textField.removeListener(this);
  167.          delete this.textField[!this.__get__horizontal() ? "vScroller" : "hScroller"];
  168.          if(this.textField.hScroller != undefined && this.textField.vScroller != undefined)
  169.          {
  170.             this.textField.unwatch("text");
  171.             this.textField.unwatch("htmltext");
  172.          }
  173.       }
  174.       this.textField = undefined;
  175.       if(!(tF instanceof TextField))
  176.       {
  177.          return undefined;
  178.       }
  179.       this.textField = tF;
  180.       if(this.__get__horizontal())
  181.       {
  182.          this.textField.hScroller = this;
  183.          this.textField.hScroller.lineScrollSize = 5;
  184.       }
  185.       else
  186.       {
  187.          this.textField.vScroller = this;
  188.          this.textField.vScroller.lineScrollSize = 1;
  189.       }
  190.       this.onTextChanged();
  191.       this.onChanged = function(Void)
  192.       {
  193.          this.onTextChanged();
  194.       };
  195.       this.onScroller = function(Void)
  196.       {
  197.          if(!this.isScrolling)
  198.          {
  199.             if(!this.horizontal)
  200.             {
  201.                this.scrollPosition = this.textField.scroll;
  202.             }
  203.             else
  204.             {
  205.                this.scrollPosition = this.textField.hscroll;
  206.             }
  207.          }
  208.       };
  209.       this.textField.addListener(this);
  210.       this.textField.watch("text",this.callback);
  211.       this.textField.watch("htmlText",this.callback);
  212.    }
  213.    function scrollHandler(Void)
  214.    {
  215.       if(this.__get__horizontal())
  216.       {
  217.          var _loc2_ = this.textField.background;
  218.          this.textField.hscroll = this.scrollPosition;
  219.          this.textField.background = _loc2_;
  220.       }
  221.       else
  222.       {
  223.          this.textField.scroll = this.scrollPosition;
  224.       }
  225.    }
  226.    function setEnabled(enable)
  227.    {
  228.       super.setEnabled(enable);
  229.       if(enable)
  230.       {
  231.          this.textField.addListener(this);
  232.       }
  233.       else
  234.       {
  235.          this.textField.removeListener();
  236.       }
  237.    }
  238.    function dispatchScrollEvent(detail)
  239.    {
  240.       this.dispatchEvent({type:"scroll"});
  241.    }
  242. }
  243.