diff --git a/ChangeLog b/ChangeLog index 2689b7b73..8c0700a4a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2004-09-09 Mike Kestner + + * gdk/Device.custom : manual GetHistory impl. + * gdk/Display.custom : manual GetPointer overloads. + * gdk/Gdk.metadata : hides and array params. + * gdk/Makefile.am : add new file. + * gdk/TextProperty.cs : new manual impl of methods. + 2004-09-03 Mike Kestner * configure.in : expand new doc/updater makefile diff --git a/gdk/Device.custom b/gdk/Device.custom index aff77c3e4..e397dbf66 100644 --- a/gdk/Device.custom +++ b/gdk/Device.custom @@ -104,3 +104,27 @@ public Gdk.DeviceKey GetDeviceKey (uint axis) { return gtksharp_gdk_device_get_device_key (Handle, axis); } + + [DllImport("libgdk-win32-2.0-0.dll")] + static extern void gdk_device_free_history(IntPtr events, int n_events); + + [DllImport("libgdk-win32-2.0-0.dll")] + static extern bool gdk_device_get_history(IntPtr device, IntPtr window, uint start, uint stop, out IntPtr events, out int n_events); + + public TimeCoord[] GetHistory (Gdk.Window window, uint start, uint stop) + { + IntPtr coords_handle; + int count; + + if (gdk_device_get_history (Handle, window.Handle, start, stop, out coords_handle, out count)) { + TimeCoord[] result = new TimeCoord [count]; + for (int i = 0; i < count; i++) { + IntPtr ptr = Marshal.ReadIntPtr (coords_handle, i + IntPtr.Size); + result [i] = TimeCoord.New (ptr); + } + gdk_device_free_history (coords_handle, count); + return result; + } else + return new TimeCoord [0]; + } + diff --git a/gdk/Display.custom b/gdk/Display.custom index df292f5e8..919ce5b64 100644 --- a/gdk/Display.custom +++ b/gdk/Display.custom @@ -18,6 +18,46 @@ // Free Software Foundation, Inc., 59 Temple Place - Suite 330, // Boston, MA 02111-1307, USA. + [DllImport("libgdk-win32-2.0-0.dll")] + static extern void gdk_display_get_pointer(IntPtr raw, IntPtr screen, out int x, out int y, out int mask); + + [Obsolete] + public void GetPointer(Gdk.Screen screen, out int x, out int y, out Gdk.ModifierType mask) { + int mask_as_int; + gdk_display_get_pointer(Handle, screen.Handle, out x, out y, out mask_as_int); + mask = (Gdk.ModifierType) mask_as_int; + } + + [DllImport("libgdk-win32-2.0-0.dll")] + static extern void gdk_display_get_pointer(IntPtr raw, out IntPtr screen, out int x, out int y, out int mask); + + public void GetPointer(out Gdk.Screen screen, out int x, out int y, out Gdk.ModifierType mask) { + IntPtr screen_handle; + int mask_as_int; + gdk_display_get_pointer(Handle, out screen_handle, out x, out y, out mask_as_int); + screen = (Gdk.Screen) GLib.Object.GetObject(screen_handle); + mask = (Gdk.ModifierType) mask_as_int; + } + + public void GetPointer (out int x, out int y) + { + Gdk.ModifierType mod; + Gdk.Screen screen; + GetPointer (out screen, out x, out y, out mod); + } + + public void GetPointer (out int x, out int y, out Gdk.ModifierType mod) + { + Gdk.Screen screen; + GetPointer (out screen, out x, out y, out mod); + } + + public void GetPointer (out Gdk.Screen screen, out int x, out int y) + { + Gdk.ModifierType mod; + GetPointer (out screen, out x, out y, out mod); + } + [DllImport("libgdk-win32-2.0-0.dll")] static extern IntPtr gdk_display_list_devices (IntPtr raw); diff --git a/gdk/Gdk.metadata b/gdk/Gdk.metadata index 0d0a43863..f676498fe 100644 --- a/gdk/Gdk.metadata +++ b/gdk/Gdk.metadata @@ -10,19 +10,23 @@ out 1 1 + out + out EventHelper const-gchar* 1 + 1 1 PangoHelper 1 1 1 out - InputOutput - InputOnly out 1 + 1 + InputOutput + InputOnly GdkDrawable ref 1 @@ -30,8 +34,11 @@ ref 1 1 + 1 + 1 1 1 + 1 1 1 1 @@ -58,7 +65,12 @@ libgdk-win32-2.0-0.dll libgdk-win32-2.0-0.dll libgdk-win32-2.0-0.dll + out + out libgdk-win32-2.0-0.dll + out + out + 1 1 1 1 @@ -113,7 +125,10 @@ 1 1 1 + out 1 + 1 + n_points 128 1 GetName diff --git a/gdk/Makefile.am b/gdk/Makefile.am index 9d31275cd..165734963 100644 --- a/gdk/Makefile.am +++ b/gdk/Makefile.am @@ -35,7 +35,8 @@ sources = \ EventVisibility.cs \ EventWindowState.cs \ Key.cs \ - Size.cs + Size.cs \ + TextProperty.cs build_sources = $(addprefix $(srcdir)/, $(sources)) AssemblyInfo.cs diff --git a/gdk/TextProperty.cs b/gdk/TextProperty.cs new file mode 100644 index 000000000..212c6da19 --- /dev/null +++ b/gdk/TextProperty.cs @@ -0,0 +1,72 @@ +// Gdk.Text.cs - Custom implementation for Text class +// +// Authors: Mike Kestner +// +// Copyright (c) 2004 Novell, Inc. +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of version 2 of the Lesser GNU General +// Public License as published by the Free Software Foundation. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this program; if not, write to the +// Free Software Foundation, Inc., 59 Temple Place - Suite 330, +// Boston, MA 02111-1307, USA. + + +namespace Gdk { + + using System; + using System.Runtime.InteropServices; + + public class TextProperty { + + [DllImport("libgdk-win32-2.0-0.dll")] + static extern void gdk_free_text_list(IntPtr ptr); + + [DllImport("libgdk-win32-2.0-0.dll")] + static extern int gdk_text_property_to_utf8_list(IntPtr encoding, int format, byte[] text, int length, out IntPtr list); + + public static string[] ToStringList (Gdk.Atom encoding, int format, byte[] text, int length) + { + IntPtr list_ptr; + int count = gdk_text_property_to_utf8_list(encoding.Handle, format, text, length, out list_ptr); + + if (count == 0) + return new string [0]; + + string[] result = new string [count]; + for (int i = 0; i < count; i++) { + IntPtr ptr = Marshal.ReadIntPtr (list_ptr, i * IntPtr.Size); + result [i] = Marshal.PtrToStringAnsi (ptr); + } + gdk_free_text_list (list_ptr); + return result; + } + + [DllImport("libgdk-win32-2.0-0.dll")] + static extern int gdk_text_property_to_utf8_list_for_display(IntPtr display, IntPtr encoding, int format, byte[] text, int length, out IntPtr list); + + public static string[] ToStringListForDisplay (Gdk.Display display, Gdk.Atom encoding, int format, byte[] text, int length) + { + IntPtr list_ptr; + int count = gdk_text_property_to_utf8_list_for_display (display.Handle, encoding.Handle, format, text, length, out list_ptr); + + if (count == 0) + return new string [0]; + + string[] result = new string [count]; + for (int i = 0; i < count; i++) { + IntPtr ptr = Marshal.ReadIntPtr (list_ptr, i * IntPtr.Size); + result [i] = Marshal.PtrToStringAnsi (ptr); + } + gdk_free_text_list (list_ptr); + return result; + } + } +}