[Mono-dev] patch for Mono.Cairo to rename Graphics to Context

Ben Maurer bmaurer at ximian.com
Tue Nov 29 13:59:46 EST 2005


On Tue, 2005-11-29 at 10:35 -0600, Mike Kestner wrote:
> 
> We are already exposing Cairo.Graphics in the 2.7.1 release of Gtk#.
> It's an unstable release, so I can change the symbol still, but the
> change as posted would break 2.7.1 on newer mono releases.
> 
> If this change is going to be made, at the very least I would suggest
> adding something like:
> 
> [Obsolete ("Replaced by Cairo.Context")]
> public class Graphics : Context {}
> 
> That would at least give source compat, if not runtime compat. But I
> don't personally think it's worth changing just to be consistent with
> other language bindings.

I really hope we aren't considering the Cairo bindings to be stable
right now. I took a quick look and found a few api issues:

      * Things like Point are classes not structs. This is confusing as
        all the other graphics apis (S.Drawing, Gdk) use structs.
      * Point, Color, etc use public fields rather than properties. For
        example, Color should probably check that r,g,b,a are <= 1.0.
      * There are many apis to do the same thing:


		// FIXME should be made into a property
                public void FontSetSize (double size)
                {
                        CairoAPI.cairo_set_font_size (state, size);
                }

		public double FontSize {
			set { CairoAPI.cairo_set_font_size (state, value); }
		}
		
		public void SetFontSize (double scale)
		{
			CairoAPI.cairo_set_font_size (state, scale);
		}



		public void SelectFontFace (string family, FontSlant slant, FontWeight weight)
		{
			CairoAPI.cairo_select_font_face (state, family, slant, weight);
		}
		
		public void FontFace (string family, FontSlant s, FontWeight w)
		{
			CairoAPI.cairo_select_font_face (state, family, s, w);
		}


                public IntPtr Handle {
                        get {
				return surface;
			}
                }
                public IntPtr Pointer {
                        get {
				return surface;
			}
                }

      * Other todos in the API, (See Graphics.cs around line 531).
      * Inconsistent following of API guidelines wrt case of API names:
              * public Cairo.Color ColorRgb {
              * public void SetSourceRGB (double r, double g, double b
              * (Micorosft uses public static Color FromArgb (int argb))
                

In short, I don't think this API has had the level of auditing needed to
declare it stable. If we consider the current API to be stable, we will
be left with binding full of [Obsolete] methods and riddled with some
unfixable issues.

-- Ben





More information about the Mono-devel-list mailing list