Beispiel #1
0
        protected override void DrawControl(Renderer renderer, Rectangle rect, GameTime gameTime)
        {
            //base.DrawControl(renderer, rect, gameTime);

            SkinLayer s = new SkinLayer(Skin.Layers[0]);
            s.Text.Alignment = alignment;
            renderer.DrawString(this, s, Text, rect, true, 0, 0, ellipsis);
        }
Beispiel #2
0
        protected override void DrawControl(Renderer renderer, Rectangle rect, GameTime gameTime)
        {
            SkinLayer layer = Skin.Layers["Control"];
            SpriteFont font = (layer.Text != null && layer.Text.Font != null) ? layer.Text.Font.Resource : null;
            Color col = (layer.Text != null) ? layer.Text.Colors.Enabled : Color.White;
            Point offset = new Point(layer.Text.OffsetX, layer.Text.OffsetY);

            renderer.DrawLayer(this, layer, rect);

            if (font != null && Text != null && Text != "")
                renderer.DrawString(this, layer, Text, new Rectangle(rect.Left, rect.Top + layer.ContentMargins.Top, rect.Width, Skin.ClientMargins.Top - layer.ContentMargins.Horizontal), false, offset.X, offset.Y, false);
        }
Beispiel #3
0
        protected override void DrawControl(Renderer renderer, Rectangle rect, GameTime gameTime)
        {
            SkinLayer layer = Skin.Layers[lrChecked];
            SkinText font = Skin.Layers[lrChecked].Text;

            if (!state)
            {
                layer = Skin.Layers[lrCheckBox];
                font = Skin.Layers[lrCheckBox].Text;
            }

            rect.Width = layer.Width;
            rect.Height = layer.Height;
            Rectangle rc = new Rectangle(rect.Left + rect.Width + 4, rect.Y, Width - (layer.Width + 4), rect.Height);

            renderer.DrawLayer(this, layer, rect);
            renderer.DrawString(this, layer, Text, rc, false, 0, 0);
        }
Beispiel #4
0
        protected override void DrawControl(Renderer renderer, Rectangle rect, GameTime gameTime)
        {
            SkinLayer l1 = Skin.Layers["Control"];
            SkinLayer l2 = Skin.Layers["Selection"];
            rs = new Rectangle[Items.Count];

            renderer.DrawLayer(this, l1, rect, ControlState.Enabled);

            int prev = l1.ContentMargins.Left;
            for (int i = 0; i < Items.Count; i++)
            {
                MenuItem mi = Items[i];

                int tw = (int)l1.Text.Font.Resource.MeasureString(mi.Text).X + l1.ContentMargins.Horizontal;
                rs[i] = new Rectangle(rect.Left + prev, rect.Top + l1.ContentMargins.Top, tw, Height - l1.ContentMargins.Vertical);
                prev += tw;

                if (ItemIndex != i)
                {
                    if (mi.Enabled && Enabled)
                        renderer.DrawString(this, l1, mi.Text, rs[i], ControlState.Enabled, false);
                    else
                        renderer.DrawString(this, l1, mi.Text, rs[i], ControlState.Disabled, false);
                }
                else
                {
                    if (Items[i].Enabled && Enabled)
                    {
                        renderer.DrawLayer(this, l2, rs[i], ControlState.Enabled);
                        renderer.DrawString(this, l2, mi.Text, rs[i], ControlState.Enabled, false);
                    }
                    else
                    {
                        renderer.DrawLayer(this, l2, rs[i], ControlState.Disabled);
                        renderer.DrawString(this, l2, mi.Text, rs[i], ControlState.Disabled, false);
                    }
                }
            }
        }
