protected void DrawCircle(Cairo.Context cr, double x, double y, double size)
 {
     x += 0.5; y += 0.5;
     cr.NewPath();
     cr.Arc(x + size / 2, y + size / 2, (size - 4) / 2, 0, 2 * Math.PI);
     cr.ClosePath();
 }
Exemple #2
0
        protected override bool OnExposeEvent(Gdk.EventExpose evnt)
        {
            Gdk.Rectangle rect;

            if (GradientBackround)
            {
                rect = new Gdk.Rectangle(Allocation.X, Allocation.Y, Allocation.Width, Allocation.Height);
                HslColor gcol = useCustomColor ? customColor : Parent.Style.Background(Gtk.StateType.Normal);

                using (Cairo.Context cr = Gdk.CairoHelper.Create(GdkWindow))
                {
                    cr.NewPath();
                    cr.MoveTo(rect.X, rect.Y);
                    cr.RelLineTo(rect.Width, 0);
                    cr.RelLineTo(0, rect.Height);
                    cr.RelLineTo(-rect.Width, 0);
                    cr.RelLineTo(0, -rect.Height);
                    cr.ClosePath();
                    Cairo.Gradient pat    = new Cairo.LinearGradient(rect.X, rect.Y, rect.X, rect.Bottom);
                    Cairo.Color    color1 = gcol;
                    pat.AddColorStop(0, color1);
                    gcol.L -= 0.1;
                    if (gcol.L < 0)
                    {
                        gcol.L = 0;
                    }
                    pat.AddColorStop(1, gcol);
                    cr.Pattern = pat;
                    cr.FillPreserve();
                }
            }

            bool res = base.OnExposeEvent(evnt);

            Gdk.GC borderColor = Parent.Style.DarkGC(Gtk.StateType.Normal);

            rect = Allocation;
            for (int n = 0; n < topMargin; n++)
            {
                GdkWindow.DrawLine(borderColor, rect.X, rect.Y + n, rect.Right - 1, rect.Y + n);
            }

            for (int n = 0; n < bottomMargin; n++)
            {
                GdkWindow.DrawLine(borderColor, rect.X, rect.Bottom - n - 1, rect.Right - 1, rect.Bottom - n - 1);
            }

            for (int n = 0; n < leftMargin; n++)
            {
                GdkWindow.DrawLine(borderColor, rect.X + n, rect.Y, rect.X + n, rect.Bottom - 1);
            }

            for (int n = 0; n < rightMargin; n++)
            {
                GdkWindow.DrawLine(borderColor, rect.Right - n - 1, rect.Y, rect.Right - n - 1, rect.Bottom - 1);
            }

            return(res);
        }
Exemple #3
0
 internal static void StrokeCircle(this Cairo.Context g, Point center, float radius, Color color)
 {
     g.NewPath();
     g.LineWidth = 1;
     g.SetSourceColor(color);
     g.Arc(center.X, center.Y, radius, 0, 2 * Math.PI);
     g.Stroke();
 }
Exemple #4
0
        void DrawSerie(Cairo.Context ctx, Serie serie)
        {
            ctx.NewPath();
            ctx.Rectangle(left, top, width + 1, height + 1);
            ctx.Clip();

            ctx.NewPath();
            ctx.SetSourceColor(serie.Color);
            ctx.LineWidth = serie.LineWidth;

            bool first     = true;
            bool blockMode = serie.DisplayMode == DisplayMode.BlockLine;

            double lastY = 0;

            foreach (Data d in serie.GetData(startX, endX))
            {
                double x, y;
                GetPoint(d.X, d.Y, out x, out y);
                if (first)
                {
                    ctx.MoveTo(x, y);
                    lastY = y;
                    first = false;
                }
                else
                {
                    if (blockMode)
                    {
                        if (lastY != y)
                        {
                            ctx.LineTo(x, lastY);
                        }
                        ctx.LineTo(x, y);
                    }
                    else
                    {
                        ctx.LineTo(x, y);
                    }
                }
                lastY = y;
            }

            ctx.Stroke();
        }
