/// <summary>
        /// Initializes a new instance of the <see cref="ScrollControl"/> class.
        /// </summary>
        /// <param name="parent">Parent control.</param>
        public ScrollControl(ZGE.Components.ZComponent parent)
            : base(parent)
        {
            MouseInputEnabled = true;

            m_VerticalScrollBar = new VerticalScrollBar(this);
            m_VerticalScrollBar.Dock = Pos.Right;
            m_VerticalScrollBar.BarMoved += VBarMoved;
            m_CanScrollV = true;
            m_VerticalScrollBar.NudgeAmount = 30;

            m_HorizontalScrollBar = new HorizontalScrollBar(this);
            m_HorizontalScrollBar.Dock = Pos.Bottom;
            m_HorizontalScrollBar.BarMoved += HBarMoved;
            m_CanScrollH = true;
            m_HorizontalScrollBar.NudgeAmount = 30;

            m_InnerPanel = new GUIControl(this);
            m_InnerPanel.SetPosition(0, 0);
            m_InnerPanel.Margin = Margin.Five;
            m_InnerPanel.SendToBack();
            m_InnerPanel.MouseInputEnabled = false;

            m_AutoHideBars = false;
        }
Example #2
0
 public static void Add(GUIControl control, Animation animation)
 {
     animation.m_Control = control;
     if (!m_Animations.ContainsKey(control))
         m_Animations[control] = new List<Animation>();
     m_Animations[control].Add(animation);
 }
Example #3
0
        /// <summary>
        /// Centers the control vertically inside its parent.
        /// </summary>
        /// <param name="control"></param>
        public static void CenterVertically(GUIControl control)
        {
            GUIControl parent = control.ParentControl;
            if (null == parent) return;

            control.SetPosition(control.X, (parent.Height - control.Height) / 2);
        }
Example #4
0
        /// <summary>
        /// Enables tooltip display for the specified control.
        /// </summary>
        /// <param name="control">Target control.</param>
        public static void Enable(GUIControl control)
        {
            if (null == control.ToolTip)
                return;

            g_ToolTip = control;
        }
Example #5
0
 /// <summary>
 /// Disables tooltip display for the specified control.
 /// </summary>
 /// <param name="control">Target control.</param>
 public static void Disable(GUIControl control)
 {
     if (g_ToolTip == control)
     {
         g_ToolTip = null;
     }
 }
Example #6
0
        /// <summary>
        /// Moves the control to the left of its parent.
        /// </summary>
        /// <param name="control"></param>
        public static void AlignLeft(GUIControl control)
        {
            GUIControl parent = control.ParentControl;
            if (null == parent) return;

            control.SetPosition(parent.Padding.Left, control.Y);
        }
