From ae21ffa9f20ebd4a0b11a8c8f153d2b012630ac3 Mon Sep 17 00:00:00 2001 From: Miguel de Icaza Date: Fri, 28 Feb 2003 07:28:06 +0000 Subject: [PATCH] 2003-02-28 Miguel de Icaza * gdk/Color.custom: Added constructors from System.Drawing.Color and from rgb byte tuples. * gdk/Colormap.custom: Add new .custom file for the AllocColor call. svn path=/trunk/gtk-sharp/; revision=12054 --- ChangeLog | 11 +++++++++++ gdk/Color.custom | 33 +++++++++++++++++++++++---------- gdk/Colormap.custom | 9 +++++++++ 3 files changed, 43 insertions(+), 10 deletions(-) create mode 100644 gdk/Colormap.custom diff --git a/ChangeLog b/ChangeLog index d9fa967b8..6a015dd89 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +2003-02-28 Miguel de Icaza + + * gdk/Color.custom: Added constructors from System.Drawing.Color + and from rgb byte tuples. + + * gdk/Colormap.custom: Add new .custom file for the AllocColor + call. + + * sources/Gdk.metadata: Make Colormap.AllocColor GdkColor + parameter be a `ref' parameter. + 2003-02-27 Miguel de Icaza * gdk/Drawable.custom: Added nice overload for DrawRectangle. diff --git a/gdk/Color.custom b/gdk/Color.custom index 0bc67c29f..a693cde11 100644 --- a/gdk/Color.custom +++ b/gdk/Color.custom @@ -1,22 +1,35 @@ // Gdk.Color.custom - Gdk Color class customizations // -// Author: Jasper van Putten +// Author: Jasper van Putten , Miguel de Icaza. // // (c) 2002 Jasper van Putten +// (c) 2003 Miguel de Icaza. // // This code is inserted after the automatically generated code. -/// -/// ToString method -/// -/// -/// -/// returns a string representation of this color -/// -/// - public override string ToString () { return String.Format ("rgb:{0:x}/{1:x}/{2:x}", red, green, blue); } + +public Color (byte r, byte g, byte b) +{ + red = (ushort) (r << 8 | r); + green = (ushort) (g << 8 | g); + blue = (ushort) (b << 8 | b); + pixel = 0; +} + +public Color (System.Drawing.Color color) +{ + byte r, g, b; + r = color.R; + g = color.G; + b = color.B; + + red = (ushort) (r << 8 | r); + green = (ushort) (g << 8 | g); + blue = (ushort) (b << 8 | b); + pixel = 0; +} \ No newline at end of file diff --git a/gdk/Colormap.custom b/gdk/Colormap.custom new file mode 100644 index 000000000..941f1b692 --- /dev/null +++ b/gdk/Colormap.custom @@ -0,0 +1,9 @@ +[DllImport("libgdk-win32-2.0-0.dll", EntryPoint="gdk_colormap_alloc_color")] +static extern bool _gdk_colormap_alloc_color(IntPtr raw, ref Gdk.Color color, bool writeable, bool best_match); + +public bool AllocColor(ref Gdk.Color color, bool writeable, bool best_match) +{ + bool raw_ret = _gdk_colormap_alloc_color(Handle, ref color, writeable, best_match); + bool ret = raw_ret; + return ret; +}