Beispiel #5
0
        protected override void DrawControl(Renderer renderer, Rectangle rect, GameTime gameTime)
        {
            int x = rect.Left;
            int y = rect.Top;
            int w = rect.Width;
            int h = rect.Height;
            int s = bevelMargin;

            if (bevelBorder != BevelBorder.None)
            {
                if (bevelStyle != BevelStyle.Flat)
                    s += 2;
                else
                    s += 1;

                if (bevelBorder == BevelBorder.Left || bevelBorder == BevelBorder.All)
                {
                    x += s;
                    w -= s;
                }
                if (bevelBorder == BevelBorder.Top || bevelBorder == BevelBorder.All)
                {
                    y += s;
                    h -= s;
                }
                if (bevelBorder == BevelBorder.Right || bevelBorder == BevelBorder.All)
                    w -= s;
                if (bevelBorder == BevelBorder.Bottom || bevelBorder == BevelBorder.All)
                    h -= s;
            }
            base.DrawControl(renderer, new Rectangle(x, y, w, h), gameTime);
        }
Beispiel #6
0
        protected override void DrawControl(Renderer renderer, Rectangle rect, GameTime gameTime)
        {
            CheckLayer(Skin, "Control");
            CheckLayer(Skin, "Scale");

            base.DrawControl(renderer, rect, gameTime);

            if (Value > 0 || mode == ProgressBarMode.Infinite)
            {
                SkinLayer p = Skin.Layers["Control"];
                SkinLayer l = Skin.Layers["Scale"];
                Rectangle r = new Rectangle(rect.Left + p.ContentMargins.Left,
                                            rect.Top + p.ContentMargins.Top,
                                            rect.Width - p.ContentMargins.Vertical,
                                            rect.Height - p.ContentMargins.Horizontal);

                float perc = ((float)value / range) * 100;
                int w = (int)((perc / 100) * r.Width);
                Rectangle rx;
                if (mode == ProgressBarMode.Default)
                {
                    if (w < l.SizingMargins.Vertical) w = l.SizingMargins.Vertical;
                    rx = new Rectangle(r.Left, r.Top, w, r.Height);
                }
                else
                {
                    int s = r.Left + w;
                    if (s > r.Left + p.ContentMargins.Left + r.Width - (r.Width / 4)) s = r.Left + p.ContentMargins.Left + r.Width - (r.Width / 4);
                    rx = new Rectangle(s, r.Top, (r.Width / 4), r.Height);
                }

                renderer.DrawLayer(this, l, rx);
            }
        }
Beispiel #7
0
        protected override void DrawControl(Renderer renderer, Rectangle rect, GameTime gameTime)
        {
            if (image != null)
            {
                if (sizeMode == SizeMode.Normal)
                    renderer.Draw(image, rect.X, rect.Y, sourceRect, Color);
                else if (sizeMode == SizeMode.Auto)
                    renderer.Draw(image, rect.X, rect.Y, sourceRect, Color);
                else if (sizeMode == SizeMode.Stretched)
                    renderer.Draw(image, rect, sourceRect, Color);
                else if (sizeMode == SizeMode.Centered)
                {
                    int x = (rect.Width / 2) - (image.Width / 2);
                    int y = (rect.Height / 2) - (image.Height / 2);

                    renderer.Draw(image, x, y, sourceRect, Color);
                }
            }
        }
