2004-08-26 Manuel V. Santos <mvsl@telefonica.net>

* gdk/Device.custom : glue to expose object fields.
	* gdk/DeviceAxis.custom : expand the ToString to incl use:
	* gdk/EventButton.custom : fix for Axes prop.
	* gdk/EventMotion.custom : fix for Axes prop.
	* gdk/Gdk.metadata : hide some accessors on Device.
	* gdk/Makefile.am : add new custom.
	* gdk/glue/Makefile.am : add new .c
	* gdk/glue/makefile.win32 : add new .o
	* gdk/glue/device.c : ditto.
	* gtk/InputDialog.custom : glue to expose button fields.
	* gtk/Makefile.am : add new custom.
	* gtk/glue/Makefile.am : add new .c
	* gtk/glue/makefile.win32 : add new .o
	* gtk/glue/inputdialog.c : ditto.
	* sample/ScribbleXInput.cs : new sample using extension events.

svn path=/trunk/gtk-sharp/; revision=32899
This commit is contained in:
Mike Kestner 2004-08-26 19:10:48 +00:00
parent efb53c5ec7
commit e5dde2ff7e
19 changed files with 657 additions and 61 deletions

View file

@ -1,3 +1,21 @@
2004-08-26 Manuel V. Santos <mvsl@telefonica.net>
* gdk/Device.custom : glue to expose object fields.
* gdk/DeviceAxis.custom : expand the ToString to incl use:
* gdk/EventButton.custom : fix for Axes prop.
* gdk/EventMotion.custom : fix for Axes prop.
* gdk/Gdk.metadata : hide some accessors on Device.
* gdk/Makefile.am : add new custom.
* gdk/glue/Makefile.am : add new .c
* gdk/glue/makefile.win32 : add new .o
* gdk/glue/device.c : ditto.
* gtk/InputDialog.custom : glue to expose button fields.
* gtk/Makefile.am : add new custom.
* gtk/glue/Makefile.am : add new .c
* gtk/glue/makefile.win32 : add new .o
* gtk/glue/inputdialog.c : ditto.
* sample/ScribbleXInput.cs : new sample using extension events.
2004-08-25 Mike Kestner <mkestner@ximian.com>
* generator/Signal.cs : use typeof instead of Type.GetType to

View file

