Ejemplo n.º 1
0
        public G2DScrollPane(G2DComponent scrollableContent, ScrollBarPolicy horizontalPolicy, ScrollBarPolicy verticalPolicy)
        {
            if (!(scrollableContent is Scrollable))
                throw new ArgumentException("The scrollableContent has to implement Scrollable interface");

            this.scrollableContent = scrollableContent;

            enableWheelScroll = true;

            drawBackground = false;

            hBarPolicy = horizontalPolicy;
            vBarPolicy = verticalPolicy;

            hScrollBar = new G2DScrollBar(GoblinEnums.Orientation.Horizontal, 0, 2, 2);
            vScrollBar = new G2DScrollBar(GoblinEnums.Orientation.Vertical, 2, 2, 2);

            if (vBarPolicy == ScrollBarPolicy.Always)
                showVScroll = true;
            else
                showVScroll = false;

            if (hBarPolicy == ScrollBarPolicy.Always)
                showHScroll = true;
            else
                showHScroll = false;
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Removes a child component from this panel if already added.
        /// </summary>
        /// <param name="comp">A 2D component to be removed</param>
        /// <returns>Whether removal succeeded</returns>
        public virtual bool RemoveChild(G2DComponent comp)
        {
            bool removed = children.Remove(comp);

            if (removed)
            {
                comp.Parent = null;
                comp.RemoveKeyInput();
                comp.RemoveMouseInput();

                InvokeComponentRemovedEvent(this, comp);
            }

            return(removed);
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Gets the parent right before reaching the root
 /// </summary>
 /// <param name="comp"></param>
 /// <returns></returns>
 protected virtual G2DPanel GetPreRootParent(G2DComponent comp)
 {
     if (comp.HasParent && ((G2DPanel)comp.Parent).HasParent)
     {
         return(GetPreRootParent((G2DComponent)comp.Parent));
     }
     else
     {
         if (comp is G2DPanel)
         {
             return((G2DPanel)comp);
         }
         else
         {
             return(null);
         }
     }
 }
Ejemplo n.º 4
0
        /*/// <summary>
         * /// Set the border to be a titled border with a title
         * /// </summary>
         * /// <param name="title"></param>
         * public virtual void SetTitledBorder(String title)
         * {
         *  this.title = title;
         *  this.border = GoblinEnums.BorderFactory.TitledBorder;
         * }*/
        #endregion

        #region Action Methods
        /// <summary>
        /// Adds a child component to this panel.
        /// </summary>
        /// <remarks>
        /// Note that when you add a child component, the child component will automatically inherit the following
        /// properties from this panel: Transparency, TextTransparency, Visible, and Enabled. If you want to have
        /// a different value for these properties, then you should set these property values of the child component
        /// after adding to this panel.
        /// </remarks>
        /// <param name="comp">A 2D component to be added</param>
        public virtual void AddChild(G2DComponent comp)
        {
            if (comp.Parent != null)
            {
                throw new GoblinException("This G2DComponent already has a parent");
            }

            if (comp != null && !children.Contains(comp))
            {
                comp.Parent           = this;
                comp.Transparency     = Transparency;
                comp.TextTransparency = TextTransparency;
                comp.Visible          = Visible;
                comp.Enabled          = Enabled;
                comp.RegisterKeyInput();
                comp.RegisterMouseInput();
                children.Add(comp);

                G2DPanel root = (G2DPanel)comp.RootParent;

                InvokeComponentAddedEvent(this, comp);
            }
        }
Ejemplo n.º 5
0
        public G2DScrollPane(G2DComponent scrollableContent, ScrollBarPolicy horizontalPolicy, ScrollBarPolicy verticalPolicy)
        {
            if (!(scrollableContent is Scrollable))
            {
                throw new ArgumentException("The scrollableContent has to implement Scrollable interface");
            }

            this.scrollableContent = scrollableContent;

            enableWheelScroll = true;

            drawBackground = false;

            hBarPolicy = horizontalPolicy;
            vBarPolicy = verticalPolicy;

            hScrollBar = new G2DScrollBar(GoblinEnums.Orientation.Horizontal, 0, 2, 2);
            vScrollBar = new G2DScrollBar(GoblinEnums.Orientation.Vertical, 2, 2, 2);

            if (vBarPolicy == ScrollBarPolicy.Always)
            {
                showVScroll = true;
            }
            else
            {
                showVScroll = false;
            }

            if (hBarPolicy == ScrollBarPolicy.Always)
            {
                showHScroll = true;
            }
            else
            {
                showHScroll = false;
            }
        }
Ejemplo n.º 6
0
 public G2DScrollPane(G2DComponent scrollableContent)
     : this(scrollableContent, ScrollBarPolicy.Never, ScrollBarPolicy.AsNeeded)
 {
 }
Ejemplo n.º 7
0
 public G2DScrollPane(G2DComponent scrollableContent) 
     : this(scrollableContent, ScrollBarPolicy.Never, ScrollBarPolicy.AsNeeded) { }
Ejemplo n.º 8
0
 /// <summary>
 /// Removes a 2D UI component from the rendering process.
 /// </summary>
 /// <param name="comp2d"></param>
 public void Remove2DComponent(G2DComponent comp2d)
 {
     comp2Ds.Remove(comp2d);
     comp2d.RemoveKeyInput();
     comp2d.RemoveMouseInput();
 }
Ejemplo n.º 9
0
 /// <summary>
 /// Adds a 2D UI component to be rendered on the screen.
 /// </summary>
 /// <remarks>You should only add top-level components that do not have a parent component.</remarks>
 /// <param name="comp2d">A top-level G2DComponent object</param>
 public void Add2DComponent(G2DComponent comp2d)
 {
     if (!comp2Ds.Contains(comp2d))
     {
         if (comp2d.HasParent)
             throw new GoblinException("You should only add root components to this list. "
                 + "Any component with parents are automatically rendered by its parent " +
                 "component");
         else
         {
             comp2Ds.Add(comp2d);
             comp2d.RegisterKeyInput();
             comp2d.RegisterMouseInput();
         }
     }
 }
Ejemplo n.º 10
0
 /// <summary>
 /// Gets the parent right before reaching the root
 /// </summary>
 /// <param name="comp"></param>
 /// <returns></returns>
 protected virtual G2DPanel GetPreRootParent(G2DComponent comp)
 {
     if (comp.HasParent && ((G2DPanel)comp.Parent).HasParent)
         return GetPreRootParent((G2DComponent)comp.Parent);
     else
     {
         if (comp is G2DPanel)
             return (G2DPanel)comp;
         else
             return null;
     }
 }
Ejemplo n.º 11
0
        /// <summary>
        /// Removes a child component from this panel if already added.
        /// </summary>
        /// <param name="comp">A 2D component to be removed</param>
        /// <returns>Whether removal succeeded</returns>
        public virtual bool RemoveChild(G2DComponent comp)
        {
            bool removed = children.Remove(comp);
            if (removed)
            {
                comp.Parent = null;
                comp.RemoveKeyInput();
                comp.RemoveMouseInput();

                InvokeComponentRemovedEvent(this, comp);
            }

            return removed;
        }
Ejemplo n.º 12
0
        /*/// <summary>
        /// Set the border to be a titled border with a title
        /// </summary>
        /// <param name="title"></param>
        public virtual void SetTitledBorder(String title)
        {
            this.title = title;
            this.border = GoblinEnums.BorderFactory.TitledBorder;
        }*/
        #endregion

        #region Action Methods
        /// <summary>
        /// Adds a child component to this panel.
        /// </summary>
        /// <remarks>
        /// Note that when you add a child component, the child component will automatically inherit the following
        /// properties from this panel: Transparency, TextTransparency, Visible, and Enabled. If you want to have
        /// a different value for these properties, then you should set these property values of the child component 
        /// after adding to this panel. 
        /// </remarks>
        /// <param name="comp">A 2D component to be added</param>
        public virtual void AddChild(G2DComponent comp)
        {
            if (comp.Parent != null)
                throw new GoblinException("This G2DComponent already has a parent");

            if (comp != null && !children.Contains(comp))
            {
                comp.Parent = this;
                comp.Transparency = Transparency;
                comp.TextTransparency = TextTransparency;
                comp.Visible = Visible;
                comp.Enabled = Enabled;
                comp.RegisterKeyInput();
                comp.RegisterMouseInput();
                children.Add(comp);

                G2DPanel root = (G2DPanel)comp.RootParent;

                InvokeComponentAddedEvent(this, comp);
            }
        }