Beispiel #8
0
        private void DrawPart(Renderer renderer, Rectangle rect, BevelBorder pos, BevelStyle style, bool all)
        {
            SkinLayer layer = Skin.Layers["Control"];
            Color c1 = Utilities.ParseColor(layer.Attributes["LightColor"].Value);
            Color c2 = Utilities.ParseColor(layer.Attributes["DarkColor"].Value);
            Color c3 = Utilities.ParseColor(layer.Attributes["FlatColor"].Value);

            if (Color != UndefinedColor) c3 = Color;

            Texture2D img = Skin.Layers["Control"].Image.Resource;

            int x1 = 0; int y1 = 0; int w1 = 0; int h1 = 0;
            int x2 = 0; int y2 = 0; int w2 = 0; int h2 = 0;

            if (style == BevelStyle.Bumped || style == BevelStyle.Etched)
            {
                if (all && (pos == BevelBorder.Top || pos == BevelBorder.Bottom))
                    rect = new Rectangle(rect.Left + 1, rect.Top, rect.Width - 2, rect.Height);
                else if (all && (pos == BevelBorder.Left))
                    rect = new Rectangle(rect.Left, rect.Top, rect.Width, rect.Height - 1);

                switch (pos)
                {
                    case BevelBorder.Left:
                        {
                            x1 = rect.Left; y1 = rect.Top; w1 = 1; h1 = rect.Height;
                            x2 = x1 + 1; y2 = y1; w2 = w1; h2 = h1;
                            break;
                        }
                    case BevelBorder.Top:
                        {
                            x1 = rect.Left; y1 = rect.Top; w1 = rect.Width; h1 = 1;
                            x2 = x1; y2 = y1 + 1; w2 = w1; h2 = h1;
                            break;
                        }
                    case BevelBorder.Right:
                        {
                            x1 = rect.Left + rect.Width - 2; y1 = rect.Top; w1 = 1; h1 = rect.Height;
                            x2 = x1 + 1; y2 = y1; w2 = w1; h2 = h1;
                            break;
                        }
                    case BevelBorder.Bottom:
                        {
                            x1 = rect.Left; y1 = rect.Top + rect.Height - 2; w1 = rect.Width; h1 = 1;
                            x2 = x1; y2 = y1 + 1; w2 = w1; h2 = h1;
                            break;
                        }
                }
            }
            else
            {
                switch (pos)
                {
                    case BevelBorder.Left:
                        {
                            x1 = rect.Left; y1 = rect.Top; w1 = 1; h1 = rect.Height;
                            break;
                        }
                    case BevelBorder.Top:
                        {
                            x1 = rect.Left; y1 = rect.Top; w1 = rect.Width; h1 = 1;
                            break;
                        }
                    case BevelBorder.Right:
                        {
                            x1 = rect.Left + rect.Width - 1; y1 = rect.Top; w1 = 1; h1 = rect.Height;
                            break;
                        }
                    case BevelBorder.Bottom:
                        {
                            x1 = rect.Left; y1 = rect.Top + rect.Height - 1; w1 = rect.Width; h1 = 1;
                            break;
                        }
                }
            }

            switch (Style)
            {
                case BevelStyle.Bumped:
                    {
                        renderer.Draw(img, new Rectangle(x1, y1, w1, h1), c1);
                        renderer.Draw(img, new Rectangle(x2, y2, w2, h2), c2);
                        break;
                    }
                case BevelStyle.Etched:
                    {
                        renderer.Draw(img, new Rectangle(x1, y1, w1, h1), c2);
                        renderer.Draw(img, new Rectangle(x2, y2, w2, h2), c1);
                        break;
                    }
                case BevelStyle.Raised:
                    {
                        Color c = c1;
                        if (pos == BevelBorder.Left || pos == BevelBorder.Top) c = c1;
                        else c = c2;

                        renderer.Draw(img, new Rectangle(x1, y1, w1, h1), c);
                        break;
                    }
                case BevelStyle.Lowered:
                    {
                        Color c = c1;
                        if (pos == BevelBorder.Left || pos == BevelBorder.Top) c = c2;
                        else c = c1;

                        renderer.Draw(img, new Rectangle(x1, y1, w1, h1), c);
                        break;
                    }
                default:
                    {
                        renderer.Draw(img, new Rectangle(x1, y1, w1, h1), c3);
                        break;
                    }
            }
        }
Beispiel #9
0
        protected override void DrawControl(Renderer renderer, Rectangle rect, GameTime gameTime)
        {
            if (mode == ButtonMode.PushButton && pushed)
            {
                SkinLayer l = Skin.Layers[lrButton];
                renderer.DrawLayer(l, rect, l.States.Pressed.Color, l.States.Pressed.Index);
                if (l.States.Pressed.Overlay)
                    renderer.DrawLayer(l, rect, l.Overlays.Pressed.Color, l.Overlays.Pressed.Index);
            }
            else
                base.DrawControl(renderer, rect, gameTime);

            SkinLayer layer = Skin.Layers[lrButton];
            SpriteFont font = (layer.Text != null && layer.Text.Font != null) ? layer.Text.Font.Resource : null;
            Color col = Color.White;
            int ox = 0; int oy = 0;

            if (ControlState == ControlState.Pressed)
            {
                if (layer.Text != null) col = layer.Text.Colors.Pressed;
                ox = 1; oy = 1;
            }

            if (glyph != null)
            {
                Margins cont = layer.ContentMargins;
                Rectangle r = new Rectangle(rect.Left + cont.Left, rect.Top + cont.Top, rect.Width - cont.Horizontal, rect.Height - cont.Vertical);
                renderer.DrawGlyph(glyph, r);
            }
            else
                renderer.DrawString(this, layer, Text, rect, true, ox, oy);
        }