Example #7
0
 public static void Cancel(GUIControl control)
 {
     if (m_Animations.ContainsKey(control))
     {
         m_Animations[control].Clear();
         m_Animations.Remove(control);
     }
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="RadioButtonGroup"/> class.
 /// </summary>
 /// <param name="parent">Parent control.</param>
 /// <param name="label">Label for the outlining GroupBox.</param>
 public RadioButtonGroup(GUIControl parent, String label)
     : base(parent)
 {
     IsTabable = false;
     KeyboardInputEnabled = true;
     Text = label;
     AutoSizeToContents = true;
 }
Example #9
0
        /// <summary>
        /// Centers the control horizontally inside its parent.
        /// </summary>
        /// <param name="control"></param>
        public static void CenterHorizontally(GUIControl control)
        {
            GUIControl parent = control.ParentControl;
            if (null == parent) return;


            control.SetPosition(parent.Padding.Left + (((parent.Width - parent.Padding.Left - parent.Padding.Right) - control.Width) / 2), control.Y);
        }
Example #10
0
        /// <summary>
        /// Moves the control to the right of its parent.
        /// </summary>
        /// <param name="control"></param>
        public static void AlignRight(GUIControl control)
        {
            GUIControl parent = control.ParentControl;
            if (null == parent) return;


            control.SetPosition(parent.Width - control.Width - parent.Padding.Right, control.Y);
        }
Example #11
0
        void OpenMsgbox(GUIControl control)
        {
            MessageBox window = new MessageBox(GetCanvas(), 
                String.Format("Window {0}   MessageBox window = new MessageBox(GetCanvas(), String.Format(  MessageBox window = new MessageBox(GetCanvas(), String.Format(", m_WindowCount), "");
            window.SetPosition(rand.Next(700), rand.Next(400));

            m_WindowCount++;
        }
Example #12
0
 /// <summary>
 /// Centers the control inside its parent.
 /// </summary>
 /// <param name="control">Control to center.</param>
 public static void Center(GUIControl control)
 {
     GUIControl parent = control.ParentControl;
     if (parent == null) 
         return;
     control.SetPosition(
         parent.Padding.Left + (((parent.Width - parent.Padding.Left - parent.Padding.Right) - control.Width)/2),
         (parent.Height - control.Height)/2);
 }
 void ColorChanged(GUIControl control)
 {
     IColorPicker picker = control as IColorPicker;
     Color c = picker.SelectedColor;
     HSV hsv = c.ToHSV();
     String text = String.Format("Color changed: RGB: {0:X2}{1:X2}{2:X2} HSV: {3:F1} {4:F2} {5:F2}",
                                 c.R, c.G, c.B, hsv.h, hsv.s, hsv.v);
     UnitPrint(text);
 }
Example #14
0
        void OpenWindow(GUIControl control)
        {
            Control.WindowControl window = new Control.WindowControl(GetCanvas(),"",false);
            window.Caption = String.Format("Window {0}", m_WindowCount);
            window.SetSize(rand.Next(200, 400), rand.Next(200, 400));
            window.SetPosition(rand.Next(700), rand.Next(400));

            m_WindowCount++;
        }
Example #15
0
        private static void UpdateHoveredControl(GUIControl control, int x, int y)
        {
            //
            // We use this global variable to represent our hovered control
            // That way, if the new hovered control gets deleted in one of the
            // Hover callbacks, we won't be left with a hanging pointer.
            // This isn't ideal - but it's minimal.
            //
            m_NewHoveredControl = control;

            // Nothing to change..
            if (HoveredControl == m_NewHoveredControl)
                return;

            // We changed - tell the old hovered control that it's no longer hovered.
            if (HoveredControl != null && HoveredControl != m_NewHoveredControl)
                HoveredControl.DragAndDrop_HoverLeave(CurrentPackage);

            // If we're hovering where the control came from, just forget it.
            // By changing it to null here we're not going to show any error cursors
            // it will just do nothing if you drop it.
            if (m_NewHoveredControl == SourceControl)
                m_NewHoveredControl = null;

            // Check to see if the new potential control can accept this type of package.
            // If not, ignore it and show an error cursor.
            while (m_NewHoveredControl != null && !m_NewHoveredControl.DragAndDrop_CanAcceptPackage(CurrentPackage))
            {
                // We can't drop on this control, so lets try to drop
                // onto its parent..
                m_NewHoveredControl = m_NewHoveredControl.ParentControl;

                // Its parents are dead. We can't drop it here.
                // Show the NO WAY cursor.
                if (m_NewHoveredControl == null)
                {
                    Platform.Neutral.SetCursor(Cursors.No);
                }
            }

            // Become out new hovered control
            HoveredControl = m_NewHoveredControl;

            // If we exist, tell us that we've started hovering.
            if (HoveredControl != null)
            {
                HoveredControl.DragAndDrop_HoverEnter(CurrentPackage, x, y);
            }

            m_NewHoveredControl = null;
        }
Example #16
0
        /// <summary>
        /// Initializes a new instance of the <see cref="PropertyRow"/> class.
        /// </summary>
        /// <param name="parent">Parent control.</param>
        /// <param name="prop">Property control associated with this row.</param>
        public PropertyRow(GUIControl parent, Property.PropertyBase prop)
            : base(parent)
        {
            PropertyRowLabel label = new PropertyRowLabel(this);
            label.Dock = Pos.Left;
            label.Alignment = Pos.Left | Pos.Top;
            label.Margin = new Margin(2, 2, 0, 0);
            m_Label = label;

            m_Property = prop;
            m_Property.ParentControl = this;
            m_Property.Dock = Pos.Fill;
            m_Property.ValueChanged += OnValueChanged;
        }
        /// <summary>
        /// Handler for CheckChanged event.
        /// </summary>
        protected virtual void OnCheckChanged(GUIControl control)
        {
            if (m_CheckBox.IsChecked)
            {
                if (Checked != null)
                    Checked.Invoke(this);
            }
            else
            {
                if (UnChecked != null)
                    UnChecked.Invoke(this);
            }

            if (CheckChanged != null)
                CheckChanged.Invoke(this);
        }
Example #18
0
        private static bool onDrop(int x, int y)
        {
            bool success = false;

            if (HoveredControl != null)
            {
                HoveredControl.DragAndDrop_HoverLeave(CurrentPackage);
                success = HoveredControl.DragAndDrop_HandleDrop(CurrentPackage, x, y);
            }

            // Report back to the source control, to tell it if we've been successful.
            SourceControl.DragAndDrop_EndDragging(success, x, y);

            CurrentPackage = null;
            SourceControl = null;

            return true;
        }
Example #19
0
        /// <summary>
        /// Initializes a new instance of the <see cref="GroupBox"/> class.
        /// </summary>
        /// <param name="parent">Parent control.</param>
        public GroupBox(ZGE.Components.ZComponent parent)
            : base(parent)
        {
            // Set to true, because it's likely that our  
            // children will want mouse input, and they
            // can't get it without us..
            MouseInputEnabled = true;
            KeyboardInputEnabled = true;

            TextPadding = new Padding(10, 0, 10, 0);
            Alignment = Pos.Top | Pos.Left;
            Invalidate();

            m_InnerPanel = new GUIControl(this);
            m_InnerPanel.Dock = Pos.Fill;
            m_InnerPanel.Margin = new Margin(5, TextHeight+5, 5, 5);
            //Margin = new Margin(5, 5, 5, 5);
        }
Example #20
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ComboBox"/> class.
        /// </summary>
        /// <param name="parent">Parent control.</param>
        public ComboBox(ZGE.Components.ZComponent parent)
            : base(parent)
        {
            SetSize(100, 20);
            m_Menu = new Menu(this);
            m_Menu.IsHidden = true;
            m_Menu.IconMarginDisabled = true;
            m_Menu.IsTabable = false;

            DownArrow arrow = new DownArrow(this);
            m_Button = arrow;

            Alignment = Pos.Left | Pos.CenterV;
            Text = String.Empty;
            Margin = new Margin(3, 0, 0, 0);

            IsTabable = true;
            KeyboardInputEnabled = true;
        }
        /// <summary>
        /// Handler for Selected event.
        /// </summary>
        /// <param name="control">Event source.</param>
        protected virtual void OnSelected(GUIControl control)
        {
            CategoryButton child = control as CategoryButton;
            if (child == null) return;

            if (m_List != null)
            {
                m_List.UnselectAll();
            }
            else
            {
                UnselectAll();
            }

            child.ToggleState = true;

            if (Selected != null)
                Selected.Invoke(this);
        }
Example #22
0
        private static bool ShouldStartDraggingControl( int x, int y )
        {
            // We're not holding a control down..
            if (m_LastPressedControl == null) 
                return false;

            // Not been dragged far enough
            int length = Math.Abs(x - m_LastPressedPos.X) + Math.Abs(y - m_LastPressedPos.Y);
            if (length < 5) 
                return false;

            // Create the dragging package

            CurrentPackage = m_LastPressedControl.DragAndDrop_GetPackage(m_LastPressedPos.X, m_LastPressedPos.Y);

            // We didn't create a package!
            if (CurrentPackage == null)
            {
                m_LastPressedControl = null;
                SourceControl = null;
                return false;
            }

            // Now we're dragging something!
            SourceControl = m_LastPressedControl;
            InputHandler.MouseFocus = null;
            m_LastPressedControl = null;
            CurrentPackage.DrawControl = null;

            // Some controls will want to decide whether they should be dragged at that moment.
            // This function is for them (it defaults to true)
            if (!SourceControl.DragAndDrop_ShouldStartDrag())
            {
                SourceControl = null;
                CurrentPackage = null;
                return false;
            }

            SourceControl.DragAndDrop_StartDragging(CurrentPackage, m_LastPressedPos.X, m_LastPressedPos.Y);

            return true;
        }
Example #23
0
        /// <summary>
        /// Initializes a new instance of the <see cref="MessageBox"/> class.
        /// </summary>
        /// <param name="parent">Parent control.</param>
        /// <param name="text">Message to display.</param>
        /// <param name="caption">Window caption.</param>
        public MessageBox(GUIControl parent, String text, String caption) 
            : base(parent, caption, true)
        {
            DeleteOnClose = true;

            m_Label = new Label(m_InnerPanel);
            m_Label.Text = text;
            m_Label.Margin = Margin.Five;
            m_Label.Dock = Pos.Top;
            m_Label.Alignment = Pos.Center;
            m_Label.AutoSizeToContents = true;

            m_Button = new Button(m_InnerPanel);
            m_Button.Text = "OK"; // todo: parametrize buttons
            m_Button.Clicked += CloseButtonPressed;
            m_Button.Clicked += DismissedHandler;
            m_Button.Margin = Margin.Five;
            m_Button.SetSize(50, 20);

            Align.Center(this);
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="WindowControl"/> class.
        /// </summary>
        /// <param name="parent">Parent control.</param>
        /// <param name="caption">Window caption.</param>
        /// <param name="modal">Determines whether the window should be modal.</param>
        public WindowControl(GUIControl parent, String caption, bool modal)
            : base(parent)
        {
            m_TitleBar = new Dragger(this);
            m_TitleBar.Height = 24;
            m_TitleBar.Padding = Gwen.Padding.Zero;
            m_TitleBar.Margin = new Margin(0, 0, 0, 4);
            m_TitleBar.Target = this;
            m_TitleBar.Dock = Pos.Top;

            m_Caption = new Label(m_TitleBar);
            m_Caption.Alignment = Pos.Left | Pos.CenterV;
            m_Caption.Text = caption;
            m_Caption.Dock = Pos.Fill;
            m_Caption.Padding = new Padding(8, 0, 0, 0);
            m_Caption.TextColor = Skin.Colors.Window.TitleInactive;

            m_CloseButton = new CloseButton(m_TitleBar, this);
            //m_CloseButton.Text = String.Empty;
            m_CloseButton.SetSize(24, 24);
            m_CloseButton.Dock = Pos.Right;
            m_CloseButton.Clicked += CloseButtonPressed;
            m_CloseButton.IsTabable = false;
            m_CloseButton.Name = "closeButton";

            //Create a blank content control, dock it to the top - Should this be a ScrollControl?
            m_InnerPanel = new GUIControl(this);
            m_InnerPanel.Dock = Pos.Fill;
            GetResizer(8).Hide();
            BringToFront();
            IsTabable = false;
            Focus();
            MinimumSize = new Point(100, 40);
            ClampMovement = true;
            KeyboardInputEnabled = false;

            if (modal)
                MakeModal(false);
        }
        protected virtual void CloseButtonPressed(GUIControl control)
        {
            IsHidden = true;

            if (m_Modal != null)
            {
                m_Modal.DelayedDelete();
                m_Modal = null;
            }

            if (m_DeleteOnClose)
            {
                ParentControl.RemoveChild(this, true);
            }
        }
Example #26
0
 private void OnCategorySelect(GUIControl control)
 {
     if (m_LastControl != null)
     {
         m_LastControl.Hide();
     }
     GUIControl test = control.UserData as GUIControl;
     test.Show();
     m_LastControl = test;
 }
Example #27
0
 private void DebugCheckChanged(GUIControl control)
 {
     /*if (m_DebugCheck.IsChecked)
         m_Center.DrawDebugOutlines = true;
     else
         m_Center.DrawDebugOutlines = false;*/
     Invalidate();
 }
Example #28
0
        /// <summary>
        /// Moves the control to the bottom of its parent.
        /// </summary>
        /// <param name="control"></param>
        public static void AlignBottom(GUIControl control)
        {
            GUIControl parent = control.ParentControl;
            if (null == parent) return;

            control.SetPosition(control.X, parent.Height - control.Height);
        }
Example #29
0
 /// <summary>
 /// Moves the control to the top of its parent.
 /// </summary>
 /// <param name="control"></param>
 public static void AlignTop(GUIControl control)
 {
     control.SetPosition(control.X, 0);
 }
Example #30
0
 public static void PlaceRightBottom(GUIControl control, GUIControl anchor, int spacing)
 {
     control.SetPosition(anchor.Right + spacing, anchor.Y - control.Height + anchor.Height);
 }