Пример #1
0
        override public void ConstructFromXML(XML cxml)
        {
            base.ConstructFromXML(cxml);

            XML xml = cxml.GetNode("ComboBox");

            string str;

            _buttonController = GetController("button");
            _titleObject      = GetChildByName("title") as GTextField;

            str = (string)xml.GetAttribute("dropdown");
            if (string.IsNullOrEmpty(str))
            {
                Debug.Log(this.resourceURL + ": 需要定义下拉框资源");
                return;
            }

            _dropdownObject = UIPackage.CreateObjectFromURL(str) as GComponent;
            if (_dropdownObject == null)
            {
                Debug.Log(this.resourceURL + ": 下拉框必须为元件");
                return;
            }

            _list = _dropdownObject.GetChildByName("list") as GList;
            if (_list == null)
            {
                Debug.Log(this.resourceURL + ": 下拉框的弹出元件里必须包含名为list的列表");
                return;
            }
            _list.AddEventListener(ItemEvent.CLICK, __clickItemObsolete);
            _list.onClickItem.Add(__clickItem);

            _list.AddRelation(_dropdownObject, RelationType.Width);
            _dropdownObject.AddRelation(_list, RelationType.Height);

            _displayObject.AddEventListenerObsolete(MouseEvent.ROLL_OVER, __rolloverObsolete);
            _displayObject.AddEventListenerObsolete(MouseEvent.ROLL_OUT, __rolloutObsolete);
            _displayObject.AddEventListenerObsolete(MouseEvent.MOUSE_DOWN, __mousedown);

            displayObject.onRollOver.Add(__rollover);
            displayObject.onRollOut.Add(__rollout);
            displayObject.onTouchBegin.Add(__touchBegin);
        }
Пример #2
0
        public PopupMenu(int width = 100, string resourceURL = null)
        {
            if (resourceURL == null)
            {
                resourceURL = UIConfig.popupMenu;
            }

            _contentPane = UIPackage.CreateObjectFromURL(resourceURL).asCom;
            _contentPane.AddEventListener(EventContext.ADDED_TO_STAGE, __addedToStage);

            _contentPane.width = width;
            _list = _contentPane.GetChildByName("list").asList;
            _list.RemoveChildrenToPool();

            _list.AddRelation(_contentPane, RelationType.Width);
            _contentPane.AddRelation(_list, RelationType.Height);

            _list.AddEventListener(ItemEvent.CLICK, __clickItem);
        }
Пример #3
0
        public static GObject NewObject(string type, AppContext context)
        {
            GObject cls = null;

            switch (type)
            {
            case "image":
                cls = new GImage();
                break;

            case "movieclip":
                cls = new GMovieClip();
                break;

            case "swf":
                cls = new GSwfObject();
                break;

            case "jta":
                cls = new GJtaObject();
                break;

            case "component":
                cls = new GComponent();
                break;

            case "text":
                cls = new GTextField();
                break;

            case "group":
                cls = new GGroup();
                break;

            case "list":
                cls = new GList();
                break;

            case "graph":
                cls = new GGraph();
                break;

            case "loader":
                cls = new GLoader();
                break;

            //component derived
            case "Button":
                cls = new GButton();
                break;

            case "Label":
                cls = new GLabel();
                break;

            case "ProgressBar":
                cls = new GProgressBar();
                break;

            case "Slider":
                cls = new GSlider();
                break;

            case "ScrollBar":
                cls = new GScrollBar();
                break;

            case "ComboBox":
                cls = new GComboBox();
                break;
            }
            cls.OnCreate(context);
            return(cls);
        }