Beispiel #10
0
        protected override void DrawControl(Renderer renderer, Rectangle rect, GameTime gameTime)
        {
            sbVert.Invalidate();
            pane.Invalidate();
            //DrawPane(this, new DrawEventArgs(renderer, rect, gameTime));

            base.DrawControl(renderer, rect, gameTime);
        }
Beispiel #11
0
        private void DrawSelection(Renderer renderer, Rectangle rect)
        {
            if (!selection.IsEmpty)
            {
                int s = selection.Start;
                int e = selection.End;

                int sl = GetPosY(s);
                int el = GetPosY(e);
                int sc = GetPosX(s);
                int ec = GetPosX(e);

                int hgt = font.LineSpacing;

                int start = sl;
                int end = el;

                if (start < vert.Value) start = vert.Value;
                if (end > vert.Value + linesDrawn) end = vert.Value + linesDrawn;

                for (int i = start; i <= end; i++)
                {
                    Rectangle r = Rectangle.Empty;

                    if (mode == TextBoxMode.Normal)
                    {
                        int m = ClientArea.Height - font.LineSpacing;
                        r = new Rectangle(rect.Left - horz.Value + (int)font.MeasureString(Lines[i].Substring(0, sc)).X, rect.Top + m / 2,
                                         (int)font.MeasureString(Lines[i].Substring(0, ec + 0)).X - (int)font.MeasureString(Lines[i].Substring(0, sc)).X, hgt);
                    }
                    else if (sl == el)
                    {
                        r = new Rectangle(rect.Left - horz.Value + (int)font.MeasureString(Lines[i].Substring(0, sc)).X, rect.Top + (i - vert.Value) * hgt,
                                          (int)font.MeasureString(Lines[i].Substring(0, ec + 0)).X - (int)font.MeasureString(Lines[i].Substring(0, sc)).X, hgt);
                    }
                    else
                    {
                        if (i == sl) r = new Rectangle(rect.Left - horz.Value + (int)font.MeasureString(Lines[i].Substring(0, sc)).X, rect.Top + (i - vert.Value) * hgt, (int)font.MeasureString(Lines[i]).X - (int)font.MeasureString(Lines[i].Substring(0, sc)).X, hgt);
                        else if (i == el) r = new Rectangle(rect.Left - horz.Value, rect.Top + (i - vert.Value) * hgt, (int)font.MeasureString(Lines[i].Substring(0, ec + 0)).X, hgt);
                        else r = new Rectangle(rect.Left - horz.Value, rect.Top + (i - vert.Value) * hgt, (int)font.MeasureString(Lines[i]).X, hgt);
                    }

                    renderer.Draw(Manager.Skin.Images["Control"].Resource, r, Color.FromNonPremultiplied(160, 160, 160, 128));
                }
            }
        }
