From 07f2ce086d5479ff5f3ca785029e0c25898f70f3 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jean-Philippe=20Bruy=C3=A8re?= Date: Sat, 26 Aug 2017 15:04:39 +0200 Subject: [PATCH] raise/sunken border --- src/GraphicObjects/Border.cs | 66 ++++++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) diff --git a/src/GraphicObjects/Border.cs b/src/GraphicObjects/Border.cs index 672d5ab8..375d7321 100644 --- a/src/GraphicObjects/Border.cs +++ b/src/GraphicObjects/Border.cs @@ -31,6 +31,12 @@ using System.Diagnostics; namespace Crow { + public enum BorderStyle { + Normal, + Raised, + Sunken + }; + public class Border : Container { #region CTOR @@ -39,9 +45,34 @@ namespace Crow #region private fields int _borderWidth; + BorderStyle _borderStyle; + Fill raiseColor = Color.Gray; + Fill sunkenColor = Color.Jet; #endregion #region public properties + [XmlAttributeAttribute] + public virtual Fill RaiseColor { + get { return raiseColor; } + set { + if (raiseColor == value) + return; + raiseColor = value; + NotifyValueChanged ("RaiseColor", raiseColor); + RegisterForRedraw (); + } + } + [XmlAttributeAttribute] + public virtual Fill SunkenColor { + get { return sunkenColor; } + set { + if (sunkenColor == value) + return; + sunkenColor = value; + NotifyValueChanged ("SunkenColor", sunkenColor); + RegisterForRedraw (); + } + } [XmlAttributeAttribute()][DefaultValue(1)] public virtual int BorderWidth { get { return _borderWidth; } @@ -50,6 +81,16 @@ namespace Crow RegisterForGraphicUpdate (); } } + [XmlAttributeAttribute][DefaultValue(BorderStyle.Normal)] + public virtual BorderStyle BorderStyle { + get { return _borderStyle; } + set { + if (_borderStyle == value) + return; + _borderStyle = value; + RegisterForGraphicUpdate (); + } + } #endregion #region GraphicObject override @@ -83,6 +124,31 @@ namespace Crow CairoHelpers.CairoRectangle(gr, rBack, CornerRadius, BorderWidth); } + if (BorderStyle != BorderStyle.Normal) { + gr.LineWidth = 1.0; + gr.SetSourceColor (sunkenColor); + gr.MoveTo (0.5 + rBack.Left, rBack.Bottom); + gr.LineTo (0.5 + rBack.Left, 0.5 + rBack.Y); + gr.LineTo (rBack.Right, 0.5 + rBack.Y); + if (BorderStyle == BorderStyle.Raised) { + gr.MoveTo (-1.5 + rBack.Right, 2.0 + rBack.Y); + gr.LineTo (-1.5 + rBack.Right, -1.5 + rBack.Bottom); + gr.LineTo (2.0 + rBack.Left, -1.5 + rBack.Bottom); + gr.Stroke (); + gr.SetSourceColor (raiseColor); + gr.MoveTo (1.5 + rBack.Left, -1.0 + rBack.Bottom); + gr.LineTo (1.5 + rBack.Left, 1.5 + rBack.Y); + gr.LineTo (rBack.Right, 1.5 + rBack.Y); + } else { + gr.Stroke (); + gr.SetSourceColor (raiseColor); + } + gr.MoveTo (-0.5 + rBack.Right, 1.5 + rBack.Y); + gr.LineTo (-0.5 + rBack.Right, -0.5 + rBack.Bottom); + gr.LineTo (1.0 + rBack.Left, -0.5 + rBack.Bottom); + gr.Stroke (); + } + gr.Save (); if (ClipToClientRect) { //clip to client zone -- 2.47.3