home *** CD-ROM | disk | FTP | other *** search
/ FCE Gold Plus / GOLD.iso / pc / shell.swf / scripts / __Packages / mx / controls / List.as < prev    next >
Text File  |  2007-10-16  |  6KB  |  182 lines

  1. class mx.controls.List extends mx.controls.listclasses.ScrollSelectList
  2. {
  3.    static var symbolOwner = mx.controls.List;
  4.    static var symbolName = "List";
  5.    static var version = "2.0.0.377";
  6.    var clipParameters = {rowHeight:1,enabled:1,visible:1,labels:1};
  7.    var scrollDepth = 1;
  8.    var __vScrollPolicy = "on";
  9.    var autoHScrollAble = false;
  10.    function List()
  11.    {
  12.       super();
  13.    }
  14.    function setEnabled(v)
  15.    {
  16.       super.setEnabled(v);
  17.       this.border_mc.backgroundColorName = !v ? "backgroundDisabledColor" : "backgroundColor";
  18.       this.border_mc.invalidate();
  19.    }
  20.    function get labels()
  21.    {
  22.       return this.__labels;
  23.    }
  24.    function set labels(lbls)
  25.    {
  26.       this.__labels = lbls;
  27.       this.setDataProvider(lbls);
  28.    }
  29.    function setVPosition(pos)
  30.    {
  31.       pos = Math.min(this.__dataProvider.length - this.__get__rowCount() + this.roundUp,pos);
  32.       pos = Math.max(0,pos);
  33.       super.setVPosition(pos);
  34.    }
  35.    function setHPosition(pos)
  36.    {
  37.       pos = Math.max(Math.min(this.__maxHPosition,pos),0);
  38.       super.setHPosition(pos);
  39.       this.hScroll(pos);
  40.    }
  41.    function setMaxHPosition(pos)
  42.    {
  43.       this.__maxHPosition = pos;
  44.       this.invScrollProps = true;
  45.       this.invalidate();
  46.    }
  47.    function setHScrollPolicy(policy)
  48.    {
  49.       if(policy.toLowerCase() == "auto" && !this.autoHScrollAble)
  50.       {
  51.          return undefined;
  52.       }
  53.       super.setHScrollPolicy(policy);
  54.       if(policy == "off")
  55.       {
  56.          this.setHPosition(0);
  57.          this.setVPosition(Math.min(this.__dataProvider.length - this.__get__rowCount() + this.roundUp,this.__vPosition));
  58.       }
  59.    }
  60.    function setRowCount(rC)
  61.    {
  62.       if(isNaN(rC))
  63.       {
  64.          return undefined;
  65.       }
  66.       var _loc2_ = this.getViewMetrics();
  67.       this.setSize(this.__width,this.__rowHeight * rC + _loc2_.top + _loc2_.bottom);
  68.    }
  69.    function layoutContent(x, y, tW, tH, dW, dH)
  70.    {
  71.       this.totalWidth = tW;
  72.       this.totalHeight = tH;
  73.       this.displayWidth = dW;
  74.       var _loc4_ = !(this.__hScrollPolicy == "on" || this.__hScrollPolicy == "auto") ? dW : Math.max(tW,dW);
  75.       super.layoutContent(x,y,_loc4_,dH);
  76.    }
  77.    function modelChanged(eventObj)
  78.    {
  79.       super.modelChanged(eventObj);
  80.       var _loc3_ = eventObj.eventName;
  81.       if(_loc3_ == "addItems" || _loc3_ == "removeItems" || _loc3_ == "updateAll" || _loc3_ == "filterModel")
  82.       {
  83.          this.invScrollProps = true;
  84.          this.invalidate("invScrollProps");
  85.       }
  86.    }
  87.    function onScroll(eventObj)
  88.    {
  89.       var _loc3_ = eventObj.target;
  90.       if(_loc3_ == this.vScroller)
  91.       {
  92.          this.setVPosition(_loc3_.scrollPosition);
  93.       }
  94.       else
  95.       {
  96.          this.hScroll(_loc3_.scrollPosition);
  97.       }
  98.       super.onScroll(eventObj);
  99.    }
  100.    function hScroll(pos)
  101.    {
  102.       this.__hPosition = pos;
  103.       this.listContent._x = - pos;
  104.    }
  105.    function init(Void)
  106.    {
  107.       super.init();
  108.       if(this.labels.length > 0)
  109.       {
  110.          var _loc6_ = new Array();
  111.          var _loc3_ = 0;
  112.          while(_loc3_ < this.labels.length)
  113.          {
  114.             _loc6_.addItem({label:this.labels[_loc3_],data:this.data[_loc3_]});
  115.             _loc3_ = _loc3_ + 1;
  116.          }
  117.          this.setDataProvider(_loc6_);
  118.       }
  119.       this.__maxHPosition = 0;
  120.    }
  121.    function createChildren(Void)
  122.    {
  123.       super.createChildren();
  124.       this.listContent.setMask(this.mask_mc);
  125.       this.border_mc.move(0,0);
  126.       this.border_mc.setSize(this.__width,this.__height);
  127.    }
  128.    function getRowCount(Void)
  129.    {
  130.       var _loc2_ = this.getViewMetrics();
  131.       return this.__rowCount != 0 ? this.__rowCount : Math.ceil((this.__height - _loc2_.top - _loc2_.bottom) / this.__rowHeight);
  132.    }
  133.    function size(Void)
  134.    {
  135.       super.size();
  136.       this.configureScrolling();
  137.       var _loc3_ = this.getViewMetrics();
  138.       this.layoutContent(_loc3_.left,_loc3_.top,this.__width + this.__maxHPosition,this.totalHeight,this.__width - _loc3_.left - _loc3_.right,this.__height - _loc3_.top - _loc3_.bottom);
  139.    }
  140.    function draw(Void)
  141.    {
  142.       if(this.invRowHeight)
  143.       {
  144.          this.invScrollProps = true;
  145.          super.draw();
  146.          this.listContent.setMask(this.mask_mc);
  147.          this.invLayoutContent = true;
  148.       }
  149.       if(this.invScrollProps)
  150.       {
  151.          this.configureScrolling();
  152.          delete this.invScrollProps;
  153.       }
  154.       if(this.invLayoutContent)
  155.       {
  156.          var _loc3_ = this.getViewMetrics();
  157.          this.layoutContent(_loc3_.left,_loc3_.top,this.__width + this.__maxHPosition,this.totalHeight,this.__width - _loc3_.left - _loc3_.right,this.__height - _loc3_.top - _loc3_.bottom);
  158.       }
  159.       super.draw();
  160.    }
  161.    function configureScrolling(Void)
  162.    {
  163.       var _loc2_ = this.__dataProvider.length;
  164.       if(this.__vPosition > Math.max(0,_loc2_ - this.getRowCount() + this.roundUp))
  165.       {
  166.          this.setVPosition(Math.max(0,Math.min(_loc2_ - this.getRowCount() + this.roundUp,this.__vPosition)));
  167.       }
  168.       var _loc3_ = this.getViewMetrics();
  169.       var _loc4_ = this.__hScrollPolicy == "off" ? this.__width - _loc3_.left - _loc3_.right : this.__maxHPosition + this.__width - _loc3_.left - _loc3_.right;
  170.       if(_loc2_ == undefined)
  171.       {
  172.          _loc2_ = 0;
  173.       }
  174.       this.setScrollProperties(_loc4_,1,_loc2_,this.__rowHeight);
  175.       if(this.oldVWidth != _loc4_)
  176.       {
  177.          this.invLayoutContent = true;
  178.       }
  179.       this.oldVWidth = _loc4_;
  180.    }
  181. }
  182.