Пример #4
0
        public ScrollPane(GComponent owner,
                          ScrollType scrollType,
                          Margin margin,
                          int scrollSpeed,
                          ScrollBarDisplayType scrollBarDisplay)
        {
            if (_easeTypeFunc == null)
            {
                _easeTypeFunc = Ease.CubeOut;
            }

            _owner         = owner;
            _container     = _owner.rootContainer;
            _maskContent   = _owner.container;
            _maskContent.x = 0;
            _maskContent.y = 0;

            _maskHolder = new Sprite();
            _container.AddChild(_maskHolder);

            _maskContentHolder = new Sprite();
            _maskContentHolder.AddChild(_maskContent);
            _maskHolder.AddChild(_maskContentHolder);

            if (GRoot.touchScreen)
            {
                _holdArea = 20;
            }
            else
            {
                _holdArea = 10;
            }
            _holdAreaPoint    = Vector2.zero;
            _margin           = new Margin();
            _bouncebackEffect = UIConfig.defaultScrollBounceEffect;
            _touchEffect      = UIConfig.defaultScrollTouchEffect;
            _xPerc            = 0;
            _yPerc            = 0;
            _aniFlag          = true;

            _scrollType  = scrollType;
            _scrollSpeed = scrollSpeed;
            if (_scrollSpeed == 0)
            {
                _scrollSpeed = UIConfig.defaultScrollSpeed;
            }
            _mouseWheelSpeed = _scrollSpeed * 2;

            if (scrollBarDisplay == ScrollBarDisplayType.Default)
            {
                scrollBarDisplay = UIConfig.defaultScrollBarDisplay;
            }

            if (scrollBarDisplay != ScrollBarDisplayType.Hidden)
            {
                if (_scrollType == ScrollType.Both || _scrollType == ScrollType.Vertical)
                {
                    if (UIConfig.verticalScrollBar != null)
                    {
                        _vtScrollBar = UIPackage.CreateObjectFromURL(UIConfig.verticalScrollBar) as GScrollBar;
                        if (_vtScrollBar == null)
                        {
                            throw new Exception("cannot create scrollbar from " + UIConfig.verticalScrollBar);
                        }
                        _vtScrollBar.SetScrollPane(this, true);
                        owner.rootContainer.AddChild(_vtScrollBar.displayObject);
                    }
                }
                if (_scrollType == ScrollType.Both || _scrollType == ScrollType.Horizontal)
                {
                    if (UIConfig.horizontalScrollBar != null)
                    {
                        _hzScrollBar = UIPackage.CreateObjectFromURL(UIConfig.horizontalScrollBar) as GScrollBar;
                        if (_hzScrollBar == null)
                        {
                            throw new Exception("cannot create scrollbar from " + UIConfig.horizontalScrollBar);
                        }
                        _hzScrollBar.SetScrollPane(this, false);
                        owner.rootContainer.AddChild(_hzScrollBar.displayObject);
                    }
                }

                _scrollBarDisplayAuto = scrollBarDisplay == ScrollBarDisplayType.Auto;
                if (_scrollBarDisplayAuto)
                {
                    if (_vtScrollBar != null)
                    {
                        _vtScrollBar.displayObject.visible = false;
                    }
                    if (_hzScrollBar != null)
                    {
                        _hzScrollBar.displayObject.visible = false;
                    }

                    owner.rootContainer.AddEventListenerObsolete(MouseEvent.ROLL_OVER, __rollOver);
                    owner.rootContainer.AddEventListenerObsolete(MouseEvent.ROLL_OUT, __rollOut);
                }
            }

            _margin.left   = margin.left;
            _margin.top    = margin.top;
            _margin.right  = margin.right;
            _margin.bottom = margin.bottom;

            _maskHolder.x = _margin.left;
            _maskHolder.y = _margin.top;

            SetSize(owner.width, owner.height);
            SetContentSize((int)owner.bounds.width, (int)owner.bounds.height);

            _container.AddEventListenerObsolete(MouseEvent.MOUSE_WHEEL, __mouseWheel);
            _container.AddEventListenerObsolete(MouseEvent.MOUSE_DOWN, __mouseDown);
            //
            onScroll = new EventListener(this, "onScroll");
        }
Пример #5
0
        public void SetItemText(string name, string caption)
        {
            GComponent item = _list.GetChildByName(name).asCom;

            item.GetChildByName("title").asTextField.text = caption;
        }