@ -99,21 +99,6 @@
<remarks>None.</remarks>
</Docs>
</Member>
<Member MemberName="Source">
<MemberSignature Language="C#" Value="public Gdk.InputSource Source { set; };" />
<MemberType>Property</MemberType>
<ReturnValue>
<ReturnType>Gdk.InputSource</ReturnType>
</ReturnValue>
<Parameters>
</Parameters>
<Docs>
<summary>Sets the source type for an input device.</summary>
<param name="value">Sets the source type for an input device.</param>
<returns>None.</returns>
<remarks>None.</remarks>
</Docs>
</Member>
<Member MemberName="SetKey">
<MemberSignature Language="C#" Value="public void SetKey (uint index_, uint keyval, Gdk.ModifierType modifiers);" />
<MemberType>Method</MemberType>
@ -150,45 +135,6 @@
<remarks>To be added</remarks>
</Docs>
</Member>
<Member MemberName="GetState">
<MemberSignature Language="C#" Value="public void GetState (Gdk.Window window, out double axes, out Gdk.ModifierType mask);" />
<MemberType>Method</MemberType>
<ReturnValue>
<ReturnType>System.Void</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="window" Type="Gdk.Window" />
<Parameter Name="axes" Type="System.Double&amp;" RefType="out" />
<Parameter Name="mask" Type="Gdk.ModifierType&amp;" RefType="out" />
</Parameters>
<Docs>
<summary>To be added</summary>
<param name="window">a <see cref="T:Gdk.Window" /></param>
<param name="axes">a <see cref="T:System.Double&amp;" /></param>
<param name="mask">a <see cref="T:Gdk.ModifierType&amp;" /></param>
<remarks>To be added</remarks>
</Docs>
</Member>
<Member MemberName="GetAxis">
<MemberSignature Language="C#" Value="public bool GetAxis (out double axes, Gdk.AxisUse use, out double value);" />
<MemberType>Method</MemberType>
<ReturnValue>
<ReturnType>System.Boolean</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="axes" Type="System.Double&amp;" RefType="out" />
<Parameter Name="use" Type="Gdk.AxisUse" />
<Parameter Name="value" Type="System.Double&amp;" RefType="out" />
</Parameters>
<Docs>
<summary>Interprets an array of double as axis values for a given device, and locates the value in the array for a given axis use.</summary>
<param name="axes">An array of axes.</param>
<param name="use">The <see cref="T:Gdk.AxisUse" /> to look for.</param>
<param name="value">Found value.</param>
<returns>True if the given axis use was found, otherwise false.</returns>
<remarks>To be added</remarks>
</Docs>
</Member>
<Member MemberName="GetHistory">
<MemberSignature Language="C#" Value="public bool GetHistory (Gdk.Window window, uint start, uint stop, Gdk.TimeCoord events, out int n_events);" />
<MemberType>Method</MemberType>
@ -251,5 +197,154 @@
<remarks>None.</remarks>
</Docs>
</Member>
<Member MemberName="Name">
<MemberSignature Language="C#" Value="public string Name { get; };" />
<MemberType>Property</MemberType>
<ReturnValue>
<ReturnType>System.String</ReturnType>
</ReturnValue>
<Parameters />
<Docs>
<summary>To be added</summary>
<returns>a <see cref="T:System.String" /></returns>
<remarks>To be added</remarks>
</Docs>
</Member>
<Member MemberName="Source">
<MemberSignature Language="C#" Value="public Gdk.InputSource Source { set; get; };" />
<MemberType>Property</MemberType>
<ReturnValue>
<ReturnType>Gdk.InputSource</ReturnType>
</ReturnValue>
<Parameters />
<Docs>
<summary>To be added</summary>
<returns>a <see cref="T:Gdk.InputSource" /></returns>
<remarks>To be added</remarks>
</Docs>
</Member>
<Member MemberName="Mode">
<MemberSignature Language="C#" Value="public Gdk.InputMode Mode { get; };" />
<MemberType>Property</MemberType>
<ReturnValue>
<ReturnType>Gdk.InputMode</ReturnType>
</ReturnValue>
<Parameters />
<Docs>
<summary>To be added</summary>
<returns>a <see cref="T:Gdk.InputMode" /></returns>
<remarks>To be added</remarks>
</Docs>
</Member>
<Member MemberName="HasCursor">
<MemberSignature Language="C#" Value="public bool HasCursor { get; };" />
<MemberType>Property</MemberType>
<ReturnValue>
<ReturnType>System.Boolean</ReturnType>
</ReturnValue>
<Parameters />
<Docs>
<summary>To be added</summary>
<returns>a <see cref="T:System.Boolean" /></returns>
<remarks>To be added</remarks>
</Docs>
</Member>
<Member MemberName="NumAxes">
<MemberSignature Language="C#" Value="public int NumAxes { get; };" />
<MemberType>Property</MemberType>
<ReturnValue>
<ReturnType>System.Int32</ReturnType>
</ReturnValue>
<Parameters />
<Docs>
<summary>To be added</summary>
<returns>a <see cref="T:System.Int32" /></returns>
<remarks>To be added</remarks>
</Docs>
</Member>
<Member MemberName="NumKeys">
<MemberSignature Language="C#" Value="public int NumKeys { get; };" />
<MemberType>Property</MemberType>
<ReturnValue>
<ReturnType>System.Int32</ReturnType>
</ReturnValue>
<Parameters />
<Docs>
<summary>To be added</summary>
<returns>a <see cref="T:System.Int32" /></returns>
<remarks>To be added</remarks>
</Docs>
</Member>
<Member MemberName="GetAxis">
<MemberSignature Language="C#" Value="public bool GetAxis (double [] axes, Gdk.AxisUse use, out double value);" />
<MemberType>Method</MemberType>
<ReturnValue>
<ReturnType>System.Boolean</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="axes" Type="System.Double[]" />
<Parameter Name="use" Type="Gdk.AxisUse" />
<Parameter Name="value" Type="System.Double&amp;" RefType="out" />
</Parameters>
<Docs>
<summary>To be added</summary>
<param name="axes">a <see cref="T:System.Double" /></param>
<param name="use">a <see cref="T:System.Int32" /></param>
<param name="value">a <see cref="T:System.Double" /></param>
<returns>a <see cref="T:System.Boolean" /></returns>
<remarks>To be added</remarks>
</Docs>
</Member>
<Member MemberName="GetState">
<MemberSignature Language="C#" Value="public void GetState (Gdk.Window window, out double [] axes, out Gdk.ModifierType mask);" />
<MemberType>Method</MemberType>
<ReturnValue>
<ReturnType>System.Void</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="window" Type="Gdk.Window" />
<Parameter Name="axes" Type="System.Double[]&amp;" RefType="out" />
<Parameter Name="mask" Type="Gdk.ModifierType&amp;" RefType="out" />
</Parameters>
<Docs>
<summary>To be added</summary>
<param name="window">a <see cref="T:Gdk.Window" /></param>
<param name="axes">a <see cref="T:System.Double[]" /></param>
<param name="mask">a <see cref="T:Gdk.ModifierType" /></param>
<remarks>To be added</remarks>
</Docs>
</Member>
<Member MemberName="GetDeviceAxis">
<MemberSignature Language="C#" Value="public Gdk.DeviceAxis GetDeviceAxis (uint axis);" />
<MemberType>Method</MemberType>
<ReturnValue>
<ReturnType>Gdk.DeviceAxis</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="axis" Type="System.UInt32" />
</Parameters>
<Docs>
<summary>To be added</summary>
<param name="axis">a <see cref="T:System.UInt32" /></param>
<returns>a <see cref="T:Gdk.DeviceAxis" /></returns>
<remarks>To be added</remarks>
</Docs>
</Member>
<Member MemberName="GetDeviceKey">
<MemberSignature Language="C#" Value="public Gdk.DeviceKey GetDeviceKey (uint axis);" />
<MemberType>Method</MemberType>
<ReturnValue>
<ReturnType>Gdk.DeviceKey</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="axis" Type="System.UInt32" />
</Parameters>
<Docs>
<summary>To be added</summary>
<param name="axis">a <see cref="T:System.UInt32" /></param>
<returns>a <see cref="T:Gdk.DeviceKey" /></returns>
<remarks>To be added</remarks>
</Docs>
</Member>
</Members>
</Type>

