Exemple #1
0
        public override void OnControlMsg(Element2D the_control, ControlMsg msg, float xparam, float yparam)
        {
            if (the_control.GetElementType() == ElementType.ListBoxWidget && msg == ControlMsg.SELECTCHANGED)
            {
                var index = (int)xparam;
                if (index < 0 || index >= listboxwidget.Items.Count)
                {
                    return;
                }

                editboxwidget.Text = listboxwidget.Items[index].ToString();
                ShowDropDown       = false;
            }
            else if (the_control.GetElementType() == ElementType.EditBoxWidget && msg == ControlMsg.TEXT_CHANGED)
            {
                if (TextChangedCallback == null)
                {
                    return;
                }

                TextChangedCallback(this);
            }
            else
            {
                base.OnControlMsg(the_control, msg, xparam, yparam);
            }
        }
Exemple #2
0
 public ProgressBarWidget(int ID, Element2D parent)
     : base(ID, parent)
 {
     drawable_sprite = new Sprite();
     bar_color       = new Color4(0.5f, 0.9f, 1f, 1f);
     complete        = 0.0f;
 }
Exemple #3
0
        public void SetParent(Element2D parent)
        {
            this.parent = parent;
            IParent     = parent;
            SetBaseParent(parent);
            if (parent == null)
            {
                return;
            }

            if (relative_x > 0.0)
            {
                RelativeX = RelativeX;
            }

            if (relative_y > 0.0)
            {
                RelativeY = RelativeY;
            }

            if (relative_width > 0.0)
            {
                RelativeWidth = RelativeWidth;
            }

            if (relative_height <= 0.0)
            {
                return;
            }

            RelativeHeight = RelativeHeight;
        }
Exemple #4
0
 public override void InitChildren(Element2D parent, GUIHost host, ButtonCallback MyButtonCallback)
 {
     base.InitChildren(parent, host, MyButtonCallback);
     if (u0 != 0.0 || v0 != 0.0 || (u1 != 0.0 || v1 != 0.0))
     {
         Init(host, ImageSrc, u0, v0, u1, v1, over_u0, over_v0, over_u1, over_v1, down_u0, down_v0, down_u1, down_v1, disabled_u0, disabled_v0, disabled_u1, disabled_v1);
         SetGrowableWidth(leftbordersize_pixels, rightbordersize_pixels, minimum_width_pixels);
         SetGrowableHeight(topbordersize_pixels, bottombordersize_pixels, minimum_height_pixels);
     }
     else
     {
         if (!parent.IsComboBoxElement() && !parent.IsListBoxElement())
         {
             u0          = 896f;
             v0          = 192f;
             u1          = 959f;
             v1          = byte.MaxValue;
             over_u0     = 896f;
             over_v0     = 256f;
             over_u1     = 959f;
             over_v1     = 319f;
             down_u0     = 896f;
             down_v0     = 320f;
             down_u1     = 959f;
             down_v1     = 383f;
             disabled_u0 = 960f;
             disabled_v0 = 128f;
             disabled_u1 = 1023f;
             disabled_v1 = 191f;
             Init(host, "guicontrols", u0, v0, u1, v1, over_u0, over_v0, over_u1, over_v1, down_u0, down_v0, down_u1, down_v1, disabled_u0, disabled_v0, disabled_u1, disabled_v1);
         }
         SetGrowableWidth(4, 4, 12);
         SetGrowableHeight(4, 4, 12);
     }
 }
Exemple #5
0
 public ListBoxWidget(int ID, Element2D parent)
     : base(ID, parent)
 {
     Items        = new List <object>();
     image_widget = new ImageWidget(0)
     {
         IgnoreMouse = true
     };
     scrollbar = new VerticalSliderWidget(1)
     {
         Visible       = false,
         RoundingPlace = -1
     };
     white = new Color4(1f, 1f, 1f, 1f);
     imageHasFocusColor      = white;
     leftbordersize_pixels   = 0;
     rightbordersize_pixels  = 0;
     topbordersize_pixels    = 0;
     bottombordersize_pixels = 0;
     rowheight          = 0;
     start_row          = 0;
     item_count         = 0;
     Selected           = 0;
     highlightmouseover = false;
     mouse_over_row     = -1;
     MouseOverHighlight = true;
     color             = new Color4(0.15f, 0.15f, 0.15f, 1f);
     color_selected    = new Color4(0.7f, 0.7f, 1f, 1f);
     color_highlighted = new Color4(1f, 1f, 0.5f, 1f);
     ChildList         = ChildList + image_widget;
     ChildList         = ChildList + scrollbar;
     onchangecallback  = null;
 }
