home *** CD-ROM | disk | FTP | other *** search
/ Computer Active 2010 August / CA08.iso / Darbas / kidoz_v1.air / kidoz.swf / scripts / mx / core / Window.as < prev    next >
Encoding:
Text File  |  2009-05-06  |  56.7 KB  |  1,793 lines

  1. package mx.core
  2. {
  3.    import flash.desktop.NativeApplication;
  4.    import flash.display.DisplayObject;
  5.    import flash.display.Graphics;
  6.    import flash.display.NativeWindow;
  7.    import flash.display.NativeWindowDisplayState;
  8.    import flash.display.NativeWindowInitOptions;
  9.    import flash.display.NativeWindowResize;
  10.    import flash.display.Sprite;
  11.    import flash.events.Event;
  12.    import flash.events.MouseEvent;
  13.    import flash.events.NativeWindowBoundsEvent;
  14.    import flash.events.NativeWindowDisplayStateEvent;
  15.    import flash.geom.Point;
  16.    import flash.geom.Rectangle;
  17.    import flash.system.Capabilities;
  18.    import mx.controls.Button;
  19.    import mx.controls.FlexNativeMenu;
  20.    import mx.core.windowClasses.StatusBar;
  21.    import mx.core.windowClasses.TitleBar;
  22.    import mx.events.AIREvent;
  23.    import mx.events.FlexEvent;
  24.    import mx.events.FlexNativeWindowBoundsEvent;
  25.    import mx.managers.CursorManagerImpl;
  26.    import mx.managers.FocusManager;
  27.    import mx.managers.ICursorManager;
  28.    import mx.managers.ISystemManager;
  29.    import mx.managers.WindowedSystemManager;
  30.    import mx.styles.CSSStyleDeclaration;
  31.    import mx.styles.StyleManager;
  32.    import mx.styles.StyleProxy;
  33.    
  34.    use namespace mx_internal;
  35.    
  36.    public class Window extends LayoutContainer implements IWindow
  37.    {
  38.       mx_internal static const VERSION:String = "3.2.0.3958";
  39.       
  40.       private static const HEADER_PADDING:Number = 4;
  41.       
  42.       private static const MOUSE_SLACK:Number = 5;
  43.       
  44.       private static const DEFAULT_WINDOW_HEIGHT:Number = 100;
  45.       
  46.       private static const DEFAULT_WINDOW_WIDTH:Number = 100;
  47.       
  48.       private static var _statusBarStyleFilters:Object = {
  49.          "statusBarBackgroundColor":"statusBarBackgroundColor",
  50.          "statusBarBackgroundSkin":"statusBarBackgroundSkin",
  51.          "statusTextStyleName":"statusTextStyleName"
  52.       };
  53.       
  54.       private static var _titleBarStyleFilters:Object = {
  55.          "buttonAlignment":"buttonAlignment",
  56.          "buttonPadding":"buttonPadding",
  57.          "closeButtonSkin":"closeButtonSkin",
  58.          "cornerRadius":"cornerRadius",
  59.          "headerHeight":"headerHeight",
  60.          "maximizeButtonSkin":"maximizeButtonSkin",
  61.          "minimizeButtonSkin":"minimizeButtonSkin",
  62.          "restoreButtonSkin":"restoreButtonSkin",
  63.          "titleAlignment":"titleAlignment",
  64.          "titleBarBackgroundSkin":"titleBarBackgroundSkin",
  65.          "titleBarButtonPadding":"titleBarButtonPadding",
  66.          "titleBarColors":"titleBarColors",
  67.          "titleTextStyleName":"titleTextStyleName"
  68.       };
  69.       
  70.       private var showGripperChanged:Boolean = true;
  71.       
  72.       private var _maxWidth:Number = 10000;
  73.       
  74.       private var _type:String = "normal";
  75.       
  76.       mx_internal var titleBarBackground:IFlexDisplayObject;
  77.       
  78.       private var _maxHeight:Number = 10000;
  79.       
  80.       private var _menu:FlexNativeMenu;
  81.       
  82.       private var boundsChanged:Boolean = false;
  83.       
  84.       private var _showStatusBar:Boolean = true;
  85.       
  86.       private var menuChanged:Boolean = false;
  87.       
  88.       private var minHeightChanged:Boolean = false;
  89.       
  90.       private var statusChanged:Boolean = false;
  91.       
  92.       private var titleIconChanged:Boolean = false;
  93.       
  94.       private var prevX:Number;
  95.       
  96.       private var prevY:Number;
  97.       
  98.       private var maxHeightChanged:Boolean = false;
  99.       
  100.       private var gripper:Button;
  101.       
  102.       private var _showTitleBar:Boolean = true;
  103.       
  104.       private var _minHeight:Number = 0;
  105.       
  106.       private var resizeHandlerAdded:Boolean = false;
  107.       
  108.       private var _nativeWindow:NativeWindow;
  109.       
  110.       private var _nativeWindowVisible:Boolean = true;
  111.       
  112.       mx_internal var statusBarBackground:IFlexDisplayObject;
  113.       
  114.       private var _minimizable:Boolean = true;
  115.       
  116.       private var showTitleBarChanged:Boolean = true;
  117.       
  118.       private var toMax:Boolean = false;
  119.       
  120.       private var _alwaysInFront:Boolean = false;
  121.       
  122.       private var resizeHeight:Boolean = true;
  123.       
  124.       private var gripperHit:Sprite;
  125.       
  126.       private var _showGripper:Boolean = true;
  127.       
  128.       private var oldX:Number;
  129.       
  130.       private var oldY:Number;
  131.       
  132.       private var maximized:Boolean = false;
  133.       
  134.       private var _status:String = "";
  135.       
  136.       private var _resizable:Boolean = true;
  137.       
  138.       private var titleChanged:Boolean = false;
  139.       
  140.       private var _statusBar:UIComponent;
  141.       
  142.       private var _title:String = "";
  143.       
  144.       private var _statusBarFactory:IFactory = new ClassFactory(StatusBar);
  145.       
  146.       private var statusBarFactoryChanged:Boolean = false;
  147.       
  148.       private var _systemChrome:String = "standard";
  149.       
  150.       private var resizeWidth:Boolean = true;
  151.       
  152.       public var controlBar:IUIComponent;
  153.       
  154.       private var _cursorManager:ICursorManager;
  155.       
  156.       private var _titleIcon:Class;
  157.       
  158.       private var appViewMetrics:EdgeMetrics;
  159.       
  160.       private var minWidthChanged:Boolean = false;
  161.       
  162.       private var maxWidthChanged:Boolean = false;
  163.       
  164.       private var flagForOpen:Boolean = false;
  165.       
  166.       private var _titleBarFactory:IFactory = new ClassFactory(TitleBar);
  167.       
  168.       private var _transparent:Boolean = false;
  169.       
  170.       private var titleBarFactoryChanged:Boolean = false;
  171.       
  172.       private var frameCounter:int = 0;
  173.       
  174.       private var showStatusBarChanged:Boolean = true;
  175.       
  176.       private var _maximizable:Boolean = true;
  177.       
  178.       private var _bounds:Rectangle = new Rectangle(0,0,DEFAULT_WINDOW_WIDTH,DEFAULT_WINDOW_HEIGHT);
  179.       
  180.       private var openActive:Boolean = true;
  181.       
  182.       private var _minWidth:Number = 0;
  183.       
  184.       private var _titleBar:UIComponent;
  185.       
  186.       public function Window()
  187.       {
  188.          super();
  189.          addEventListener(FlexEvent.CREATION_COMPLETE,creationCompleteHandler);
  190.          addEventListener(FlexEvent.PREINITIALIZE,preinitializeHandler);
  191.          invalidateProperties();
  192.       }
  193.       
  194.       public static function getWindow(param1:UIComponent) : Window
  195.       {
  196.          if(param1.systemManager is WindowedSystemManager)
  197.          {
  198.             return WindowedSystemManager(param1.systemManager).mx_internal::window;
  199.          }
  200.          return null;
  201.       }
  202.       
  203.       public function orderInBackOf(param1:IWindow) : Boolean
  204.       {
  205.          if(Boolean(nativeWindow) && !nativeWindow.closed)
  206.          {
  207.             return nativeWindow.orderInBackOf(param1.nativeWindow);
  208.          }
  209.          return false;
  210.       }
  211.       
  212.       public function set statusBarFactory(param1:IFactory) : void
  213.       {
  214.          _statusBarFactory = param1;
  215.          statusBarFactoryChanged = true;
  216.          invalidateProperties();
  217.          dispatchEvent(new Event("statusBarFactoryChanged"));
  218.       }
  219.       
  220.       private function enterFrameHandler(param1:Event) : void
  221.       {
  222.          if(frameCounter == 2)
  223.          {
  224.             removeEventListener(Event.ENTER_FRAME,enterFrameHandler);
  225.             _nativeWindow.visible = _nativeWindowVisible;
  226.             dispatchEvent(new AIREvent(AIREvent.WINDOW_COMPLETE));
  227.             if(_nativeWindow.visible)
  228.             {
  229.                if(openActive)
  230.                {
  231.                   _nativeWindow.activate();
  232.                }
  233.             }
  234.          }
  235.          ++frameCounter;
  236.       }
  237.       
  238.       [Bindable("windowComplete")]
  239.       [Bindable("minHeightChanged")]
  240.       override public function get minHeight() : Number
  241.       {
  242.          if(Boolean(nativeWindow) && !minHeightChanged)
  243.          {
  244.             return nativeWindow.minSize.y - chromeHeight();
  245.          }
  246.          return _minHeight;
  247.       }
  248.       
  249.       override public function set minHeight(param1:Number) : void
  250.       {
  251.          _minHeight = param1;
  252.          minHeightChanged = true;
  253.          invalidateProperties();
  254.       }
  255.       
  256.       private function nativeApplication_deactivateHandler(param1:Event) : void
  257.       {
  258.          dispatchEvent(new AIREvent(AIREvent.APPLICATION_DEACTIVATE));
  259.       }
  260.       
  261.       private function chromeHeight() : Number
  262.       {
  263.          return nativeWindow.height - systemManager.stage.stageHeight;
  264.       }
  265.       
  266.       private function window_closeHandler(param1:Event) : void
  267.       {
  268.          dispatchEvent(new Event("close"));
  269.       }
  270.       
  271.       public function get showStatusBar() : Boolean
  272.       {
  273.          return _showStatusBar;
  274.       }
  275.       
  276.       override mx_internal function initThemeColor() : Boolean
  277.       {
  278.          var _loc2_:Object = null;
  279.          var _loc3_:Number = NaN;
  280.          var _loc4_:Number = NaN;
  281.          var _loc5_:CSSStyleDeclaration = null;
  282.          var _loc1_:Boolean = super.mx_internal::initThemeColor();
  283.          if(!_loc1_)
  284.          {
  285.             _loc5_ = StyleManager.getStyleDeclaration("global");
  286.             if(_loc5_)
  287.             {
  288.                _loc2_ = _loc5_.getStyle("themeColor");
  289.                _loc3_ = _loc5_.getStyle("rollOverColor");
  290.                _loc4_ = _loc5_.getStyle("selectionColor");
  291.             }
  292.             if(_loc2_ && isNaN(_loc3_) && isNaN(_loc4_))
  293.             {
  294.                mx_internal::setThemeColor(_loc2_);
  295.             }
  296.             _loc1_ = true;
  297.          }
  298.          return _loc1_;
  299.       }
  300.       
  301.       override public function set height(param1:Number) : void
  302.       {
  303.          if(param1 < minHeight)
  304.          {
  305.             param1 = minHeight;
  306.          }
  307.          else if(param1 > maxHeight)
  308.          {
  309.             param1 = maxHeight;
  310.          }
  311.          _bounds.height = param1;
  312.          boundsChanged = true;
  313.          invalidateProperties();
  314.          invalidateSize();
  315.          mx_internal::invalidateViewMetricsAndPadding();
  316.          dispatchEvent(new Event("heightChanged"));
  317.       }
  318.       
  319.       public function open(param1:Boolean = true) : void
  320.       {
  321.          flagForOpen = true;
  322.          openActive = param1;
  323.          commitProperties();
  324.       }
  325.       
  326.       private function mouseMoveHandler(param1:MouseEvent) : void
  327.       {
  328.          stage.nativeWindow.x += param1.stageX - prevX;
  329.          stage.nativeWindow.y += param1.stageY - prevY;
  330.       }
  331.       
  332.       protected function mouseDownHandler(param1:MouseEvent) : void
  333.       {
  334.          var _loc2_:int = 0;
  335.          var _loc3_:int = 0;
  336.          if(systemManager.stage.nativeWindow.systemChrome != "none")
  337.          {
  338.             return;
  339.          }
  340.          if(param1.target == gripperHit)
  341.          {
  342.             startResize(NativeWindowResize.BOTTOM_RIGHT);
  343.             param1.stopPropagation();
  344.          }
  345.          else
  346.          {
  347.             _loc2_ = Number(getStyle("borderThickness")) + 6;
  348.             _loc3_ = 12;
  349.             if(param1.stageY < Number(getStyle("borderThickness")))
  350.             {
  351.                if(param1.stageX < _loc3_)
  352.                {
  353.                   startResize(NativeWindowResize.TOP_LEFT);
  354.                }
  355.                else if(param1.stageX > width - _loc3_)
  356.                {
  357.                   startResize(NativeWindowResize.TOP_RIGHT);
  358.                }
  359.                else
  360.                {
  361.                   startResize(NativeWindowResize.TOP);
  362.                }
  363.             }
  364.             else if(param1.stageY > height - _loc2_)
  365.             {
  366.                if(param1.stageX < _loc3_)
  367.                {
  368.                   startResize(NativeWindowResize.BOTTOM_LEFT);
  369.                }
  370.                else if(param1.stageX > width - _loc3_)
  371.                {
  372.                   startResize(NativeWindowResize.BOTTOM_RIGHT);
  373.                }
  374.                else
  375.                {
  376.                   startResize(NativeWindowResize.BOTTOM);
  377.                }
  378.             }
  379.             else if(param1.stageX < _loc2_)
  380.             {
  381.                if(param1.stageY < _loc3_)
  382.                {
  383.                   startResize(NativeWindowResize.TOP_LEFT);
  384.                }
  385.                else if(param1.stageY > height - _loc3_)
  386.                {
  387.                   startResize(NativeWindowResize.BOTTOM_LEFT);
  388.                }
  389.                else
  390.                {
  391.                   startResize(NativeWindowResize.LEFT);
  392.                }
  393.                param1.stopPropagation();
  394.             }
  395.             else if(param1.stageX > width - _loc2_)
  396.             {
  397.                if(param1.stageY < _loc3_)
  398.                {
  399.                   startResize(NativeWindowResize.TOP_RIGHT);
  400.                }
  401.                else if(param1.stageY > height - _loc3_)
  402.                {
  403.                   startResize(NativeWindowResize.BOTTOM_RIGHT);
  404.                }
  405.                else
  406.                {
  407.                   startResize(NativeWindowResize.RIGHT);
  408.                }
  409.             }
  410.          }
  411.       }
  412.       
  413.       override public function get viewMetrics() : EdgeMetrics
  414.       {
  415.          var _loc3_:Number = NaN;
  416.          var _loc4_:Number = NaN;
  417.          var _loc1_:EdgeMetrics = super.viewMetrics;
  418.          var _loc2_:EdgeMetrics = new EdgeMetrics(_loc1_.left,_loc1_.top,_loc1_.right,_loc1_.bottom);
  419.          if(showTitleBar)
  420.          {
  421.             _loc3_ = getHeaderHeight();
  422.             if(!isNaN(_loc3_))
  423.             {
  424.                _loc2_.top += _loc3_;
  425.             }
  426.          }
  427.          if(showStatusBar)
  428.          {
  429.             _loc4_ = getStatusBarHeight();
  430.             if(!isNaN(_loc4_))
  431.             {
  432.                _loc2_.bottom += _loc4_;
  433.             }
  434.          }
  435.          if(Boolean(controlBar) && Boolean(controlBar.includeInLayout))
  436.          {
  437.             _loc2_.top += controlBar.getExplicitOrMeasuredHeight();
  438.          }
  439.          return _loc2_;
  440.       }
  441.       
  442.       [Bindable("titleChanged")]
  443.       public function get title() : String
  444.       {
  445.          return _title;
  446.       }
  447.       
  448.       private function window_moveHandler(param1:NativeWindowBoundsEvent) : void
  449.       {
  450.          var _loc2_:FlexNativeWindowBoundsEvent = new FlexNativeWindowBoundsEvent(FlexNativeWindowBoundsEvent.WINDOW_MOVE,param1.bubbles,param1.cancelable,param1.beforeBounds,param1.afterBounds);
  451.          dispatchEvent(_loc2_);
  452.       }
  453.       
  454.       protected function get statusBarStyleFilters() : Object
  455.       {
  456.          return _statusBarStyleFilters;
  457.       }
  458.       
  459.       [Bindable("windowComplete")]
  460.       [Bindable("show")]
  461.       [Bindable("hide")]
  462.       override public function get visible() : Boolean
  463.       {
  464.          if(!nativeWindow.closed)
  465.          {
  466.             return _nativeWindow.visible;
  467.          }
  468.          return false;
  469.       }
  470.       
  471.       public function set type(param1:String) : void
  472.       {
  473.          if(!_nativeWindow)
  474.          {
  475.             _type = param1;
  476.             invalidateProperties();
  477.          }
  478.       }
  479.       
  480.       public function get minimizable() : Boolean
  481.       {
  482.          return _minimizable;
  483.       }
  484.       
  485.       public function restore() : void
  486.       {
  487.          var _loc1_:NativeWindowDisplayStateEvent = null;
  488.          if(!nativeWindow.closed)
  489.          {
  490.             if(stage.nativeWindow.displayState == NativeWindowDisplayState.MAXIMIZED)
  491.             {
  492.                _loc1_ = new NativeWindowDisplayStateEvent(NativeWindowDisplayStateEvent.DISPLAY_STATE_CHANGING,false,true,NativeWindowDisplayState.MAXIMIZED,NativeWindowDisplayState.NORMAL);
  493.                stage.nativeWindow.dispatchEvent(_loc1_);
  494.                if(!_loc1_.isDefaultPrevented())
  495.                {
  496.                   nativeWindow.restore();
  497.                }
  498.             }
  499.             else if(stage.nativeWindow.displayState == NativeWindowDisplayState.MINIMIZED)
  500.             {
  501.                _loc1_ = new NativeWindowDisplayStateEvent(NativeWindowDisplayStateEvent.DISPLAY_STATE_CHANGING,false,true,NativeWindowDisplayState.MINIMIZED,NativeWindowDisplayState.NORMAL);
  502.                stage.nativeWindow.dispatchEvent(_loc1_);
  503.                if(!_loc1_.isDefaultPrevented())
  504.                {
  505.                   nativeWindow.restore();
  506.                }
  507.             }
  508.          }
  509.       }
  510.       
  511.       public function set showStatusBar(param1:Boolean) : void
  512.       {
  513.          if(_showStatusBar == param1)
  514.          {
  515.             return;
  516.          }
  517.          _showStatusBar = param1;
  518.          showStatusBarChanged = true;
  519.          invalidateProperties();
  520.          invalidateDisplayList();
  521.       }
  522.       
  523.       private function getHeaderHeight() : Number
  524.       {
  525.          if(!nativeWindow.closed)
  526.          {
  527.             if(getStyle("headerHeight") != null)
  528.             {
  529.                return getStyle("headerHeight");
  530.             }
  531.             if(!systemManager.stage)
  532.             {
  533.                return 0;
  534.             }
  535.             if(systemManager.stage.nativeWindow.systemChrome != "none")
  536.             {
  537.                return 0;
  538.             }
  539.             if(titleBar)
  540.             {
  541.                return titleBar.getExplicitOrMeasuredHeight();
  542.             }
  543.          }
  544.          return 0;
  545.       }
  546.       
  547.       [Bindable("windowComplete")]
  548.       [Bindable("minWidthChanged")]
  549.       override public function get minWidth() : Number
  550.       {
  551.          if(Boolean(nativeWindow) && !minWidthChanged)
  552.          {
  553.             return nativeWindow.minSize.x - chromeWidth();
  554.          }
  555.          return _minWidth;
  556.       }
  557.       
  558.       public function minimize() : void
  559.       {
  560.          var _loc1_:NativeWindowDisplayStateEvent = null;
  561.          if(!nativeWindow.closed)
  562.          {
  563.             _loc1_ = new NativeWindowDisplayStateEvent(NativeWindowDisplayStateEvent.DISPLAY_STATE_CHANGING,false,true,nativeWindow.displayState,NativeWindowDisplayState.MINIMIZED);
  564.             stage.nativeWindow.dispatchEvent(_loc1_);
  565.             if(!_loc1_.isDefaultPrevented())
  566.             {
  567.                stage.nativeWindow.minimize();
  568.             }
  569.          }
  570.       }
  571.       
  572.       public function get titleBar() : UIComponent
  573.       {
  574.          return _titleBar;
  575.       }
  576.       
  577.       public function set transparent(param1:Boolean) : void
  578.       {
  579.          if(!_nativeWindow)
  580.          {
  581.             _transparent = param1;
  582.             invalidateProperties();
  583.          }
  584.       }
  585.       
  586.       public function get resizable() : Boolean
  587.       {
  588.          return _resizable;
  589.       }
  590.       
  591.       public function set title(param1:String) : void
  592.       {
  593.          titleChanged = true;
  594.          _title = param1;
  595.          invalidateProperties();
  596.          invalidateSize();
  597.          mx_internal::invalidateViewMetricsAndPadding();
  598.          invalidateDisplayList();
  599.          dispatchEvent(new Event("titleChanged"));
  600.       }
  601.       
  602.       protected function get bounds() : Rectangle
  603.       {
  604.          return _bounds;
  605.       }
  606.       
  607.       public function get showTitleBar() : Boolean
  608.       {
  609.          return _showTitleBar;
  610.       }
  611.       
  612.       private function windowMinimizeHandler(param1:Event) : void
  613.       {
  614.          if(!nativeWindow.closed)
  615.          {
  616.             stage.nativeWindow.minimize();
  617.          }
  618.          removeEventListener("effectEnd",windowMinimizeHandler);
  619.       }
  620.       
  621.       public function set menu(param1:FlexNativeMenu) : void
  622.       {
  623.          _menu = param1;
  624.          menuChanged = true;
  625.       }
  626.       
  627.       public function get statusBar() : UIComponent
  628.       {
  629.          return _statusBar;
  630.       }
  631.       
  632.       [Bindable("windowComplete")]
  633.       [Bindable("maxWidthChanged")]
  634.       override public function get maxWidth() : Number
  635.       {
  636.          if(Boolean(nativeWindow) && !maxWidthChanged)
  637.          {
  638.             return nativeWindow.maxSize.x - chromeWidth();
  639.          }
  640.          return _maxWidth;
  641.       }
  642.       
  643.       private function window_boundsHandler(param1:NativeWindowBoundsEvent) : void
  644.       {
  645.          var _loc3_:Rectangle = null;
  646.          var _loc4_:Boolean = false;
  647.          var _loc2_:Rectangle = param1.afterBounds;
  648.          if(param1.type == NativeWindowBoundsEvent.MOVING)
  649.          {
  650.             dispatchEvent(param1);
  651.             if(param1.isDefaultPrevented())
  652.             {
  653.                return;
  654.             }
  655.          }
  656.          else
  657.          {
  658.             dispatchEvent(param1);
  659.             if(param1.isDefaultPrevented())
  660.             {
  661.                return;
  662.             }
  663.             _loc4_ = false;
  664.             if(_loc2_.width < nativeWindow.minSize.x)
  665.             {
  666.                _loc4_ = true;
  667.                if(_loc2_.x != param1.beforeBounds.x && !isNaN(oldX))
  668.                {
  669.                   _loc2_.x = oldX;
  670.                }
  671.                _loc2_.width = nativeWindow.minSize.x;
  672.             }
  673.             else if(_loc2_.width > nativeWindow.maxSize.x)
  674.             {
  675.                _loc4_ = true;
  676.                if(_loc2_.x != param1.beforeBounds.x && !isNaN(oldX))
  677.                {
  678.                   _loc2_.x = oldX;
  679.                }
  680.                _loc2_.width = nativeWindow.maxSize.x;
  681.             }
  682.             if(_loc2_.height < nativeWindow.minSize.y)
  683.             {
  684.                _loc4_ = true;
  685.                if(param1.afterBounds.y != param1.beforeBounds.y && !isNaN(oldY))
  686.                {
  687.                   _loc2_.y = oldY;
  688.                }
  689.                _loc2_.height = nativeWindow.minSize.y;
  690.             }
  691.             else if(_loc2_.height > nativeWindow.maxSize.y)
  692.             {
  693.                _loc4_ = true;
  694.                if(param1.afterBounds.y != param1.beforeBounds.y && !isNaN(oldY))
  695.                {
  696.                   _loc2_.y = oldY;
  697.                }
  698.                _loc2_.height = nativeWindow.maxSize.y;
  699.             }
  700.             if(_loc4_)
  701.             {
  702.                param1.preventDefault();
  703.                stage.nativeWindow.bounds = _loc2_;
  704.             }
  705.          }
  706.          oldX = _loc2_.x;
  707.          oldY = _loc2_.y;
  708.       }
  709.       
  710.       public function get showGripper() : Boolean
  711.       {
  712.          return _showGripper;
  713.       }
  714.       
  715.       public function maximize() : void
  716.       {
  717.          var _loc1_:NativeWindowDisplayStateEvent = null;
  718.          if(!nativeWindow || !nativeWindow.maximizable || Boolean(nativeWindow.closed))
  719.          {
  720.             return;
  721.          }
  722.          if(stage.nativeWindow.displayState != NativeWindowDisplayState.MAXIMIZED)
  723.          {
  724.             _loc1_ = new NativeWindowDisplayStateEvent(NativeWindowDisplayStateEvent.DISPLAY_STATE_CHANGING,false,true,stage.nativeWindow.displayState,NativeWindowDisplayState.MAXIMIZED);
  725.             stage.nativeWindow.dispatchEvent(_loc1_);
  726.             if(!_loc1_.isDefaultPrevented())
  727.             {
  728.                toMax = true;
  729.                invalidateProperties();
  730.                invalidateSize();
  731.             }
  732.          }
  733.       }
  734.       
  735.       private function windowMaximizeHandler(param1:Event) : void
  736.       {
  737.          removeEventListener("effectEnd",windowMaximizeHandler);
  738.          if(!nativeWindow.closed)
  739.          {
  740.             stage.nativeWindow.maximize();
  741.          }
  742.       }
  743.       
  744.       private function nativeWindow_deactivateHandler(param1:Event) : void
  745.       {
  746.          dispatchEvent(new AIREvent(AIREvent.WINDOW_DEACTIVATE));
  747.       }
  748.       
  749.       public function get nativeWindow() : NativeWindow
  750.       {
  751.          if(Boolean(systemManager) && Boolean(systemManager.stage))
  752.          {
  753.             return systemManager.stage.nativeWindow;
  754.          }
  755.          return null;
  756.       }
  757.       
  758.       [Bindable("titleIconChanged")]
  759.       public function get titleIcon() : Class
  760.       {
  761.          return _titleIcon;
  762.       }
  763.       
  764.       private function creationCompleteHandler(param1:Event = null) : void
  765.       {
  766.          systemManager.stage.nativeWindow.addEventListener("closing",window_closingHandler);
  767.          systemManager.stage.nativeWindow.addEventListener("close",window_closeHandler,false,0,true);
  768.          systemManager.stage.nativeWindow.addEventListener(NativeWindowBoundsEvent.MOVING,window_boundsHandler);
  769.          systemManager.stage.nativeWindow.addEventListener(NativeWindowBoundsEvent.MOVE,window_moveHandler);
  770.          systemManager.stage.nativeWindow.addEventListener(NativeWindowBoundsEvent.RESIZING,window_boundsHandler);
  771.          systemManager.stage.nativeWindow.addEventListener(NativeWindowBoundsEvent.RESIZE,window_resizeHandler);
  772.       }
  773.       
  774.       override public function set visible(param1:Boolean) : void
  775.       {
  776.          var _loc2_:FlexEvent = null;
  777.          if(!_nativeWindow)
  778.          {
  779.             _nativeWindowVisible = param1;
  780.             invalidateProperties();
  781.          }
  782.          else if(!_nativeWindow.closed)
  783.          {
  784.             if(param1)
  785.             {
  786.                _nativeWindow.visible = param1;
  787.                _loc2_ = new FlexEvent(FlexEvent.SHOW);
  788.                dispatchEvent(_loc2_);
  789.             }
  790.             else
  791.             {
  792.                _loc2_ = new FlexEvent(FlexEvent.HIDE);
  793.                if(getStyle("hideEffect"))
  794.                {
  795.                   addEventListener("effectEnd",hideEffectEndHandler);
  796.                }
  797.                else
  798.                {
  799.                   _nativeWindow.visible = param1;
  800.                   dispatchEvent(_loc2_);
  801.                }
  802.             }
  803.          }
  804.       }
  805.       
  806.       public function get alwaysInFront() : Boolean
  807.       {
  808.          if(Boolean(_nativeWindow) && !_nativeWindow.closed)
  809.          {
  810.             return nativeWindow.alwaysInFront;
  811.          }
  812.          return _alwaysInFront;
  813.       }
  814.       
  815.       public function orderToBack() : Boolean
  816.       {
  817.          if(Boolean(nativeWindow) && !nativeWindow.closed)
  818.          {
  819.             return nativeWindow.orderToBack();
  820.          }
  821.          return false;
  822.       }
  823.       
  824.       public function set minimizable(param1:Boolean) : void
  825.       {
  826.          if(!_nativeWindow)
  827.          {
  828.             _minimizable = param1;
  829.             invalidateProperties();
  830.          }
  831.       }
  832.       
  833.       private function windowUnminimizeHandler(param1:Event) : void
  834.       {
  835.          removeEventListener("effectEnd",windowUnminimizeHandler);
  836.       }
  837.       
  838.       private function window_closingHandler(param1:Event) : void
  839.       {
  840.          var _loc2_:Event = new Event("closing",true,true);
  841.          dispatchEvent(_loc2_);
  842.          if(_loc2_.isDefaultPrevented())
  843.          {
  844.             param1.preventDefault();
  845.          }
  846.          else if(getStyle("closeEffect") && stage.nativeWindow.transparent == true)
  847.          {
  848.             addEventListener("effectEnd",window_closeEffectEndHandler);
  849.             dispatchEvent(new Event("windowClose"));
  850.             param1.preventDefault();
  851.          }
  852.       }
  853.       
  854.       [Bindable("statusBarFactoryChanged")]
  855.       public function get statusBarFactory() : IFactory
  856.       {
  857.          return _statusBarFactory;
  858.       }
  859.       
  860.       public function activate() : void
  861.       {
  862.          if(!nativeWindow.closed)
  863.          {
  864.             _nativeWindow.activate();
  865.          }
  866.       }
  867.       
  868.       private function windowUnmaximizeHandler(param1:Event) : void
  869.       {
  870.          removeEventListener("effectEnd",windowUnmaximizeHandler);
  871.          if(!nativeWindow.closed)
  872.          {
  873.             stage.nativeWindow.restore();
  874.          }
  875.       }
  876.       
  877.       override protected function createChildren() : void
  878.       {
  879.          var _loc1_:String = null;
  880.          var _loc2_:CSSStyleDeclaration = null;
  881.          width = _bounds.width;
  882.          height = _bounds.height;
  883.          super.createChildren();
  884.          if(getStyle("showFlexChrome") == false || getStyle("showFlexChrome") == "false")
  885.          {
  886.             setStyle("borderStyle","none");
  887.             setStyle("backgroundAlpha",0);
  888.             return;
  889.          }
  890.          if(systemManager.stage.nativeWindow.type != "utility")
  891.          {
  892.             if(!_statusBar)
  893.             {
  894.                _statusBar = statusBarFactory.newInstance();
  895.                _statusBar.styleName = new StyleProxy(this,statusBarStyleFilters);
  896.                rawChildren.addChild(DisplayObject(_statusBar));
  897.                showStatusBarChanged = true;
  898.             }
  899.          }
  900.          if(!gripper)
  901.          {
  902.             gripper = new Button();
  903.             _loc1_ = getStyle("gripperStyleName");
  904.             if(_loc1_)
  905.             {
  906.                _loc2_ = StyleManager.getStyleDeclaration("." + _loc1_);
  907.                gripper.styleName = _loc1_;
  908.             }
  909.             gripper.tabEnabled = false;
  910.             rawChildren.addChild(gripper);
  911.             gripperHit = new Sprite();
  912.             rawChildren.addChild(gripperHit);
  913.             gripperHit.addEventListener(MouseEvent.MOUSE_DOWN,mouseDownHandler);
  914.          }
  915.          if(systemManager.stage.nativeWindow.systemChrome != "none")
  916.          {
  917.             setStyle("borderStyle","none");
  918.             return;
  919.          }
  920.          if(!_titleBar)
  921.          {
  922.             _titleBar = titleBarFactory.newInstance();
  923.             _titleBar.styleName = new StyleProxy(this,titleBarStyleFilters);
  924.             rawChildren.addChild(DisplayObject(titleBar));
  925.             showTitleBarChanged = true;
  926.          }
  927.       }
  928.       
  929.       public function set systemChrome(param1:String) : void
  930.       {
  931.          if(!_nativeWindow)
  932.          {
  933.             _systemChrome = param1;
  934.             invalidateProperties();
  935.          }
  936.       }
  937.       
  938.       private function mouseUpHandler(param1:MouseEvent) : void
  939.       {
  940.          removeEventListener(MouseEvent.MOUSE_MOVE,mouseMoveHandler);
  941.          removeEventListener(MouseEvent.MOUSE_UP,mouseUpHandler);
  942.       }
  943.       
  944.       public function set maximizable(param1:Boolean) : void
  945.       {
  946.          if(!_nativeWindow)
  947.          {
  948.             _maximizable = param1;
  949.             invalidateProperties();
  950.          }
  951.       }
  952.       
  953.       override public function set minWidth(param1:Number) : void
  954.       {
  955.          _minWidth = param1;
  956.          minWidthChanged = true;
  957.          invalidateProperties();
  958.       }
  959.       
  960.       public function getStatusBarHeight() : Number
  961.       {
  962.          if(_statusBar)
  963.          {
  964.             return _statusBar.getExplicitOrMeasuredHeight();
  965.          }
  966.          return 0;
  967.       }
  968.       
  969.       [Bindable("heightChanged")]
  970.       override public function get height() : Number
  971.       {
  972.          return _bounds.height;
  973.       }
  974.       
  975.       public function get type() : String
  976.       {
  977.          return _type;
  978.       }
  979.       
  980.       public function orderToFront() : Boolean
  981.       {
  982.          if(Boolean(nativeWindow) && !nativeWindow.closed)
  983.          {
  984.             return nativeWindow.orderToFront();
  985.          }
  986.          return false;
  987.       }
  988.       
  989.       private function window_displayStateChangeHandler(param1:NativeWindowDisplayStateEvent) : void
  990.       {
  991.          dispatchEvent(param1);
  992.          height = stage.stageHeight;
  993.          width = stage.stageWidth;
  994.       }
  995.       
  996.       protected function get titleBarStyleFilters() : Object
  997.       {
  998.          return _titleBarStyleFilters;
  999.       }
  1000.       
  1001.       public function orderInFrontOf(param1:IWindow) : Boolean
  1002.       {
  1003.          if(Boolean(nativeWindow) && !nativeWindow.closed)
  1004.          {
  1005.             return nativeWindow.orderInFrontOf(param1.nativeWindow);
  1006.          }
  1007.          return false;
  1008.       }
  1009.       
  1010.       private function nativeApplication_activateHandler(param1:Event) : void
  1011.       {
  1012.          dispatchEvent(new AIREvent(AIREvent.APPLICATION_ACTIVATE));
  1013.       }
  1014.       
  1015.       public function get transparent() : Boolean
  1016.       {
  1017.          return _transparent;
  1018.       }
  1019.       
  1020.       private function startMove(param1:MouseEvent) : void
  1021.       {
  1022.          addEventListener(MouseEvent.MOUSE_MOVE,mouseMoveHandler);
  1023.          addEventListener(MouseEvent.MOUSE_UP,mouseUpHandler);
  1024.          prevX = param1.stageX;
  1025.          prevY = param1.stageY;
  1026.       }
  1027.       
  1028.       override public function set maxHeight(param1:Number) : void
  1029.       {
  1030.          _maxHeight = param1;
  1031.          maxHeightChanged = true;
  1032.          invalidateProperties();
  1033.       }
  1034.       
  1035.       private function preinitializeHandler(param1:FlexEvent) : void
  1036.       {
  1037.          systemManager.stage.nativeWindow.addEventListener(NativeWindowDisplayStateEvent.DISPLAY_STATE_CHANGING,window_displayStateChangingHandler);
  1038.          systemManager.stage.nativeWindow.addEventListener(NativeWindowDisplayStateEvent.DISPLAY_STATE_CHANGE,window_displayStateChangeHandler);
  1039.       }
  1040.       
  1041.       public function set resizable(param1:Boolean) : void
  1042.       {
  1043.          if(!_nativeWindow)
  1044.          {
  1045.             _resizable = param1;
  1046.             invalidateProperties();
  1047.          }
  1048.       }
  1049.       
  1050.       override protected function measure() : void
  1051.       {
  1052.          if(maximized)
  1053.          {
  1054.             maximized = false;
  1055.             if(!nativeWindow.closed)
  1056.             {
  1057.                systemManager.stage.nativeWindow.maximize();
  1058.             }
  1059.          }
  1060.          super.measure();
  1061.       }
  1062.       
  1063.       public function get menu() : FlexNativeMenu
  1064.       {
  1065.          return _menu;
  1066.       }
  1067.       
  1068.       private function window_displayStateChangingHandler(param1:NativeWindowDisplayStateEvent) : void
  1069.       {
  1070.          dispatchEvent(param1);
  1071.          if(param1.isDefaultPrevented())
  1072.          {
  1073.             return;
  1074.          }
  1075.          if(param1.afterDisplayState == NativeWindowDisplayState.MINIMIZED)
  1076.          {
  1077.             if(getStyle("minimizeEffect"))
  1078.             {
  1079.                param1.preventDefault();
  1080.                addEventListener("effectEnd",windowMinimizeHandler);
  1081.                dispatchEvent(new Event("windowMinimize"));
  1082.             }
  1083.          }
  1084.          else if(param1.beforeDisplayState == NativeWindowDisplayState.MINIMIZED)
  1085.          {
  1086.             addEventListener("effectEnd",windowUnminimizeHandler);
  1087.             dispatchEvent(new Event("windowUnminimize"));
  1088.          }
  1089.       }
  1090.       
  1091.       private function window_closeEffectEndHandler(param1:Event) : void
  1092.       {
  1093.          removeEventListener("effectEnd",window_closeEffectEndHandler);
  1094.          if(!nativeWindow.closed)
  1095.          {
  1096.             stage.nativeWindow.close();
  1097.          }
  1098.       }
  1099.       
  1100.       protected function set bounds(param1:Rectangle) : void
  1101.       {
  1102.          _bounds = param1;
  1103.          boundsChanged = true;
  1104.          invalidateProperties();
  1105.          invalidateSize();
  1106.          mx_internal::invalidateViewMetricsAndPadding();
  1107.       }
  1108.       
  1109.       public function get closed() : Boolean
  1110.       {
  1111.          return nativeWindow.closed;
  1112.       }
  1113.       
  1114.       public function set showTitleBar(param1:Boolean) : void
  1115.       {
  1116.          if(_showTitleBar == param1)
  1117.          {
  1118.             return;
  1119.          }
  1120.          _showTitleBar = param1;
  1121.          showTitleBarChanged = true;
  1122.          invalidateProperties();
  1123.          invalidateDisplayList();
  1124.       }
  1125.       
  1126.       private function chromeWidth() : Number
  1127.       {
  1128.          return nativeWindow.width - systemManager.stage.stageWidth;
  1129.       }
  1130.       
  1131.       override public function get cursorManager() : ICursorManager
  1132.       {
  1133.          return _cursorManager;
  1134.       }
  1135.       
  1136.       private function closeButton_clickHandler(param1:Event) : void
  1137.       {
  1138.          if(!nativeWindow.closed)
  1139.          {
  1140.             stage.nativeWindow.close();
  1141.          }
  1142.       }
  1143.       
  1144.       private function nativeWindow_activateHandler(param1:Event) : void
  1145.       {
  1146.          dispatchEvent(new AIREvent(AIREvent.WINDOW_ACTIVATE));
  1147.       }
  1148.       
  1149.       override public function set maxWidth(param1:Number) : void
  1150.       {
  1151.          _maxWidth = param1;
  1152.          maxWidthChanged = true;
  1153.          invalidateProperties();
  1154.       }
  1155.       
  1156.       override public function validateDisplayList() : void
  1157.       {
  1158.          var _loc1_:Graphics = null;
  1159.          super.validateDisplayList();
  1160.          if(Capabilities.os.substring(0,3) == "Mac" && systemChrome == "standard")
  1161.          {
  1162.             if((horizontalScrollBar || verticalScrollBar) && !(Boolean(horizontalScrollBar) && Boolean(verticalScrollBar)) && !showStatusBar)
  1163.             {
  1164.                if(!whiteBox)
  1165.                {
  1166.                   whiteBox = new FlexShape();
  1167.                   whiteBox.name = "whiteBox";
  1168.                   _loc1_ = whiteBox.graphics;
  1169.                   _loc1_.beginFill(16777215);
  1170.                   _loc1_.drawRect(0,0,!!verticalScrollBar ? verticalScrollBar.minWidth : 15,!!horizontalScrollBar ? horizontalScrollBar.minHeight : 15);
  1171.                   _loc1_.endFill();
  1172.                   rawChildren.addChild(whiteBox);
  1173.                }
  1174.                whiteBox.visible = true;
  1175.                if(horizontalScrollBar)
  1176.                {
  1177.                   horizontalScrollBar.setActualSize(horizontalScrollBar.width - whiteBox.width,horizontalScrollBar.height);
  1178.                }
  1179.                if(verticalScrollBar)
  1180.                {
  1181.                   verticalScrollBar.setActualSize(verticalScrollBar.width,verticalScrollBar.height - whiteBox.height);
  1182.                }
  1183.                whiteBox.x = systemManager.stage.stageWidth - whiteBox.width;
  1184.                whiteBox.y = systemManager.stage.stageHeight - whiteBox.height;
  1185.             }
  1186.             else if(!(Boolean(horizontalScrollBar) && Boolean(verticalScrollBar)))
  1187.             {
  1188.                if(whiteBox)
  1189.                {
  1190.                   rawChildren.removeChild(whiteBox);
  1191.                   whiteBox = null;
  1192.                }
  1193.             }
  1194.          }
  1195.          else if(gripper && showGripper && !showStatusBar)
  1196.          {
  1197.             if(whiteBox)
  1198.             {
  1199.                whiteBox.visible = false;
  1200.                if(gripperHit.height > whiteBox.height)
  1201.                {
  1202.                   verticalScrollBar.setActualSize(verticalScrollBar.width,verticalScrollBar.height - (gripperHit.height - whiteBox.height));
  1203.                }
  1204.                if(gripperHit.width > whiteBox.width)
  1205.                {
  1206.                   horizontalScrollBar.setActualSize(horizontalScrollBar.width - (gripperHit.width - whiteBox.height),horizontalScrollBar.height);
  1207.                }
  1208.             }
  1209.             else if(horizontalScrollBar)
  1210.             {
  1211.                horizontalScrollBar.setActualSize(horizontalScrollBar.width - gripperHit.width,horizontalScrollBar.height);
  1212.             }
  1213.             else if(verticalScrollBar)
  1214.             {
  1215.                verticalScrollBar.setActualSize(verticalScrollBar.width,verticalScrollBar.height - gripperHit.height);
  1216.             }
  1217.          }
  1218.          else if(whiteBox)
  1219.          {
  1220.             whiteBox.visible = true;
  1221.          }
  1222.       }
  1223.       
  1224.       override public function set width(param1:Number) : void
  1225.       {
  1226.          if(param1 < minWidth)
  1227.          {
  1228.             param1 = minWidth;
  1229.          }
  1230.          else if(param1 > maxWidth)
  1231.          {
  1232.             param1 = maxWidth;
  1233.          }
  1234.          _bounds.width = param1;
  1235.          boundsChanged = true;
  1236.          invalidateProperties();
  1237.          invalidateSize();
  1238.          mx_internal::invalidateViewMetricsAndPadding();
  1239.          dispatchEvent(new Event("widthChanged"));
  1240.       }
  1241.       
  1242.       private function initManagers(param1:ISystemManager) : void
  1243.       {
  1244.          if(param1.isTopLevel())
  1245.          {
  1246.             focusManager = new FocusManager(this);
  1247.             param1.activate(this);
  1248.             _cursorManager = new CursorManagerImpl(param1);
  1249.          }
  1250.       }
  1251.       
  1252.       override public function initialize() : void
  1253.       {
  1254.          var _loc2_:Object = null;
  1255.          var _loc1_:ISystemManager = systemManager;
  1256.          if(mx_internal::documentDescriptor)
  1257.          {
  1258.             creationPolicy = mx_internal::documentDescriptor.properties.creationPolicy;
  1259.             if(creationPolicy == null || creationPolicy.length == 0)
  1260.             {
  1261.                creationPolicy = ContainerCreationPolicy.AUTO;
  1262.             }
  1263.             _loc2_ = mx_internal::documentDescriptor.properties;
  1264.             if(_loc2_.width != null)
  1265.             {
  1266.                width = _loc2_.width;
  1267.                delete _loc2_.width;
  1268.             }
  1269.             if(_loc2_.height != null)
  1270.             {
  1271.                height = _loc2_.height;
  1272.                delete _loc2_.height;
  1273.             }
  1274.             mx_internal::documentDescriptor.events = null;
  1275.          }
  1276.          super.initialize();
  1277.       }
  1278.       
  1279.       public function set showGripper(param1:Boolean) : void
  1280.       {
  1281.          if(_showGripper == param1)
  1282.          {
  1283.             return;
  1284.          }
  1285.          _showGripper = param1;
  1286.          showGripperChanged = true;
  1287.          invalidateProperties();
  1288.          invalidateDisplayList();
  1289.       }
  1290.       
  1291.       public function get systemChrome() : String
  1292.       {
  1293.          return _systemChrome;
  1294.       }
  1295.       
  1296.       public function get maximizable() : Boolean
  1297.       {
  1298.          return _maximizable;
  1299.       }
  1300.       
  1301.       [Bindable("windowComplete")]
  1302.       [Bindable("maxHeightChanged")]
  1303.       override public function get maxHeight() : Number
  1304.       {
  1305.          if(Boolean(nativeWindow) && !maxHeightChanged)
  1306.          {
  1307.             return nativeWindow.maxSize.y - chromeHeight();
  1308.          }
  1309.          return _maxHeight;
  1310.       }
  1311.       
  1312.       private function startResize(param1:String) : void
  1313.       {
  1314.          if(resizable && !nativeWindow.closed)
  1315.          {
  1316.             stage.nativeWindow.startResize(param1);
  1317.          }
  1318.       }
  1319.       
  1320.       private function nativeApplication_networkChangeHandler(param1:Event) : void
  1321.       {
  1322.          dispatchEvent(param1);
  1323.       }
  1324.       
  1325.       private function hideEffectEndHandler(param1:Event) : void
  1326.       {
  1327.          _nativeWindow.visible = false;
  1328.          dispatchEvent(new FlexEvent(FlexEvent.HIDE));
  1329.       }
  1330.       
  1331.       override public function styleChanged(param1:String) : void
  1332.       {
  1333.          super.styleChanged(param1);
  1334.          if(!nativeWindow.closed)
  1335.          {
  1336.             if(!(getStyle("showFlexChrome") == "false" || getStyle("showFlexChrome") == false))
  1337.             {
  1338.                if(param1 == null || param1 == "headerHeight" || param1 == "gripperPadding")
  1339.                {
  1340.                   mx_internal::invalidateViewMetricsAndPadding();
  1341.                   invalidateDisplayList();
  1342.                   invalidateSize();
  1343.                }
  1344.             }
  1345.          }
  1346.       }
  1347.       
  1348.       [Bindable("widthChanged")]
  1349.       override public function get width() : Number
  1350.       {
  1351.          return _bounds.width;
  1352.       }
  1353.       
  1354.       override protected function commitProperties() : void
  1355.       {
  1356.          var _loc1_:NativeWindowInitOptions = null;
  1357.          var _loc2_:WindowedSystemManager = null;
  1358.          var _loc3_:NativeApplication = null;
  1359.          var _loc4_:Object = null;
  1360.          var _loc5_:Number = NaN;
  1361.          var _loc6_:Number = NaN;
  1362.          var _loc7_:Number = NaN;
  1363.          var _loc8_:Number = NaN;
  1364.          var _loc9_:Number = NaN;
  1365.          var _loc10_:Number = NaN;
  1366.          super.commitProperties();
  1367.          if(flagForOpen && !_nativeWindow)
  1368.          {
  1369.             _loc1_ = new NativeWindowInitOptions();
  1370.             _loc1_.maximizable = _maximizable;
  1371.             _loc1_.minimizable = _minimizable;
  1372.             _loc1_.resizable = _resizable;
  1373.             _loc1_.type = _type;
  1374.             _loc1_.systemChrome = _systemChrome;
  1375.             _loc1_.transparent = _transparent;
  1376.             _nativeWindow = new NativeWindow(_loc1_);
  1377.             _loc2_ = new WindowedSystemManager(this);
  1378.             _nativeWindow.stage.addChild(_loc2_);
  1379.             systemManager = _loc2_;
  1380.             _loc2_.mx_internal::window = this;
  1381.             _nativeWindow.alwaysInFront = _alwaysInFront;
  1382.             initManagers(_loc2_);
  1383.             addEventListener(MouseEvent.MOUSE_DOWN,mouseDownHandler);
  1384.             _loc3_ = NativeApplication.nativeApplication;
  1385.             _loc3_.addEventListener(Event.ACTIVATE,nativeApplication_activateHandler,false,0,true);
  1386.             _loc3_.addEventListener(Event.DEACTIVATE,nativeApplication_deactivateHandler,false,0,true);
  1387.             _loc3_.addEventListener(Event.NETWORK_CHANGE,nativeApplication_networkChangeHandler,false,0,true);
  1388.             _nativeWindow.addEventListener("activate",nativeWindow_activateHandler,false,0,true);
  1389.             _nativeWindow.addEventListener("deactivate",nativeWindow_deactivateHandler,false,0,true);
  1390.             addEventListener(Event.ENTER_FRAME,enterFrameHandler);
  1391.             _loc4_ = StyleManager.mx_internal::stylesRoot;
  1392.             _loc2_.mx_internal::addWindow(this);
  1393.          }
  1394.          if(minWidthChanged || minHeightChanged)
  1395.          {
  1396.             _loc5_ = minWidthChanged ? _minWidth + chromeWidth() : Number(nativeWindow.minSize.x);
  1397.             _loc6_ = minHeightChanged ? _minHeight + chromeHeight() : Number(nativeWindow.minSize.y);
  1398.             nativeWindow.minSize = new Point(_loc5_,_loc6_);
  1399.             if(minWidthChanged)
  1400.             {
  1401.                minWidthChanged = false;
  1402.                if(width < minWidth)
  1403.                {
  1404.                   width = minWidth;
  1405.                }
  1406.                dispatchEvent(new Event("minWidthChanged"));
  1407.             }
  1408.             if(minHeightChanged)
  1409.             {
  1410.                minHeightChanged = false;
  1411.                if(height < minHeight)
  1412.                {
  1413.                   height = minHeight;
  1414.                }
  1415.                dispatchEvent(new Event("minHeightChanged"));
  1416.             }
  1417.          }
  1418.          if(maxWidthChanged || maxHeightChanged)
  1419.          {
  1420.             _loc7_ = maxWidthChanged ? _maxWidth + chromeWidth() : Number(nativeWindow.maxSize.x);
  1421.             _loc8_ = maxHeightChanged ? _maxHeight + chromeHeight() : Number(nativeWindow.maxSize.y);
  1422.             nativeWindow.maxSize = new Point(_loc7_,_loc8_);
  1423.             if(maxWidthChanged)
  1424.             {
  1425.                maxWidthChanged = false;
  1426.                if(width > maxWidth)
  1427.                {
  1428.                   width = maxWidth;
  1429.                }
  1430.                dispatchEvent(new Event("maxWidthChanged"));
  1431.             }
  1432.             if(maxHeightChanged)
  1433.             {
  1434.                maxHeightChanged = false;
  1435.                if(height > maxHeight)
  1436.                {
  1437.                   height = maxHeight;
  1438.                }
  1439.                dispatchEvent(new Event("maxHeightChanged"));
  1440.             }
  1441.          }
  1442.          if(boundsChanged)
  1443.          {
  1444.             _loc9_ = _bounds.width;
  1445.             _loc10_ = _bounds.height;
  1446.             systemManager.stage.stageWidth = _loc9_;
  1447.             systemManager.stage.stageHeight = _loc10_;
  1448.             boundsChanged = false;
  1449.          }
  1450.          if(menuChanged && !nativeWindow.closed)
  1451.          {
  1452.             menuChanged = false;
  1453.             if(menu == null)
  1454.             {
  1455.                if(NativeWindow.supportsMenu)
  1456.                {
  1457.                   nativeWindow.menu = null;
  1458.                }
  1459.             }
  1460.             else if(menu.nativeMenu)
  1461.             {
  1462.                if(NativeWindow.supportsMenu)
  1463.                {
  1464.                   nativeWindow.menu = menu.nativeMenu;
  1465.                }
  1466.             }
  1467.          }
  1468.          if(titleBarFactoryChanged)
  1469.          {
  1470.             if(_titleBar)
  1471.             {
  1472.                rawChildren.removeChild(DisplayObject(titleBar));
  1473.                _titleBar = null;
  1474.             }
  1475.             _titleBar = titleBarFactory.newInstance();
  1476.             _titleBar.styleName = new StyleProxy(this,titleBarStyleFilters);
  1477.             rawChildren.addChild(DisplayObject(titleBar));
  1478.             titleBarFactoryChanged = false;
  1479.             invalidateDisplayList();
  1480.          }
  1481.          if(showTitleBarChanged)
  1482.          {
  1483.             if(_titleBar)
  1484.             {
  1485.                _titleBar.visible = _showTitleBar;
  1486.             }
  1487.             showTitleBarChanged = false;
  1488.          }
  1489.          if(titleIconChanged)
  1490.          {
  1491.             if(Boolean(_titleBar) && "titleIcon" in _titleBar)
  1492.             {
  1493.                _titleBar["titleIcon"] = _titleIcon;
  1494.             }
  1495.             titleIconChanged = false;
  1496.          }
  1497.          if(titleChanged)
  1498.          {
  1499.             if(!nativeWindow.closed)
  1500.             {
  1501.                systemManager.stage.nativeWindow.title = _title;
  1502.             }
  1503.             if(Boolean(_titleBar) && "title" in _titleBar)
  1504.             {
  1505.                _titleBar["title"] = _title;
  1506.             }
  1507.             titleChanged = false;
  1508.          }
  1509.          if(statusBarFactoryChanged)
  1510.          {
  1511.             if(_statusBar)
  1512.             {
  1513.                rawChildren.removeChild(DisplayObject(_statusBar));
  1514.                _statusBar = null;
  1515.             }
  1516.             _statusBar = statusBarFactory.newInstance();
  1517.             _statusBar.styleName = new StyleProxy(this,statusBarStyleFilters);
  1518.             if(gripper)
  1519.             {
  1520.                rawChildren.addChildAt(DisplayObject(_statusBar),rawChildren.getChildIndex(gripper));
  1521.             }
  1522.             else
  1523.             {
  1524.                rawChildren.addChild(DisplayObject(_statusBar));
  1525.             }
  1526.             statusBarFactoryChanged = false;
  1527.             showStatusBarChanged = true;
  1528.             invalidateDisplayList();
  1529.          }
  1530.          if(showStatusBarChanged)
  1531.          {
  1532.             if(_statusBar)
  1533.             {
  1534.                _statusBar.visible = _showStatusBar;
  1535.             }
  1536.             showStatusBarChanged = false;
  1537.          }
  1538.          if(statusChanged)
  1539.          {
  1540.             if(Boolean(_statusBar) && "status" in _statusBar)
  1541.             {
  1542.                _statusBar["status"] = _status;
  1543.             }
  1544.             statusChanged = false;
  1545.          }
  1546.          if(showGripperChanged)
  1547.          {
  1548.             if(gripper)
  1549.             {
  1550.                gripper.visible = _showGripper;
  1551.                gripperHit.visible = _showGripper;
  1552.             }
  1553.             showGripperChanged = false;
  1554.          }
  1555.          if(toMax)
  1556.          {
  1557.             toMax = false;
  1558.             if(!nativeWindow.closed)
  1559.             {
  1560.                nativeWindow.maximize();
  1561.             }
  1562.          }
  1563.       }
  1564.       
  1565.       override public function move(param1:Number, param2:Number) : void
  1566.       {
  1567.          var _loc3_:Rectangle = null;
  1568.          if(Boolean(nativeWindow) && !nativeWindow.closed)
  1569.          {
  1570.             _loc3_ = nativeWindow.bounds;
  1571.             _loc3_.x = param1;
  1572.             _loc3_.y = param2;
  1573.             nativeWindow.bounds = _loc3_;
  1574.          }
  1575.       }
  1576.       
  1577.       public function set titleBarFactory(param1:IFactory) : void
  1578.       {
  1579.          _titleBarFactory = param1;
  1580.          titleBarFactoryChanged = true;
  1581.          invalidateProperties();
  1582.          dispatchEvent(new Event("titleBarFactoryChanged"));
  1583.       }
  1584.       
  1585.       public function set status(param1:String) : void
  1586.       {
  1587.          _status = param1;
  1588.          statusChanged = true;
  1589.          invalidateProperties();
  1590.          invalidateSize();
  1591.          mx_internal::invalidateViewMetricsAndPadding();
  1592.          dispatchEvent(new Event("statusChanged"));
  1593.       }
  1594.       
  1595.       private function window_resizeHandler(param1:NativeWindowBoundsEvent) : void
  1596.       {
  1597.          mx_internal::invalidateViewMetricsAndPadding();
  1598.          invalidateDisplayList();
  1599.          var _loc2_:* = bounds.width != stage.stageWidth;
  1600.          var _loc3_:* = bounds.height != stage.stageHeight;
  1601.          bounds.x = stage.x;
  1602.          bounds.y = stage.y;
  1603.          bounds.width = stage.stageWidth;
  1604.          bounds.height = stage.stageHeight;
  1605.          validateNow();
  1606.          var _loc4_:FlexNativeWindowBoundsEvent = new FlexNativeWindowBoundsEvent(FlexNativeWindowBoundsEvent.WINDOW_RESIZE,param1.bubbles,param1.cancelable,param1.beforeBounds,param1.afterBounds);
  1607.          dispatchEvent(_loc4_);
  1608.          if(_loc2_)
  1609.          {
  1610.             dispatchEvent(new Event("widthChanged"));
  1611.          }
  1612.          if(_loc3_)
  1613.          {
  1614.             dispatchEvent(new Event("heightChanged"));
  1615.          }
  1616.       }
  1617.       
  1618.       public function set titleIcon(param1:Class) : void
  1619.       {
  1620.          _titleIcon = param1;
  1621.          titleIconChanged = true;
  1622.          invalidateProperties();
  1623.          invalidateSize();
  1624.          mx_internal::invalidateViewMetricsAndPadding();
  1625.          invalidateDisplayList();
  1626.          dispatchEvent(new Event("titleIconChanged"));
  1627.       }
  1628.       
  1629.       public function set alwaysInFront(param1:Boolean) : void
  1630.       {
  1631.          _alwaysInFront = param1;
  1632.          if(Boolean(_nativeWindow) && !_nativeWindow.closed)
  1633.          {
  1634.             nativeWindow.alwaysInFront = param1;
  1635.          }
  1636.       }
  1637.       
  1638.       [Bindable("titleBarFactoryChanged")]
  1639.       public function get titleBarFactory() : IFactory
  1640.       {
  1641.          return _titleBarFactory;
  1642.       }
  1643.       
  1644.       [Bindable("statusChanged")]
  1645.       public function get status() : String
  1646.       {
  1647.          return _status;
  1648.       }
  1649.       
  1650.       override protected function updateDisplayList(param1:Number, param2:Number) : void
  1651.       {
  1652.          var _loc3_:EdgeMetrics = null;
  1653.          var _loc4_:Number = NaN;
  1654.          var _loc5_:Number = NaN;
  1655.          var _loc6_:String = null;
  1656.          var _loc7_:Number = NaN;
  1657.          if(!nativeWindow.closed)
  1658.          {
  1659.             super.updateDisplayList(param1,param2);
  1660.             resizeWidth = isNaN(explicitWidth);
  1661.             resizeHeight = isNaN(explicitHeight);
  1662.             if(resizeWidth || resizeHeight)
  1663.             {
  1664.                resizeHandler(new Event(Event.RESIZE));
  1665.                if(!resizeHandlerAdded)
  1666.                {
  1667.                   systemManager.addEventListener(Event.RESIZE,resizeHandler,false,0,true);
  1668.                   resizeHandlerAdded = true;
  1669.                }
  1670.             }
  1671.             else if(resizeHandlerAdded)
  1672.             {
  1673.                systemManager.removeEventListener(Event.RESIZE,resizeHandler);
  1674.                resizeHandlerAdded = false;
  1675.             }
  1676.             createBorder();
  1677.             _loc3_ = borderMetrics;
  1678.             _loc4_ = 10;
  1679.             _loc5_ = 10;
  1680.             if(_statusBar)
  1681.             {
  1682.                _statusBar.move(_loc3_.left,param2 - _loc3_.bottom - getStatusBarHeight());
  1683.                _statusBar.setActualSize(param1 - _loc3_.left - _loc3_.right,getStatusBarHeight());
  1684.             }
  1685.             if(systemManager.stage.nativeWindow.systemChrome != "none")
  1686.             {
  1687.                return;
  1688.             }
  1689.             _loc6_ = String(getStyle("buttonAlignment"));
  1690.             if(titleBar)
  1691.             {
  1692.                titleBar.move(_loc3_.left,_loc3_.top);
  1693.                titleBar.setActualSize(param1 - _loc3_.left - _loc3_.right,getHeaderHeight());
  1694.             }
  1695.             if(Boolean(titleBar) && Boolean(controlBar))
  1696.             {
  1697.                controlBar.move(0,titleBar.height);
  1698.             }
  1699.             if(Boolean(gripper) && showGripper)
  1700.             {
  1701.                _loc7_ = getStyle("gripperPadding");
  1702.                gripper.setActualSize(gripper.measuredWidth,gripper.measuredHeight);
  1703.                gripperHit.graphics.beginFill(16777215,0.0001);
  1704.                gripperHit.graphics.drawRect(0,0,gripper.width + 2 * _loc7_,gripper.height + 2 * _loc7_);
  1705.                gripper.move(param1 - gripper.measuredWidth - _loc7_,param2 - gripper.measuredHeight - _loc7_);
  1706.                gripperHit.x = gripper.x - _loc7_;
  1707.                gripperHit.y = gripper.y - _loc7_;
  1708.             }
  1709.          }
  1710.       }
  1711.       
  1712.       public function close() : void
  1713.       {
  1714.          var _loc1_:Event = null;
  1715.          if(Boolean(_nativeWindow) && !nativeWindow.closed)
  1716.          {
  1717.             _loc1_ = new Event("closing",false,true);
  1718.             stage.nativeWindow.dispatchEvent(_loc1_);
  1719.             if(!_loc1_.isDefaultPrevented())
  1720.             {
  1721.                stage.nativeWindow.close();
  1722.                _nativeWindow = null;
  1723.                systemManager.removeChild(this);
  1724.             }
  1725.          }
  1726.       }
  1727.       
  1728.       private function resizeHandler(param1:Event) : void
  1729.       {
  1730.          var _loc2_:Number = NaN;
  1731.          var _loc3_:Number = NaN;
  1732.          if(resizeWidth)
  1733.          {
  1734.             if(isNaN(percentWidth))
  1735.             {
  1736.                _loc2_ = DisplayObject(systemManager).width;
  1737.             }
  1738.             else
  1739.             {
  1740.                super.percentWidth = Math.max(percentWidth,0);
  1741.                super.percentWidth = Math.min(percentWidth,100);
  1742.                _loc2_ = percentWidth * screen.width / 100;
  1743.             }
  1744.             if(!isNaN(explicitMaxWidth))
  1745.             {
  1746.                _loc2_ = Math.min(_loc2_,explicitMaxWidth);
  1747.             }
  1748.             if(!isNaN(explicitMinWidth))
  1749.             {
  1750.                _loc2_ = Math.max(_loc2_,explicitMinWidth);
  1751.             }
  1752.          }
  1753.          else
  1754.          {
  1755.             _loc2_ = width;
  1756.          }
  1757.          if(resizeHeight)
  1758.          {
  1759.             if(isNaN(percentHeight))
  1760.             {
  1761.                _loc3_ = DisplayObject(systemManager).height;
  1762.             }
  1763.             else
  1764.             {
  1765.                super.percentHeight = Math.max(percentHeight,0);
  1766.                super.percentHeight = Math.min(percentHeight,100);
  1767.                _loc3_ = percentHeight * screen.height / 100;
  1768.             }
  1769.             if(!isNaN(explicitMaxHeight))
  1770.             {
  1771.                _loc3_ = Math.min(_loc3_,explicitMaxHeight);
  1772.             }
  1773.             if(!isNaN(explicitMinHeight))
  1774.             {
  1775.                _loc3_ = Math.max(_loc3_,explicitMinHeight);
  1776.             }
  1777.          }
  1778.          else
  1779.          {
  1780.             _loc3_ = height;
  1781.          }
  1782.          if(_loc2_ != width || _loc3_ != height)
  1783.          {
  1784.             invalidateProperties();
  1785.             invalidateSize();
  1786.          }
  1787.          setActualSize(_loc2_,_loc3_);
  1788.          invalidateDisplayList();
  1789.       }
  1790.    }
  1791. }
  1792.  
  1793.