View file

@ -171,5 +171,31 @@
<remarks>Chain to this constructor if you have manually registered a native <see cref="T:GLib.GType" /> value for your subclass.</remarks>
</Docs>
</Member>
<Member MemberName="SaveButton">
<MemberSignature Language="C#" Value="public Gtk.Button SaveButton { get; };" />
<MemberType>Property</MemberType>
<ReturnValue>
<ReturnType>Gtk.Button</ReturnType>
</ReturnValue>
<Parameters />
<Docs>
<summary>To be added</summary>
<returns>a <see cref="T:Gtk.Button" /></returns>
<remarks>To be added</remarks>
</Docs>
</Member>
<Member MemberName="CloseButton">
<MemberSignature Language="C#" Value="public Gtk.Button CloseButton { get; };" />
<MemberType>Property</MemberType>
<ReturnValue>
<ReturnType>Gtk.Button</ReturnType>
</ReturnValue>
<Parameters />
<Docs>
<summary>To be added</summary>
<returns>a <see cref="T:Gtk.Button" /></returns>
<remarks>To be added</remarks>
</Docs>
</Member>
</Members>
</Type>

106
gdk/Device.custom Normal file
View file

@ -0,0 +1,106 @@
// Display.custom - customizations to Gdk.Display
//
// Authors: Manuel V. Santos <mvsl@telefonica.net>
//
// Copyright (c) 2004 Manuel V. Santos
//
// 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.
[DllImport("gdksharpglue")]
static extern IntPtr gtksharp_gdk_device_get_name (IntPtr device);
[DllImport("gdksharpglue")]
static extern InputSource gtksharp_gdk_device_get_source (IntPtr device);
[DllImport("gdksharpglue")]
static extern InputMode gtksharp_gdk_device_get_mode (IntPtr device);
[DllImport("gdksharpglue")]
static extern bool gtksharp_gdk_device_has_cursor (IntPtr device);
[DllImport("gdksharpglue")]
static extern int gtksharp_gdk_device_get_num_axes (IntPtr device);
[DllImport("gdksharpglue")]
static extern int gtksharp_gdk_device_get_num_keys (IntPtr device);
[DllImport("gdksharpglue")]
static extern DeviceAxis gtksharp_gdk_device_get_device_axis (IntPtr device, uint axis);
[DllImport("gdksharpglue")]
static extern DeviceKey gtksharp_gdk_device_get_device_key (IntPtr device, uint axis);
[DllImport("libgdk-win32-2.0-0.dll")]
static extern void gdk_device_set_source(IntPtr device, int source);
[DllImport("libgdk-win32-2.0-0.dll")]
static extern void gdk_device_get_state(IntPtr device, IntPtr window, double [] axes, out int maskAsInt);
public string Name {
get {
IntPtr rawName = gtksharp_gdk_device_get_name (Handle);
return Marshal.PtrToStringAnsi(rawName);
}
}
public Gdk.InputSource Source {
get {
return gtksharp_gdk_device_get_source (Handle);
}
set {
gdk_device_set_source(Handle, (int) value);
}
}
public Gdk.InputMode Mode {
get {
return gtksharp_gdk_device_get_mode (Handle);
}
}
public bool HasCursor {
get {
return gtksharp_gdk_device_has_cursor (Handle);
}
}
public int NumAxes {
get {
return gtksharp_gdk_device_get_num_axes (Handle);
}
}
public int NumKeys {
get {
return gtksharp_gdk_device_get_num_keys (Handle);
}
}
public void GetState(Gdk.Window window, out double [] axes, out Gdk.ModifierType mask) {
int maskAsInt;
axes = new double [this.NumAxes];
gdk_device_get_state(Handle, window.Handle, axes, out maskAsInt);
mask = (Gdk.ModifierType) maskAsInt;
}
public Gdk.DeviceAxis GetDeviceAxis (uint axis) {
return gtksharp_gdk_device_get_device_axis (Handle, axis);
}
public Gdk.DeviceKey GetDeviceKey (uint axis) {
return gtksharp_gdk_device_get_device_key (Handle, axis);
}

