home *** CD-ROM | disk | FTP | other *** search
/ Computer Active 2010 August / CA08.iso / Multimedija / shufflr.air / ShufflrClient.swf / scripts / mx / containers / Form.as < prev    next >
Encoding:
Text File  |  2010-06-23  |  4.8 KB  |  166 lines

  1. package mx.containers
  2. {
  3.    import flash.display.DisplayObject;
  4.    import mx.containers.utilityClasses.BoxLayout;
  5.    import mx.controls.Label;
  6.    import mx.core.Container;
  7.    import mx.core.IInvalidating;
  8.    import mx.core.IUIComponent;
  9.    import mx.core.mx_internal;
  10.    import mx.styles.StyleManager;
  11.    
  12.    use namespace mx_internal;
  13.    
  14.    public class Form extends Container
  15.    {
  16.       mx_internal static const VERSION:String = "3.5.0.12683";
  17.       
  18.       private static var classInitialized:Boolean = false;
  19.       
  20.       mx_internal var layoutObject:BoxLayout = new BoxLayout();
  21.       
  22.       private var measuredLabelWidth:Number;
  23.       
  24.       public function Form()
  25.       {
  26.          super();
  27.          if(!classInitialized)
  28.          {
  29.             initializeClass();
  30.             classInitialized = true;
  31.          }
  32.          showInAutomationHierarchy = true;
  33.          mx_internal::layoutObject.target = this;
  34.          mx_internal::layoutObject.direction = BoxDirection.VERTICAL;
  35.       }
  36.       
  37.       private static function initializeClass() : void
  38.       {
  39.          StyleManager.registerInheritingStyle("labelWidth");
  40.          StyleManager.registerSizeInvalidatingStyle("labelWidth");
  41.          StyleManager.registerInheritingStyle("indicatorGap");
  42.          StyleManager.registerSizeInvalidatingStyle("indicatorGap");
  43.       }
  44.       
  45.       override public function addChild(param1:DisplayObject) : DisplayObject
  46.       {
  47.          invalidateLabelWidth();
  48.          return super.addChild(param1);
  49.       }
  50.       
  51.       override public function styleChanged(param1:String) : void
  52.       {
  53.          if(!param1 || param1 == "styleName" || StyleManager.isSizeInvalidatingStyle(param1))
  54.          {
  55.             invalidateLabelWidth();
  56.          }
  57.          super.styleChanged(param1);
  58.       }
  59.       
  60.       override public function removeChildAt(param1:int) : DisplayObject
  61.       {
  62.          invalidateLabelWidth();
  63.          return super.removeChildAt(param1);
  64.       }
  65.       
  66.       internal function calculateLabelWidth() : Number
  67.       {
  68.          var _loc5_:DisplayObject = null;
  69.          if(!isNaN(measuredLabelWidth))
  70.          {
  71.             return measuredLabelWidth;
  72.          }
  73.          var _loc1_:Number = 0;
  74.          var _loc2_:Boolean = false;
  75.          var _loc3_:int = numChildren;
  76.          var _loc4_:int = 0;
  77.          while(_loc4_ < _loc3_)
  78.          {
  79.             _loc5_ = getChildAt(_loc4_);
  80.             if(_loc5_ is FormItem && FormItem(_loc5_).includeInLayout)
  81.             {
  82.                _loc1_ = Math.max(_loc1_,FormItem(_loc5_).getPreferredLabelWidth());
  83.                _loc2_ = true;
  84.             }
  85.             _loc4_++;
  86.          }
  87.          if(_loc2_)
  88.          {
  89.             measuredLabelWidth = _loc1_;
  90.          }
  91.          return _loc1_;
  92.       }
  93.       
  94.       internal function invalidateLabelWidth() : void
  95.       {
  96.          var _loc1_:int = 0;
  97.          var _loc2_:int = 0;
  98.          var _loc3_:IUIComponent = null;
  99.          if(!isNaN(measuredLabelWidth) && initialized)
  100.          {
  101.             measuredLabelWidth = NaN;
  102.             _loc1_ = numChildren;
  103.             _loc2_ = 0;
  104.             while(_loc2_ < _loc1_)
  105.             {
  106.                _loc3_ = IUIComponent(getChildAt(_loc2_));
  107.                if(_loc3_ is IInvalidating)
  108.                {
  109.                   IInvalidating(_loc3_).invalidateSize();
  110.                }
  111.                _loc2_++;
  112.             }
  113.          }
  114.       }
  115.       
  116.       [Bindable("updateComplete")]
  117.       public function get maxLabelWidth() : Number
  118.       {
  119.          var _loc3_:DisplayObject = null;
  120.          var _loc4_:Label = null;
  121.          var _loc1_:int = numChildren;
  122.          var _loc2_:int = 0;
  123.          while(_loc2_ < _loc1_)
  124.          {
  125.             _loc3_ = getChildAt(_loc2_);
  126.             if(_loc3_ is FormItem)
  127.             {
  128.                _loc4_ = FormItem(_loc3_).itemLabel;
  129.                if(_loc4_)
  130.                {
  131.                   return _loc4_.width;
  132.                }
  133.             }
  134.             _loc2_++;
  135.          }
  136.          return 0;
  137.       }
  138.       
  139.       override protected function updateDisplayList(param1:Number, param2:Number) : void
  140.       {
  141.          super.updateDisplayList(param1,param2);
  142.          mx_internal::layoutObject.updateDisplayList(param1,param2);
  143.       }
  144.       
  145.       override public function addChildAt(param1:DisplayObject, param2:int) : DisplayObject
  146.       {
  147.          invalidateLabelWidth();
  148.          return super.addChildAt(param1,param2);
  149.       }
  150.       
  151.       override protected function measure() : void
  152.       {
  153.          super.measure();
  154.          mx_internal::layoutObject.measure();
  155.          calculateLabelWidth();
  156.       }
  157.       
  158.       override public function removeChild(param1:DisplayObject) : DisplayObject
  159.       {
  160.          invalidateLabelWidth();
  161.          return super.removeChild(param1);
  162.       }
  163.    }
  164. }
  165.  
  166.