Example #1
0
        public InputBoxWidget(string name, string caption, float width, float boxWidth, string text = null)
        {
            isTextMode      = false;
            element         = OverlayManager.Singleton.CreateOverlayElementFromTemplate("AMGE/UI/InputBox", "BorderPanel", name);
            isFitToContents = false;

            inputBoxElement       = (BorderPanelOverlayElement)((OverlayContainer)element).GetChild(name + "/InputBoxText");
            inputBoxElement.Width = width - 10;

            captionTextAreaElement       = (TextAreaOverlayElement)((OverlayContainer)element).GetChild(name + "/InputBoxCaption");
            captionTextAreaElement.Width = width - inputBoxElement.Width;

            contentTextAreaElement       = (TextAreaOverlayElement)inputBoxElement.GetChild(name + "/InputBoxText/InputBoxContentText");
            contentTextAreaElement.Width = inputBoxElement.Width;

            inputCursorElement       = (BorderPanelOverlayElement)inputBoxElement.GetChild(name + "/InputBoxText/InputBoxCursor");
            inputCursorElement.Width = 2;
            inputCursorElement.Hide();

            element.Width = width;
            originalText  = string.Empty;

            if (boxWidth > 0)
            {
                if (width <= 0)
                {
                    isFitToContents = true;
                }
                inputBoxElement.Width = boxWidth;
                inputBoxElement.Top   = 2;
                inputBoxElement.Left  = width - boxWidth - 5;
                element.Height        = inputBoxElement.Height + 4;
                captionTextAreaElement.HorizontalAlignment = GuiHorizontalAlignment.GHA_LEFT;
                captionTextAreaElement.SetAlignment(TextAreaOverlayElement.Alignment.Left);
                captionTextAreaElement.Left = 12;
                captionTextAreaElement.Top  = 9;
            }

            if (!string.IsNullOrEmpty(text))
            {
                contentTextAreaElement.Caption = text;
                originalText = text;
            }

            setCaption(caption);
        }
Example #2
0
        public SelectMenuWidget(string name, string caption, float width, float boxWidth, uint maxItemsShown)
        {
            Items                 = new List <string>();
            highlightIndex        = 0;
            displayIndex          = 0;
            dragOffset            = 0.0f;
            selectionIndex        = -1;
            isFitToContents       = false;
            isCursorOver          = false;
            isExpanded            = false;
            isDragging            = false;
            this.maxItemsShown    = maxItemsShown;
            itemsShown            = 0;
            element               = (Mogre.BorderPanelOverlayElement)Mogre.OverlayManager.Singleton.CreateOverlayElementFromTemplate("SdkTrays/SelectMenu", "BorderPanel", name);
            textAreaElement       = (Mogre.TextAreaOverlayElement)((Mogre.OverlayContainer)element).GetChild(name + "/MenuCaption");
            smallBoxElement       = (Mogre.BorderPanelOverlayElement)((Mogre.OverlayContainer)element).GetChild(name + "/MenuSmallBox");
            smallBoxElement.Width = (width - 10);
            smallTextAreaElement  = (Mogre.TextAreaOverlayElement)smallBoxElement.GetChild(name + "/MenuSmallBox/MenuSmallText");
            element.Width         = (width);

            if (boxWidth > 0f)             // long style
            {
                if (width <= 0f)
                {
                    isFitToContents = true;
                }
                smallBoxElement.Width = (boxWidth);
                smallBoxElement.Top   = (2f);
                smallBoxElement.Left  = (width - boxWidth - 5f);
                element.Height        = (smallBoxElement.Height + 4f);
                textAreaElement.HorizontalAlignment = (GuiHorizontalAlignment.GHA_LEFT);
                textAreaElement.SetAlignment(Mogre.TextAreaOverlayElement.Alignment.Left);
                textAreaElement.Left = (12f);
                textAreaElement.Top  = (10f);
            }

            expandedBoxElement       = (Mogre.BorderPanelOverlayElement)((Mogre.OverlayContainer)element).GetChild(name + "/MenuExpandedBox");
            expandedBoxElement.Width = (smallBoxElement.Width + 10);
            expandedBoxElement.Hide();
            scrollTrackElement  = (Mogre.BorderPanelOverlayElement)expandedBoxElement.GetChild(expandedBoxElement.Name + "/MenuScrollTrack");
            scrollHandleElement = (Mogre.PanelOverlayElement)scrollTrackElement.GetChild(scrollTrackElement.Name + "/MenuScrollHandle");

            setCaption(caption);
        }
Example #3
0
        public InputBox(String name, string caption, float width, float boxWidth, string text = null, bool onlyAcceptNum = false)
        {
            this.isTextMode          = false;
            this.mElement            = OverlayManager.Singleton.CreateOverlayElementFromTemplate("AMGE/UI/InputBox", "BorderPanel", name);
            this.mHighlightIndex     = 0;
            this.mDisplayIndex       = 0;
            this.mDragOffset         = 0.0f;
            this.mSelectionIndex     = -1;
            this.mFitToContents      = false;
            this.mCursorOver         = false;
            this.mDragging           = false;
            this.mItemsShown         = 0;
            this.mTextArea           = (TextAreaOverlayElement)((OverlayContainer)this.mElement).GetChild(name + "/InputBoxCaption");
            this.mInputBoxText       = (BorderPanelOverlayElement)((OverlayContainer)this.mElement).GetChild(name + "/InputBoxText");
            this.mInputBoxText.Width = width - 10;
            this.mSmallTextArea      = (TextAreaOverlayElement)this.mInputBoxText.GetChild(name + "/InputBoxText/InputBoxSmallText");
            this.mElement.Width      = width;
            this.mItemElements       = new List <BorderPanelOverlayElement>();
            this.mText          = string.Empty;
            this.bOnlyAcceptNum = onlyAcceptNum;

            if (boxWidth > 0)
            {
                if (width <= 0)
                {
                    this.mFitToContents = true;
                }
                this.mInputBoxText.Width           = boxWidth;
                this.mInputBoxText.Top             = 2;
                this.mInputBoxText.Left            = width - boxWidth - 5;
                this.mElement.Height               = this.mInputBoxText.Height + 4;
                this.mTextArea.HorizontalAlignment = GuiHorizontalAlignment.GHA_LEFT;
                this.mTextArea.SetAlignment(TextAreaOverlayElement.Alignment.Left);
                this.mTextArea.Left = 12;
                this.mTextArea.Top  = 10;
            }

            if (!string.IsNullOrEmpty(text))
            {
                mSmallTextArea.Caption = text;
            }

            this.setCaption(caption);
        }
Example #4
0
        public SimplePanelScrollableWidget(string name, float width = 0, float height = 0, float left = 0, float top = 0, float eachRowHeight = 0.03f, int col = 1, bool hasBorder = true) : base(name, width, height, left, top, (int)(height / eachRowHeight), col, hasBorder)
        {
            visualWidgets = new List <Widget>();
            string scrollName = name + "_Scroll";

            scroll = OverlayManager.Singleton.CreateOverlayElementFromTemplate("ScrollComponet", "BorderPanel", scrollName) as BorderPanelOverlayElement;
            drag   = scroll.GetChild(scrollName + "/Drag") as OverlayElement;

            for (int i = 0; i < Rows.Count; i++)
            {
                Rows[i].Type = ValueType.Auto;
            }

            scroll.Left = -0.01f;
            scroll.Top  = 0;
            AddChildOverlayElement(scroll);
            initDragTop = drag.Top;

            scroll.Hide();
            drag.Hide();
        }
Example #5
0
        public StaticMultiLineTextBoxWidget(string name, string caption, float width, float height)
        {
            element        = OverlayManager.Singleton.CreateOverlayElementFromTemplate("SdkTrays/TextBox", "BorderPanel", name);
            element.Width  = (width);
            element.Height = (height);
            OverlayContainer container = (OverlayContainer)element;

            textArea         = (TextAreaOverlayElement)container.GetChild(Name + "/TextBoxText");
            captionBar       = (BorderPanelOverlayElement)container.GetChild(Name + "/TextBoxCaptionBar");
            captionBar.Width = (width - 4f);
            captionTextArea  = (TextAreaOverlayElement)captionBar.GetChild(captionBar.Name + "/TextBoxCaption");
            setCaption(caption);
            scrollTrack  = (BorderPanelOverlayElement)container.GetChild(Name + "/TextBoxScrollTrack");
            scrollHandle = (PanelOverlayElement)scrollTrack.GetChild(scrollTrack.Name + "/TextBoxScrollHandle");
            scrollHandle.Hide();
            dragging         = false;
            scrollPercentage = 0f;
            startingLine     = 0;
            contentPadding   = 15f;
            originalText     = "";

            refitContents();
        }
Example #6
0
        public SimpleButtonWidget(string name, string caption, float width, float height, float left = 0, float top = 0)
        {
            OverlayManager overlayMgr = OverlayManager.Singleton;

            element                             = OverlayManager.Singleton.CreateOverlayElementFromTemplate("SimpleButton", "BorderPanel", name);
            element.MetricsMode                 = GuiMetricsMode.GMM_RELATIVE;
            element.Top                         = top;
            element.Left                        = left;
            element.Height                      = height;
            element.Width                       = width;
            borderPanelElement                  = (BorderPanelOverlayElement)element;
            textAreaElement                     = overlayMgr.CreateOverlayElement("TextArea", name + "/StaticTextCaption") as TextAreaOverlayElement;
            textAreaElement.MetricsMode         = GuiMetricsMode.GMM_RELATIVE;
            textAreaElement.HorizontalAlignment = GuiHorizontalAlignment.GHA_CENTER;
            textAreaElement.SetAlignment(TextAreaOverlayElement.Alignment.Center);
            textAreaElement.FontName   = "EngineFont";
            textAreaElement.CharHeight = 0.025f;
            textAreaElement.SpaceWidth = 0.02f;
            textAreaElement.Colour     = ColourValue.Black;
            textAreaElement.Top        = height / 45f;
            ((OverlayContainer)element).AddChild(textAreaElement);
            textAreaElement.Caption = caption;
        }