home *** CD-ROM | disk | FTP | other *** search
/ The Complete Idiot's Guide to Microsoft Excel 2010 / CIGExcel.iso / Videos / Flash / controller.swf / scripts / __Packages / mx / containers / Window.as < prev   
Encoding:
Text File  |  2010-09-09  |  8.3 KB  |  276 lines

  1. class mx.containers.Window extends mx.core.ScrollView
  2. {
  3.    var __contentPath;
  4.    var boundingBox_mc;
  5.    var modalWindow;
  6.    var regX;
  7.    var regY;
  8.    var onMouseMove;
  9.    var back_mc;
  10.    var depth;
  11.    var titleStyleDeclaration;
  12.    var title;
  13.    var button_mc;
  14.    var validateNow;
  15.    var _title;
  16.    var _child0;
  17.    var border_mc;
  18.    var vScroller;
  19.    var hScroller;
  20.    var closeButton;
  21.    var dispatchEvent;
  22.    static var symbolName = "Window";
  23.    static var symbolOwner = mx.containers.Window;
  24.    static var version = "2.0.2.126";
  25.    var className = "Window";
  26.    static var skinIDBorder = 0;
  27.    static var skinIDTitleBackground = 1;
  28.    static var skinIDForm = 2;
  29.    var idNames = new Array("border_mc","back_mc","content");
  30.    var skinTitleBackground = "TitleBackground";
  31.    var skinCloseUp = "CloseButtonUp";
  32.    var skinCloseOver = "CloseButtonOver";
  33.    var skinCloseDown = "CloseButtonDown";
  34.    var skinCloseDisabled = "CloseButtonDisabled";
  35.    var clipParameters = {title:1,contentPath:1,closeButton:1};
  36.    static var mergedClipParameters = mx.core.UIObject.mergeClipParameters(mx.containers.Window.prototype.clipParameters,mx.core.ScrollView.prototype.clipParameters);
  37.    var initializing = true;
  38.    var loadingChild = false;
  39.    function Window()
  40.    {
  41.       super();
  42.    }
  43.    function set contentPath(scrollableContent)
  44.    {
  45.       if(!this.initializing)
  46.       {
  47.          if(scrollableContent == undefined)
  48.          {
  49.             this.destroyChildAt(0);
  50.          }
  51.          else
  52.          {
  53.             if(this[mx.core.View.childNameBase + 0] != undefined)
  54.             {
  55.                this.destroyChildAt(0);
  56.             }
  57.             this.createChild(scrollableContent,"content",{styleName:this});
  58.          }
  59.       }
  60.       this.__contentPath = scrollableContent;
  61.    }
  62.    function get contentPath()
  63.    {
  64.       return this.__contentPath;
  65.    }
  66.    function init(Void)
  67.    {
  68.       super.init();
  69.       this.boundingBox_mc._visible = false;
  70.       this.boundingBox_mc._width = this.boundingBox_mc._height = 0;
  71.    }
  72.    function delegateClick(obj)
  73.    {
  74.       this._parent.dispatchEvent({type:"click"});
  75.    }
  76.    function startDragging(Void)
  77.    {
  78.       if(this.modalWindow == undefined)
  79.       {
  80.          var _loc2_ = this._parent.createChildAtDepth("BoundingBox",mx.managers.DepthManager.kTop,{_visible:false});
  81.          this.swapDepths(_loc2_);
  82.          _loc2_.removeMovieClip();
  83.       }
  84.       this.regX = this._xmouse;
  85.       this.regY = this._ymouse;
  86.       this.onMouseMove = this.dragTracking;
  87.    }
  88.    function stopDragging(Void)
  89.    {
  90.       delete this.onMouseMove;
  91.    }
  92.    function dragTracking()
  93.    {
  94.       var _loc5_ = this._parent._xmouse - this.regX;
  95.       var _loc4_ = this._parent._ymouse - this.regY;
  96.       var _loc3_ = 5;
  97.       var _loc2_ = mx.managers.SystemManager.screen;
  98.       if(_loc5_ < _loc2_.x - this.regX + _loc3_)
  99.       {
  100.          _loc5_ = _loc2_.x - this.regX + _loc3_;
  101.       }
  102.       if(_loc5_ > _loc2_.width + _loc2_.x - (this.regX + _loc3_))
  103.       {
  104.          _loc5_ = _loc2_.width + _loc2_.x - (this.regX + _loc3_);
  105.       }
  106.       if(_loc4_ < _loc2_.y - this.regY + _loc3_)
  107.       {
  108.          _loc4_ = _loc2_.y - this.regY + _loc3_;
  109.       }
  110.       if(_loc4_ > _loc2_.height + _loc2_.y - (this.regY + _loc3_))
  111.       {
  112.          _loc4_ = _loc2_.height + _loc2_.y - (this.regY + _loc3_);
  113.       }
  114.       this.move(_loc5_,_loc4_);
  115.       updateAfterEvent();
  116.    }
  117.    function createChildren(Void)
  118.    {
  119.       super.createChildren();
  120.       if(this.back_mc == undefined)
  121.       {
  122.          this.createClassObject(mx.core.UIObject,"back_mc",1);
  123.          this.back_mc.createObject(this.skinTitleBackground,"back_mc",0);
  124.       }
  125.       this.back_mc.visible = false;
  126.       this.depth = 3;
  127.       var _loc6_ = new Object();
  128.       this.back_mc.useHandCursor = false;
  129.       this.back_mc.onPress = function()
  130.       {
  131.          if(this._parent.enabled)
  132.          {
  133.             this._parent.startDragging();
  134.          }
  135.       };
  136.       this.back_mc.onDragOut = this.back_mc.onRollOut = this.back_mc.onReleaseOutside = this.back_mc.onRelease = function()
  137.       {
  138.          var _loc2_ = this._parent;
  139.          _loc2_.stopDragging();
  140.       };
  141.       this.back_mc.tabEnabled = false;
  142.       if(this.back_mc.title_mc == undefined)
  143.       {
  144.          this.back_mc.createLabel("title_mc",1,this.title);
  145.          var _loc4_ = this.back_mc.title_mc;
  146.          if(this.titleStyleDeclaration == undefined)
  147.          {
  148.             _loc4_.fontSize = 10;
  149.             _loc4_.color = 16777215;
  150.             _loc4_.fontWeight = "bold";
  151.          }
  152.          else
  153.          {
  154.             _loc4_.styleName = this.titleStyleDeclaration;
  155.          }
  156.          _loc4_.invalidateStyle();
  157.       }
  158.       else
  159.       {
  160.          this.back_mc.title_mc.text = this.title;
  161.       }
  162.       var _loc3_ = new Object();
  163.       _loc3_.falseUpSkin = this.skinCloseUp;
  164.       _loc3_.falseOverSkin = this.skinCloseOver;
  165.       _loc3_.falseDownSkin = this.skinCloseDown;
  166.       _loc3_.falseDisabledSkin = this.skinCloseDisabled;
  167.       _loc3_.tabEnabled = false;
  168.       this.createClassObject(mx.controls.SimpleButton,"button_mc",2,_loc3_);
  169.       this.button_mc.clickHandler = this.delegateClick;
  170.       this.button_mc.visible = false;
  171.       if(this.validateNow)
  172.       {
  173.          this.redraw(true);
  174.       }
  175.       else
  176.       {
  177.          this.invalidate();
  178.       }
  179.    }
  180.    function get title()
  181.    {
  182.       return this._title;
  183.    }
  184.    function set title(s)
  185.    {
  186.       this._title = s;
  187.       this.back_mc.title_mc.text = s;
  188.       if(!this.initializing)
  189.       {
  190.          this.draw();
  191.       }
  192.    }
  193.    function setEnabled(enable)
  194.    {
  195.       super.setEnabled(enable);
  196.       this.button_mc.enabled = enable;
  197.       this._child0.enabled = enable;
  198.    }
  199.    function getComponentCount(Void)
  200.    {
  201.       return 1;
  202.    }
  203.    function getComponentRect(container)
  204.    {
  205.       if(container == 1)
  206.       {
  207.          var _loc3_ = this.border_mc.borderMetrics;
  208.          var _loc2_ = new Object();
  209.          _loc2_.x = _loc3_.left;
  210.          _loc2_.y = _loc3_.top + this.back_mc.height;
  211.          _loc2_.width = this.width - _loc2_.x - _loc3_.right;
  212.          _loc2_.height = this.height - _loc2_.y - _loc3_.bottom;
  213.          return _loc2_;
  214.       }
  215.       return undefined;
  216.    }
  217.    function draw(Void)
  218.    {
  219.       if(this.initializing)
  220.       {
  221.          this.initializing = false;
  222.          if(this.__contentPath != undefined)
  223.          {
  224.             this.contentPath = this.__contentPath;
  225.          }
  226.          this._child0.visible = true;
  227.          this.border_mc.visible = true;
  228.          this.back_mc.visible = true;
  229.       }
  230.       this.size();
  231.    }
  232.    function getViewMetrics(Void)
  233.    {
  234.       var _loc3_ = super.getViewMetrics();
  235.       _loc3_.top += this.back_mc.height;
  236.       return _loc3_;
  237.    }
  238.    function doLayout(Void)
  239.    {
  240.       super.doLayout();
  241.       var _loc3_ = this.border_mc.borderMetrics;
  242.       _loc3_.right += this.vScroller.visible != true ? 0 : this.vScroller.width;
  243.       _loc3_.bottom += this.hScroller.visible != true ? 0 : this.hScroller.height;
  244.       var _loc4_ = _loc3_.left;
  245.       var _loc6_ = _loc3_.top;
  246.       this.back_mc.move(_loc4_,_loc6_);
  247.       this.back_mc.back_mc.setSize(this.width - _loc4_ - _loc3_.right,this.back_mc.height);
  248.       this._child0.move(_loc4_,_loc6_ + this.back_mc.height);
  249.       if(this._child0.size != mx.core.UIObject.prototype.size)
  250.       {
  251.          this._child0.setSize(this.width - _loc4_ - _loc3_.right,this.height - _loc6_ - this.back_mc.height - _loc3_.bottom);
  252.       }
  253.       this.button_mc.visible = this.closeButton == true;
  254.       this.button_mc.move(this.width - _loc4_ - _loc4_ - this.button_mc.width,(this.back_mc.height - this.button_mc.height) / 2 + _loc6_);
  255.       var _loc7_ = this.back_mc.title_mc.textHeight;
  256.       var _loc5_ = (this.back_mc.height - _loc7_ - 4) / 2;
  257.       this.back_mc.title_mc.move(_loc5_,_loc5_ - 1);
  258.       this.back_mc.title_mc.setSize(this.width - _loc5_ - _loc5_,_loc7_ + 4);
  259.    }
  260.    function createChild(id, name, props)
  261.    {
  262.       this.loadingChild = true;
  263.       var _loc3_ = super.createChild(id,name,props);
  264.       this.loadingChild = false;
  265.       return _loc3_;
  266.    }
  267.    function childLoaded(obj)
  268.    {
  269.       super.childLoaded(obj);
  270.       if(this.loadingChild)
  271.       {
  272.          this.dispatchEvent({type:"complete",current:obj.getBytesLoaded(),total:obj.getBytesTotal()});
  273.       }
  274.    }
  275. }
  276.