Exemple #5
0
 protected void paintGrid(Cairo.Context context)
 {
     context.LineWidth = 0.3;
     context.SetSourceRGBA(0, 0, 0, 0.2);
     for (int i = 0; i < width; i++)
     {
         context.MoveTo(i * fieldSize, 0);
         context.LineTo(i * fieldSize, height * fieldSize);
         context.Stroke();
         context.NewPath();
     }
     for (int i = 0; i < height; i++)
     {
         context.MoveTo(0, i * fieldSize);
         context.LineTo(width * fieldSize, i * fieldSize);
         context.Stroke();
         context.NewPath();
     }
 }
Exemple #6
0
 protected void paintTrail(Cairo.Context context, int x, int y)
 {
     context.Save();
     context.SetSourceRGB(0, 1, 0);
     context.Translate(x, y);
     context.Rectangle(new Cairo.Rectangle(0, 0, fieldSize, fieldSize));
     context.SetSourceRGBA(0, 1, 0, 0.3);
     context.FillPreserve();
     context.NewPath();
     context.Restore();
 }
Exemple #7
0
 protected void paintSquare(Cairo.Context context, int x, int y, bool fill)
 {
     context.Save();
     context.SetSourceRGB(0, 0, 1);
     context.Translate(x, y);
     context.Rectangle(new Cairo.Rectangle(0, 0, fieldSize, fieldSize));
     context.SetSourceRGBA(0, 0, 0, fill ? 0.5 : 0.3);
     context.FillPreserve();
     context.NewPath();
     context.Restore();
 }
Exemple #8
0
 internal static void DrawLine(this Cairo.Context g, Point p0, Point p1, float width, Color color)
 {
     g.NewPath();
     g.Save();
     g.SetSourceColor(color);
     g.LineWidth = width;
     g.MoveTo(p0.ToPointD());
     g.LineTo(p1.ToPointD());
     g.Stroke();
     g.Restore();
 }
Exemple #9
0
 protected void paintSniffer(Cairo.Context context, Monster monster)
 {
     context.Save();
     context.Translate(monster.X, monster.Y);
     rotateContext(context, monster.Direction);
     context.Arc(fieldSize / 2, fieldSize / 2, fieldSize / 3, 0, 2 * Math.PI);
     context.FillPreserve();
     context.MoveTo(0, 0);
     context.LineTo(fieldSize, fieldSize);
     context.Stroke();
     context.NewPath();
     context.MoveTo(fieldSize, 0);
     context.LineTo(0, fieldSize);
     context.Stroke();
     context.NewPath();
     context.MoveTo(0, fieldSize / 2);
     context.LineTo(fieldSize, fieldSize / 2);
     context.Stroke();
     context.NewPath();
     context.Restore();
 }
Exemple #10
0
        protected virtual void Paint(Gdk.Rectangle area)
        {
            if (!IsDrawable)
            {
                return;
            }
            if (!drawFrame && !fill)
            {
                /* Nothing to draw. */
                return;
            }

            /* You shouldn't change the size of the drawing area
             * to avoid glitches when switching panes, though
             * you can enlarge the big frame.
             * This workaround is enlarging only the frame which has
             * radius == 0, so when the window is not composited.
             * Pretty ugly, I should think on something better.
             *
             * int offset = radius == 0 ? 1 : 0;
             *
             * x = childAlloc.X - offset;
             * y = childAlloc.Y - offset;
             * width  = childAlloc.Width + offset * 2;
             * height = childAlloc.Height + offset * 2;
             */

            x      = childAlloc.X;
            y      = childAlloc.Y;
            width  = childAlloc.Width;
            height = childAlloc.Height;

            if (this.radius < 0.0)
            {
                radius = Math.Min(width, height);
                radius = (radius / 100) * 10;
            }

            using (cairo = Gdk.CairoHelper.Create(GdkWindow)) {
                cairo.Operator = Cairo.Operator.Over;

                if (fill)
                {
                    PaintFill();
                }
                cairo.NewPath();

                if (drawFrame)
                {
                    PaintBorder();
                }
            }
        }
Exemple #11
0
 protected void DrawDiamond(Cairo.Context cr, double x, double y, double size)
 {
     x    += 0.5; y += 0.5;
     size -= 2;
     cr.NewPath();
     cr.MoveTo(x + size / 2, y);
     cr.LineTo(x + size, y + size / 2);
     cr.LineTo(x + size / 2, y + size);
     cr.LineTo(x, y + size / 2);
     cr.LineTo(x + size / 2, y);
     cr.ClosePath();
 }
