2005-04-26 Miguel de Icaza <miguel@novell.com>
* gtkdotnet/Graphics.cs: Contribution from Sebastian Faltoni <sebastian.faltoni@gmail.com> that implements support for using System.Drawing on Windows. svn path=/trunk/gtk-sharp/; revision=43619
This commit is contained in:
parent
f88799c77e
commit
01b62e8572
2 changed files with 60 additions and 19 deletions
|
@ -1,3 +1,9 @@
|
||||||
|
2005-04-26 Miguel de Icaza <miguel@novell.com>
|
||||||
|
|
||||||
|
* gtkdotnet/Graphics.cs: Contribution from Sebastian Faltoni
|
||||||
|
<sebastian.faltoni@gmail.com> that implements support for using
|
||||||
|
System.Drawing on Windows.
|
||||||
|
|
||||||
2005-04-26 Mike Kestner <mkestner@novell.com>
|
2005-04-26 Mike Kestner <mkestner@novell.com>
|
||||||
|
|
||||||
* gtk/NodeStore.cs : implement IEnumerable.
|
* gtk/NodeStore.cs : implement IEnumerable.
|
||||||
|
|
|
@ -33,6 +33,15 @@ namespace Gtk.DotNet {
|
||||||
|
|
||||||
private Graphics () {}
|
private Graphics () {}
|
||||||
|
|
||||||
|
[DllImport("libgdk-win32-2.0-0.dll")]
|
||||||
|
internal static extern IntPtr gdk_win32_drawable_get_handle(IntPtr raw);
|
||||||
|
|
||||||
|
[DllImport("libgdk-win32-2.0-0.dll")]
|
||||||
|
internal static extern IntPtr gdk_win32_hdc_get(IntPtr drawable, IntPtr gc, int usage);
|
||||||
|
|
||||||
|
[DllImport("libgdk-win32-2.0-0.dll")]
|
||||||
|
internal static extern void gdk_win32_hdc_release(IntPtr drawable,IntPtr gc,int usage);
|
||||||
|
|
||||||
[DllImport("libgdk-win32-2.0-0.dll")]
|
[DllImport("libgdk-win32-2.0-0.dll")]
|
||||||
internal static extern IntPtr gdk_x11_drawable_get_xdisplay (IntPtr raw);
|
internal static extern IntPtr gdk_x11_drawable_get_xdisplay (IntPtr raw);
|
||||||
|
|
||||||
|
@ -40,12 +49,37 @@ namespace Gtk.DotNet {
|
||||||
internal static extern IntPtr gdk_x11_drawable_get_xid (IntPtr raw);
|
internal static extern IntPtr gdk_x11_drawable_get_xid (IntPtr raw);
|
||||||
|
|
||||||
public static System.Drawing.Graphics FromDrawable (Gdk.Drawable drawable)
|
public static System.Drawing.Graphics FromDrawable (Gdk.Drawable drawable)
|
||||||
|
{
|
||||||
|
return FromDrawable (drawable, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static System.Drawing.Graphics FromDrawable(Gdk.Drawable drawable, bool double_buffered)
|
||||||
{
|
{
|
||||||
IntPtr x_drawable;
|
IntPtr x_drawable;
|
||||||
int x_off = 0, y_off = 0;
|
int x_off = 0, y_off = 0;
|
||||||
|
|
||||||
|
PlatformID osversion = Environment.OSVersion.Platform;
|
||||||
|
|
||||||
if (drawable is Gdk.Window)
|
if (osversion == PlatformID.Win32Windows || osversion == PlatformID.Win32NT ||
|
||||||
|
osversion == PlatformID.Win32S || osversion == PlatformID.WinCE){
|
||||||
|
if (drawable is Gdk.Window && double_buffered)
|
||||||
|
((Gdk.Window)drawable).GetInternalPaintInfo(out drawable, out x_off, out y_off);
|
||||||
|
|
||||||
|
Gdk.GC gcc = new Gdk.GC(drawable);
|
||||||
|
|
||||||
|
IntPtr windc = gdk_win32_hdc_get(drawable.Handle, gcc.Handle, 0);
|
||||||
|
|
||||||
|
System.Drawing.Graphics g = System.Drawing.Graphics.FromHdc(windc);
|
||||||
|
|
||||||
|
if (double_buffered) {
|
||||||
|
gdk_win32_hdc_release(drawable.Handle, gcc.Handle, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
g.TranslateTransform(-x_off, -y_off);
|
||||||
|
|
||||||
|
return g;
|
||||||
|
} else {
|
||||||
|
if (drawable is Gdk.Window && double_buffered)
|
||||||
((Gdk.Window) drawable).GetInternalPaintInfo(out drawable, out x_off, out y_off);
|
((Gdk.Window) drawable).GetInternalPaintInfo(out drawable, out x_off, out y_off);
|
||||||
|
|
||||||
x_drawable = drawable.Handle;
|
x_drawable = drawable.Handle;
|
||||||
|
@ -65,5 +99,6 @@ namespace Gtk.DotNet {
|
||||||
return g;
|
return g;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue