/// <summary>
/// Initializes a new instance of BmpPicture.
/// </summary>
- public BmpPicture ()
- {}
+ public BmpPicture () {}
/// <summary>
/// Initializes a new instance of BmpPicture by loading the image pointed by the path argument
/// </summary>
/// <param name="path">image path, may be embedded</param>
- public BmpPicture (string path) : base(path)
- {
- Load ();
- }
+ public BmpPicture (string path) : base(path) { }
#endregion
/// <summary>
/// load the image for rendering from the path given as argument
/// </summary>
- /// <param name="path">image path, may be embedded</param>
- 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];
//loadBitmap (new System.Drawing.Bitmap (stream));
}
- sharedResources [Path] = new sharedPicture (image, Dimensions);
+ iFace.sharedPictures [Path] = new sharedPicture (image, Dimensions);
}
#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;
/// <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 (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;
/// </summary>
/// <param name="ctx">backend context</param>
/// <param name="bounds">paint operation bounding box, unused for SolidColor</param>
- 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;
#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) {
/// </summary>
public abstract class Picture : Fill
{
- /// <summary>
- /// share a single store for picture resources among usage in different controls
- /// </summary>
- internal static Dictionary<string, sharedPicture> sharedResources = new Dictionary<string, sharedPicture>();
-
/// <summary>
/// path of the picture
/// </summary>
}
#endregion
- #region Image Loading
- /// <summary>
- /// load the image for rendering from the stream given as argument
- /// </summary>
- /// <param name="stream">picture stream</param>
- //public abstract void Load(Interface iface, string path);
- #endregion
-
/// <summary>
/// abstract method to paint the image in the rectangle given in arguments according
/// to the Scale and keepProportion parameters.
/// <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 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)
#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)
{
/// <summary>
/// Initializes a new instance of SvgPicture.
/// </summary>
- public SvgPicture ()
- {}
+ public SvgPicture () {}
/// <summary>
/// Initializes a new instance of SvgPicture by loading the SVG file pointed by the path argument
/// </summary>
/// <param name="path">image path, may be embedded</param>
- 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);
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) {
#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;
/// <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 (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;
/// <summary>
/// Initializes a new instance of the Instantiator class.
/// </summary>
- public Instantiator (Interface _iface, string path) : this (_iface, Interface.GetStreamFromPath(path), path) {
+ public Instantiator (Interface _iface, string path) : this (_iface, _iface.GetStreamFromPath(path), path) {
}
/// <summary>
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)) {
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)
{
}
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);
#region Load/Save
+ /// <summary>
+ /// share a single store for picture resources among usage in different controls
+ /// </summary>
+ internal Dictionary<string, sharedPicture> sharedPictures = new Dictionary<string, sharedPicture> ();
+
static bool tryGetResource (Assembly a, string resId, out Stream stream) {
stream = null;
if (a == null)
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;
#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);
}
/// <param name="_dataType">type this item will be choosen for, or member of the data item</param>
/// <param name="_fetchDataMethod">for hierarchical data, method to call for children fetching</param>
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;
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);
}
// 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 {
// if (BorderWidth > 0)
// rBack.Inflate (-BorderWidth / 2);
- Background.SetAsSource (gr, rBack);
+ Background.SetAsSource (IFace, gr, rBack);
CairoHelpers.CairoRectangle(gr, rBack, CornerRadius);
gr.Fill ();
if (bw > 0) {
if (BorderStyle == BorderStyle.Normal)
- Foreground.SetAsSource (gr, rBack);
+ Foreground.SetAsSource (IFace, gr, rBack);
else {
if (BorderStyle == BorderStyle.Sunken)
gr.SetSource (raisedColor);
break;
}
- grad.SetAsSource (gr, r);
+ grad.SetAsSource (IFace, gr, r);
CairoHelpers.CairoRectangle (gr, r, CornerRadius);
gr.Fill ();
Rectangle rBack = new Rectangle (Slot.Size);
- Background.SetAsSource (gr, rBack);
+ Background.SetAsSource (IFace, gr, rBack);
CairoHelpers.CairoRectangle (gr, rBack, CornerRadius);
gr.Fill ();
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 ();
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);
}
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();
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 ();
}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));
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);
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();
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 ();
}
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();
{
Rectangle rBack = new Rectangle (Slot.Size);
- Background.SetAsSource (gr, rBack);
+ Background.SetAsSource (IFace, gr, rBack);
CairoHelpers.CairoRectangle(gr,rBack, CornerRadius);
gr.Fill ();
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");
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);
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 ();
{
Rectangle rBack = new Rectangle (Slot.Size);
- Background.SetAsSource (gr, rBack);
+ Background.SetAsSource (IFace, gr, rBack);
CairoHelpers.CairoRectangle(gr,rBack, CornerRadius);
gr.Fill ();
{
SelectedTab = Children.IndexOf (sender as Widget);
}
+ internal bool isSelectedTab (TabItem ti) =>
+ Children.IndexOf (ti) == selectedTab;
}
}
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);
continue;
}
- Foreground.SetAsSource (gr);
+ Foreground.SetAsSource (IFace, gr);
gr.MoveTo (rText.X, rText.Y + fe.Ascent + fe.Height * curLineCount);
gr.ShowText (ll);
- 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);
gr.MoveTo (ptrX, values [i] * scaleY);
- Foreground.SetAsSource (gr);
+ Foreground.SetAsSource (IFace, gr);
gr.SetDash (new double[]{ }, 0.0);
while (i >= 0) {
Rectangle rBack = new Rectangle (Slot.Size);
- background.SetAsSource (gr, rBack);
+ background.SetAsSource (IFace, gr, rBack);
CairoHelpers.CairoRectangle (gr, rBack, cornerRadius);
gr.Fill ();
}
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;
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)