Exemple #12
0
        void DrawTab(Gdk.EventExpose evnt, Tab tab, int pos)
        {
            Gdk.Rectangle rect = GetTabArea(tab, pos);
            StateType     st;

            if (tab.Active)
            {
                st = StateType.Normal;
            }
            else
            {
                st = StateType.Active;
            }

            if (DockFrame.IsWindows)
            {
                GdkWindow.DrawRectangle(Style.DarkGC(Gtk.StateType.Normal), false, rect);
                rect.X++;
                rect.Width--;
                if (tab.Active)
                {
                    GdkWindow.DrawRectangle(Style.LightGC(Gtk.StateType.Normal), true, rect);
                }
                else
                {
                    using (Cairo.Context cr = Gdk.CairoHelper.Create(evnt.Window))
                    {
                        cr.NewPath();
                        cr.MoveTo(rect.X, rect.Y);
                        cr.RelLineTo(rect.Width, 0);
                        cr.RelLineTo(0, rect.Height);
                        cr.RelLineTo(-rect.Width, 0);
                        cr.RelLineTo(0, -rect.Height);
                        cr.ClosePath();
                        Cairo.Gradient pat    = new Cairo.LinearGradient(rect.X, rect.Y, rect.X, rect.Y + rect.Height);
                        Cairo.Color    color1 = DockFrame.ToCairoColor(Style.Mid(Gtk.StateType.Normal));
                        pat.AddColorStop(0, color1);
                        color1.R *= 1.2;
                        color1.G *= 1.2;
                        color1.B *= 1.2;
                        pat.AddColorStop(1, color1);
                        cr.Pattern = pat;
                        cr.FillPreserve();
                    }
                }
            }
            else
            {
                Gtk.Style.PaintExtension(Style, GdkWindow, st, ShadowType.Out, evnt.Area, this, "tab", rect.X, rect.Y, rect.Width, rect.Height, Gtk.PositionType.Top);
            }
        }
Exemple #13
0
 protected void paintArrow(Cairo.Context context, Direction direction, int x, int y)
 {
     context.Save();
     context.Translate(x, y);
     rotateContext(context, direction);
     context.MoveTo(fieldSize / 2, 0);
     context.LineTo(fieldSize, fieldSize);
     context.LineTo(fieldSize / 2, 3 * fieldSize / 4);
     context.LineTo(0, fieldSize);
     context.LineTo(fieldSize / 2, 0);
     context.FillPreserve();
     context.NewPath();
     context.Restore();
 }
Exemple #14
0
 internal static void StrokeRectangle(this Cairo.Context g,
                                      Rect rect,
                                      Color color)
 {
     g.NewPath();
     g.MoveTo(rect.TopLeft.ToPointD());
     g.SetSourceColor(color);
     g.LineTo(rect.TopRight.ToPointD());    //Top
     g.LineTo(rect.BottomRight.ToPointD()); //Right
     g.LineTo(rect.BottomLeft.ToPointD());  //Bottom
     g.LineTo(rect.TopLeft.ToPointD());     //Left
     g.ClosePath();
     g.Stroke();
 }
Exemple #15
0
 internal static void FillRectangle(this Cairo.Context g,
                                    Rect rect,
                                    Color color)
 {
     g.NewPath();
     g.MoveTo(rect.TopLeft.ToPointD());
     g.SetSourceColor(color);
     g.LineTo(rect.TopRight.ToPointD());
     g.LineTo(rect.BottomRight.ToPointD());
     g.LineTo(rect.BottomLeft.ToPointD());
     g.LineTo(rect.TopLeft.ToPointD());
     g.ClosePath();
     g.Fill();
 }
        private void HeaderExpose(object ob, Gtk.ExposeEventArgs a)
        {
            Gdk.Rectangle rect = new Gdk.Rectangle(0, 0, header.Allocation.Width - 1, header.Allocation.Height);
            HslColor      gcol = frame.Style.Background(Gtk.StateType.Normal);

            if (pointerHover)
            {
                gcol.L *= 1.05;
            }
            gcol.L = Math.Min(1, gcol.L);

            using (Cairo.Context cr = Gdk.CairoHelper.Create(a.Event.Window))
            {
                cr.NewPath();
                cr.MoveTo(0, 0);
                cr.RelLineTo(rect.Width, 0);
                cr.RelLineTo(0, rect.Height);
                cr.RelLineTo(-rect.Width, 0);
                cr.RelLineTo(0, -rect.Height);
                cr.ClosePath();
                Cairo.SolidPattern solidPattern = new Cairo.SolidPattern(gcol);
                cr.Pattern = solidPattern;
                cr.FillPreserve();
                solidPattern.Destroy();

                cr.NewPath();
                cr.LineWidth = 1d;
                cr.Color     = (HslColor)frame.Style.Dark(StateType.Normal);
                cr.Rectangle(rect.X + 0.5d, rect.Y + 0.5d, rect.Width, rect.Height);
                cr.Stroke();
            }

            foreach (Widget child in header.Children)
            {
                header.PropagateExpose(child, a.Event);
            }
        }
Exemple #17
0
        void DrawShadow(Cairo.Context ctx, Gdk.Rectangle ar, PositionType pos, List <Section> secs)
        {
            foreach (Section s in secs)
            {
                Cairo.Gradient pat = null;
                Gdk.Rectangle  r   = ar;
                switch (pos)
                {
                case PositionType.Top:
                    r.Height = shadowSize > r.Height ? r.Height / 2 : shadowSize;
                    r.X     += s.Offset;
                    r.Width  = s.Size;
                    pat      = new Cairo.LinearGradient(r.X, r.Y, r.X, r.Bottom);
                    break;

                case PositionType.Bottom:
                    r.Y      = r.Bottom - shadowSize;
                    r.Height = shadowSize > r.Height ? r.Height / 2 : shadowSize;
                    r.X      = r.X + s.Offset;
                    r.Width  = s.Size;
                    pat      = new Cairo.LinearGradient(r.X, r.Bottom, r.X, r.Y);
                    break;

                case PositionType.Left:
                    r.Width  = shadowSize > r.Width ? r.Width / 2 : shadowSize;
                    r.Y     += s.Offset;
                    r.Height = s.Size;
                    pat      = new Cairo.LinearGradient(r.X, r.Y, r.Right, r.Y);
                    break;

                case PositionType.Right:
                    r.X      = r.Right - shadowSize;
                    r.Width  = shadowSize > r.Width ? r.Width / 2 : shadowSize;
                    r.Y     += s.Offset;
                    r.Height = s.Size;
                    pat      = new Cairo.LinearGradient(r.Right, r.Y, r.X, r.Y);
                    break;
                }
                Cairo.Color c = darkColor.ToCairoColor();
                pat.AddColorStop(0, c);
                c.A = 0;
                pat.AddColorStop(1, c);
                ctx.NewPath();
                ctx.Rectangle(r.X, r.Y, r.Width, r.Height);
                ctx.SetSource(pat);
                ctx.Fill();
                pat.Dispose();
            }
        }
 void DrawGradient(Cairo.Context cr, Gdk.Rectangle rect, int fx, int fy, int fw, int fh, Cairo.Color c1, Cairo.Color c2)
 {
     cr.NewPath();
     cr.MoveTo(rect.X, rect.Y);
     cr.RelLineTo(rect.Width, 0);
     cr.RelLineTo(0, rect.Height);
     cr.RelLineTo(-rect.Width, 0);
     cr.RelLineTo(0, -rect.Height);
     cr.ClosePath();
     Cairo.LinearGradient pat = new Cairo.LinearGradient(rect.X + rect.Width * fx, rect.Y + rect.Height * fy, rect.X + rect.Width * fw, rect.Y + rect.Height * fh);
     pat.AddColorStop(0, c1);
     pat.AddColorStop(1, c2);
     cr.Pattern = pat;
     cr.FillPreserve();
 }