Beispiel #12
0
        protected override void DrawControl(Renderer renderer, Rectangle rect, GameTime gameTime)
        {
            SkinLayer l1 = captionVisible ? Skin.Layers[lrCaption] : Skin.Layers[lrFrameTop];
            SkinLayer l2 = Skin.Layers[lrFrameLeft];
            SkinLayer l3 = Skin.Layers[lrFrameRight];
            SkinLayer l4 = Skin.Layers[lrFrameBottom];
            SkinLayer l5 = Skin.Layers[lrIcon];
            LayerStates s1, s2, s3, s4;
            SpriteFont f1 = l1.Text.Font.Resource;
            Color c1 = l1.Text.Colors.Enabled;

            if ((Focused || (Manager.FocusedControl != null && Manager.FocusedControl.Root == this.Root)) && ControlState != ControlState.Disabled)
            {
                s1 = l1.States.Focused;
                s2 = l2.States.Focused;
                s3 = l3.States.Focused;
                s4 = l4.States.Focused;
                c1 = l1.Text.Colors.Focused;
            }
            else if (ControlState == ControlState.Disabled)
            {
                s1 = l1.States.Disabled;
                s2 = l2.States.Disabled;
                s3 = l3.States.Disabled;
                s4 = l4.States.Disabled;
                c1 = l1.Text.Colors.Disabled;
            }
            else
            {
                s1 = l1.States.Enabled;
                s2 = l2.States.Enabled;
                s3 = l3.States.Enabled;
                s4 = l4.States.Enabled;
                c1 = l1.Text.Colors.Enabled;
            }

            renderer.DrawLayer(Skin.Layers[lrWindow], rect, Skin.Layers[lrWindow].States.Enabled.Color, Skin.Layers[lrWindow].States.Enabled.Index);

            if (borderVisible)
            {
                renderer.DrawLayer(l1, new Rectangle(rect.Left, rect.Top, rect.Width, l1.Height), s1.Color, s1.Index);
                renderer.DrawLayer(l2, new Rectangle(rect.Left, rect.Top + l1.Height, l2.Width, rect.Height - l1.Height - l4.Height), s2.Color, s2.Index);
                renderer.DrawLayer(l3, new Rectangle(rect.Right - l3.Width, rect.Top + l1.Height, l3.Width, rect.Height - l1.Height - l4.Height), s3.Color, s3.Index);
                renderer.DrawLayer(l4, new Rectangle(rect.Left, rect.Bottom - l4.Height, rect.Width, l4.Height), s4.Color, s4.Index);

                if (iconVisible && (icon != null || l5 != null) && captionVisible)
                {
                    Texture2D i = (icon != null) ? icon : l5.Image.Resource;
                    renderer.Draw(i, GetIconRect(), Color.White);
                }

                int icosize = 0;
                if (l5 != null && iconVisible && captionVisible)
                    icosize = l1.Height - l1.ContentMargins.Vertical + 4 + l5.OffsetX;

                int closesize = 0;
                if (btnClose.Visible)
                    closesize = btnClose.Width - (btnClose.Skin.Layers[lrButton].OffsetX);

                Rectangle r = new Rectangle(rect.Left + l1.ContentMargins.Left + icosize,
                                            rect.Top + l1.ContentMargins.Top,
                                            rect.Width - l1.ContentMargins.Horizontal - closesize - icosize,
                                            l1.Height - l1.ContentMargins.Top - l1.ContentMargins.Bottom);
                int ox = l1.Text.OffsetX;
                int oy = l1.Text.OffsetY;
                renderer.DrawString(f1, Text, r, c1, l1.Text.Alignment, ox, oy, true);
            }
        }
Beispiel #13
0
        internal override void Render(Renderer renderer, GameTime gameTime)
        {
            if (Visible && Shadow)
            {
                SkinControl c = Manager.Skin.Controls[skShadow];
                SkinLayer l = c.Layers[lrShadow];

                Color cl = Color.FromNonPremultiplied(l.States.Enabled.Color.R, l.States.Enabled.Color.G, l.States.Enabled.Color.B, Alpha);

                renderer.Begin(BlendingMode.Default);
                renderer.DrawLayer(l, new Rectangle(Left - c.OriginMargins.Left, Top - c.OriginMargins.Top, Width + c.OriginMargins.Horizontal, Height + c.OriginMargins.Vertical), cl, 0);
                renderer.End();
            }
            base.Render(renderer, gameTime);
        }
