diff options
| author | Jean-Philippe Bruyère <jp_bruyere@hotmail.com> | 2018-02-04 21:04:32 +0100 |
|---|---|---|
| committer | Jean-Philippe Bruyère <jp_bruyere@hotmail.com> | 2018-02-04 21:04:32 +0100 |
| commit | 56383b7cadef47e34ba7dce0a676082544bccac7 (patch) | |
| tree | 317c935914ff270949fe0c8a32c2d042a05edf71 /src | |
| parent | 2d93d89034894255917733d9a38bfd7998805f4c (diff) | |
:book: tutorials and some small improvements (iml fragment loading helpers
Diffstat (limited to 'src')
| -rw-r--r-- | src/BmpPicture.cs | 4 | ||||
| -rw-r--r-- | src/Fill/Fill.cs | 5 | ||||
| -rw-r--r-- | src/Gradient.cs | 3 | ||||
| -rw-r--r-- | src/GraphicObjects/Border.cs | 7 | ||||
| -rw-r--r-- | src/GraphicObjects/GraphicObject.cs | 12 | ||||
| -rw-r--r-- | src/GraphicObjects/HueSelector.cs | 8 | ||||
| -rw-r--r-- | src/GraphicObjects/NumericControl.cs | 2 | ||||
| -rw-r--r-- | src/GraphicObjects/SaturationValueSelector.cs | 2 | ||||
| -rw-r--r-- | src/GraphicObjects/TabItem.cs | 3 | ||||
| -rw-r--r-- | src/GraphicObjects/TemplatedControl.cs | 3 | ||||
| -rw-r--r-- | src/GraphicObjects/TestCairoPatch.cs | 148 | ||||
| -rw-r--r-- | src/GraphicObjects/Trend.cs | 3 | ||||
| -rw-r--r-- | src/Instantiator.cs | 12 | ||||
| -rw-r--r-- | src/Interface.cs | 25 | ||||
| -rw-r--r-- | src/Mono.Cairo/Context.cs | 10 | ||||
| -rw-r--r-- | src/Mono.Cairo/Rectangle.cs | 132 | ||||
| -rw-r--r-- | src/Mono.Cairo/Surface.cs | 4 | ||||
| -rw-r--r-- | src/SolidColor.cs | 3 | ||||
| -rw-r--r-- | src/SvgPicture.cs | 4 | ||||
| -rw-r--r-- | src/rsvg/Handle.cs | 5 |
20 files changed, 289 insertions, 106 deletions
diff --git a/src/BmpPicture.cs b/src/BmpPicture.cs index 79302354..b8271615 100644 --- a/src/BmpPicture.cs +++ b/src/BmpPicture.cs @@ -114,7 +114,7 @@ namespace Crow } using (ImageSurface tmp = new ImageSurface (Format.Argb32, bounds.Width, bounds.Height)) { - using (Cairo.Context gr = new Context (tmp)) { + using (Context gr = new Context (tmp)) { gr.Translate (bounds.Left, bounds.Top); gr.Scale (widthRatio, heightRatio); gr.Translate ((bounds.Width/widthRatio - Dimensions.Width)/2, (bounds.Height/heightRatio - Dimensions.Height)/2); @@ -137,7 +137,7 @@ namespace Crow /// <param name="gr">drawing Backend context</param> /// <param name="rect">bounds of the target surface to paint</param> /// <param name="subPart">used for svg only</param> - public override void Paint (Cairo.Context gr, Rectangle rect, string subPart = "") + public override void Paint (Context gr, Rectangle rect, string subPart = "") { float widthRatio = 1f; float heightRatio = 1f; diff --git a/src/Fill/Fill.cs b/src/Fill/Fill.cs index d0a14f60..d98e47cf 100644 --- a/src/Fill/Fill.cs +++ b/src/Fill/Fill.cs @@ -26,6 +26,7 @@ using System; using System.Collections.Generic; +using Cairo; namespace Crow { @@ -38,8 +39,8 @@ namespace Crow /// set content of fill as source for drawing operations on the backend context /// </summary> /// <param name="ctx">backend context</param> - /// <param name="bounds">drawing operation bounding box</param> - public abstract void SetAsSource (Cairo.Context ctx, Rectangle bounds = default(Rectangle)); + /// <param name="bounds">paint operation bounding box, unused for SolidColor</param> + public abstract void SetAsSource (Context ctx, Rectangle bounds = default(Rectangle)); public static object Parse (string s){ if (string.IsNullOrEmpty (s)) return null; diff --git a/src/Gradient.cs b/src/Gradient.cs index 56873889..0806e885 100644 --- a/src/Gradient.cs +++ b/src/Gradient.cs @@ -26,6 +26,7 @@ using System; using System.Collections.Generic; +using Cairo; namespace Crow { @@ -78,7 +79,7 @@ namespace Crow #region implemented abstract members of Fill - public override void SetAsSource (Cairo.Context ctx, Rectangle bounds = default(Rectangle)) + public override void SetAsSource (Context ctx, Rectangle bounds = default(Rectangle)) { Cairo.Gradient grad = null; switch (GradientType) { diff --git a/src/GraphicObjects/Border.cs b/src/GraphicObjects/Border.cs index a7c039c3..569315cc 100644 --- a/src/GraphicObjects/Border.cs +++ b/src/GraphicObjects/Border.cs @@ -28,6 +28,7 @@ using System; using System.Xml.Serialization; using System.ComponentModel; using System.Diagnostics; +using Cairo; namespace Crow { @@ -126,7 +127,7 @@ namespace Crow int tmp = base.measureRawSize (lt); return tmp < 0 ? tmp : tmp + 2 * BorderWidth; } - protected override void onDraw (Cairo.Context gr) + protected override void onDraw (Context gr) { drawborder2 (gr); @@ -141,7 +142,7 @@ namespace Crow child.Paint (ref gr); gr.Restore (); } - void drawborder2(Cairo.Context gr){ + void drawborder2(Context gr){ Rectangle rBack = new Rectangle (Slot.Size); //rBack.Inflate (-Margin); @@ -228,7 +229,7 @@ namespace Crow } } } - void drawborder1(Cairo.Context gr){ + void drawborder1(Context gr){ Rectangle rBack = new Rectangle (Slot.Size); //rBack.Inflate (-Margin); diff --git a/src/GraphicObjects/GraphicObject.cs b/src/GraphicObjects/GraphicObject.cs index 2523810e..b7ca11f6 100644 --- a/src/GraphicObjects/GraphicObject.cs +++ b/src/GraphicObjects/GraphicObject.cs @@ -38,7 +38,7 @@ using Crow.IML; namespace Crow { /// <summary> - /// This is the base class for all the graphic trees elements + /// The base class for all the graphic tree elements. /// </summary> public class GraphicObject : ILayoutable, IValueChange, IDisposable { @@ -1375,7 +1375,7 @@ namespace Crow #region Rendering /// <summary> This is the common overridable drawing routine to create new widget </summary> - protected virtual void onDraw(Cairo.Context gr) + protected virtual void onDraw(Context gr) { #if DEBUG_UPDATE Debug.WriteLine (string.Format("OnDraw -> {0}", this.ToString ())); @@ -1400,13 +1400,13 @@ namespace Crow if (bmp != null) bmp.Dispose (); bmp = new ImageSurface (Format.Argb32, Slot.Width, Slot.Height); - using (Cairo.Context gr = new Cairo.Context (bmp)) { + using (Context gr = new Context (bmp)) { gr.Antialias = Interface.Antialias; onDraw (gr); } bmp.Flush (); } - protected virtual void UpdateCache(Cairo.Context ctx){ + protected virtual void UpdateCache(Context ctx){ #if DEBUG_UPDATE Debug.WriteLine (string.Format("UpdateCache -> {0}", this.ToString ())); #endif @@ -1425,7 +1425,7 @@ namespace Crow } /// <summary> Chained painting routine on the parent context of the actual cached version /// of the widget </summary> - public virtual void Paint (ref Cairo.Context ctx) + public virtual void Paint (ref Context ctx) { #if DEBUG_UPDATE Debug.WriteLine (string.Format("Paint -> {0}", this.ToString ())); @@ -1461,7 +1461,7 @@ namespace Crow LastPaintedSlot = Slot; } } - void paintDisabled(Cairo.Context gr, Rectangle rb){ + void paintDisabled(Context gr, Rectangle rb){ gr.Operator = Operator.Xor; gr.SetSourceRGBA (0.6, 0.6, 0.6, 0.3); gr.Rectangle (rb); diff --git a/src/GraphicObjects/HueSelector.cs b/src/GraphicObjects/HueSelector.cs index a94053fd..08c84deb 100644 --- a/src/GraphicObjects/HueSelector.cs +++ b/src/GraphicObjects/HueSelector.cs @@ -67,11 +67,13 @@ namespace Crow RegisterForRedraw (); } } - protected override void onDraw (Cairo.Context gr) + protected override void onDraw (Context gr) { base.onDraw (gr); Rectangle r = ClientRectangle; + r.Height -= 4; + r.Y += 2; Gradient.Type gt = Gradient.Type.Horizontal; if (Orientation == Orientation.Vertical) @@ -111,9 +113,9 @@ namespace Crow r.Y = mousePos.Y - 2; } - CairoHelpers.CairoRectangle (ctx, r, 2); + CairoHelpers.CairoRectangle (ctx, r, 1); ctx.SetSourceColor (Color.White); - ctx.LineWidth = 2.0; + ctx.LineWidth = 1.0; ctx.Stroke(); ctx.Restore (); } diff --git a/src/GraphicObjects/NumericControl.cs b/src/GraphicObjects/NumericControl.cs index d8fdead4..21cb1961 100644 --- a/src/GraphicObjects/NumericControl.cs +++ b/src/GraphicObjects/NumericControl.cs @@ -113,7 +113,7 @@ namespace Crow RegisterForRedraw (); } } - [XmlAttributeAttribute][DefaultValue(0.0)] + [DefaultValue(0.0)] public double Value { get { return _actualValue; } diff --git a/src/GraphicObjects/SaturationValueSelector.cs b/src/GraphicObjects/SaturationValueSelector.cs index 8d726685..b0bf270e 100644 --- a/src/GraphicObjects/SaturationValueSelector.cs +++ b/src/GraphicObjects/SaturationValueSelector.cs @@ -65,7 +65,7 @@ namespace Crow RegisterForRedraw (); } } - protected override void onDraw (Cairo.Context gr) + protected override void onDraw (Context gr) { base.onDraw (gr); diff --git a/src/GraphicObjects/TabItem.cs b/src/GraphicObjects/TabItem.cs index 2fdc3802..9dfff864 100644 --- a/src/GraphicObjects/TabItem.cs +++ b/src/GraphicObjects/TabItem.cs @@ -28,6 +28,7 @@ using System; using System.Xml.Serialization; using System.ComponentModel; using System.Diagnostics; +using Cairo; namespace Crow { @@ -105,7 +106,7 @@ namespace Crow NotifyValueChanged ("IsSelected", isSelected); } } - protected override void onDraw (Cairo.Context gr) + protected override void onDraw (Context gr) { gr.Save (); diff --git a/src/GraphicObjects/TemplatedControl.cs b/src/GraphicObjects/TemplatedControl.cs index 01ba22c2..6e236c8d 100644 --- a/src/GraphicObjects/TemplatedControl.cs +++ b/src/GraphicObjects/TemplatedControl.cs @@ -34,6 +34,7 @@ using System.Linq; using System.Collections.Generic; using System.Text; using System.Reflection; +using Cairo; namespace Crow { @@ -105,7 +106,7 @@ namespace Crow ///this allow applying root background to random template's component /// </summary> /// <param name="gr">Backend context</param> - protected override void onDraw (Cairo.Context gr) + protected override void onDraw (Context gr) { gr.Save (); diff --git a/src/GraphicObjects/TestCairoPatch.cs b/src/GraphicObjects/TestCairoPatch.cs new file mode 100644 index 00000000..f155d3c0 --- /dev/null +++ b/src/GraphicObjects/TestCairoPatch.cs @@ -0,0 +1,148 @@ +// +// TestCairoPatch.cs +// +// Author: +// jp <> +// +// Copyright (c) 2013-2017 Jean-Philippe Bruyère +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. +using System; +using Cairo; + +namespace Crow +{ + public class TestCairoPatch : GraphicObject + { + void computeControlPoints ( + double xc, double yc, + double x1, double y1, + out double x2, out double y2, + out double x3, out double y3, + double x4, double y4){ + double ax = x1 - xc; + double ay = y1 - yc; + double bx = x4 - xc; + double byy = y4 - yc; + double q1 = ax * ax + ay * ay; + double q2 = q1 + ax * bx + ay * byy; + double k2 = 4.0/3.0 * (Math.Sqrt(2.0 * q1 * q2) - q2) / (ax * byy - ay * bx); + + + x2 = xc + ax - k2 * ay; + y2 = yc + ay + k2 * ax; + x3 = xc + bx + k2 * byy; + y3 = yc + byy - k2 * bx; + } + protected override void onDraw (Context gr) + { + base.onDraw (gr); + + double radius = 100; + + double pi3 = Math.PI / 3.0; + + MeshPattern mp = new MeshPattern (); + + double x1 = radius,y1 = 0, + x2 = 0, y2 = 0, x3 = 0, y3 = 0, x4 = 0, y4 = 0, + xc = radius,yc = radius; + + double dx = Math.Sin (pi3) * radius; + double dy = Math.Cos (pi3) * radius; + + mp.BeginPatch (); + mp.MoveTo (xc, yc); + mp.LineTo (x1, y1); + x4 = xc + dx; + y4 = yc - dy; + computeControlPoints (xc, yc, x1, y1, out x2, out y2, out x3, out y3, x4, y4); + mp.CurveTo (x2, y2, x3, y3, x4, y4); + + mp.SetCornerColorRGB (0, 1, 1, 1); + mp.SetCornerColorRGB (1, 1, 0, 0); + mp.SetCornerColorRGB (2, 1, 1, 0); + + x1 = x4; + y1 = y4; + y4 = yc + dy; + + computeControlPoints (xc, yc, x1, y1, out x2, out y2, out x3, out y3, x4, y4); + mp.CurveTo (x2, y2, x3, y3, x4, y4); + + mp.SetCornerColorRGB (3, 0, 1, 0); + mp.EndPatch (); + + x1 = x4; + y1 = y4; + x4 = xc; + y4 = yc * 2.0; + + mp.BeginPatch (); + mp.MoveTo (xc, yc); + mp.LineTo (x1, y1); + computeControlPoints (xc, yc, x1, y1, out x2, out y2, out x3, out y3, x4, y4); + mp.CurveTo (x2, y2, x3, y3, x4, y4); + + mp.SetCornerColorRGB (0, 1, 1, 1); + mp.SetCornerColorRGB (1, 0, 1, 0); + mp.SetCornerColorRGB (2, 0, 1, 1); + + x1 = x4; + y1 = y4; + x4 = xc-dx; + y4 = yc+dy; + + computeControlPoints (xc, yc, x1, y1, out x2, out y2, out x3, out y3, x4, y4); + mp.CurveTo (x2, y2, x3, y3, x4, y4); + + mp.SetCornerColorRGB (3, 0, 0, 1); + mp.EndPatch (); + + x1 = x4; + y1 = y4; + y4 = yc - dy; + + mp.BeginPatch (); + mp.MoveTo (xc, yc); + mp.LineTo (x1, y1); + computeControlPoints (xc, yc, x1, y1, out x2, out y2, out x3, out y3, x4, y4); + mp.CurveTo (x2, y2, x3, y3, x4, y4); + + mp.SetCornerColorRGB (0, 1, 1, 1); + mp.SetCornerColorRGB (1, 0, 0, 1); + mp.SetCornerColorRGB (2, 1, 0, 1); + + x1 = x4; + y1 = y4; + x4 = radius; + y4 = 0; + + computeControlPoints (xc, yc, x1, y1, out x2, out y2, out x3, out y3, x4, y4); + mp.CurveTo (x2, y2, x3, y3, x4, y4); + + mp.SetCornerColorRGB (3, 1, 0, 0); + mp.EndPatch (); + + gr.SetSource (mp); + gr.Paint (); + } + } +} + diff --git a/src/GraphicObjects/Trend.cs b/src/GraphicObjects/Trend.cs index 50a1e56f..055c870d 100644 --- a/src/GraphicObjects/Trend.cs +++ b/src/GraphicObjects/Trend.cs @@ -28,6 +28,7 @@ using System; using System.Collections.Generic; using System.Xml.Serialization; using System.ComponentModel; +using Cairo; namespace Crow { @@ -139,7 +140,7 @@ namespace Crow RegisterForRedraw (); } } - protected override void onDraw (Cairo.Context gr) + protected override void onDraw (Context gr) { base.onDraw (gr); diff --git a/src/Instantiator.cs b/src/Instantiator.cs index a1012e2b..902092e2 100644 --- a/src/Instantiator.cs +++ b/src/Instantiator.cs @@ -36,7 +36,7 @@ using System.Collections.Generic; using System.Linq; using Crow.IML; -namespace Crow +namespace Crow.IML { public delegate object InstanciatorInvoker(Interface iface); @@ -123,7 +123,15 @@ namespace Crow public GraphicObject CreateInstance(Interface iface){ return loader (iface) as GraphicObject; } - + /// <summary> + /// Creates a new instance of T compiled in the instantiator + /// and bind it the an interface + /// </summary> + /// <returns>The new T instance</returns> + /// <param name="iface">The interface to bind to</param> + public T CreateInstance<T>(Interface iface){ + return (T)loader (iface); + } List<DynamicMethod> dsValueChangedDynMeths = new List<DynamicMethod>(); List<Delegate> cachedDelegates = new List<Delegate>(); /// <summary> diff --git a/src/Interface.cs b/src/Interface.cs index 15c6de35..32b9549e 100644 --- a/src/Interface.cs +++ b/src/Interface.cs @@ -35,6 +35,7 @@ using System.Xml; using System.Xml.Serialization; using Cairo; using System.Globalization; +using Crow.IML; namespace Crow { @@ -212,6 +213,8 @@ namespace Crow } /// <summary> Search for .style resources in assembly </summary> static void loadStylingFromAssembly (Assembly assembly) { + if (assembly == null) + return; foreach (string s in assembly .GetManifestResourceNames () .Where (r => r.EndsWith (".style", StringComparison.OrdinalIgnoreCase))) { @@ -221,9 +224,9 @@ namespace Crow } static void loadCursors(){ //Load cursors - XCursor.Cross = XCursorFile.Load("#Crow.Images.Icons.Cursors.cross").Cursors[0]; - XCursor.Default = XCursorFile.Load("#Crow.Images.Icons.Cursors.arrow").Cursors[0]; - XCursor.NW = XCursorFile.Load("#Crow.Images.Icons.Cursors.top_left_corner").Cursors[0]; + XCursor.Cross = XCursorFile.Load("#Crow.Images.Icons.Cursors.cross").Cursors[3]; + XCursor.Default = XCursorFile.Load("#Crow.Images.Icons.Cursors.arrow").Cursors[3]; + XCursor.NW = XCursorFile.Load("#Crow.Images.Icons.Cursors.top_left_corner").Cursors[3]; XCursor.NE = XCursorFile.Load("#Crow.Images.Icons.Cursors.top_right_corner").Cursors[0]; XCursor.SW = XCursorFile.Load("#Crow.Images.Icons.Cursors.bottom_left_corner").Cursors[0]; XCursor.SE = XCursorFile.Load("#Crow.Images.Icons.Cursors.bottom_right_corner").Cursors[0]; @@ -258,6 +261,8 @@ namespace Crow } } static void searchTemplatesIn(Assembly assembly){ + if (assembly == null) + return; foreach (string resId in assembly .GetManifestResourceNames () .Where (r => r.EndsWith (".template", StringComparison.OrdinalIgnoreCase))) { @@ -295,7 +300,18 @@ namespace Crow } return stream; } - + /// <summary> + /// Add the content of the IML fragment to the graphic tree of this interface + /// </summary> + /// <returns>return the new instance for convenience, may be ignored</returns> + /// <param name="imlFragment">a valid IML string</param> + public GraphicObject LoadIMLFragment (string imlFragment) { + lock (UpdateMutex) { + GraphicObject tmp = Instantiator.CreateFromImlFragment (imlFragment).CreateInstance(this); + AddWidget (tmp); + return tmp; + } + } /// <summary>Create an instance of a GraphicObject and add it to the GraphicTree /// of this Interface</summary> public GraphicObject LoadInterface (string path) @@ -303,7 +319,6 @@ namespace Crow lock (UpdateMutex) { GraphicObject tmp = Load (path); AddWidget (tmp); - return tmp; } } diff --git a/src/Mono.Cairo/Context.cs b/src/Mono.Cairo/Context.cs index 3b731a98..264774dd 100644 --- a/src/Mono.Cairo/Context.cs +++ b/src/Mono.Cairo/Context.cs @@ -450,7 +450,7 @@ namespace Cairo { NativeMethods.cairo_arc_negative (handle, xc, yc, radius, angle1, angle2); } - public void Rectangle (Rectangle rectangle) + public void Rectangle (Crow.Rectangle rectangle) { Rectangle (rectangle.X, rectangle.Y, rectangle.Width, rectangle.Height); } @@ -518,11 +518,11 @@ namespace Cairo { NativeMethods.cairo_stroke_preserve (handle); } - public Rectangle StrokeExtents () + public Crow.Rectangle StrokeExtents () { double x1, y1, x2, y2; NativeMethods.cairo_stroke_extents (handle, out x1, out y1, out x2, out y2); - return new Rectangle (x1, y1, x2 - x1, y2 - y1); + return new Crow.Rectangle ((int)x1, (int)y1, (int)(x2 - x1), (int)(y2 - y1)); } public void Fill () @@ -530,11 +530,11 @@ namespace Cairo { NativeMethods.cairo_fill (handle); } - public Rectangle FillExtents () + public Crow.Rectangle FillExtents () { double x1, y1, x2, y2; NativeMethods.cairo_fill_extents (handle, out x1, out y1, out x2, out y2); - return new Rectangle (x1, y1, x2 - x1, y2 - y1); + return new Crow.Rectangle ((int)x1, (int)y1, (int)(x2 - x1), (int)(y2 - y1)); } public void FillPreserve () diff --git a/src/Mono.Cairo/Rectangle.cs b/src/Mono.Cairo/Rectangle.cs index 233a1bac..6766aa45 100644 --- a/src/Mono.Cairo/Rectangle.cs +++ b/src/Mono.Cairo/Rectangle.cs @@ -30,70 +30,70 @@ using System; namespace Cairo { - public struct Rectangle - { - double x; - double y; - double width; - double height; - - public Rectangle (double x, double y, double width, double height) - { - this.x = x; - this.y = y; - this.width = width; - this.height = height; - } - - public Rectangle (Point point, double width, double height) - { - x = point.X; - y = point.Y; - this.width = width; - this.height = height; - } - - public double X { - get { return x; } - } - - public double Y { - get { return y; } - } - - public double Width { - get { return width; } - } - - public double Height { - get { return height; } - } - - public override bool Equals (object obj) - { - if (obj is Rectangle) - return this == (Rectangle)obj; - return false; - } - - public override int GetHashCode () - { - return (int) (x + y + width + height); - } - - public override string ToString () - { - return String.Format ("x:{0} y:{1} w:{2} h:{3}", x, y, width, height); - } - - public static bool operator == (Rectangle rectangle, Rectangle other) - { - return rectangle.X == other.X && rectangle.Y == other.Y && rectangle.Width == other.Width && rectangle.Height == other.Height; - } - - public static bool operator != (Rectangle rectangle, Rectangle other) - { - return !(rectangle == other); - } - } +// public struct Rectangle +// { +// double x; +// double y; +// double width; +// double height; +// +// public Rectangle (double x, double y, double width, double height) +// { +// this.x = x; +// this.y = y; +// this.width = width; +// this.height = height; +// } +// +// public Rectangle (Point point, double width, double height) +// { +// x = point.X; +// y = point.Y; +// this.width = width; +// this.height = height; +// } +// +// public double X { +// get { return x; } +// } +// +// public double Y { +// get { return y; } +// } +// +// public double Width { +// get { return width; } +// } +// +// public double Height { +// get { return height; } +// } +// +// public override bool Equals (object obj) +// { +// if (obj is Rectangle) +// return this == (Rectangle)obj; +// return false; +// } +// +// public override int GetHashCode () +// { +// return (int) (x + y + width + height); +// } +// +// public override string ToString () +// { +// return String.Format ("x:{0} y:{1} w:{2} h:{3}", x, y, width, height); +// } +// +// public static bool operator == (Rectangle rectangle, Rectangle other) +// { +// return rectangle.X == other.X && rectangle.Y == other.Y && rectangle.Width == other.Width && rectangle.Height == other.Height; +// } +// +// public static bool operator != (Rectangle rectangle, Rectangle other) +// { +// return !(rectangle == other); +// } +// } } diff --git a/src/Mono.Cairo/Surface.cs b/src/Mono.Cairo/Surface.cs index d38b7555..6a55496a 100644 --- a/src/Mono.Cairo/Surface.cs +++ b/src/Mono.Cairo/Surface.cs @@ -169,9 +169,9 @@ namespace Cairo { NativeMethods.cairo_surface_mark_dirty (Handle); } - public void MarkDirty (Rectangle rectangle) + public void MarkDirty (Crow.Rectangle rectangle) { - NativeMethods.cairo_surface_mark_dirty_rectangle (Handle, (int)rectangle.X, (int)rectangle.Y, (int)rectangle.Width, (int)rectangle.Height); + NativeMethods.cairo_surface_mark_dirty_rectangle (Handle, rectangle.X, rectangle.Y, rectangle.Width, rectangle.Height); } public IntPtr Handle { diff --git a/src/SolidColor.cs b/src/SolidColor.cs index a8574b35..d6423d31 100644 --- a/src/SolidColor.cs +++ b/src/SolidColor.cs @@ -31,6 +31,7 @@ using System.Text; using System.Xml.Serialization; using System.Reflection; using System.Diagnostics; +using Cairo; @@ -48,7 +49,7 @@ namespace Crow #region implemented abstract members of Fill - public override void SetAsSource (Cairo.Context ctx, Rectangle bounds = default(Rectangle)) + public override void SetAsSource (Context ctx, Rectangle bounds = default(Rectangle)) { ctx.SetSourceRGBA (color.R, color.G, color.B, color.A); } diff --git a/src/SvgPicture.cs b/src/SvgPicture.cs index b4026852..01aaeb5f 100644 --- a/src/SvgPicture.cs +++ b/src/SvgPicture.cs @@ -91,7 +91,7 @@ namespace Crow } using (ImageSurface tmp = new ImageSurface (Format.Argb32, bounds.Width, bounds.Height)) { - using (Cairo.Context gr = new Context (tmp)) { + using (Context gr = new Context (tmp)) { gr.Translate (bounds.Left, bounds.Top); gr.Scale (widthRatio, heightRatio); gr.Translate ((bounds.Width/widthRatio - Dimensions.Width)/2, (bounds.Height/heightRatio - Dimensions.Height)/2); @@ -110,7 +110,7 @@ namespace Crow /// <param name="gr">drawing Backend context</param> /// <param name="rect">bounds of the target surface to paint</param> /// <param name="subPart">limit rendering to svg part named 'subPart'</param> - public override void Paint (Cairo.Context gr, Rectangle rect, string subPart = "") + public override void Paint (Context gr, Rectangle rect, string subPart = "") { float widthRatio = 1f; float heightRatio = 1f; diff --git a/src/rsvg/Handle.cs b/src/rsvg/Handle.cs index 039d3b6e..e13f79ad 100644 --- a/src/rsvg/Handle.cs +++ b/src/rsvg/Handle.cs @@ -1,4 +1,7 @@ //Copyright GPL2 +using Cairo; + + namespace Rsvg { using System; @@ -55,7 +58,7 @@ namespace Rsvg { [DllImport("rsvg-2")] static extern void rsvg_handle_render_cairo(IntPtr raw, IntPtr cr); - public void RenderCairo(Cairo.Context cr) { + public void RenderCairo(Context cr) { unsafe{ rsvg_handle_render_cairo (Raw, cr == null ? IntPtr.Zero : cr.Handle); } |