Exemple #19
0
        public new void Draw(Cairo.Context cr)
        {
            Gdk.Rectangle rect;

            if (GradientBackround)
            {
                rect = new Gdk.Rectangle(Allocation.X, Allocation.Y, Allocation.Width, Allocation.Height);
                HslColor gcol = useCustomColor ? customColor : Parent.Style.Background(Gtk.StateType.Normal);

                cr.NewPath();
                cr.MoveTo(rect.X, rect.Y);
                cr.RelLineTo(rect.Width, 0);
                cr.RelLineTo(0, rect.Height);
                cr.RelLineTo(-rect.Width, 0);
                cr.RelLineTo(0, -rect.Height);
                cr.ClosePath();
                using (Cairo.Gradient pat = new Cairo.LinearGradient(rect.X, rect.Y, rect.X, rect.Y + rect.Height - 1)) {
                    Cairo.Color color1 = gcol;
                    pat.AddColorStop(0, color1);
                    gcol.L -= 0.1;
                    if (gcol.L < 0)
                    {
                        gcol.L = 0;
                    }
                    pat.AddColorStop(1, gcol);
                    cr.Pattern = pat;
                    cr.FillPreserve();
                }
            }

            base.Draw(cr);
            //FIXME: Get this drawing properly again!
//			Gdk.Color colour = Parent.Style.Dark (Gtk.StateType.Normal);
//			cr.SetSourceRGB (colour.Red, colour.Green, colour.Blue);
//
//			rect = Allocation;
//			for (int n=0; n<topMargin; n++)
//				GdkWindow.DrawLine (borderColor, rect.X, rect.Y + n, rect.Left + rect.Width - 1, rect.Y + n);
//
//			for (int n=0; n<bottomMargin; n++)
//				GdkWindow.DrawLine (borderColor, rect.X, rect.Top + rect.Height - 1 - n, rect.Left + rect.Width - 1, rect.Top + rect.Height - 1 - n);
//
//			for (int n=0; n<leftMargin; n++)
//				GdkWindow.DrawLine (borderColor, rect.X + n, rect.Y, rect.X + n, rect.Top + rect.Height - 1);
//
//			for (int n=0; n<rightMargin; n++)
//				GdkWindow.DrawLine (borderColor, rect.Left + rect.Width - 1 - n, rect.Y, rect.Left + rect.Width - 1 - n, rect.Top + rect.Height - 1);
        }
Exemple #20
0
        internal static void StrokeLineStrip(this Cairo.Context g, Point[] vPoint, Color color)
        {
            if (vPoint.Length <= 2)
            {
                throw new ArgumentException("vPoint should contains 3 ore more points!");
            }

            g.NewPath();
            g.SetSourceColor(color);
            g.MoveTo(vPoint[0].ToPointD());
            foreach (var t in vPoint)
            {
                g.LineTo(t.ToPointD());
            }
            g.Stroke();
        }
Exemple #21
0
        protected override bool OnDrawn(Cairo.Context cr)
        {
            base.OnDrawn(cr);

            if (!Selectable)
            {
                return(true);
            }

            cr.NewPath();
            cr.SetSourceColor(SelectionColor);
            cr.Rectangle(XOffset + SelectedX * TileWidth * Scale + 0.5, SelectedY * TileHeight * Scale + 0.5, TileWidth * Scale - 1, TileHeight * Scale - 1);
            cr.LineWidth = 1;
            cr.Stroke();

            return(true);
        }
Exemple #22
0
        protected void paintWanderer(Cairo.Context context, Monster monster)
        {
            context.Save();
            context.Translate(monster.X + fieldSize / 2, monster.Y + fieldSize / 2);

            for (int i = 0; i < 12; i++)
            {
                context.LineTo((fieldSize / 2) * Math.Cos(i * Math.PI / 6), (fieldSize / 2) * Math.Sin(i * Math.PI / 6));
                context.LineTo((fieldSize / 3) * Math.Cos(Math.PI / 12 + i * Math.PI / 6), (fieldSize / 3) * Math.Sin(Math.PI / 12 + i * Math.PI / 6));
            }

            context.ClosePath();
            context.FillPreserve();
            context.NewPath();

            context.Restore();
        }
Exemple #23
0
        void DrawGradient(Cairo.Context cr, Gdk.Rectangle rect, int fx, int fy, int fw, int fh, Cairo.Color c1, Cairo.Color c2)
        {
            cr.NewPath();
            cr.MoveTo(rect.X, rect.Y);
            cr.RelLineTo(rect.Width, 0);
            cr.RelLineTo(0, rect.Height);
            cr.RelLineTo(-rect.Width, 0);
            cr.RelLineTo(0, -rect.Height);
            cr.ClosePath();

            // FIXME: VV: Remove gradient features
            using (var pat = new Cairo.LinearGradient(rect.X + rect.Width * fx, rect.Y + rect.Height * fy, rect.X + rect.Width * fw, rect.Y + rect.Height * fh)) {
                pat.AddColorStop(0, c1);
                pat.AddColorStop(1, c2);
                cr.Source = pat;
                cr.FillPreserve();
            }
        }
