Пример #1
0
        public bool OnMouseWheel(System.Windows.Forms.MouseEventArgs e)
        {
            bool handled = false;

            // if we aren't active do nothing.
            if ((!m_visible) || (!m_enabled))
            {
                return(false);
            }

            for (int index = 0; index < m_ChildWidgets.Count; index++)
            {
                jhuapl.util.IWidget currentWidget = m_ChildWidgets[index] as jhuapl.util.IWidget;

                if (currentWidget != null && currentWidget is jhuapl.util.IInteractive)
                {
                    jhuapl.util.IInteractive currentInteractive = m_ChildWidgets[index] as jhuapl.util.IInteractive;

                    handled = currentInteractive.OnMouseWheel(e);
                    if (handled)
                    {
                        return(handled);
                    }
                }
            }

            return(handled);
        }
Пример #2
0
 public void Insert(jhuapl.util.IWidget widget, int index)
 {
     if (index <= m_ChildWidgets.Count)
     {
         m_ChildWidgets.Insert(index, widget);
     }
     //probably want to throw an indexoutofrange type of exception
 }
Пример #3
0
 public void BringToFront(int index)
 {
     jhuapl.util.IWidget currentWidget = m_ChildWidgets[index] as jhuapl.util.IWidget;
     if (currentWidget != null)
     {
         m_ChildWidgets.RemoveAt(index);
         m_ChildWidgets.Insert(0, currentWidget);
     }
 }
Пример #4
0
 public jhuapl.util.IWidget RemoveAt(int index)
 {
     if (index < m_ChildWidgets.Count)
     {
         jhuapl.util.IWidget oldWidget = m_ChildWidgets[index] as jhuapl.util.IWidget;
         m_ChildWidgets.RemoveAt(index);
         return(oldWidget);
     }
     else
     {
         return(null);
     }
 }
Пример #5
0
        public void BringToFront(jhuapl.util.IWidget widget)
        {
            int foundIndex = -1;

            for (int index = 0; index < m_ChildWidgets.Count; index++)
            {
                jhuapl.util.IWidget currentWidget = m_ChildWidgets[index] as jhuapl.util.IWidget;
                if (currentWidget != null)
                {
                    if (currentWidget == widget)
                    {
                        foundIndex = index;
                        break;
                    }
                }
            }

            if (foundIndex > 0)
            {
                BringToFront(foundIndex);
            }
        }
Пример #6
0
        public void Render(DrawArgs drawArgs)
        {
            // if we aren't active do nothing.
            if ((!m_visible) || (!m_enabled))
            {
                return;
            }

            for (int index = m_ChildWidgets.Count - 1; index >= 0; index--)
            {
                jhuapl.util.IWidget currentWidget = m_ChildWidgets[index] as jhuapl.util.IWidget;
                if (currentWidget != null)
                {
                    if (currentWidget.ParentWidget == null || currentWidget.ParentWidget != this)
                    {
                        currentWidget.ParentWidget = this;
                    }

                    currentWidget.Render(drawArgs);
                }
            }
        }
Пример #7
0
 public void Add(jhuapl.util.IWidget widget)
 {
     m_ChildWidgets.Add(widget);
 }
Пример #8
0
        /// <summary>
        /// The render method to draw this widget on the screen.
        ///
        /// Called on the GUI thread.
        /// </summary>
        /// <param name="drawArgs">The drawing arguments passed from the WW GUI thread.</param>
        public void Render(DrawArgs drawArgs)
        {
            if ((!m_visible) || (!m_enabled))
            {
                return;
            }

            if (!m_isInitialized)
            {
                Initialize(drawArgs);
            }

            int widgetTop    = this.Top;
            int widgetBottom = this.Bottom;
            int widgetLeft   = this.Left;
            int widgetRight  = this.Right;

            m_currHeaderHeight = 0;

            #region Header Rendering

            // If we should render the header
            if (HeaderEnabled)
            {
                m_currHeaderHeight = m_headerHeight;

                JHU_Utilities.DrawBox(
                    this.AbsoluteLocation.X,
                    this.AbsoluteLocation.Y,
                    m_size.Width,
                    m_currHeaderHeight,
                    0.0f,
                    m_HeaderColor.ToArgb(),
                    drawArgs.device);

                Rectangle nameBounds = m_TitleFont.MeasureString(
                    null,
                    m_name,
                    DrawTextFormat.None,
                    0);

                int widthLeft = m_size.Width;

                m_TitleFont.DrawText(
                    null,
                    m_name,
                    new System.Drawing.Rectangle(this.AbsoluteLocation.X + 2, this.AbsoluteLocation.Y + 2, widthLeft, m_currHeaderHeight),
                    DrawTextFormat.None,
                    m_TextColor.ToArgb());


                // if we don't render the body add whatever is in the text field as annotation
                if (!m_renderBody)
                {
                    widthLeft -= nameBounds.Width + 10;
                    if (widthLeft > 20)
                    {
                        m_TextFont.DrawText(
                            null,
                            Text,
                            new System.Drawing.Rectangle(this.AbsoluteLocation.X + 10 + nameBounds.Width, this.AbsoluteLocation.Y + 3, widthLeft, m_currHeaderHeight),
                            DrawTextFormat.None,
                            m_TextColor.ToArgb());
                    }
                }

                // Render border
                m_OutlineVertsHeader[0].X = AbsoluteLocation.X;
                m_OutlineVertsHeader[0].Y = AbsoluteLocation.Y;

                m_OutlineVertsHeader[1].X = AbsoluteLocation.X + m_size.Width;
                m_OutlineVertsHeader[1].Y = AbsoluteLocation.Y;

                m_OutlineVertsHeader[2].X = AbsoluteLocation.X + m_size.Width;
                m_OutlineVertsHeader[2].Y = AbsoluteLocation.Y + m_currHeaderHeight;

                m_OutlineVertsHeader[3].X = AbsoluteLocation.X;
                m_OutlineVertsHeader[3].Y = AbsoluteLocation.Y + m_currHeaderHeight;

                m_OutlineVertsHeader[4].X = AbsoluteLocation.X;
                m_OutlineVertsHeader[4].Y = AbsoluteLocation.Y;

                JHU_Utilities.DrawLine(m_OutlineVertsHeader, m_BorderColor.ToArgb(), drawArgs.device);
            }

            #endregion

            #region Body Rendering

            if (m_renderBody)
            {
                // Draw the interior background
                JHU_Utilities.DrawBox(
                    this.AbsoluteLocation.X,
                    this.AbsoluteLocation.Y + m_currHeaderHeight,
                    m_size.Width,
                    m_size.Height - m_currHeaderHeight,
                    0.0f,
                    m_BackgroundColor.ToArgb(),
                    drawArgs.device);

                int childrenHeight = 0;
                int childrenWidth  = 0;

                int bodyHeight = m_size.Height - m_currHeaderHeight;
                int bodyWidth  = m_size.Width;

                getChildrenSize(out childrenHeight, out childrenWidth);

                // Render each child widget

                int bodyLeft    = this.BodyLocation.X;
                int bodyRight   = this.BodyLocation.X + this.ClientSize.Width;
                int bodyTop     = this.BodyLocation.Y;
                int bodyBottom  = this.BodyLocation.Y + this.ClientSize.Height;
                int childLeft   = 0;
                int childRight  = 0;
                int childTop    = 0;
                int childBottom = 0;

                for (int index = m_ChildWidgets.Count - 1; index >= 0; index--)
                {
                    jhuapl.util.IWidget currentChildWidget = m_ChildWidgets[index] as jhuapl.util.IWidget;
                    if (currentChildWidget != null)
                    {
                        if (currentChildWidget.ParentWidget == null || currentChildWidget.ParentWidget != this)
                        {
                            currentChildWidget.ParentWidget = this;
                        }
                        System.Drawing.Point childLocation = currentChildWidget.AbsoluteLocation;

                        // if any portion is visible try to render
                        childLeft   = childLocation.X;
                        childRight  = childLocation.X + currentChildWidget.WidgetSize.Width;
                        childTop    = childLocation.Y;
                        childBottom = childLocation.Y + currentChildWidget.WidgetSize.Height;

                        if ((((childLeft >= bodyLeft) && (childLeft <= bodyRight)) ||
                             ((childRight >= bodyLeft) && (childRight <= bodyRight)) ||
                             ((childLeft <= bodyLeft) && (childRight >= bodyRight)))
                            &&
                            (((childTop >= bodyTop) && (childTop <= bodyBottom)) ||
                             ((childBottom >= bodyTop) && (childBottom <= bodyBottom)) ||
                             ((childTop <= bodyTop) && (childBottom >= bodyBottom)))
                            )
                        {
                            currentChildWidget.Visible = true;
                            currentChildWidget.Render(drawArgs);
                        }
                        else
                        {
                            currentChildWidget.Visible = false;
                        }
                    }
                }

                m_OutlineVerts[0].X = AbsoluteLocation.X;
                m_OutlineVerts[0].Y = AbsoluteLocation.Y + m_currHeaderHeight;

                m_OutlineVerts[1].X = AbsoluteLocation.X + m_size.Width;
                m_OutlineVerts[1].Y = AbsoluteLocation.Y + m_currHeaderHeight;

                m_OutlineVerts[2].X = AbsoluteLocation.X + m_size.Width;
                m_OutlineVerts[2].Y = AbsoluteLocation.Y + m_size.Height;

                m_OutlineVerts[3].X = AbsoluteLocation.X;
                m_OutlineVerts[3].Y = AbsoluteLocation.Y + m_size.Height;

                m_OutlineVerts[4].X = AbsoluteLocation.X;
                m_OutlineVerts[4].Y = AbsoluteLocation.Y + m_currHeaderHeight;

                JHU_Utilities.DrawLine(m_OutlineVerts, m_BorderColor.ToArgb(), drawArgs.device);
            }

            #endregion
        }
Пример #9
0
 /// <summary>
 /// Removes a child widget
 /// </summary>
 /// <param name="widget">The widget to be removed</param>
 new public void Remove(jhuapl.util.IWidget widget)
 {
     m_ChildWidgets.Remove(widget);
 }
Пример #10
0
 /// <summary>
 /// Adds a new child widget
 /// </summary>
 /// <param name="widget">The widget to be added</param>
 new public void Add(jhuapl.util.IWidget widget)
 {
     m_ChildWidgets.Add(widget);
     widget.ParentWidget = this;
 }
Пример #11
0
 new public void Remove(jhuapl.util.IWidget widget)
 {
     m_subNodes.Remove(widget);
 }
Пример #12
0
 new public void Add(jhuapl.util.IWidget widget)
 {
     m_subNodes.Add(widget);
     widget.ParentWidget = this;
 }