From: Jean-Philippe Bruyère Date: Fri, 11 Dec 2020 09:40:38 +0000 (+0100) Subject: GetStreamFromPath as instance method of iface X-Git-Tag: v0.9.5-beta~112 X-Git-Url: https://git.osiis.dedyn.io/?a=commitdiff_plain;h=325d56497d2aa5790c5e9f54dfb3aaa41e44d71c;p=jp%2Fcrow.git GetStreamFromPath as instance method of iface --- diff --git a/Crow/src/Fill/BmpPicture.cs b/Crow/src/Fill/BmpPicture.cs index 1aade935..70f36d3f 100644 --- a/Crow/src/Fill/BmpPicture.cs +++ b/Crow/src/Fill/BmpPicture.cs @@ -21,30 +21,25 @@ namespace Crow /// /// Initializes a new instance of BmpPicture. /// - public BmpPicture () - {} + public BmpPicture () {} /// /// Initializes a new instance of BmpPicture by loading the image pointed by the path argument /// /// image path, may be embedded - public BmpPicture (string path) : base(path) - { - Load (); - } + public BmpPicture (string path) : base(path) { } #endregion /// /// load the image for rendering from the path given as argument /// - /// image path, may be embedded - void Load () + void load (Interface iFace) { - if (sharedResources.ContainsKey (Path)) { - sharedPicture sp = sharedResources [Path]; + if (iFace.sharedPictures.ContainsKey (Path)) { + sharedPicture sp = iFace.sharedPictures [Path]; image = (byte[])sp.Data; Dimensions = sp.Dims; return; } - using (Stream stream = Interface.GetStreamFromPath (Path)) { + using (Stream stream = iFace.GetStreamFromPath (Path)) { #if STB_SHARP StbImageSharp.ImageResult stbi = StbImageSharp.ImageResult.FromStream (stream, StbImageSharp.ColorComponents.RedGreenBlueAlpha); image = new byte [stbi.Data.Length]; @@ -72,7 +67,7 @@ namespace Crow //loadBitmap (new System.Drawing.Bitmap (stream)); } - sharedResources [Path] = new sharedPicture (image, Dimensions); + iFace.sharedPictures [Path] = new sharedPicture (image, Dimensions); } @@ -100,8 +95,11 @@ namespace Crow #region implemented abstract members of Fill - public override void SetAsSource (Context ctx, Rectangle bounds = default(Rectangle)) + public override void SetAsSource (Interface iFace, Context ctx, Rectangle bounds = default(Rectangle)) { + if (image == null) + load (iFace); + float widthRatio = 1f; float heightRatio = 1f; @@ -141,8 +139,11 @@ namespace Crow /// drawing Backend context /// bounds of the target surface to paint /// used for svg only - public override void Paint (Context gr, Rectangle rect, string subPart = "") + public override void Paint (Interface iFace, Context gr, Rectangle rect, string subPart = "") { + if (image == null) + load (iFace); + float widthRatio = 1f; float heightRatio = 1f; diff --git a/Crow/src/Fill/Fill.cs b/Crow/src/Fill/Fill.cs index cb555b07..022f6c05 100644 --- a/Crow/src/Fill/Fill.cs +++ b/Crow/src/Fill/Fill.cs @@ -17,7 +17,7 @@ namespace Crow /// /// backend context /// paint operation bounding box, unused for SolidColor - public abstract void SetAsSource (Context ctx, Rectangle bounds = default(Rectangle)); + public abstract void SetAsSource (Interface iFace, Context ctx, Rectangle bounds = default(Rectangle)); public static object Parse (string s){ if (string.IsNullOrEmpty (s)) return null; diff --git a/Crow/src/Fill/Gradient.cs b/Crow/src/Fill/Gradient.cs index 94311dfa..ac6a638e 100644 --- a/Crow/src/Fill/Gradient.cs +++ b/Crow/src/Fill/Gradient.cs @@ -79,7 +79,7 @@ namespace Crow #region implemented abstract members of Fill - public override void SetAsSource (Context ctx, Rectangle bounds = default(Rectangle)) + public override void SetAsSource (Interface iFace, Context ctx, Rectangle bounds = default(Rectangle)) { Cairo.Gradient grad = null; switch (GradientType) { diff --git a/Crow/src/Fill/Picture.cs b/Crow/src/Fill/Picture.cs index 2a71d6b5..fd86506a 100644 --- a/Crow/src/Fill/Picture.cs +++ b/Crow/src/Fill/Picture.cs @@ -51,11 +51,6 @@ namespace Crow /// public abstract class Picture : Fill { - /// - /// share a single store for picture resources among usage in different controls - /// - internal static Dictionary sharedResources = new Dictionary(); - /// /// path of the picture /// @@ -91,14 +86,6 @@ namespace Crow } #endregion - #region Image Loading - /// - /// load the image for rendering from the stream given as argument - /// - /// picture stream - //public abstract void Load(Interface iface, string path); - #endregion - /// /// abstract method to paint the image in the rectangle given in arguments according /// to the Scale and keepProportion parameters. @@ -106,27 +93,11 @@ namespace Crow /// drawing Backend context /// bounds of the target surface to paint /// used for svg only - public abstract void Paint(Context ctx, Rectangle rect, string subPart = ""); + public abstract void Paint(Interface iFace, Context ctx, Rectangle rect, string subPart = ""); #region Operators - public static implicit operator Picture(string path) - { - if (string.IsNullOrEmpty (path)) - return null; - - Picture _pic = null; - - if (path.EndsWith (".svg", true, System.Globalization.CultureInfo.InvariantCulture)) - _pic = new SvgPicture (path); - else - _pic = new BmpPicture (path); - - return _pic; - } - public static implicit operator string(Picture _pic) - { - return _pic == null ? null : _pic.Path; - } + public static implicit operator Picture(string path) => Parse (path) as Picture; + public static implicit operator string(Picture _pic) => _pic == null ? null : _pic.Path; #endregion public static new object Parse(string path) diff --git a/Crow/src/Fill/SolidColor.cs b/Crow/src/Fill/SolidColor.cs index efccd399..8ed77fbe 100644 --- a/Crow/src/Fill/SolidColor.cs +++ b/Crow/src/Fill/SolidColor.cs @@ -26,9 +26,9 @@ namespace Crow #endregion #region implemented abstract members of Fill - public override void SetAsSource (Context ctx, Rectangle bounds = default) + public override void SetAsSource (Interface iFace, Context ctx, Rectangle bounds = default) { - ctx.SetSourceRGBA (color.R / 255.0, color.G / 255.0, color.B / 255.0, color.A / 255.0); + ctx.SetSource (color.R / 255.0, color.G / 255.0, color.B / 255.0, color.A / 255.0); } public static new object Parse(string s) { diff --git a/Crow/src/Fill/SvgPicture.cs b/Crow/src/Fill/SvgPicture.cs index 850400cd..ee6ae1ea 100644 --- a/Crow/src/Fill/SvgPicture.cs +++ b/Crow/src/Fill/SvgPicture.cs @@ -41,27 +41,23 @@ namespace Crow /// /// Initializes a new instance of SvgPicture. /// - public SvgPicture () - {} + public SvgPicture () {} /// /// Initializes a new instance of SvgPicture by loading the SVG file pointed by the path argument /// /// image path, may be embedded - public SvgPicture (string path) : base(path) - { - Load (); - } + public SvgPicture (string path) : base(path) {} #endregion - void Load () + void load (Interface iFace) { - if (sharedResources.ContainsKey (Path)) { - sharedPicture sp = sharedResources [Path]; + if (iFace.sharedPictures.ContainsKey (Path)) { + sharedPicture sp = iFace.sharedPictures [Path]; hSVG = (Rsvg.Handle)sp.Data; Dimensions = sp.Dims; return; } - using (Stream stream = Interface.GetStreamFromPath (Path)) { + using (Stream stream = iFace.GetStreamFromPath (Path)) { using (MemoryStream ms = new MemoryStream ()) { stream.CopyTo (ms); @@ -69,7 +65,7 @@ namespace Crow Dimensions = new Size (hSVG.Dimensions.Width, hSVG.Dimensions.Height); } } - sharedResources [Path] = new sharedPicture (hSVG, Dimensions); + iFace.sharedPictures [Path] = new sharedPicture (hSVG, Dimensions); } public void LoadSvgFragment (string fragment) { @@ -79,8 +75,11 @@ namespace Crow #region implemented abstract members of Fill - public override void SetAsSource (Context ctx, Rectangle bounds = default(Rectangle)) + public override void SetAsSource (Interface iFace, Context ctx, Rectangle bounds = default(Rectangle)) { + if (hSVG == null) + load (iFace); + float widthRatio = 1f; float heightRatio = 1f; @@ -116,10 +115,11 @@ namespace Crow /// drawing Backend context /// bounds of the target surface to paint /// limit rendering to svg part named 'subPart' - public override void Paint (Context gr, Rectangle rect, string subPart = "") + public override void Paint (Interface iFace, Context gr, Rectangle rect, string subPart = "") { if (hSVG == null) - return; + load (iFace); + float widthRatio = 1f; float heightRatio = 1f; diff --git a/Crow/src/IML/Instantiator.cs b/Crow/src/IML/Instantiator.cs index ac203f08..32afce34 100644 --- a/Crow/src/IML/Instantiator.cs +++ b/Crow/src/IML/Instantiator.cs @@ -65,7 +65,7 @@ namespace Crow.IML { /// /// Initializes a new instance of the Instantiator class. /// - public Instantiator (Interface _iface, string path) : this (_iface, Interface.GetStreamFromPath(path), path) { + public Instantiator (Interface _iface, string path) : this (_iface, _iface.GetStreamFromPath(path), path) { } /// @@ -316,7 +316,7 @@ namespace Crow.IML { if (iface.ItemTemplates.ContainsKey (itemTemplatePath)) { itemTemplateIds.Add (new string [] { "default", itemTemplatePath, "" }); } else { - using (Stream stream = Interface.GetStreamFromPath (itemTemplatePath)) { + using (Stream stream = iface.GetStreamFromPath (itemTemplatePath)) { //itemtemplate files may have multiple root nodes XmlReaderSettings itrSettings = new XmlReaderSettings { ConformanceLevel = ConformanceLevel.Fragment }; using (XmlReader itr = XmlReader.Create (stream, itrSettings)) { diff --git a/Crow/src/Interface.cs b/Crow/src/Interface.cs index a9a9fa1b..2f5f664d 100644 --- a/Crow/src/Interface.cs +++ b/Crow/src/Interface.cs @@ -92,8 +92,6 @@ namespace Crow FontRenderingOptions.HintMetrics = HintMetrics.On; FontRenderingOptions.HintStyle = HintStyle.Full; FontRenderingOptions.SubpixelOrder = SubpixelOrder.Default; - - loadCursors (); } public Interface (int width, int height, IntPtr glfwWindowHandle) : this (width, height, false, false) { @@ -101,6 +99,8 @@ namespace Crow } public Interface (int width = 800, int height = 600, bool startUIThread = true, bool createSurface = true) { + loadCursors (); + CultureInfo.DefaultThreadCurrentCulture = CultureInfo.InvariantCulture; CurrentInterface = this; clientRectangle = new Rectangle (0, 0, width, height); @@ -504,6 +504,11 @@ namespace Crow #region Load/Save + /// + /// share a single store for picture resources among usage in different controls + /// + internal Dictionary sharedPictures = new Dictionary (); + static bool tryGetResource (Assembly a, string resId, out Stream stream) { stream = null; if (a == null) @@ -512,10 +517,8 @@ namespace Crow return stream != null; } - public delegate Stream GetStreamFromPathDelegate (string path); - public static GetStreamFromPathDelegate GetStreamFromPath = _getStreamFromPath; - static Stream _getStreamFromPath (string path) + public virtual Stream GetStreamFromPath (string path) { if (path.StartsWith ("#", StringComparison.Ordinal)) { Stream stream = null; @@ -1016,73 +1019,76 @@ namespace Crow #region Mouse and Keyboard Handling MouseCursor cursor = MouseCursor.top_left_arrow; - static void loadCursors () + void loadCursors () { const int minimumSize = 24; + + if (XCursor.Cursors.ContainsKey (MouseCursor.arrow)) + return; //Load cursors - XCursor.Cursors [MouseCursor.arrow] = XCursorFile.Load ("#Crow.Cursors.arrow").Cursors.First (c => c.Width >= minimumSize); - XCursor.Cursors [MouseCursor.base_arrow_down] = XCursorFile.Load ("#Crow.Cursors.base_arrow_down").Cursors.First (c => c.Width >= minimumSize); - XCursor.Cursors [MouseCursor.base_arrow_up] = XCursorFile.Load ("#Crow.Cursors.base_arrow_up").Cursors.First (c => c.Width >= minimumSize); - XCursor.Cursors [MouseCursor.boat] = XCursorFile.Load ("#Crow.Cursors.boat").Cursors.First (c => c.Width >= minimumSize); - XCursor.Cursors [MouseCursor.bottom_left_corner] = XCursorFile.Load ("#Crow.Cursors.bottom_left_corner").Cursors.First (c => c.Width >= minimumSize); - XCursor.Cursors [MouseCursor.bottom_right_corner] = XCursorFile.Load ("#Crow.Cursors.bottom_right_corner").Cursors.First (c => c.Width >= minimumSize); - XCursor.Cursors [MouseCursor.bottom_side] = XCursorFile.Load ("#Crow.Cursors.bottom_side").Cursors.First (c => c.Width >= minimumSize); - XCursor.Cursors [MouseCursor.bottom_tee] = XCursorFile.Load ("#Crow.Cursors.bottom_tee").Cursors.First (c => c.Width >= minimumSize); - XCursor.Cursors [MouseCursor.center_ptr] = XCursorFile.Load ("#Crow.Cursors.center_ptr").Cursors.First (c => c.Width >= minimumSize); - XCursor.Cursors [MouseCursor.circle] = XCursorFile.Load ("#Crow.Cursors.circle").Cursors.First (c => c.Width >= minimumSize); - XCursor.Cursors [MouseCursor.cross] = XCursorFile.Load ("#Crow.Cursors.cross").Cursors.First (c => c.Width >= minimumSize); - XCursor.Cursors [MouseCursor.cross_reverse] = XCursorFile.Load ("#Crow.Cursors.cross_reverse").Cursors.First (c => c.Width >= minimumSize); - XCursor.Cursors [MouseCursor.crosshair] = XCursorFile.Load ("#Crow.Cursors.crosshair").Cursors.First (c => c.Width >= minimumSize); - XCursor.Cursors [MouseCursor.dot] = XCursorFile.Load ("#Crow.Cursors.dot").Cursors.First (c => c.Width >= minimumSize); - XCursor.Cursors [MouseCursor.dot_box_mask] = XCursorFile.Load ("#Crow.Cursors.dot_box_mask").Cursors.First (c => c.Width >= minimumSize); - XCursor.Cursors [MouseCursor.double_arrow] = XCursorFile.Load ("#Crow.Cursors.double_arrow").Cursors.First (c => c.Width >= minimumSize); - XCursor.Cursors [MouseCursor.draft_large] = XCursorFile.Load ("#Crow.Cursors.draft_large").Cursors.First (c => c.Width >= minimumSize); - XCursor.Cursors [MouseCursor.draft_small] = XCursorFile.Load ("#Crow.Cursors.draft_small").Cursors.First (c => c.Width >= minimumSize); - XCursor.Cursors [MouseCursor.draped_box] = XCursorFile.Load ("#Crow.Cursors.draped_box").Cursors.First (c => c.Width >= minimumSize); - XCursor.Cursors [MouseCursor.exchange] = XCursorFile.Load ("#Crow.Cursors.exchange").Cursors.First (c => c.Width >= minimumSize); - XCursor.Cursors [MouseCursor.fleur] = XCursorFile.Load ("#Crow.Cursors.fleur").Cursors.First (c => c.Width >= minimumSize); - XCursor.Cursors [MouseCursor.gumby] = XCursorFile.Load ("#Crow.Cursors.gumby").Cursors.First (c => c.Width >= minimumSize); - XCursor.Cursors [MouseCursor.hand] = XCursorFile.Load ("#Crow.Cursors.hand").Cursors.First (c => c.Width >= minimumSize); - XCursor.Cursors [MouseCursor.hand1] = XCursorFile.Load ("#Crow.Cursors.hand1").Cursors.First (c => c.Width >= minimumSize); - XCursor.Cursors [MouseCursor.hand2] = XCursorFile.Load ("#Crow.Cursors.hand2").Cursors.First (c => c.Width >= minimumSize); - XCursor.Cursors [MouseCursor.help] = XCursorFile.Load ("#Crow.Cursors.help").Cursors.First (c => c.Width >= minimumSize); - XCursor.Cursors [MouseCursor.ibeam] = XCursorFile.Load ("#Crow.Cursors.ibeam").Cursors.First (c => c.Width >= minimumSize); - XCursor.Cursors [MouseCursor.left_ptr] = XCursorFile.Load ("#Crow.Cursors.left_ptr").Cursors.First (c => c.Width >= minimumSize); - XCursor.Cursors [MouseCursor.left_ptr_watch] = XCursorFile.Load ("#Crow.Cursors.left_ptr_watch").Cursors.First (c => c.Width >= minimumSize); - XCursor.Cursors [MouseCursor.left_side] = XCursorFile.Load ("#Crow.Cursors.left_side").Cursors.First (c => c.Width >= minimumSize); - XCursor.Cursors [MouseCursor.left_tee] = XCursorFile.Load ("#Crow.Cursors.left_tee").Cursors.First (c => c.Width >= minimumSize); - XCursor.Cursors [MouseCursor.ll_angle] = XCursorFile.Load ("#Crow.Cursors.ll_angle").Cursors.First (c => c.Width >= minimumSize); - XCursor.Cursors [MouseCursor.lr_angle] = XCursorFile.Load ("#Crow.Cursors.lr_angle").Cursors.First (c => c.Width >= minimumSize); - XCursor.Cursors [MouseCursor.move] = XCursorFile.Load ("#Crow.Cursors.move").Cursors.First (c => c.Width >= minimumSize); - XCursor.Cursors [MouseCursor.pencil] = XCursorFile.Load ("#Crow.Cursors.pencil").Cursors.First (c => c.Width >= minimumSize); - XCursor.Cursors [MouseCursor.pirate] = XCursorFile.Load ("#Crow.Cursors.pirate").Cursors.First (c => c.Width >= minimumSize); - XCursor.Cursors [MouseCursor.plus] = XCursorFile.Load ("#Crow.Cursors.plus").Cursors.First (c => c.Width >= minimumSize); - XCursor.Cursors [MouseCursor.question_arrow] = XCursorFile.Load ("#Crow.Cursors.question_arrow").Cursors.First (c => c.Width >= minimumSize); - XCursor.Cursors [MouseCursor.right_ptr] = XCursorFile.Load ("#Crow.Cursors.right_ptr").Cursors.First (c => c.Width >= minimumSize); - XCursor.Cursors [MouseCursor.right_side] = XCursorFile.Load ("#Crow.Cursors.right_side").Cursors.First (c => c.Width >= minimumSize); - XCursor.Cursors [MouseCursor.right_tee] = XCursorFile.Load ("#Crow.Cursors.right_tee").Cursors.First (c => c.Width >= minimumSize); - XCursor.Cursors [MouseCursor.sailboat] = XCursorFile.Load ("#Crow.Cursors.sailboat").Cursors.First (c => c.Width >= minimumSize); - XCursor.Cursors [MouseCursor.sb_down_arrow] = XCursorFile.Load ("#Crow.Cursors.sb_down_arrow").Cursors.First (c => c.Width >= minimumSize); - XCursor.Cursors [MouseCursor.sb_h_double_arrow] = XCursorFile.Load ("#Crow.Cursors.sb_h_double_arrow").Cursors.First (c => c.Width >= minimumSize); - XCursor.Cursors [MouseCursor.sb_left_arrow] = XCursorFile.Load ("#Crow.Cursors.sb_left_arrow").Cursors.First (c => c.Width >= minimumSize); - XCursor.Cursors [MouseCursor.sb_right_arrow] = XCursorFile.Load ("#Crow.Cursors.sb_right_arrow").Cursors.First (c => c.Width >= minimumSize); - XCursor.Cursors [MouseCursor.sb_up_arrow] = XCursorFile.Load ("#Crow.Cursors.sb_up_arrow").Cursors.First (c => c.Width >= minimumSize); - XCursor.Cursors [MouseCursor.sb_v_double_arrow] = XCursorFile.Load ("#Crow.Cursors.sb_v_double_arrow").Cursors.First (c => c.Width >= minimumSize); - XCursor.Cursors [MouseCursor.shuttle] = XCursorFile.Load ("#Crow.Cursors.shuttle").Cursors.First (c => c.Width >= minimumSize); - XCursor.Cursors [MouseCursor.sizing] = XCursorFile.Load ("#Crow.Cursors.sizing").Cursors.First (c => c.Width >= minimumSize); - XCursor.Cursors [MouseCursor.target] = XCursorFile.Load ("#Crow.Cursors.target").Cursors.First (c => c.Width >= minimumSize); - XCursor.Cursors [MouseCursor.tcross] = XCursorFile.Load ("#Crow.Cursors.tcross").Cursors.First (c => c.Width >= minimumSize); - XCursor.Cursors [MouseCursor.top_left_arrow] = XCursorFile.Load ("#Crow.Cursors.top_left_arrow").Cursors.First (c => c.Width >= minimumSize); - XCursor.Cursors [MouseCursor.top_left_corner] = XCursorFile.Load ("#Crow.Cursors.top_left_corner").Cursors.First (c => c.Width >= minimumSize); - XCursor.Cursors [MouseCursor.top_right_corner] = XCursorFile.Load ("#Crow.Cursors.top_right_corner").Cursors.First (c => c.Width >= minimumSize); - XCursor.Cursors [MouseCursor.top_side] = XCursorFile.Load ("#Crow.Cursors.top_side").Cursors.First (c => c.Width >= minimumSize); - XCursor.Cursors [MouseCursor.top_tee] = XCursorFile.Load ("#Crow.Cursors.top_tee").Cursors.First (c => c.Width >= minimumSize); - XCursor.Cursors [MouseCursor.trek] = XCursorFile.Load ("#Crow.Cursors.trek").Cursors.First (c => c.Width >= minimumSize); - XCursor.Cursors [MouseCursor.ul_angle] = XCursorFile.Load ("#Crow.Cursors.ul_angle").Cursors.First (c => c.Width >= minimumSize); - XCursor.Cursors [MouseCursor.ur_angle] = XCursorFile.Load ("#Crow.Cursors.ur_angle").Cursors.First (c => c.Width >= minimumSize); - XCursor.Cursors [MouseCursor.watch] = XCursorFile.Load ("#Crow.Cursors.watch").Cursors.First (c => c.Width >= minimumSize); - XCursor.Cursors [MouseCursor.X_cursor] = XCursorFile.Load ("#Crow.Cursors.X_cursor").Cursors.First (c => c.Width >= minimumSize); - XCursor.Cursors [MouseCursor.xterm] = XCursorFile.Load ("#Crow.Cursors.xterm").Cursors.First (c => c.Width >= minimumSize); + XCursor.Cursors [MouseCursor.arrow] = XCursorFile.Load (this, "#Crow.Cursors.arrow").Cursors.First (c => c.Width >= minimumSize); + XCursor.Cursors [MouseCursor.base_arrow_down] = XCursorFile.Load (this, "#Crow.Cursors.base_arrow_down").Cursors.First (c => c.Width >= minimumSize); + XCursor.Cursors [MouseCursor.base_arrow_up] = XCursorFile.Load (this, "#Crow.Cursors.base_arrow_up").Cursors.First (c => c.Width >= minimumSize); + XCursor.Cursors [MouseCursor.boat] = XCursorFile.Load (this, "#Crow.Cursors.boat").Cursors.First (c => c.Width >= minimumSize); + XCursor.Cursors [MouseCursor.bottom_left_corner] = XCursorFile.Load (this, "#Crow.Cursors.bottom_left_corner").Cursors.First (c => c.Width >= minimumSize); + XCursor.Cursors [MouseCursor.bottom_right_corner] = XCursorFile.Load (this, "#Crow.Cursors.bottom_right_corner").Cursors.First (c => c.Width >= minimumSize); + XCursor.Cursors [MouseCursor.bottom_side] = XCursorFile.Load (this, "#Crow.Cursors.bottom_side").Cursors.First (c => c.Width >= minimumSize); + XCursor.Cursors [MouseCursor.bottom_tee] = XCursorFile.Load (this, "#Crow.Cursors.bottom_tee").Cursors.First (c => c.Width >= minimumSize); + XCursor.Cursors [MouseCursor.center_ptr] = XCursorFile.Load (this, "#Crow.Cursors.center_ptr").Cursors.First (c => c.Width >= minimumSize); + XCursor.Cursors [MouseCursor.circle] = XCursorFile.Load (this, "#Crow.Cursors.circle").Cursors.First (c => c.Width >= minimumSize); + XCursor.Cursors [MouseCursor.cross] = XCursorFile.Load (this, "#Crow.Cursors.cross").Cursors.First (c => c.Width >= minimumSize); + XCursor.Cursors [MouseCursor.cross_reverse] = XCursorFile.Load (this, "#Crow.Cursors.cross_reverse").Cursors.First (c => c.Width >= minimumSize); + XCursor.Cursors [MouseCursor.crosshair] = XCursorFile.Load (this, "#Crow.Cursors.crosshair").Cursors.First (c => c.Width >= minimumSize); + XCursor.Cursors [MouseCursor.dot] = XCursorFile.Load (this, "#Crow.Cursors.dot").Cursors.First (c => c.Width >= minimumSize); + XCursor.Cursors [MouseCursor.dot_box_mask] = XCursorFile.Load (this, "#Crow.Cursors.dot_box_mask").Cursors.First (c => c.Width >= minimumSize); + XCursor.Cursors [MouseCursor.double_arrow] = XCursorFile.Load (this, "#Crow.Cursors.double_arrow").Cursors.First (c => c.Width >= minimumSize); + XCursor.Cursors [MouseCursor.draft_large] = XCursorFile.Load (this, "#Crow.Cursors.draft_large").Cursors.First (c => c.Width >= minimumSize); + XCursor.Cursors [MouseCursor.draft_small] = XCursorFile.Load (this, "#Crow.Cursors.draft_small").Cursors.First (c => c.Width >= minimumSize); + XCursor.Cursors [MouseCursor.draped_box] = XCursorFile.Load (this, "#Crow.Cursors.draped_box").Cursors.First (c => c.Width >= minimumSize); + XCursor.Cursors [MouseCursor.exchange] = XCursorFile.Load (this, "#Crow.Cursors.exchange").Cursors.First (c => c.Width >= minimumSize); + XCursor.Cursors [MouseCursor.fleur] = XCursorFile.Load (this, "#Crow.Cursors.fleur").Cursors.First (c => c.Width >= minimumSize); + XCursor.Cursors [MouseCursor.gumby] = XCursorFile.Load (this, "#Crow.Cursors.gumby").Cursors.First (c => c.Width >= minimumSize); + XCursor.Cursors [MouseCursor.hand] = XCursorFile.Load (this, "#Crow.Cursors.hand").Cursors.First (c => c.Width >= minimumSize); + XCursor.Cursors [MouseCursor.hand1] = XCursorFile.Load (this, "#Crow.Cursors.hand1").Cursors.First (c => c.Width >= minimumSize); + XCursor.Cursors [MouseCursor.hand2] = XCursorFile.Load (this, "#Crow.Cursors.hand2").Cursors.First (c => c.Width >= minimumSize); + XCursor.Cursors [MouseCursor.help] = XCursorFile.Load (this, "#Crow.Cursors.help").Cursors.First (c => c.Width >= minimumSize); + XCursor.Cursors [MouseCursor.ibeam] = XCursorFile.Load (this, "#Crow.Cursors.ibeam").Cursors.First (c => c.Width >= minimumSize); + XCursor.Cursors [MouseCursor.left_ptr] = XCursorFile.Load (this, "#Crow.Cursors.left_ptr").Cursors.First (c => c.Width >= minimumSize); + XCursor.Cursors [MouseCursor.left_ptr_watch] = XCursorFile.Load (this, "#Crow.Cursors.left_ptr_watch").Cursors.First (c => c.Width >= minimumSize); + XCursor.Cursors [MouseCursor.left_side] = XCursorFile.Load (this, "#Crow.Cursors.left_side").Cursors.First (c => c.Width >= minimumSize); + XCursor.Cursors [MouseCursor.left_tee] = XCursorFile.Load (this, "#Crow.Cursors.left_tee").Cursors.First (c => c.Width >= minimumSize); + XCursor.Cursors [MouseCursor.ll_angle] = XCursorFile.Load (this, "#Crow.Cursors.ll_angle").Cursors.First (c => c.Width >= minimumSize); + XCursor.Cursors [MouseCursor.lr_angle] = XCursorFile.Load (this, "#Crow.Cursors.lr_angle").Cursors.First (c => c.Width >= minimumSize); + XCursor.Cursors [MouseCursor.move] = XCursorFile.Load (this, "#Crow.Cursors.move").Cursors.First (c => c.Width >= minimumSize); + XCursor.Cursors [MouseCursor.pencil] = XCursorFile.Load (this, "#Crow.Cursors.pencil").Cursors.First (c => c.Width >= minimumSize); + XCursor.Cursors [MouseCursor.pirate] = XCursorFile.Load (this, "#Crow.Cursors.pirate").Cursors.First (c => c.Width >= minimumSize); + XCursor.Cursors [MouseCursor.plus] = XCursorFile.Load (this, "#Crow.Cursors.plus").Cursors.First (c => c.Width >= minimumSize); + XCursor.Cursors [MouseCursor.question_arrow] = XCursorFile.Load (this, "#Crow.Cursors.question_arrow").Cursors.First (c => c.Width >= minimumSize); + XCursor.Cursors [MouseCursor.right_ptr] = XCursorFile.Load (this, "#Crow.Cursors.right_ptr").Cursors.First (c => c.Width >= minimumSize); + XCursor.Cursors [MouseCursor.right_side] = XCursorFile.Load (this, "#Crow.Cursors.right_side").Cursors.First (c => c.Width >= minimumSize); + XCursor.Cursors [MouseCursor.right_tee] = XCursorFile.Load (this, "#Crow.Cursors.right_tee").Cursors.First (c => c.Width >= minimumSize); + XCursor.Cursors [MouseCursor.sailboat] = XCursorFile.Load (this, "#Crow.Cursors.sailboat").Cursors.First (c => c.Width >= minimumSize); + XCursor.Cursors [MouseCursor.sb_down_arrow] = XCursorFile.Load (this, "#Crow.Cursors.sb_down_arrow").Cursors.First (c => c.Width >= minimumSize); + XCursor.Cursors [MouseCursor.sb_h_double_arrow] = XCursorFile.Load (this, "#Crow.Cursors.sb_h_double_arrow").Cursors.First (c => c.Width >= minimumSize); + XCursor.Cursors [MouseCursor.sb_left_arrow] = XCursorFile.Load (this, "#Crow.Cursors.sb_left_arrow").Cursors.First (c => c.Width >= minimumSize); + XCursor.Cursors [MouseCursor.sb_right_arrow] = XCursorFile.Load (this, "#Crow.Cursors.sb_right_arrow").Cursors.First (c => c.Width >= minimumSize); + XCursor.Cursors [MouseCursor.sb_up_arrow] = XCursorFile.Load (this, "#Crow.Cursors.sb_up_arrow").Cursors.First (c => c.Width >= minimumSize); + XCursor.Cursors [MouseCursor.sb_v_double_arrow] = XCursorFile.Load (this, "#Crow.Cursors.sb_v_double_arrow").Cursors.First (c => c.Width >= minimumSize); + XCursor.Cursors [MouseCursor.shuttle] = XCursorFile.Load (this, "#Crow.Cursors.shuttle").Cursors.First (c => c.Width >= minimumSize); + XCursor.Cursors [MouseCursor.sizing] = XCursorFile.Load (this, "#Crow.Cursors.sizing").Cursors.First (c => c.Width >= minimumSize); + XCursor.Cursors [MouseCursor.target] = XCursorFile.Load (this, "#Crow.Cursors.target").Cursors.First (c => c.Width >= minimumSize); + XCursor.Cursors [MouseCursor.tcross] = XCursorFile.Load (this, "#Crow.Cursors.tcross").Cursors.First (c => c.Width >= minimumSize); + XCursor.Cursors [MouseCursor.top_left_arrow] = XCursorFile.Load (this, "#Crow.Cursors.top_left_arrow").Cursors.First (c => c.Width >= minimumSize); + XCursor.Cursors [MouseCursor.top_left_corner] = XCursorFile.Load (this, "#Crow.Cursors.top_left_corner").Cursors.First (c => c.Width >= minimumSize); + XCursor.Cursors [MouseCursor.top_right_corner] = XCursorFile.Load (this, "#Crow.Cursors.top_right_corner").Cursors.First (c => c.Width >= minimumSize); + XCursor.Cursors [MouseCursor.top_side] = XCursorFile.Load (this, "#Crow.Cursors.top_side").Cursors.First (c => c.Width >= minimumSize); + XCursor.Cursors [MouseCursor.top_tee] = XCursorFile.Load (this, "#Crow.Cursors.top_tee").Cursors.First (c => c.Width >= minimumSize); + XCursor.Cursors [MouseCursor.trek] = XCursorFile.Load (this, "#Crow.Cursors.trek").Cursors.First (c => c.Width >= minimumSize); + XCursor.Cursors [MouseCursor.ul_angle] = XCursorFile.Load (this, "#Crow.Cursors.ul_angle").Cursors.First (c => c.Width >= minimumSize); + XCursor.Cursors [MouseCursor.ur_angle] = XCursorFile.Load (this, "#Crow.Cursors.ur_angle").Cursors.First (c => c.Width >= minimumSize); + XCursor.Cursors [MouseCursor.watch] = XCursorFile.Load (this, "#Crow.Cursors.watch").Cursors.First (c => c.Width >= minimumSize); + XCursor.Cursors [MouseCursor.X_cursor] = XCursorFile.Load (this, "#Crow.Cursors.X_cursor").Cursors.First (c => c.Width >= minimumSize); + XCursor.Cursors [MouseCursor.xterm] = XCursorFile.Load (this, "#Crow.Cursors.xterm").Cursors.First (c => c.Width >= minimumSize); } diff --git a/Crow/src/ItemTemplate.cs b/Crow/src/ItemTemplate.cs index 11fea671..e1696256 100644 --- a/Crow/src/ItemTemplate.cs +++ b/Crow/src/ItemTemplate.cs @@ -82,7 +82,7 @@ namespace Crow /// type this item will be choosen for, or member of the data item /// for hierarchical data, method to call for children fetching public ItemTemplate (Interface _iface, string path, string _dataTest = "TypeOf", string _dataType = "default", string _fetchDataMethod = null) - : base(_iface, Interface.GetStreamFromPath (path)) { + : base(_iface, _iface.GetStreamFromPath (path)) { strDataType = _dataType; fetchMethodName = _fetchDataMethod; dataTest = _dataTest; diff --git a/Crow/src/Mono.Cairo/Context.cs b/Crow/src/Mono.Cairo/Context.cs index 1ce4cd0f..6463ecf0 100644 --- a/Crow/src/Mono.Cairo/Context.cs +++ b/Crow/src/Mono.Cairo/Context.cs @@ -329,12 +329,12 @@ namespace Crow.Cairo { NativeMethods.cairo_set_source_rgba (handle, color.R / 255.0, color.G / 255.0, color.B / 255.0, color.A / 255.0); } - public void SetSourceRGB (double r, double g, double b) + public void SetSource (double r, double g, double b) { NativeMethods.cairo_set_source_rgb (handle, r, g, b); } - public void SetSourceRGBA (double r, double g, double b, double a) + public void SetSource (double r, double g, double b, double a) { NativeMethods.cairo_set_source_rgba (handle, r, g, b, a); } diff --git a/Crow/src/Widgets/Border.cs b/Crow/src/Widgets/Border.cs index e0a9ba5e..d9de7f6a 100644 --- a/Crow/src/Widgets/Border.cs +++ b/Crow/src/Widgets/Border.cs @@ -121,14 +121,14 @@ namespace Crow // if (BorderWidth > 0) // rBack.Inflate (-BorderWidth / 2); - Background.SetAsSource (gr, rBack); + Background.SetAsSource (IFace, gr, rBack); CairoHelpers.CairoRectangle(gr, rBack, CornerRadius); gr.Fill (); if (BorderStyle == BorderStyle.Normal) { if (BorderWidth > 0) { - Foreground?.SetAsSource (gr, rBack); + Foreground?.SetAsSource (IFace, gr, rBack); CairoHelpers.CairoRectangle (gr, rBack, CornerRadius, BorderWidth); } } else { @@ -208,7 +208,7 @@ namespace Crow // if (BorderWidth > 0) // rBack.Inflate (-BorderWidth / 2); - Background.SetAsSource (gr, rBack); + Background.SetAsSource (IFace, gr, rBack); CairoHelpers.CairoRectangle(gr, rBack, CornerRadius); gr.Fill (); @@ -217,7 +217,7 @@ namespace Crow if (bw > 0) { if (BorderStyle == BorderStyle.Normal) - Foreground.SetAsSource (gr, rBack); + Foreground.SetAsSource (IFace, gr, rBack); else { if (BorderStyle == BorderStyle.Sunken) gr.SetSource (raisedColor); diff --git a/Crow/src/Widgets/ColorSlider.cs b/Crow/src/Widgets/ColorSlider.cs index 52e7e620..a1b54d7c 100644 --- a/Crow/src/Widgets/ColorSlider.cs +++ b/Crow/src/Widgets/ColorSlider.cs @@ -181,7 +181,7 @@ namespace Crow break; } - grad.SetAsSource (gr, r); + grad.SetAsSource (IFace, gr, r); CairoHelpers.CairoRectangle (gr, r, CornerRadius); gr.Fill (); diff --git a/Crow/src/Widgets/DockStack.cs b/Crow/src/Widgets/DockStack.cs index da9110e4..728a35e1 100644 --- a/Crow/src/Widgets/DockStack.cs +++ b/Crow/src/Widgets/DockStack.cs @@ -173,7 +173,7 @@ namespace Crow Rectangle rBack = new Rectangle (Slot.Size); - Background.SetAsSource (gr, rBack); + Background.SetAsSource (IFace, gr, rBack); CairoHelpers.CairoRectangle (gr, rBack, CornerRadius); gr.Fill (); @@ -226,9 +226,9 @@ namespace Crow break; } gr.LineWidth = 1; - gr.SetSourceRGBA (0.4, 0.4, 0.9, 0.4); + gr.SetSource (0.4, 0.4, 0.9, 0.4); gr.FillPreserve (); - gr.SetSourceRGBA (0.9, 0.9, 1.0, 0.8); + gr.SetSource (0.9, 0.9, 1.0, 0.8); gr.Stroke (); } gr.Restore (); diff --git a/Crow/src/Widgets/Gauge.cs b/Crow/src/Widgets/Gauge.cs index 267692d7..191a9faf 100644 --- a/Crow/src/Widgets/Gauge.cs +++ b/Crow/src/Widgets/Gauge.cs @@ -114,10 +114,10 @@ namespace Crow { else cb.Height = (int)(cb.Height / Maximum * Value); - Background.SetAsSource (gr, cb); + Background.SetAsSource (IFace, gr, cb); CairoHelpers.CairoRectangle (gr, cb, CornerRadius); gr.Fill (); - Foreground.SetAsSource (gr, cb); + Foreground.SetAsSource (IFace, gr, cb); if (borderWidth > 0) CairoHelpers.CairoRectangle (gr, cb, CornerRadius, borderWidth); } diff --git a/Crow/src/Widgets/HueSelector.cs b/Crow/src/Widgets/HueSelector.cs index 7bf2895c..64f8217e 100644 --- a/Crow/src/Widgets/HueSelector.cs +++ b/Crow/src/Widgets/HueSelector.cs @@ -91,7 +91,7 @@ namespace Crow grad.Stops.Add (new Gradient.ColorStop (0.833, new Color (1, 0, 1, 1))); grad.Stops.Add (new Gradient.ColorStop (1, new Color (1, 0, 0, 1))); - grad.SetAsSource (gr, r); + grad.SetAsSource (IFace, gr, r); CairoHelpers.CairoRectangle (gr, r, CornerRadius); gr.Fill(); diff --git a/Crow/src/Widgets/Image.cs b/Crow/src/Widgets/Image.cs index 04cb2e22..5f8ed06e 100644 --- a/Crow/src/Widgets/Image.cs +++ b/Crow/src/Widgets/Image.cs @@ -175,10 +175,10 @@ namespace Crow if (_pic == null) return; - _pic.Paint (gr, ClientRectangle, _svgSub); + _pic.Paint (IFace, gr, ClientRectangle, _svgSub); if (Opacity<1.0) { - gr.SetSourceRGBA (0.0, 0.0, 0.0, 1.0-Opacity); + gr.SetSource (0.0, 0.0, 0.0, 1.0-Opacity); gr.Operator = Operator.DestOut; gr.Rectangle (ClientRectangle); gr.Fill (); diff --git a/Crow/src/Widgets/Label.cs b/Crow/src/Widgets/Label.cs index fa2fe46b..3b1e4ea4 100644 --- a/Crow/src/Widgets/Label.cs +++ b/Crow/src/Widgets/Label.cs @@ -588,7 +588,7 @@ namespace Crow { }else computeTextCursorPosition(gr); - Foreground.SetAsSource (gr); + Foreground.SetAsSource (IFace, gr); gr.LineWidth = 1.0; gr.MoveTo (0.5 + textCursorPos + rText.X, rText.Y + CurrentLine * (fe.Ascent+fe.Descent)); gr.LineTo (0.5 + textCursorPos + rText.X, rText.Y + (CurrentLine + 1) * (fe.Ascent+fe.Descent)); @@ -639,7 +639,7 @@ namespace Crow { if (string.IsNullOrWhiteSpace (l)) continue; - Foreground.SetAsSource (gr); + Foreground.SetAsSource (IFace, gr); gr.MoveTo (lineRect.X,(double)rText.Y + fe.Ascent + (fe.Ascent+fe.Descent) * i) ; gr.ShowText (l); diff --git a/Crow/src/Widgets/ProgressBar.cs b/Crow/src/Widgets/ProgressBar.cs index a0d8e10a..c9e40b48 100644 --- a/Crow/src/Widgets/ProgressBar.cs +++ b/Crow/src/Widgets/ProgressBar.cs @@ -28,7 +28,7 @@ namespace Crow Rectangle rBack = ClientRectangle; rBack.Width = (int)((double)rBack.Width / Maximum * Value); - Foreground.SetAsSource (gr, rBack); + Foreground.SetAsSource (IFace, gr, rBack); CairoHelpers.CairoRectangle(gr,rBack,CornerRadius); gr.Fill(); diff --git a/Crow/src/Widgets/SaturationValueSelector.cs b/Crow/src/Widgets/SaturationValueSelector.cs index a2b39567..c56dd30c 100644 --- a/Crow/src/Widgets/SaturationValueSelector.cs +++ b/Crow/src/Widgets/SaturationValueSelector.cs @@ -49,7 +49,7 @@ namespace Crow Rectangle r = ClientRectangle; if (Foreground != null) {//TODO:test if null should be removed - Foreground.SetAsSource (gr, r); + Foreground.SetAsSource (IFace, gr, r); CairoHelpers.CairoRectangle (gr, r, CornerRadius); gr.Fill (); } @@ -57,13 +57,13 @@ namespace Crow Crow.Gradient grad = new Gradient (Gradient.Type.Horizontal); grad.Stops.Add (new Gradient.ColorStop (0, new Color (1, 1, 1, 1))); grad.Stops.Add (new Gradient.ColorStop (1, new Color (1, 1, 1, 0))); - grad.SetAsSource (gr, r); + grad.SetAsSource (IFace, gr, r); CairoHelpers.CairoRectangle (gr, r, CornerRadius); gr.Fill(); grad = new Gradient (Gradient.Type.Vertical); grad.Stops.Add (new Gradient.ColorStop (0, new Color (0, 0, 0, 0))); grad.Stops.Add (new Gradient.ColorStop (1, new Color (0, 0, 0, 1))); - grad.SetAsSource (gr, r); + grad.SetAsSource (IFace, gr, r); CairoHelpers.CairoRectangle (gr, r, CornerRadius); gr.Fill(); diff --git a/Crow/src/Widgets/Scroller.cs b/Crow/src/Widgets/Scroller.cs index 0314be50..a706d692 100644 --- a/Crow/src/Widgets/Scroller.cs +++ b/Crow/src/Widgets/Scroller.cs @@ -184,7 +184,7 @@ namespace Crow { Rectangle rBack = new Rectangle (Slot.Size); - Background.SetAsSource (gr, rBack); + Background.SetAsSource (IFace, gr, rBack); CairoHelpers.CairoRectangle(gr,rBack, CornerRadius); gr.Fill (); diff --git a/Crow/src/Widgets/Shape.cs b/Crow/src/Widgets/Shape.cs index 979d9c4a..e1f816d5 100644 --- a/Crow/src/Widgets/Shape.cs +++ b/Crow/src/Widgets/Shape.cs @@ -120,7 +120,7 @@ namespace Crow readDouble (); readDouble (); readDouble (); readDouble (); break; } - gr.SetSourceRGBA (readDouble (), readDouble (), readDouble (), readDouble ()); + gr.SetSource (readDouble (), readDouble (), readDouble (), readDouble ()); break; default: throw new Exception ("Invalid character in path string of Shape control"); @@ -223,7 +223,7 @@ namespace Crow gr.Translate ((cr.Width / widthRatio - w) / 2, (cr.Height / heightRatio - h) / 2); gr.LineWidth = strokeWidth; - Foreground.SetAsSource (gr, cr); + Foreground.SetAsSource (IFace, gr, cr); using (PathParser parser = new PathParser (path)) parser.Draw (gr); diff --git a/Crow/src/Widgets/TabItem.cs b/Crow/src/Widgets/TabItem.cs index 19fcb94e..109b1e53 100644 --- a/Crow/src/Widgets/TabItem.cs +++ b/Crow/src/Widgets/TabItem.cs @@ -154,14 +154,14 @@ namespace Crow gr.LineTo (0.5, Slot.Height-0.5); gr.ClosePath (); gr.LineWidth = 1; - Foreground.SetAsSource (gr); + Foreground.SetAsSource (IFace, gr); gr.StrokePreserve (); gr.ClipPreserve (); - if (IsSelected) - SelectedBackground.SetAsSource (gr, ClientRectangle); + if (tv.isSelectedTab (this)) + SelectedBackground.SetAsSource (IFace, gr, ClientRectangle); else - Background.SetAsSource (gr, ClientRectangle); + Background.SetAsSource (IFace, gr, ClientRectangle); gr.Fill (); diff --git a/Crow/src/Widgets/TabView.cs b/Crow/src/Widgets/TabView.cs index cce32883..9a88d72f 100644 --- a/Crow/src/Widgets/TabView.cs +++ b/Crow/src/Widgets/TabView.cs @@ -237,7 +237,7 @@ namespace Crow { Rectangle rBack = new Rectangle (Slot.Size); - Background.SetAsSource (gr, rBack); + Background.SetAsSource (IFace, gr, rBack); CairoHelpers.CairoRectangle(gr,rBack, CornerRadius); gr.Fill (); @@ -308,6 +308,8 @@ namespace Crow { SelectedTab = Children.IndexOf (sender as Widget); } + internal bool isSelectedTab (TabItem ti) => + Children.IndexOf (ti) == selectedTab; } } diff --git a/Crow/src/Widgets/TemplatedControl.cs b/Crow/src/Widgets/TemplatedControl.cs index e700513e..74c71fe2 100644 --- a/Crow/src/Widgets/TemplatedControl.cs +++ b/Crow/src/Widgets/TemplatedControl.cs @@ -119,7 +119,7 @@ namespace Crow if (!IFace.DefaultTemplates.ContainsKey (mdTok)) { string defTmpId = this.GetType ().FullName + ".template"; - Stream s = Interface.GetStreamFromPath ("#" + defTmpId); + Stream s = IFace.GetStreamFromPath ("#" + defTmpId); if (s == null) throw new Exception (string.Format ("No default template found for '{0}'", this.GetType ().FullName)); IFace.DefaultTemplates [mdTok] = new IML.Instantiator (IFace, s, defTmpId); diff --git a/Crow/src/Widgets/TextRun.cs b/Crow/src/Widgets/TextRun.cs index 042dbdbc..4c69e0e0 100644 --- a/Crow/src/Widgets/TextRun.cs +++ b/Crow/src/Widgets/TextRun.cs @@ -267,7 +267,7 @@ namespace Crow continue; } - Foreground.SetAsSource (gr); + Foreground.SetAsSource (IFace, gr); gr.MoveTo (rText.X, rText.Y + fe.Ascent + fe.Height * curLineCount); gr.ShowText (ll); diff --git a/Crow/src/Widgets/Trend.cs b/Crow/src/Widgets/Trend.cs index ebc3cedb..1a2d1375 100644 --- a/Crow/src/Widgets/Trend.cs +++ b/Crow/src/Widgets/Trend.cs @@ -135,13 +135,13 @@ namespace Crow - LowThresholdFill.SetAsSource (gr); + LowThresholdFill.SetAsSource (IFace, gr); gr.MoveTo (r.Left, r.Bottom - LowThreshold * scaleY); gr.LineTo (r.Right, r.Bottom - LowThreshold * scaleY); // gr.Rectangle (r.Left, r.Bottom - LowThreshold * scaleY, r.Width, LowThreshold * scaleY); gr.Stroke(); - HighThresholdFill.SetAsSource (gr); + HighThresholdFill.SetAsSource (IFace, gr); gr.MoveTo (r.Left, (Maximum - HighThreshold) * scaleY); gr.LineTo (r.Right, (Maximum - HighThreshold) * scaleY); // gr.Rectangle (r.Left, r.Top, r.Width, (Maximum - HighThreshold) * scaleY); @@ -149,7 +149,7 @@ namespace Crow gr.MoveTo (ptrX, values [i] * scaleY); - Foreground.SetAsSource (gr); + Foreground.SetAsSource (IFace, gr); gr.SetDash (new double[]{ }, 0.0); while (i >= 0) { diff --git a/Crow/src/Widgets/Widget.cs b/Crow/src/Widgets/Widget.cs index d75c63c4..ac170479 100644 --- a/Crow/src/Widgets/Widget.cs +++ b/Crow/src/Widgets/Widget.cs @@ -1792,7 +1792,7 @@ namespace Crow Rectangle rBack = new Rectangle (Slot.Size); - background.SetAsSource (gr, rBack); + background.SetAsSource (IFace, gr, rBack); CairoHelpers.CairoRectangle (gr, rBack, cornerRadius); gr.Fill (); @@ -1908,7 +1908,7 @@ namespace Crow } void paintDisabled(Context gr, Rectangle rb){ gr.Operator = Operator.Xor; - gr.SetSourceRGBA (0.6, 0.6, 0.6, 0.3); + gr.SetSource (0.6, 0.6, 0.6, 0.3); gr.Rectangle (rb); gr.Fill (); gr.Operator = Operator.Over; diff --git a/Crow/src/XCursor.cs b/Crow/src/XCursor.cs index cb596c70..14151b8d 100644 --- a/Crow/src/XCursor.cs +++ b/Crow/src/XCursor.cs @@ -86,9 +86,9 @@ namespace Crow return tmp; } - public static XCursorFile Load(string path) + public static XCursorFile Load(Interface iFace, string path) { - return loadFromStream (Interface.GetStreamFromPath (path)); + return loadFromStream (iFace.GetStreamFromPath (path)); } static XCursor imageLoad (BinaryReader sr)