Exemple #24
0
        protected override bool OnExposeEvent(Gdk.EventExpose evnt)
        {
            using (Cairo.Context cr = Gdk.CairoHelper.Create(GdkWindow)) {
                Gdk.Rectangle rect = Allocation;

                if (BackgroundColor.HasValue)
                {
                    cr.Rectangle(rect.X, rect.Y, rect.Width, rect.Height);
                    cr.SetSourceColor(BackgroundColor.Value.ToCairoColor());
                    cr.Fill();
                }

                if (GradientBackround)
                {
                    Color gcol = Util.ToXwtColor(Style.Background(Gtk.StateType.Normal));

                    cr.NewPath();
                    cr.MoveTo(rect.X, rect.Y);
                    cr.RelLineTo(rect.Width, 0);
                    cr.RelLineTo(0, rect.Height);
                    cr.RelLineTo(-rect.Width, 0);
                    cr.RelLineTo(0, -rect.Height);
                    cr.ClosePath();
                    using (var pat = new Cairo.LinearGradient(rect.X, rect.Y, rect.X, rect.Bottom)) {
                        Cairo.Color color1 = gcol.ToCairoColor();
                        pat.AddColorStop(0, color1);
                        gcol.Light -= 0.1;
                        pat.AddColorStop(1, gcol.ToCairoColor());
                        cr.SetSource(pat);
                        cr.FillPreserve();
                    }
                }

                cr.SetSourceColor(color.HasValue ? color.Value.ToCairoColor() : Style.Dark(Gtk.StateType.Normal).ToXwtColor().ToCairoColor());
                cr.Rectangle(rect.X, rect.Y, rect.Width, topMargin);
                cr.Rectangle(rect.X, rect.Y + rect.Height - bottomMargin, rect.Width, bottomMargin);
                cr.Rectangle(rect.X, rect.Y, leftMargin, rect.Height);
                cr.Rectangle(rect.X + rect.Width - rightMargin, rect.Y, rightMargin, rect.Height);
                cr.Fill();
            }
            bool res = base.OnExposeEvent(evnt);

            return(res);
        }
Exemple #25
0
        protected void DrawArrow(Cairo.Context cr, double x, double y, double size)
        {
            y    += 2.5;
            x    += 2.5;
            size -= 4;
            double awidth  = 0.5;
            double aheight = 0.4;
            double pich    = (size - (size * aheight)) / 2;

            cr.NewPath();
            cr.MoveTo(x + size * awidth, y);
            cr.LineTo(x + size, y + size / 2);
            cr.LineTo(x + size * awidth, y + size);
            cr.RelLineTo(0, -pich);
            cr.RelLineTo(-size * awidth, 0);
            cr.RelLineTo(0, -size * aheight);
            cr.RelLineTo(size * awidth, 0);
            cr.RelLineTo(0, -pich);
            cr.ClosePath();
        }
Exemple #26
0
        public override void Render(Cairo.Context context, Point scale)
        {
            if ((d_borderColor == null || d_borderWidth <= 0) && d_backgroundColor == null)
            {
                return;
            }

            double px = UnitToPixel(XUnits, d_origin.X, scale.X);
            double py = UnitToPixel(YUnits, d_origin.Y, scale.Y);

            double dx = UnitToPixel(XUnits, XRange.Max - XRange.Min, scale.X);
            double dy = UnitToPixel(YUnits, YRange.Max - YRange.Min, scale.Y);

            if (d_borderRadius > 0)
            {
                RoundedRectangle(context, px, py, dx, dy, d_borderRadius);
            }
            else
            {
                context.Rectangle(px, py, dx, dy);
            }

            if (d_borderColor != null && d_borderWidth > 0)
            {
                context.LineWidth = d_borderWidth;
                d_borderColor.Set(context);

                context.StrokePreserve();
            }

            if (d_backgroundColor != null)
            {
                d_backgroundColor.Set(context);
                context.Fill();
            }

            context.NewPath();
        }
