Ejemplo n.º 1
0
        /// <summary>
        /// Event clicked when the dropDownButton is clicked.  If the ListBox is not visible
        /// it will appear.
        /// </summary>
        /// <param name="callingWindow"></param>
        void OnDropDownButtonClick(Window callingWindow)
        {
            if (mListBox.Visible)
            {
                return;
            }

            // The ListBox is not visible, so "expand" it.

            GuiManager.AddPerishableWindow(mListBox);
            mListBox.Visible = true;

            if (mListBox.SpriteFrame != null)
            {
                SpriteManager.AddSpriteFrame(mListBox.SpriteFrame);
            }

//                listBox.SetPositionTL(ScaleX, ScaleY + 4);
            mListBox.SetScaleToContents(ScaleX);
            mListBox.SetPositionTL(ScaleX, ScaleY + mListBox.ScaleY + 1);

            mListBox.HighlightOnRollOver = true;

            mListBox.UpdateDependencies();


            float maximumScale = GuiManager.YEdge - (MenuStrip.MenuStripHeight / 2.0f);

            if (mListBox.ScaleY > maximumScale)
            {
                mListBox.ScrollBarVisible = true;
                mListBox.ScaleY           = maximumScale;
            }

            if (mListBox.WorldUnitY - mListBox.ScaleY < -GuiManager.Camera.YEdge)
            {
                mListBox.Y -= -GuiManager.Camera.YEdge - (mListBox.WorldUnitY - mListBox.ScaleY);
            }

            if (mListBox.WorldUnitX + mListBox.ScaleX > GuiManager.Camera.XEdge)
            {
                mListBox.X -= (mListBox.WorldUnitX + mListBox.ScaleX) - GuiManager.Camera.XEdge;
            }

            if (mListBox.WorldUnitX - mListBox.ScaleX < -GuiManager.Camera.XEdge)
            {
                mListBox.X += -GuiManager.Camera.XEdge - (mListBox.WorldUnitX - mListBox.ScaleX);
            }

            mListBox.HighlightItem(mSelectionDisplay.Text);
        }
Ejemplo n.º 2
0
        public ComboBox(Cursor cursor) : base(cursor)
        {
            #region Create the TextBox (mSelectionDisplay)
            mSelectionDisplay = new TextBox(mCursor);
            AddWindow(mSelectionDisplay);
            mSelectionDisplay.TakingInput = false;
            mSelectionDisplay.fixedLength = false;
            //mStretchListBoxToContentWidth = true;
            #endregion

            #region Create drop-down button

            mDropDownButton = new Button(mCursor);
            AddWindow(mDropDownButton);
            // Not sure why this is here.  Commented out July 31 2007
            //dropDownButton.mSprite.RotationZ = (float)System.Math.PI;
            mDropDownButton.ScaleX = .9f;

            mDropDownButton.Click += new GuiMessage(OnDropDownButtonClick);

            #endregion

            this.ScaleY    = 1.4f;
            SelectedObject = null;
            this.ScaleX    = 4;

            mListBox = new ListBox(mCursor);
            AddWindow(mListBox);
            this.RemoveWindow(mListBox);             // just a quick way to have a list box initialized for us, but not keep it on this window
            mListBox.SetPositionTL(ScaleX, ScaleY + 2);
            mListBox.Visible          = false;
            mListBox.ScrollBarVisible = false;
            mListBox.Click           += new GuiMessage(OnListBoxClicked);


            MouseWheelScroll += OnMouseWheelScroll;
            mSelectionDisplay.MouseWheelScroll += OnMouseWheelScroll;
            mDropDownButton.MouseWheelScroll   += OnMouseWheelScroll;
            mSelectionDisplay.LosingFocus      += RaiseTextChange;
        }
Ejemplo n.º 3
0
        public ComboBox(Cursor cursor) : base(cursor)
        {
            #region Create the TextBox (mSelectionDisplay)
            mSelectionDisplay = new TextBox(mCursor);
            AddWindow(mSelectionDisplay);
			mSelectionDisplay.TakingInput = false;
            mSelectionDisplay.fixedLength = false;
            //mStretchListBoxToContentWidth = true;
            #endregion

            #region Create drop-down button

            mDropDownButton = new Button(mCursor);
            AddWindow(mDropDownButton);
            // Not sure why this is here.  Commented out July 31 2007
			//dropDownButton.mSprite.RotationZ = (float)System.Math.PI;
            mDropDownButton.ScaleX = .9f;
            
			mDropDownButton.Click += new GuiMessage(OnDropDownButtonClick);

            #endregion

            this.ScaleY = 1.4f;
			SelectedObject = null;
            this.ScaleX = 4;

            mListBox = new ListBox(mCursor);
            AddWindow(mListBox);
			this.RemoveWindow(mListBox); // just a quick way to have a list box initialized for us, but not keep it on this window
			mListBox.SetPositionTL(ScaleX, ScaleY + 2);
            mListBox.Visible = false;
			mListBox.ScrollBarVisible = false;
			mListBox.Click += new GuiMessage(OnListBoxClicked);


            MouseWheelScroll += OnMouseWheelScroll;
            mSelectionDisplay.MouseWheelScroll += OnMouseWheelScroll;
            mDropDownButton.MouseWheelScroll += OnMouseWheelScroll;
            mSelectionDisplay.LosingFocus += RaiseTextChange;
		}