home *** CD-ROM | disk | FTP | other *** search
/ FCE Gold Plus / GOLD.iso / pc / shell.swf / scripts / __Packages / mx / controls / ComboBase.as < prev    next >
Text File  |  2007-10-16  |  9KB  |  296 lines

  1. class mx.controls.ComboBase extends mx.core.UIComponent
  2. {
  3.    static var mixIt1 = mx.controls.listclasses.DataSelector.Initialize(mx.controls.ComboBase);
  4.    static var symbolName = "ComboBase";
  5.    static var symbolOwner = mx.controls.ComboBase;
  6.    static var version = "2.0.0.377";
  7.    var _editable = false;
  8.    var downArrowUpName = "ScrollDownArrowUp";
  9.    var downArrowDownName = "ScrollDownArrowDown";
  10.    var downArrowOverName = "ScrollDownArrowOver";
  11.    var downArrowDisabledName = "ScrollDownArrowDisabled";
  12.    var wrapDownArrowButton = true;
  13.    var DSgetValue = mx.controls.listclasses.DataSelector.prototype.getValue;
  14.    var multipleSelection = false;
  15.    function ComboBase()
  16.    {
  17.       super();
  18.       this.getValue = this._getValue;
  19.    }
  20.    function init()
  21.    {
  22.       super.init();
  23.       this.tabEnabled = !this._editable;
  24.       this.tabChildren = this._editable;
  25.       this.boundingBox_mc._visible = false;
  26.       this.boundingBox_mc._width = this.boundingBox_mc._height = 0;
  27.    }
  28.    function createChildren()
  29.    {
  30.       var _loc3_ = new Object();
  31.       _loc3_.styleName = this;
  32.       if(this.downArrow_mc == undefined)
  33.       {
  34.          _loc3_.falseUpSkin = this.downArrowUpName;
  35.          _loc3_.falseOverSkin = this.downArrowOverName;
  36.          _loc3_.falseDownSkin = this.downArrowDownName;
  37.          _loc3_.falseDisabledSkin = this.downArrowDisabledName;
  38.          _loc3_.validateNow = true;
  39.          _loc3_.tabEnabled = false;
  40.          this.createClassObject(mx.controls.SimpleButton,"downArrow_mc",19,_loc3_);
  41.          this.downArrow_mc.buttonDownHandler = this.onDownArrow;
  42.          this.downArrow_mc.useHandCursor = false;
  43.          this.downArrow_mc.onPressWas = this.downArrow_mc.onPress;
  44.          this.downArrow_mc.onPress = function()
  45.          {
  46.             this.trackAsMenuWas = this.trackAsMenu;
  47.             this.trackAsMenu = true;
  48.             if(!this._editable)
  49.             {
  50.                this._parent.text_mc.trackAsMenu = this.trackAsMenu;
  51.             }
  52.             this.onPressWas();
  53.          };
  54.          this.downArrow_mc.onDragOutWas = this.downArrow_mc.onDragOut;
  55.          this.downArrow_mc.onDragOut = function()
  56.          {
  57.             this.trackAsMenuWas = this.trackAsMenu;
  58.             this.trackAsMenu = false;
  59.             if(!this._editable)
  60.             {
  61.                this._parent.text_mc.trackAsMenu = this.trackAsMenu;
  62.             }
  63.             this.onDragOutWas();
  64.          };
  65.          this.downArrow_mc.onDragOverWas = this.downArrow_mc.onDragOver;
  66.          this.downArrow_mc.onDragOver = function()
  67.          {
  68.             this.trackAsMenu = this.trackAsMenuWas;
  69.             if(!this._editable)
  70.             {
  71.                this._parent.text_mc.trackAsMenu = this.trackAsMenu;
  72.             }
  73.             this.onDragOverWas();
  74.          };
  75.       }
  76.       if(this.border_mc == undefined)
  77.       {
  78.          _loc3_.tabEnabled = false;
  79.          this.createClassObject(_global.styles.rectBorderClass,"border_mc",17,_loc3_);
  80.          this.border_mc.move(0,0);
  81.          this.__border = this.border_mc;
  82.       }
  83.       _loc3_.borderStyle = "none";
  84.       _loc3_.readOnly = !this._editable;
  85.       _loc3_.tabEnabled = this._editable;
  86.       if(this.text_mc == undefined)
  87.       {
  88.          this.createClassObject(mx.controls.TextInput,"text_mc",18,_loc3_);
  89.          this.text_mc.move(0,0);
  90.          this.text_mc.addEnterEvents();
  91.          this.text_mc.enterHandler = this._enterHandler;
  92.          this.text_mc.changeHandler = this._changeHandler;
  93.          this.text_mc.oldOnSetFocus = this.text_mc.onSetFocus;
  94.          this.text_mc.onSetFocus = function()
  95.          {
  96.             this.oldOnSetFocus();
  97.             this._parent.onSetFocus();
  98.          };
  99.          this.text_mc.__set__restrict("^\x1b");
  100.          this.text_mc.oldOnKillFocus = this.text_mc.onKillFocus;
  101.          this.text_mc.onKillFocus = function(n)
  102.          {
  103.             this.oldOnKillFocus(n);
  104.             this._parent.onKillFocus(n);
  105.          };
  106.          this.text_mc.drawFocus = function(b)
  107.          {
  108.             this._parent.drawFocus(b);
  109.          };
  110.          delete this.text_mc.borderStyle;
  111.       }
  112.       this.focusTextField = this.text_mc;
  113.       this.text_mc.owner = this;
  114.       this.layoutChildren(this.__width,this.__height);
  115.    }
  116.    function onKillFocus()
  117.    {
  118.       super.onKillFocus();
  119.       Key.removeListener(this.text_mc);
  120.       this.getFocusManager().defaultPushButtonEnabled = true;
  121.    }
  122.    function onSetFocus()
  123.    {
  124.       super.onSetFocus();
  125.       this.getFocusManager().defaultPushButtonEnabled = false;
  126.       Key.addListener(this.text_mc);
  127.    }
  128.    function setFocus()
  129.    {
  130.       if(this._editable)
  131.       {
  132.          Selection.setFocus(this.text_mc);
  133.       }
  134.       else
  135.       {
  136.          Selection.setFocus(this);
  137.       }
  138.    }
  139.    function setSize(w, h, noEvent)
  140.    {
  141.       super.setSize(w,h != undefined ? h : this.__get__height(),noEvent);
  142.    }
  143.    function setEnabled(enabledFlag)
  144.    {
  145.       super.setEnabled(enabledFlag);
  146.       this.downArrow_mc.enabled = enabledFlag;
  147.       this.text_mc.enabled = enabledFlag;
  148.    }
  149.    function setEditable(e)
  150.    {
  151.       this._editable = e;
  152.       if(this.wrapDownArrowButton == false)
  153.       {
  154.          if(e)
  155.          {
  156.             this.border_mc.borderStyle = "inset";
  157.             this.text_mc.borderStyle = "inset";
  158.             mx.controls.ComboBase.symbolName = "ComboBox";
  159.             this.invalidateStyle();
  160.          }
  161.          else
  162.          {
  163.             this.border_mc.borderStyle = "comboNonEdit";
  164.             this.text_mc.borderStyle = "dropDown";
  165.             mx.controls.ComboBase.symbolName = "DropDown";
  166.             this.invalidateStyle();
  167.          }
  168.       }
  169.       this.tabEnabled = !e;
  170.       this.tabChildren = e;
  171.       this.text_mc.tabEnabled = e;
  172.       if(e)
  173.       {
  174.          delete this.text_mc.onPress;
  175.          delete this.text_mc.onRelease;
  176.          delete this.text_mc.onReleaseOutside;
  177.          delete this.text_mc.onDragOut;
  178.          delete this.text_mc.onDragOver;
  179.          delete this.text_mc.onRollOver;
  180.          delete this.text_mc.onRollOut;
  181.       }
  182.       else
  183.       {
  184.          this.text_mc.onPress = function()
  185.          {
  186.             this._parent.downArrow_mc.onPress();
  187.          };
  188.          this.text_mc.onRelease = function()
  189.          {
  190.             this._parent.downArrow_mc.onRelease();
  191.          };
  192.          this.text_mc.onReleaseOutside = function()
  193.          {
  194.             this._parent.downArrow_mc.onReleaseOutside();
  195.          };
  196.          this.text_mc.onDragOut = function()
  197.          {
  198.             this._parent.downArrow_mc.onDragOut();
  199.          };
  200.          this.text_mc.onDragOver = function()
  201.          {
  202.             this._parent.downArrow_mc.onDragOver();
  203.          };
  204.          this.text_mc.onRollOver = function()
  205.          {
  206.             this._parent.downArrow_mc.onRollOver();
  207.          };
  208.          this.text_mc.onRollOut = function()
  209.          {
  210.             this._parent.downArrow_mc.onRollOut();
  211.          };
  212.          this.text_mc.useHandCursor = false;
  213.       }
  214.    }
  215.    function get editable()
  216.    {
  217.       return this._editable;
  218.    }
  219.    function set editable(e)
  220.    {
  221.       this.setEditable(e);
  222.    }
  223.    function _getValue()
  224.    {
  225.       return !this._editable ? this.DSgetValue() : this.text_mc.getText();
  226.    }
  227.    function draw()
  228.    {
  229.       this.downArrow_mc.draw();
  230.       this.border_mc.draw();
  231.    }
  232.    function size()
  233.    {
  234.       this.layoutChildren(this.__width,this.__height);
  235.    }
  236.    function setTheme(t)
  237.    {
  238.       this.downArrowUpName = t + "downArrow" + "Up_mc";
  239.       this.downArrowDownName = t + "downArrow" + "Down_mc";
  240.       this.downArrowDisabledName = t + "downArrow" + "Disabled_mc";
  241.    }
  242.    function get text()
  243.    {
  244.       return this.text_mc.getText();
  245.    }
  246.    function set text(t)
  247.    {
  248.       this.setText(t);
  249.    }
  250.    function setText(t)
  251.    {
  252.       this.text_mc.setText(t);
  253.    }
  254.    function get textField()
  255.    {
  256.       return this.text_mc;
  257.    }
  258.    function invalidateStyle()
  259.    {
  260.       this.downArrow_mc.invalidateStyle();
  261.       this.text_mc.invalidateStyle();
  262.       this.border_mc.invalidateStyle();
  263.    }
  264.    function layoutChildren(w, h)
  265.    {
  266.       if(this.downArrow_mc == undefined)
  267.       {
  268.          return undefined;
  269.       }
  270.       if(this.wrapDownArrowButton)
  271.       {
  272.          var _loc2_ = this.border_mc.__get__borderMetrics();
  273.          this.downArrow_mc._width = this.downArrow_mc._height = h - _loc2_.top - _loc2_.bottom;
  274.          this.downArrow_mc.move(w - this.downArrow_mc._width - _loc2_.right,_loc2_.top);
  275.          this.border_mc.setSize(w,h);
  276.          this.text_mc.setSize(w - this.downArrow_mc._width,h);
  277.       }
  278.       else
  279.       {
  280.          this.downArrow_mc.move(w - this.downArrow_mc._width,0);
  281.          this.border_mc.setSize(w - this.downArrow_mc.width,h);
  282.          this.text_mc.setSize(w - this.downArrow_mc._width,h);
  283.          this.downArrow_mc._height = this.height;
  284.       }
  285.    }
  286.    function _changeHandler(obj)
  287.    {
  288.    }
  289.    function _enterHandler(obj)
  290.    {
  291.       var _loc2_ = this._parent;
  292.       obj.target = _loc2_;
  293.       _loc2_.dispatchEvent(obj);
  294.    }
  295. }
  296.