Exemple #27
0
        protected override void OnDrawn(Cairo.Context cr, Gdk.Rectangle rect)
        {
            if (BackgroundColor.HasValue)
            {
                cr.Rectangle(rect.X, rect.Y, rect.Width, rect.Height);
                cr.SetSourceColor(BackgroundColor.Value.ToCairoColor());
                cr.Fill();
            }

            if (GradientBackround)
            {
                Color gcol = Style.Background(Gtk.StateType.Normal).ToXwtValue();

                cr.NewPath();
                cr.MoveTo(rect.X, rect.Y);
                cr.RelLineTo(rect.Width, 0);
                cr.RelLineTo(0, rect.Height);
                cr.RelLineTo(-rect.Width, 0);
                cr.RelLineTo(0, -rect.Height);
                cr.ClosePath();
                using (var pat = new Cairo.LinearGradient(rect.X, rect.Y, rect.X, rect.Bottom)) {
                    Cairo.Color color1 = gcol.ToCairoColor();
                    pat.AddColorStop(0, color1);
                    gcol.Light -= 0.1;
                    pat.AddColorStop(1, gcol.ToCairoColor());
                    cr.SetSource(pat);
                    cr.FillPreserve();
                }
            }

            cr.SetSourceColor(color.HasValue ? color.Value.ToCairoColor() : Style.Dark(Gtk.StateType.Normal).ToXwtValue().ToCairoColor());
            cr.Rectangle(rect.X, rect.Y, rect.Width, topMargin);
            cr.Rectangle(rect.X, rect.Y + rect.Height - bottomMargin, rect.Width, bottomMargin);
            cr.Rectangle(rect.X, rect.Y, leftMargin, rect.Height);
            cr.Rectangle(rect.X + rect.Width - rightMargin, rect.Y, rightMargin, rect.Height);
            cr.Fill();
        }
Exemple #28
0
        protected override bool OnExposeEvent(Gdk.EventExpose evnt)
        {
            if (isActive || hilight)
            {
                double x = Allocation.Left, y = Allocation.Top;
                int    w = Allocation.Width, h = Allocation.Height;
                using (Cairo.Context ctx = Gdk.CairoHelper.Create(GdkWindow)) {
                    HslColor c1 = new HslColor(Style.Background(Gtk.StateType.Normal));
                    HslColor c2 = c1;
                    if (isActive)
                    {
                        c2.L *= 0.8;
                    }
                    else
                    {
                        c2.L *= 0.9;
                    }
                    Cairo.Gradient pat;

                    // FIXME: VV: Remove gradient features
                    pat = new Cairo.LinearGradient(x, y, x + w - 2, y);
                    pat.AddColorStop(0, c2);
                    pat.AddColorStop(1, c1);
                    ctx.Pattern = pat;
                    ctx.NewPath();
                    ctx.Rectangle(x, y, w, h);
                    ctx.Fill();
                }
            }

//			Gtk.Style.PaintBox (Style, GdkWindow, StateType.Normal, ShadowType.Out, evnt.Area, this, isWindows? "button" : "",
//			                    Allocation.Left, Allocation.Top, Allocation.Width, Allocation.Height);

            bool res = base.OnExposeEvent(evnt);

            return(res);
        }
Exemple #29
0
        private void DrawStandalone(Cairo.Context graphics)
        {
            FromState(graphics, false);

            Allocation alloc = WrappedObject != null?WrappedObject.Allocation.Copy() : new Allocation(0, 0, 1, 1);

            alloc.X = 0;
            alloc.Y = 0;

            alloc.GrowBorder(-graphics.LineWidth);

            double radius = System.Math.Min(alloc.Width, alloc.Height) / 2;

            double cx = alloc.X + alloc.Width / 2;
            double cy = alloc.Y + alloc.Height / 2;

            double angle = System.Math.PI * 1.8;

            graphics.NewPath();
            graphics.Arc(cx, cy, radius, 0, angle);
            graphics.Stroke();

            DrawArrow(graphics, cx + radius * System.Math.Cos(angle), cy + radius * System.Math.Sin(angle), angle - System.Math.PI);
        }
Exemple #30
0
 public override void NewPath(object backend)
 {
     Cairo.Context ctx = ((CairoContextBackend)backend).Context;
     ctx.NewPath();
 }