Exemple #6
0
 public Element2D(int ID, Element2D parent)
     : base(ID, parent)
 {
     ChildList = new Element2DList(this);
     CenterHorizontallyInParent = false;
     CenterVerticallyInParent   = false;
     this.parent          = parent;
     _bActive             = false;
     wraponnegativeX      = true;
     wraponnegativeY      = true;
     location.x           = 0;
     location.y           = 0;
     size.width           = 0;
     size.height          = 0;
     __MinWidth           = 0;
     __MinHeight          = 0;
     __MaxWidth           = 0;
     __MaxHeight          = 0;
     auto_center_x_offset = 0;
     auto_center_y_offset = 0;
     IgnoreMouse          = false;
     hasfocus             = false;
     relativeposition     = false;
     dropdownelement      = null;
 }
Exemple #7
0
        public override void OnControlMsg(Element2D the_control, ControlMsg msg, float xparam, float yparam)
        {
            if (msg == ControlMsg.MSG_HIT)
            {
                if (the_control.ID == 2)
                {
                    SetTrackPosition(m_track_position - m_pushbuttonstep);
                }
                else if (the_control.ID == 1)
                {
                    SetTrackPosition(m_track_position + m_pushbuttonstep);
                }
            }
            if (the_control.GetElementType() == ElementType.ButtonWidget && msg == ControlMsg.MSG_MOVE && the_control.ID == 0)
            {
                var fPosition = xparam / yparam * m_range + m_range_start;
                if (rounding_place >= 0)
                {
                    fPosition = (float)Math.Round(fPosition, rounding_place, MidpointRounding.AwayFromZero);
                }

                SetTrackPosition(fPosition);
            }
            if (the_control != null)
            {
                return;
            }

            SetTrackPosition(xparam / yparam * m_range + m_range_start);
        }
Exemple #8
0
 public override void InitChildren(Element2D parent, GUIHost host, ButtonCallback MyButtonCallback)
 {
     base.InitChildren(parent, host, MyButtonCallback);
     this.host = host;
     NumBoxes  = NumBoxes;
     Color     = Color;
     Size      = Size;
     Refresh();
 }
Exemple #9
0
 public override void InitChildren(Element2D parent, GUIHost host, ButtonCallback MyButtonCallback)
 {
     Parent = parent;
     Init(host);
     lock (ChildList)
     {
         foreach (Element2D child in ChildList)
         {
             child.InitChildren(this, host, MyButtonCallback);
         }
     }
 }
Exemple #10
0
 public override void InitChildren(Element2D parent, GUIHost host, ButtonCallback MyButtonCallback)
 {
     Parent = parent;
     Init(host, "guicontrols", u0, v0, u1, v1, columns, rows, no_frames, frame_time);
     lock (ChildList)
     {
         foreach (Element2D child in ChildList)
         {
             child.InitChildren(this, host, MyButtonCallback);
         }
     }
 }
Exemple #11
0
 public ImageWidget(int ID, Element2D parent)
     : base(ID, parent)
 {
     drawable_sprite  = new Sprite();
     state            = State.Normal;
     text_area_height = 20;
     image_area_width = -1;
     sand_boxing      = false;
     sandboxingratio  = 1f;
     Text             = "";
     sandboxcolor     = new Color4(0.0f, 0.0f, 0.0f, 1f);
 }
Exemple #12
0
 public TextWidget(int ID, Element2D parent)
     : base(ID, parent)
 {
     color              = new Color4(0.0f, 0.0f, 0.0f, 1f);
     off_x              = 0;
     off_y              = 0;
     text               = "";
     size               = FontSize.Medium;
     alignment          = QFontAlignment.Centre;
     vertical_alignment = TextVerticalAlignment.Middle;
     IgnoreMouse        = true;
 }
Exemple #13
0
 public EditBoxWidget(int ID, Element2D parent)
     : base(ID, parent)
 {
     drawable_sprite  = new Sprite();
     textline         = new TextLine();
     cursor_stopwatch = new Stopwatch();
     cursor_stopwatch.Start();
     textline.SetText("");
     hint_text = "";
     SetGrowableWidth(3, 3, 32);
     SetTextWindowBorders(4, 4, 4, 4);
 }
Exemple #14
0
        public void TurnOffGroup(int group, Element2D except)
        {
            if (group == -1)
            {
                return;
            }

            foreach (Element2D child in ChildList)
            {
                if (child.GroupID == group && child != except)
                {
                    child.SetOff();
                }
            }
        }
