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

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