Beispiel #14
0
        protected override void DrawControl(Renderer renderer, Rectangle rect, GameTime gameTime)
        {
            base.DrawControl(renderer, rect, gameTime);

            if (ReadOnly && (Focused || lstCombo.Focused) && drawSelection)
            {
                SkinLayer lr = Skin.Layers[0];
                Rectangle rc = new Rectangle(rect.Left + lr.ContentMargins.Left,
                                             rect.Top + lr.ContentMargins.Top,
                                             Width - lr.ContentMargins.Horizontal - btnDown.Width,
                                             Height - lr.ContentMargins.Vertical);

                renderer.Draw(Manager.Skin.Images["ListBox.Selection"].Resource, rc, Color.FromNonPremultiplied(255, 255, 255, 128));
            }
        }
Beispiel #15
0
        protected override void DrawControl(Renderer renderer, Rectangle rect, GameTime gameTime)
        {
            SkinLayer l1 = Skin.Layers["Control"];
            SkinLayer l2 = Skin.Layers["Header"];
            Color col = this.Color != UndefinedColor ? this.Color : Color.White;

            Rectangle r1 = new Rectangle(rect.Left, rect.Top + l1.OffsetY, rect.Width, rect.Height - l1.OffsetY);
            if (tabPages.Count <= 0)
                r1 = rect;

            base.DrawControl(renderer, r1, gameTime);

            if (tabPages.Count > 0)
            {
                Rectangle prev = new Rectangle(rect.Left, rect.Top + l2.OffsetY, 0, l2.Height);
                for (int i = 0; i < tabPages.Count; i++)
                {
                    SpriteFont font = l2.Text.Font.Resource;
                    Margins margins = l2.ContentMargins;
                    Point offset = new Point(l2.OffsetX, l2.OffsetY);
                    if (i > 0) prev = tabPages[i - 1].HeaderRect;

                    tabPages[i].CalcRect(prev, font, margins, offset, i == 0);
                }

                for (int i = tabPages.Count - 1; i >= 0; i--)
                {
                    int li = tabPages[i].Enabled ? l2.States.Enabled.Index : l2.States.Disabled.Index;
                    Color lc = tabPages[i].Enabled ? l2.Text.Colors.Enabled : l2.Text.Colors.Disabled;
                    if (i == hoveredIndex)
                    {
                        li = l2.States.Hovered.Index;
                        lc = l2.Text.Colors.Hovered;
                    }

                    Margins m = l2.ContentMargins;
                    Rectangle rx = tabPages[i].HeaderRect;
                    Rectangle sx = new Rectangle(rx.Left + m.Left, rx.Top + m.Top, rx.Width - m.Horizontal, rx.Height - m.Vertical);
                    if (i != selectedIndex)
                    {
                        renderer.DrawLayer(l2, rx, col, li);
                        renderer.DrawString(l2.Text.Font.Resource, tabPages[i].Text, sx, lc, l2.Text.Alignment);
                    }
                }

                Margins mi = l2.ContentMargins;
                Rectangle ri = tabPages[selectedIndex].HeaderRect;
                Rectangle si = new Rectangle(ri.Left + mi.Left, ri.Top + mi.Top, ri.Width - mi.Horizontal, ri.Height - mi.Vertical);
                renderer.DrawLayer(l2, ri, col, l2.States.Focused.Index);
                renderer.DrawString(l2.Text.Font.Resource, tabPages[selectedIndex].Text, si, l2.Text.Colors.Focused, l2.Text.Alignment, l2.Text.OffsetX, l2.Text.OffsetY, false);
            }
        }
Beispiel #16
0
 protected override void DrawControl(Renderer renderer, Rectangle rect, GameTime gameTime)
 {
     base.DrawControl(renderer, rect, gameTime);
 }
Beispiel #17
0
 protected override void DrawControl(Renderer renderer, Rectangle rect, GameTime gameTime)
 {
     if (Border != BevelBorder.None && Style != BevelStyle.None)
     {
         if (Border != BevelBorder.All)
         {
             DrawPart(renderer, rect, Border, Style, false);
         }
         else
         {
             DrawPart(renderer, rect, BevelBorder.Left, Style, true);
             DrawPart(renderer, rect, BevelBorder.Top, Style, true);
             DrawPart(renderer, rect, BevelBorder.Right, Style, true);
             DrawPart(renderer, rect, BevelBorder.Bottom, Style, true);
         }
     }
 }