Exemple #15
0
        public virtual void InitChildren(Element2D parent, GUIHost host, ButtonCallback MyButtonCallback)
        {
            SetParent(parent);
            if (HasFocus)
            {
                SetAsFocused(host);
            }

            foreach (Element2D child in ChildList)
            {
                child.SetParent(this);
                child.InitChildren(this, host, MyButtonCallback);
            }
            Refresh();
        }
Exemple #16
0
        public override void InitChildren(Element2D parent, GUIHost host, ButtonCallback MyButtonCallback)
        {
            if (!parent.IsComboBoxElement() && !parent.IsListBoxElement() && (u0 == 0.0 && v0 == 0.0) && (u1 == 0.0 && v1 == 0.0))
            {
                SetToDefaultOptions(type_template);
            }

            base.InitChildren(parent, host, MyButtonCallback);
            if (parent.GetElementType() != ElementType.ComboBoxWidget)
            {
                SetCallback(MyButtonCallback);
            }

            SetGrowableWidth(16, 16, 48);
        }
Exemple #17
0
        public bool IsScrollFrame()
        {
            if (GetElementType() == ElementType.ScrollFrame)
            {
                return(true);
            }

            for (Element2D parent = Parent; parent != null; parent = parent.Parent)
            {
                if (parent.GetElementType() == ElementType.ScrollFrame)
                {
                    return(true);
                }
            }
            return(false);
        }
Exemple #18
0
        public ListBoxWidget GetListBoxElement()
        {
            if (GetElementType() == ElementType.ListBoxWidget)
            {
                return((ListBoxWidget)this);
            }

            for (Element2D parent = Parent; parent != null; parent = parent.Parent)
            {
                if (parent.GetElementType() == ElementType.ListBoxWidget)
                {
                    return((ListBoxWidget)parent);
                }
            }
            return(null);
        }
Exemple #19
0
        public bool IsListBoxElement()
        {
            if (GetElementType() == ElementType.ListBoxWidget)
            {
                return(true);
            }

            for (Element2D parent = Parent; parent != null; parent = parent.Parent)
            {
                if (parent.GetElementType() == ElementType.ListBoxWidget)
                {
                    return(true);
                }
            }
            return(false);
        }
Exemple #20
0
        public Frame GetScrollFrame()
        {
            if (GetElementType() == ElementType.ScrollFrame)
            {
                return((Frame)this);
            }

            for (Element2D parent = Parent; parent != null; parent = parent.Parent)
            {
                if (parent.GetElementType() == ElementType.ScrollFrame)
                {
                    return((Frame)parent);
                }
            }
            return(null);
        }
Exemple #21
0
        public virtual void OnControlMsg(Element2D the_control, ControlMsg msg, float xparam, float yparam)
        {
            if (OnControlMsgCallback != null)
            {
                OnControlMsgCallback(the_control, msg, xparam, yparam);
            }
            else
            {
                if (parent == null)
                {
                    return;
                }

                parent.OnControlMsg(the_control, msg, xparam, yparam);
            }
        }
Exemple #22
0
        public Element2D FindChildElement(int ID)
        {
            foreach (Element2D child in ChildList)
            {
                if (child.ID == ID)
                {
                    return(child);
                }

                Element2D childElement = child.FindChildElement(ID);
                if (childElement != null)
                {
                    return(childElement);
                }
            }
            return(null);
        }
Exemple #23
0
        public Element2D FindChildElement(string tag)
        {
            foreach (Element2D child in ChildList)
            {
                if (child.tag == tag)
                {
                    return(child);
                }

                Element2D childElement = child.FindChildElement(tag);
                if (childElement != null)
                {
                    return(childElement);
                }
            }
            return(null);
        }
Exemple #24
0
 public ComboBoxWidget(int ID, Element2D parent)
     : base(ID, parent)
 {
     dropdown_height = 96;
     listboxwidget   = new ListBoxWidget(2);
     buttonwidget    = new ButtonWidget(1);
     editboxwidget   = new EditBoxWidget(0);
     editboxwidget.SetCallbackOnClick(new EditBoxWidget.EditBoxCallback(MyEditBoxCallback));
     buttonwidget.DontMove = true;
     buttonwidget.SetCallback(new ButtonCallback(MyButtonCallback));
     listboxwidget.Visible = false;
     editboxwidget.Enabled = true;
     editboxwidget.Text    = "";
     ShowDropDown          = false;
     ChildList             = ChildList + listboxwidget;
     ChildList             = ChildList + buttonwidget;
     ChildList             = ChildList + editboxwidget;
 }
