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

  1. class mx.controls.Button extends mx.controls.SimpleButton
  2. {
  3.    var initIcon;
  4.    var labelPath;
  5.    var __width;
  6.    var __height;
  7.    var iconName;
  8.    var _iconLinkageName;
  9.    var hitArea_mc;
  10.    static var symbolName = "Button";
  11.    static var symbolOwner = mx.controls.Button;
  12.    var className = "Button";
  13.    static var version = "2.0.0.377";
  14.    var btnOffset = 0;
  15.    var _color = "buttonColor";
  16.    var __label = "default value";
  17.    var __labelPlacement = "right";
  18.    var falseUpSkin = "ButtonSkin";
  19.    var falseDownSkin = "ButtonSkin";
  20.    var falseOverSkin = "ButtonSkin";
  21.    var falseDisabledSkin = "ButtonSkin";
  22.    var trueUpSkin = "ButtonSkin";
  23.    var trueDownSkin = "ButtonSkin";
  24.    var trueOverSkin = "ButtonSkin";
  25.    var trueDisabledSkin = "ButtonSkin";
  26.    var falseUpIcon = "";
  27.    var falseDownIcon = "";
  28.    var falseOverIcon = "";
  29.    var falseDisabledIcon = "";
  30.    var trueUpIcon = "";
  31.    var trueDownIcon = "";
  32.    var trueOverIcon = "";
  33.    var trueDisabledIcon = "";
  34.    var clipParameters = {labelPlacement:1,icon:1,toggle:1,selected:1,label:1};
  35.    static var mergedClipParameters = mx.core.UIObject.mergeClipParameters(mx.controls.Button.prototype.clipParameters,mx.controls.SimpleButton.prototype.clipParameters);
  36.    var centerContent = true;
  37.    var borderW = 1;
  38.    function Button()
  39.    {
  40.       super();
  41.    }
  42.    function init(Void)
  43.    {
  44.       super.init();
  45.    }
  46.    function draw()
  47.    {
  48.       super.draw();
  49.       if(this.initIcon != undefined)
  50.       {
  51.          this._setIcon(this.initIcon);
  52.       }
  53.       delete this.initIcon;
  54.    }
  55.    function onRelease(Void)
  56.    {
  57.       super.onRelease();
  58.    }
  59.    function createChildren(Void)
  60.    {
  61.       super.createChildren();
  62.    }
  63.    function setSkin(tag, linkageName, initobj)
  64.    {
  65.       return super.setSkin(tag,linkageName,initobj);
  66.    }
  67.    function viewSkin(varName)
  68.    {
  69.       var _loc3_ = !this.getState() ? "false" : "true";
  70.       _loc3_ += !this.enabled ? "disabled" : this.phase;
  71.       super.viewSkin(varName,{styleName:this,borderStyle:_loc3_});
  72.    }
  73.    function invalidateStyle(c)
  74.    {
  75.       this.labelPath.invalidateStyle(c);
  76.       super.invalidateStyle(c);
  77.    }
  78.    function setColor(c)
  79.    {
  80.       var _loc2_ = 0;
  81.       while(_loc2_ < 8)
  82.       {
  83.          this[this.idNames[_loc2_]].redraw(true);
  84.          _loc2_ = _loc2_ + 1;
  85.       }
  86.    }
  87.    function setEnabled(enable)
  88.    {
  89.       this.labelPath.enabled = enable;
  90.       super.setEnabled(enable);
  91.    }
  92.    function calcSize(tag, ref)
  93.    {
  94.       if(this.__width == undefined || this.__height == undefined)
  95.       {
  96.          return undefined;
  97.       }
  98.       if(tag < 7)
  99.       {
  100.          ref.setSize(this.__width,this.__height,true);
  101.       }
  102.    }
  103.    function size(Void)
  104.    {
  105.       this.setState(this.getState());
  106.       this.setHitArea(this.__width,this.__height);
  107.       var _loc3_ = 0;
  108.       while(_loc3_ < 8)
  109.       {
  110.          var _loc4_ = this.idNames[_loc3_];
  111.          if(typeof this[_loc4_] == "movieclip")
  112.          {
  113.             this[_loc4_].setSize(this.__width,this.__height,true);
  114.          }
  115.          _loc3_ = _loc3_ + 1;
  116.       }
  117.       super.size();
  118.    }
  119.    function set labelPlacement(val)
  120.    {
  121.       this.__labelPlacement = val;
  122.       this.invalidate();
  123.    }
  124.    function get labelPlacement()
  125.    {
  126.       return this.__labelPlacement;
  127.    }
  128.    function getLabelPlacement(Void)
  129.    {
  130.       return this.__labelPlacement;
  131.    }
  132.    function setLabelPlacement(val)
  133.    {
  134.       this.__labelPlacement = val;
  135.       this.invalidate();
  136.    }
  137.    function getBtnOffset(Void)
  138.    {
  139.       if(this.getState())
  140.       {
  141.          var _loc2_ = this.btnOffset;
  142.       }
  143.       else if(this.phase == "down")
  144.       {
  145.          _loc2_ = this.btnOffset;
  146.       }
  147.       else
  148.       {
  149.          _loc2_ = 0;
  150.       }
  151.       return _loc2_;
  152.    }
  153.    function setView(offset)
  154.    {
  155.       var _loc16_ = !offset ? 0 : this.btnOffset;
  156.       var _loc12_ = this.getLabelPlacement();
  157.       var _loc7_ = 0;
  158.       var _loc6_ = 0;
  159.       var _loc11_ = 0;
  160.       var _loc8_ = 0;
  161.       var _loc5_ = 0;
  162.       var _loc4_ = 0;
  163.       var _loc3_ = this.labelPath;
  164.       var _loc2_ = this.iconName;
  165.       var _loc15_ = _loc3_.textWidth;
  166.       var _loc14_ = _loc3_.textHeight;
  167.       var _loc9_ = this.__width - this.borderW - this.borderW;
  168.       var _loc10_ = this.__height - this.borderW - this.borderW;
  169.       _loc3_._visible = true;
  170.       if(_loc2_ != undefined)
  171.       {
  172.          _loc7_ = _loc2_._width;
  173.          _loc6_ = _loc2_._height;
  174.       }
  175.       if(_loc12_ == "left" || _loc12_ == "right")
  176.       {
  177.          if(_loc3_ != undefined)
  178.          {
  179.             _loc3_._width = _loc11_ = Math.min(_loc9_ - _loc7_,_loc15_ + 5);
  180.             _loc3_._height = _loc8_ = Math.min(_loc10_,_loc14_ + 5);
  181.          }
  182.          if(_loc12_ == "right")
  183.          {
  184.             _loc5_ = _loc7_;
  185.             if(this.centerContent)
  186.             {
  187.                _loc5_ += (_loc9_ - _loc11_ - _loc7_) / 2;
  188.             }
  189.             _loc2_._x = _loc5_ - _loc7_;
  190.          }
  191.          else
  192.          {
  193.             _loc5_ = _loc9_ - _loc11_ - _loc7_;
  194.             if(this.centerContent)
  195.             {
  196.                _loc5_ /= 2;
  197.             }
  198.             _loc2_._x = _loc5_ + _loc11_;
  199.          }
  200.          _loc2_._y = _loc4_ = 0;
  201.          if(this.centerContent)
  202.          {
  203.             _loc2_._y = (_loc10_ - _loc6_) / 2;
  204.             _loc4_ = (_loc10_ - _loc8_) / 2;
  205.          }
  206.          if(!this.centerContent)
  207.          {
  208.             _loc2_._y += Math.max(0,(_loc8_ - _loc6_) / 2);
  209.          }
  210.       }
  211.       else
  212.       {
  213.          if(_loc3_ != undefined)
  214.          {
  215.             _loc3_._width = _loc11_ = Math.min(_loc9_,_loc15_ + 5);
  216.             _loc3_._height = _loc8_ = Math.min(_loc10_ - _loc6_,_loc14_ + 5);
  217.          }
  218.          _loc5_ = (_loc9_ - _loc11_) / 2;
  219.          _loc2_._x = (_loc9_ - _loc7_) / 2;
  220.          if(_loc12_ == "top")
  221.          {
  222.             _loc4_ = _loc10_ - _loc8_ - _loc6_;
  223.             if(this.centerContent)
  224.             {
  225.                _loc4_ /= 2;
  226.             }
  227.             _loc2_._y = _loc4_ + _loc8_;
  228.          }
  229.          else
  230.          {
  231.             _loc4_ = _loc6_;
  232.             if(this.centerContent)
  233.             {
  234.                _loc4_ += (_loc10_ - _loc8_ - _loc6_) / 2;
  235.             }
  236.             _loc2_._y = _loc4_ - _loc6_;
  237.          }
  238.       }
  239.       var _loc13_ = this.borderW + _loc16_;
  240.       _loc3_._x = _loc5_ + _loc13_;
  241.       _loc3_._y = _loc4_ + _loc13_;
  242.       _loc2_._x += _loc13_;
  243.       _loc2_._y += _loc13_;
  244.    }
  245.    function set label(lbl)
  246.    {
  247.       this.setLabel(lbl);
  248.    }
  249.    function setLabel(label)
  250.    {
  251.       if(label == "")
  252.       {
  253.          this.labelPath.removeTextField();
  254.          this.refresh();
  255.          return undefined;
  256.       }
  257.       if(this.labelPath == undefined)
  258.       {
  259.          var _loc2_ = this.createLabel("labelPath",200,label);
  260.          _loc2_._width = _loc2_.textWidth + 5;
  261.          _loc2_._height = _loc2_.textHeight + 5;
  262.          _loc2_.visible = false;
  263.       }
  264.       else
  265.       {
  266.          this.labelPath.text = label;
  267.          this.refresh();
  268.       }
  269.    }
  270.    function getLabel(Void)
  271.    {
  272.       return this.labelPath.text;
  273.    }
  274.    function get label()
  275.    {
  276.       return this.labelPath.text;
  277.    }
  278.    function _getIcon(Void)
  279.    {
  280.       return this._iconLinkageName;
  281.    }
  282.    function get icon()
  283.    {
  284.       if(this.initializing)
  285.       {
  286.          return this.initIcon;
  287.       }
  288.       return this._iconLinkageName;
  289.    }
  290.    function _setIcon(linkage)
  291.    {
  292.       if(this.initializing)
  293.       {
  294.          if(linkage == "")
  295.          {
  296.             return undefined;
  297.          }
  298.          this.initIcon = linkage;
  299.       }
  300.       else
  301.       {
  302.          if(linkage == "")
  303.          {
  304.             this.removeIcons();
  305.             return undefined;
  306.          }
  307.          super.changeIcon(0,linkage);
  308.          super.changeIcon(1,linkage);
  309.          super.changeIcon(4,linkage);
  310.          super.changeIcon(5,linkage);
  311.          this._iconLinkageName = linkage;
  312.          this.refresh();
  313.       }
  314.    }
  315.    function set icon(linkage)
  316.    {
  317.       this._setIcon(linkage);
  318.    }
  319.    function setHitArea(w, h)
  320.    {
  321.       if(this.hitArea_mc == undefined)
  322.       {
  323.          this.createEmptyObject("hitArea_mc",100);
  324.       }
  325.       var _loc2_ = this.hitArea_mc;
  326.       _loc2_.clear();
  327.       _loc2_.beginFill(16711680);
  328.       _loc2_.drawRect(0,0,w,h);
  329.       _loc2_.endFill();
  330.       _loc2_.setVisible(false);
  331.    }
  332. }
  333.