View file

@ -32,7 +32,7 @@
public override string ToString ()
{
return "Gdk.DeviceAxis, max:" + this.Max + ",min:" + this.Min;
return "Gdk.DeviceAxis, max:" + this.Max + ",min:" + this.Min + ",use:" + this.Use;
}

View file

@ -104,9 +104,12 @@ namespace Gdk {
public double[] Axes {
get {
double[] result = new double [2];
double[] result = null;
IntPtr axes = gtksharp_gdk_event_button_get_axes (Handle);
Marshal.Copy (result, 0, axes, 2);
if (axes != IntPtr.Zero) {
result = new double[Device.NumAxes];
Marshal.Copy (axes, result, 0, result.Length);
}
return result;
}
}

View file

@ -105,9 +105,12 @@ namespace Gdk {
public double[] Axes {
get {
double[] result = new double [2];
double[] result = null;
IntPtr axes = gtksharp_gdk_event_motion_get_axes (Handle);
Marshal.Copy (result, 0, axes, 2);
if (axes != IntPtr.Zero) {
result = new double [Device.NumAxes];
Marshal.Copy (axes, result, 0, result.Length);
}
return result;
}
}

View file

@ -28,6 +28,9 @@
<attr path="/api/namespace/object[@cname='GdkColormap']/method[@name='AllocColors']/*/*[@name='success']" name="array">1</attr>
<attr path="/api/namespace/object[@cname='GdkColormap']/method[@name='QueryColor']/*/*[@type='GdkColor*']" name="pass_as">ref</attr>
<attr path="/api/namespace/object[@cname='GdkColormap']/method[@name='FreeColors']/*/*[@type='GdkColor*']" name="array">1</attr>
<attr path="/api/namespace/object[@cname='GdkDevice']/method[@name='GetAxis']/*/*[@name='axes']" name="array">1</attr>
<attr path="/api/namespace/object[@cname='GdkDevice']/method[@name='GetState']" name="hidden">1</attr>
<attr path="/api/namespace/object[@cname='GdkDevice']/method[@name='SetSource']" name="hidden">1</attr>
<attr path="/api/namespace/object[@cname='GdkDisplay']/method[@name='ListDevices']" name="hidden">1</attr>
<attr path="/api/namespace/object[@cname='GdkDisplayManager']/method[@name='ListDisplays']" name="hidden">1</attr>
<attr path="/api/namespace/object[@cname='GdkDrawable']/method[@name='DrawGrayImage']/*/*[@name='buf']" name="array">1</attr>

View file

@ -42,6 +42,7 @@ build_sources = $(addprefix $(srcdir)/, $(sources)) AssemblyInfo.cs
customs = \
Atom.custom \
Color.custom \
Device.custom \
DeviceAxis.custom \
Display.custom \
DisplayManager.custom \

View file

@ -2,6 +2,7 @@ lib_LTLIBRARIES = libgdksharpglue.la
libgdksharpglue_la_SOURCES = \
dragcontext.c \
device.c \
event.c \
selection.c \
vmglueheaders.h \

84
gdk/glue/device.c Normal file
View file

@ -0,0 +1,84 @@
/* device.c : Glue to access fields in GdkDevice.
*
* Author: Manuel V. Santos <mvsl@telefonica.net>
*
* Copyright (c) Manuel V. Santos
*
* 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.
*/
#include <gdk/gdk.h>
/* Forward declarations */
gchar* gtksharp_gdk_device_get_name (GdkDevice *device);
GdkInputSource gtksharp_gdk_device_get_source (GdkDevice *device);
GdkInputMode gtksharp_gdk_device_get_mode (GdkDevice *device);
gboolean gtksharp_gdk_device_has_cursor (GdkDevice *device);
gint gtksharp_gdk_device_get_num_axes (GdkDevice *device);
gint gtksharp_gdk_device_get_num_keys (GdkDevice *device);
GdkDeviceAxis* gtksharp_gdk_device_get_axes (GdkDevice *device);
GdkDeviceKey* gtksharp_gdk_device_get_keys (GdkDevice *device);
/* */
gchar*
gtksharp_gdk_device_get_name (GdkDevice *device)
{
return device->name;
}
GdkInputSource
gtksharp_gdk_device_get_source (GdkDevice *device)
{
return device->source;
}
GdkInputMode
gtksharp_gdk_device_get_mode (GdkDevice *device)
{
return device->mode;
}
gboolean
gtksharp_gdk_device_has_cursor (GdkDevice *device)
{
return device->has_cursor;
}
gint
gtksharp_gdk_device_get_num_axes (GdkDevice *device)
{
return device->num_axes;
}
gint
gtksharp_gdk_device_get_num_keys (GdkDevice *device)
{
return device->num_keys;
}
GdkDeviceAxis
gtksharp_gdk_device_get_device_axis (GdkDevice *device, guint i)
{
return device->axes[i];
}
GdkDeviceKey
gtksharp_gdk_device_get_device_key (GdkDevice *device, guint i)
{
return device->keys[i];
}

View file

@ -5,6 +5,7 @@ DLLWRAP=dllwrap -mno-cygwin -mms-bitfields --target i386-mingw32 --export-all-sy
GLUE_OBJS = \
dragcontext.o \
device.o \
event.o \
selection.o \
win32dll.o

42
gtk/InputDialog.custom Normal file
View file

@ -0,0 +1,42 @@
// Gtk.InputDialog.custom - Gtk InputDialog class customizations
//
// Author: Manuel V. Santos <mvsl@telefonica.net>
//
// Copyright (C) 2004 Manuel V. Santos.
//
// This code is inserted after the automatically generated code.
//
//
// 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.
[DllImport("gtksharpglue")]
static extern IntPtr gtksharp_input_dialog_get_save_button (IntPtr i);
public Gtk.Button SaveButton {
get {
IntPtr rawButton = gtksharp_input_dialog_get_save_button (Handle);
return new Button (rawButton);
}
}
[DllImport("gtksharpglue")]
static extern IntPtr gtksharp_input_dialog_get_close_button (IntPtr i);
public Gtk.Button CloseButton {
get {
IntPtr rawButton = gtksharp_input_dialog_get_close_button (Handle);
return new Button (rawButton);
}
}

View file

@ -49,6 +49,7 @@ customs = \
IconFactory.custom \
IconSet.custom \
ImageMenuItem.custom \
InputDialog.custom \
ItemFactory.custom \
Label.custom \
Layout.custom \

View file

@ -10,6 +10,7 @@ libgtksharpglue_la_SOURCES = \
container.c \
dialog.c \
fileselection.c \
inputdialog.c \
layout.c \
nodestore.c \
object.c \

40
gtk/glue/inputdialog.c Normal file
View file

@ -0,0 +1,40 @@
/* inputdialog.c : Glue for accessing fields in the GtkInputDialog widget.
*
* Author: Manuel V. Santos <mvsl@telefonica.net>
*
* Copyright (c) 2004 Manuel V. Santos
*
* 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.
*/
#include <gtk/gtkinputdialog.h>
/* Forward declarations */
GtkWidget *gtksharp_input_dialog_get_save_button (GtkInputDialog *dialog);
GtkWidget *gtksharp_input_dialog_get_close_button (GtkInputDialog *dialog);
/* */
GtkWidget*
gtksharp_input_dialog_get_save_button (GtkInputDialog *dialog)
{
return dialog->save_button;
}
GtkWidget*
gtksharp_input_dialog_get_close_button (GtkInputDialog *dialog)
{
return dialog->close_button;
}

View file

@ -12,6 +12,7 @@ GLUE_OBJS = \
container.o \
dialog.o \
fileselection.o \
inputdialog.o \
layout.o \
nodestore.o \
object.o \

View file

@ -24,7 +24,7 @@ VTE_TARGETS=
VTE_ASSEMBLY=
endif
TARGETS = custom-cellrenderer.exe gtk-hello-world.exe button.exe calendar.exe subclass.exe menu.exe size.exe scribble.exe treeviewdemo.exe managedtreeviewdemo.exe testdnd.exe custom-widget.exe $(GNOME_TARGETS) $(GLADE_TARGETS) $(VTE_TARGETS)
TARGETS = custom-cellrenderer.exe gtk-hello-world.exe button.exe calendar.exe subclass.exe menu.exe size.exe scribble.exe scribble-xinput.exe treeviewdemo.exe managedtreeviewdemo.exe testdnd.exe custom-widget.exe $(GNOME_TARGETS) $(GLADE_TARGETS) $(VTE_TARGETS)
assemblies=../glib/glib-sharp.dll ../pango/pango-sharp.dll ../atk/atk-sharp.dll ../gdk/gdk-sharp.dll ../gtk/gtk-sharp.dll $(GNOME_ASSEMBLY) $(GLADE_ASSEMBLY) $(VTE_ASSEMBLY)
references=$(addprefix /r:, $(assemblies))
@ -65,6 +65,9 @@ size.exe: $(srcdir)/Size.cs $(assemblies)
scribble.exe: $(srcdir)/Scribble.cs $(assemblies)
$(CSC) /out:scribble.exe $(references) $(srcdir)/Scribble.cs
scribble-xinput.exe: $(srcdir)/ScribbleXInput.cs $(assemblies)
$(CSC) /out:scribble-xinput.exe $(references) $(srcdir)/ScribbleXInput.cs
treeviewdemo.exe: $(srcdir)/TreeViewDemo.cs $(assemblies)
$(CSC) /out:treeviewdemo.exe $(references) $(srcdir)/TreeViewDemo.cs
@ -107,6 +110,7 @@ EXTRA_DIST = \
Menu.cs \
Size.cs \
Scribble.cs \
ScribbleXInput.cs \
TreeViewDemo.cs \
ManagedTreeViewDemo.cs \
GladeViewer.cs \

166
sample/ScribbleXInput.cs Normal file
View file

@ -0,0 +1,166 @@
// ScribbleXInput.cs - port of Gtk+ scribble demo
//
// Author: Manuel V. Santos <mvsl@telefonica.net>
//
// (c) 2002 Rachel Hestilow
// (c) 2004 Manuel V. Santos
namespace GtkSamples {
using Gtk;
using Gdk;
using System;
public class ScribbleXInput {
private static Gtk.Window win;
private static Gtk.VBox vBox;
private static Gtk.Button inputButton;
private static Gtk.Button quitButton;
private static Gtk.DrawingArea darea;
private static Gdk.Pixmap pixmap = null;
private static Gtk.InputDialog inputDialog = null;
public static int Main (string[] args) {
Application.Init ();
win = new Gtk.Window ("Scribble XInput Demo");
win.DeleteEvent += new DeleteEventHandler (WindowDelete);
vBox = new VBox (false, 0);
win.Add (vBox);
darea = new Gtk.DrawingArea ();
darea.SetSizeRequest (200, 200);
darea.ExtensionEvents=ExtensionMode.Cursor;
vBox.PackStart (darea, true, true, 0);
darea.ExposeEvent += new ExposeEventHandler (ExposeEvent);
darea.ConfigureEvent += new ConfigureEventHandler (ConfigureEvent);
darea.MotionNotifyEvent += new MotionNotifyEventHandler (MotionNotifyEvent);
darea.ButtonPressEvent += new ButtonPressEventHandler (ButtonPressEvent);
darea.Events = EventMask.ExposureMask | EventMask.LeaveNotifyMask |
EventMask.ButtonPressMask | EventMask.PointerMotionMask;
inputButton = new Button("Input Dialog");
vBox.PackStart (inputButton, false, false, 0);
inputButton.Clicked += new EventHandler (InputButtonClicked);
quitButton = new Button("Quit");
vBox.PackStart (quitButton, false, false, 0);
quitButton.Clicked += new EventHandler (QuitButtonClicked);
win.ShowAll ();
Application.Run ();
return 0;
}
static void InputButtonClicked (object obj, EventArgs args) {
if (inputDialog == null) {
inputDialog = new InputDialog ();
inputDialog.SaveButton.Hide ();
inputDialog.CloseButton.Clicked += new EventHandler(InputDialogClose);
inputDialog.DeleteEvent += new DeleteEventHandler(InputDialogDelete);
}
inputDialog.Present ();
}
static void QuitButtonClicked (object obj, EventArgs args) {
Application.Quit ();
}
static void WindowDelete (object obj, DeleteEventArgs args) {
Application.Quit ();
args.RetVal = true;
}
static void InputDialogClose (object obj, EventArgs args) {
inputDialog.Hide ();
}
static void InputDialogDelete (object obj, DeleteEventArgs args) {
inputDialog.Hide ();
args.RetVal = true;
}
static void ExposeEvent (object obj, ExposeEventArgs args) {
Gdk.Rectangle area = args.Event.Area;
args.Event.Window.DrawDrawable (darea.Style.ForegroundGC(darea.State),
pixmap,
area.X, area.Y,
area.X, area.Y,
area.Width, area.Height);
args.RetVal = false;
}
static void ConfigureEvent (object obj, ConfigureEventArgs args) {
Gdk.EventConfigure ev = args.Event;
Gdk.Window window = ev.Window;
Gdk.Rectangle allocation = darea.Allocation;
pixmap = new Gdk.Pixmap (window, allocation.Width, allocation.Height, -1);
pixmap.DrawRectangle (darea.Style.WhiteGC, true, 0, 0,
allocation.Width, allocation.Height);
args.RetVal = true;
}
static void DrawBrush (Widget widget, InputSource source,
double x, double y, double pressure) {
Gdk.GC gc;
switch (source) {
case InputSource.Mouse:
gc = widget.Style.BlackGC;
break;
case InputSource.Pen:
gc = widget.Style.BlackGC;
break;
case InputSource.Eraser:
gc = widget.Style.WhiteGC;
break;
default:
gc = widget.Style.BlackGC;
break;
}
Gdk.Rectangle update_rect = new Gdk.Rectangle ();
update_rect.X = (int) (x - 10.0d * pressure);
update_rect.Y = (int) (y - 10.0d * pressure);
update_rect.Width = (int) (20.0d * pressure);
update_rect.Height = (int) (20.0d * pressure);
pixmap.DrawRectangle (gc, true,
update_rect.X, update_rect.Y,
update_rect.Width, update_rect.Height);
darea.QueueDrawArea (update_rect.X, update_rect.Y,
update_rect.Width, update_rect.Height);
}
static void ButtonPressEvent (object obj, ButtonPressEventArgs args) {
Gdk.EventButton ev = args.Event;
if (ev.Button == 1 && pixmap != null) {
double pressure;
ev.Device.GetAxis (ev.Axes, AxisUse.Pressure, out pressure);
DrawBrush ((Widget) obj, ev.Device.Source, ev.X, ev.Y, pressure);
}
args.RetVal = true;
}
static void MotionNotifyEvent (object obj, MotionNotifyEventArgs args) {
Gdk.EventMotion ev = args.Event;
Widget widget = (Widget) obj;
if ((ev.State & Gdk.ModifierType.Button1Mask) != 0 && pixmap != null) {
double x,y,pressure;
if (!ev.Device.GetAxis (ev.Axes, AxisUse.Pressure, out pressure)) {
pressure = 0.5;
}
DrawBrush (widget, ev.Device.Source, ev.X, ev.Y, pressure);
}
args.RetVal = true;
}
}
}