Exemple #25
0
 public virtual Element2D GetSelfOrDependantAtPoint(int x, int y)
 {
     if (ContainsPoint(x, y) && Visible && (Enabled || ChildList.Count > 0))
     {
         foreach (Element2D element2D in ChildList.Reverse())
         {
             Element2D dependantAtPoint = element2D.GetSelfOrDependantAtPoint(x, y);
             if (dependantAtPoint != null && dependantAtPoint.Enabled && !dependantAtPoint.IgnoreMouse)
             {
                 return(dependantAtPoint);
             }
         }
         if (GetElementType() != ElementType.Frame)
         {
             return(this);
         }
     }
     return(null);
 }
Exemple #26
0
 public ButtonWidget(int ID, Element2D parent)
     : base(ID, parent)
 {
     textcolor          = new Color4(0.1843137f, 0.3294118f, 0.345098f, 1f);
     textovercolor      = new Color4(0.3686275f, 0.6588235f, 0.6901961f, 1f);
     textdowncolor      = new Color4(0.25f, 0.25f, 0.25f, 1f);
     textdisabledcolor  = new Color4(0.7f, 0.7f, 0.7f, 1f);
     white              = new Color4(1f, 1f, 1f, 1f);
     imageHasFocusColor = white;
     Color              = textcolor;
     down            = false;
     state           = State.Normal;
     buttoncallback  = null;
     ClickType       = ButtonType.Clickable;
     _can_click_off  = false;
     draggable_fully = false;
     dragged_fully   = false;
     dragged_x_fully = 0;
     dragged_y_fully = 0;
     IgnoreMouse     = false;
 }
Exemple #27
0
        public override void OnControlMsg(Element2D the_control, ControlMsg msg, float xparam, float yparam)
        {
            if (the_control.ID == 1)
            {
                if (msg != ControlMsg.SCROLL_MOVE)
                {
                    return;
                }

                start_row = (int)xparam;
                if (start_row >= 0)
                {
                    return;
                }

                start_row = 0;
            }
            else
            {
                base.OnControlMsg(the_control, msg, xparam, yparam);
            }
        }
Exemple #28
0
 public SliderWidget(int ID, Element2D parent)
     : base(ID, parent)
 {
     m_trackSubControl             = new ImageWidget(0, this);
     m_buttonSubControl            = new ButtonWidget(0, this);
     m_pushButtonPlus              = new ButtonWidget(1, this);
     m_pushButtonMinus             = new ButtonWidget(2, this);
     m_buttonSubControl.DontMove   = true;
     m_pushButtonPlus.DontMove     = true;
     m_pushButtonMinus.DontMove    = true;
     m_trackSubControl.IgnoreMouse = true;
     ChildList             = ChildList + m_trackSubControl;
     ChildList             = ChildList + m_buttonSubControl;
     ChildList             = ChildList + m_pushButtonPlus;
     ChildList             = ChildList + m_pushButtonMinus;
     m_track_size          = 0.0f;
     m_track_position      = 0.0f;
     m_button_size         = 0.0f;
     m_button_size_percent = 0.0f;
     m_range_start         = 0.0f;
     m_range        = 1f;
     m_button_range = 0.0f;
 }
Exemple #29
0
 public override void InitChildren(Element2D parent, GUIHost host, ButtonCallback MyButtonCallback)
 {
     Parent = parent;
     if (parent.GetElementType() != ElementType.ComboBoxWidget)
     {
         Init(host, "guicontrols", u0, v0, u1, v1);
         SetGrowableWidth(3, 3, 32);
         SetTextWindowBorders(4, 4, 4, 4);
     }
     else
     {
         HexColor       = ((ComboBoxWidget)parent).HexColor;
         Size           = ((ComboBoxWidget)parent).Size;
         ToolTipMessage = parent.ToolTipMessage;
     }
     lock (ChildList)
     {
         foreach (Element2D child in ChildList)
         {
             child.InitChildren(this, host, MyButtonCallback);
         }
     }
 }
        public override void RemoveChildElement(Element2D child)
        {
            base.RemoveChildElement(child);
            var index = info_list.FindIndex(ci => child == ci.element);

            if (index < 0)
            {
                return;
            }

            info_list.RemoveAt(index);
            if (index == info_list.Count)
            {
                --StartIndex;
            }
            else if (index == 0)
            {
                ++StartIndex;
            }
            else
            {
                RecalcChildSizes();
            }
        }