Inheritance: XGControl
Example #1
0
        public override void Update(GameTime gameTime)
        {
            float frameTime = (float)gameTime.ElapsedGameTime.TotalSeconds;

            if (CurrentTabPage == null || Children.Count != lastPageCount)
            {
                lastPageCount = Children.Count;
                if (Children.Count > 0)
                    CurrentTabPage = Children[0] as XGTabPage;
            }
            base.Update(gameTime);
        }
Example #2
0
 internal Rectangle GetPageRect(XGTabPage tabPage)
 {
     Rectangle pageRect = ToScreen(Rectangle);
     int tabHeight = XnaGUIManager.spriteFont.LineSpacing + 5;
     pageRect.Y += tabHeight;
     pageRect.Height -= tabHeight;
     return pageRect;
 }
Example #3
0
        internal Rectangle GetTabRect(XGTabPage tabPage)
        {
            if (tabPage == null)
                return Rectangle.Empty;

            Rectangle rect = ToScreen(Rectangle);
            rect.Height = XnaGUIManager.spriteFont.LineSpacing + 8;
            rect.Width = 0;
            for (int i = 0; i < Children.Count; i++)
            {
                int tabWidth = (int )XnaGUIManager.spriteFont.MeasureString(Children[i].Text).X + 8;
                if (Children[i] == tabPage)
                {
                    rect.Width = tabWidth;
                    return rect;
                }
                rect.X += tabWidth;
            }
            return rect;
        }
Example #4
0
        internal override bool Activate(Point point)
        {
            Rectangle rect = ToScreen(Rectangle);
            int tabHeight = XnaGUIManager.spriteFont.LineSpacing + 8;
            rect.Height = tabHeight;

            if (rect.Contains(point))
            {
                // activate a tab;
                for (int i = 0; i < Children.Count; i++)
                {
                    Rectangle tabRect = GetTabRect(Children[i] as XGTabPage);
                    if (tabRect.Contains(point))
                    {
                        this.focusControl = Children[i];
                        CurrentTabPage = this.focusControl as XGTabPage;
                        return true;
                    }
                }
                return false;
            }

            return base.Activate(point);
        }