mirror of
https://github.com/Ryujinx/GtkSharp.git
synced 2024-12-23 16:15:35 +00:00
2002-08-05 Rachel Hestilow <hestilow@ximian.com>
* gnome/Canvas*.custom, IconTextItem.custom: Added. * sample/CanvasExample.cs: Added. * sample/Makefile.in: Build canvas example in gnome build. svn path=/trunk/gtk-sharp/; revision=6451
This commit is contained in:
parent
034534a606
commit
ab115875e4
|
@ -1,3 +1,10 @@
|
|||
2002-08-05 Rachel Hestilow <hestilow@ximian.com>
|
||||
|
||||
* gnome/Canvas*.custom, IconTextItem.custom: Added.
|
||||
|
||||
* sample/CanvasExample.cs: Added.
|
||||
* sample/Makefile.in: Build canvas example in gnome build.
|
||||
|
||||
2002-08-05 Rachel Hestilow <hestilow@ximian.com>
|
||||
|
||||
* parser/Gnome.metadata: Patch from duncan for
|
||||
|
|
14
gnome/CanvasBpath.custom
Normal file
14
gnome/CanvasBpath.custom
Normal file
|
@ -0,0 +1,14 @@
|
|||
//
|
||||
// Gnome.CanvasBpath.custom - Gnome CanvasBpath class customizations
|
||||
//
|
||||
// Author: Rachel Hestilow <hestilow@ximian.com>
|
||||
//
|
||||
// Copyright (C) 2002 Rachel Hestilow
|
||||
//
|
||||
// This code is inserted after the automatically generated code.
|
||||
//
|
||||
|
||||
public CanvasBpath (Gnome.CanvasGroup group) : base (group, Type)
|
||||
{
|
||||
}
|
||||
|
14
gnome/CanvasClipgroup.custom
Normal file
14
gnome/CanvasClipgroup.custom
Normal file
|
@ -0,0 +1,14 @@
|
|||
//
|
||||
// Gnome.CanvasClipgroup.custom - Gnome CanvasClipgroup class customizations
|
||||
//
|
||||
// Author: Rachel Hestilow <hestilow@ximian.com>
|
||||
//
|
||||
// Copyright (C) 2002 Rachel Hestilow
|
||||
//
|
||||
// This code is inserted after the automatically generated code.
|
||||
//
|
||||
|
||||
public CanvasClipgroup (Gnome.CanvasGroup group) : base (group, Type)
|
||||
{
|
||||
}
|
||||
|
14
gnome/CanvasEllipse.custom
Normal file
14
gnome/CanvasEllipse.custom
Normal file
|
@ -0,0 +1,14 @@
|
|||
//
|
||||
// Gnome.CanvasEllipse.custom - Gnome CanvasEllipse class customizations
|
||||
//
|
||||
// Author: Rachel Hestilow <hestilow@ximian.com>
|
||||
//
|
||||
// Copyright (C) 2002 Rachel Hestilow
|
||||
//
|
||||
// This code is inserted after the automatically generated code.
|
||||
//
|
||||
|
||||
public CanvasEllipse (Gnome.CanvasGroup group) : base (group, Type)
|
||||
{
|
||||
}
|
||||
|
14
gnome/CanvasGroup.custom
Normal file
14
gnome/CanvasGroup.custom
Normal file
|
@ -0,0 +1,14 @@
|
|||
//
|
||||
// Gnome.CanvasGroup.custom - Gnome CanvasGroup class customizations
|
||||
//
|
||||
// Author: Rachel Hestilow <hestilow@ximian.com>
|
||||
//
|
||||
// Copyright (C) 2002 Rachel Hestilow
|
||||
//
|
||||
// This code is inserted after the automatically generated code.
|
||||
//
|
||||
|
||||
protected CanvasGroup (Gnome.CanvasGroup group, int type) : base (group, type)
|
||||
{
|
||||
}
|
||||
|
19
gnome/CanvasItem.custom
Normal file
19
gnome/CanvasItem.custom
Normal file
|
@ -0,0 +1,19 @@
|
|||
//
|
||||
// Gnome.CanvasItem.custom - Gnome CanvasItem class customizations
|
||||
//
|
||||
// Author: Rachel Hestilow <hestilow@ximian.com>
|
||||
//
|
||||
// Copyright (C) 2002 Rachel Hestilow
|
||||
//
|
||||
// This code is inserted after the automatically generated code.
|
||||
//
|
||||
|
||||
|
||||
[DllImport("gnomecanvas-2")]
|
||||
static extern System.IntPtr gnome_canvas_item_new (IntPtr group, int type, IntPtr null_terminator);
|
||||
|
||||
public CanvasItem (Gnome.CanvasGroup group, int type)
|
||||
{
|
||||
Raw = gnome_canvas_item_new (group.Handle, type, IntPtr.Zero);
|
||||
}
|
||||
|
14
gnome/CanvasLine.custom
Normal file
14
gnome/CanvasLine.custom
Normal file
|
@ -0,0 +1,14 @@
|
|||
//
|
||||
// Gnome.CanvasLine.custom - Gnome CanvasLine class customizations
|
||||
//
|
||||
// Author: Rachel Hestilow <hestilow@ximian.com>
|
||||
//
|
||||
// Copyright (C) 2002 Rachel Hestilow
|
||||
//
|
||||
// This code is inserted after the automatically generated code.
|
||||
//
|
||||
|
||||
public CanvasLine (Gnome.CanvasGroup group) : base (group, Type)
|
||||
{
|
||||
}
|
||||
|
14
gnome/CanvasPixbuf.custom
Normal file
14
gnome/CanvasPixbuf.custom
Normal file
|
@ -0,0 +1,14 @@
|
|||
//
|
||||
// Gnome.CanvasPixbuf.custom - Gnome CanvasPixbuf class customizations
|
||||
//
|
||||
// Author: Rachel Hestilow <hestilow@ximian.com>
|
||||
//
|
||||
// Copyright (C) 2002 Rachel Hestilow
|
||||
//
|
||||
// This code is inserted after the automatically generated code.
|
||||
//
|
||||
|
||||
public CanvasPixbuf (Gnome.CanvasGroup group) : base (group, Type)
|
||||
{
|
||||
}
|
||||
|
14
gnome/CanvasPolygon.custom
Normal file
14
gnome/CanvasPolygon.custom
Normal file
|
@ -0,0 +1,14 @@
|
|||
//
|
||||
// Gnome.CanvasPolygon.custom - Gnome CanvasPolygon class customizations
|
||||
//
|
||||
// Author: Rachel Hestilow <hestilow@ximian.com>
|
||||
//
|
||||
// Copyright (C) 2002 Rachel Hestilow
|
||||
//
|
||||
// This code is inserted after the automatically generated code.
|
||||
//
|
||||
|
||||
public CanvasPolygon (Gnome.CanvasGroup group) : base (group, Type)
|
||||
{
|
||||
}
|
||||
|
14
gnome/CanvasRE.custom
Normal file
14
gnome/CanvasRE.custom
Normal file
|
@ -0,0 +1,14 @@
|
|||
//
|
||||
// Gnome.CanvasRE.custom - Gnome CanvasRE class customizations
|
||||
//
|
||||
// Author: Rachel Hestilow <hestilow@ximian.com>
|
||||
//
|
||||
// Copyright (C) 2002 Rachel Hestilow
|
||||
//
|
||||
// This code is inserted after the automatically generated code.
|
||||
//
|
||||
|
||||
protected CanvasRE (Gnome.CanvasGroup group, int type) : base (group, type)
|
||||
{
|
||||
}
|
||||
|
14
gnome/CanvasRect.custom
Normal file
14
gnome/CanvasRect.custom
Normal file
|
@ -0,0 +1,14 @@
|
|||
//
|
||||
// Gnome.CanvasRect.custom - Gnome CanvasRect class customizations
|
||||
//
|
||||
// Author: Rachel Hestilow <hestilow@ximian.com>
|
||||
//
|
||||
// Copyright (C) 2002 Rachel Hestilow
|
||||
//
|
||||
// This code is inserted after the automatically generated code.
|
||||
//
|
||||
|
||||
public CanvasRect (Gnome.CanvasGroup group) : base (group, Type)
|
||||
{
|
||||
}
|
||||
|
14
gnome/CanvasRichText.custom
Normal file
14
gnome/CanvasRichText.custom
Normal file
|
@ -0,0 +1,14 @@
|
|||
//
|
||||
// Gnome.CanvasRichText.custom - Gnome CanvasRichText class customizations
|
||||
//
|
||||
// Author: Rachel Hestilow <hestilow@ximian.com>
|
||||
//
|
||||
// Copyright (C) 2002 Rachel Hestilow
|
||||
//
|
||||
// This code is inserted after the automatically generated code.
|
||||
//
|
||||
|
||||
public CanvasRichText (Gnome.CanvasGroup group) : base (group, Type)
|
||||
{
|
||||
}
|
||||
|
14
gnome/CanvasShape.custom
Normal file
14
gnome/CanvasShape.custom
Normal file
|
@ -0,0 +1,14 @@
|
|||
//
|
||||
// Gnome.CanvasShape.custom - Gnome CanvasShape class customizations
|
||||
//
|
||||
// Author: Rachel Hestilow <hestilow@ximian.com>
|
||||
//
|
||||
// Copyright (C) 2002 Rachel Hestilow
|
||||
//
|
||||
// This code is inserted after the automatically generated code.
|
||||
//
|
||||
|
||||
protected CanvasShape (Gnome.CanvasGroup group, int type) : base (group, type)
|
||||
{
|
||||
}
|
||||
|
14
gnome/CanvasText.custom
Normal file
14
gnome/CanvasText.custom
Normal file
|
@ -0,0 +1,14 @@
|
|||
//
|
||||
// Gnome.CanvasText.custom - Gnome CanvasText class customizations
|
||||
//
|
||||
// Author: Rachel Hestilow <hestilow@ximian.com>
|
||||
//
|
||||
// Copyright (C) 2002 Rachel Hestilow
|
||||
//
|
||||
// This code is inserted after the automatically generated code.
|
||||
//
|
||||
|
||||
public CanvasText (Gnome.CanvasGroup group) : base (group, Type)
|
||||
{
|
||||
}
|
||||
|
14
gnome/CanvasWidget.custom
Normal file
14
gnome/CanvasWidget.custom
Normal file
|
@ -0,0 +1,14 @@
|
|||
//
|
||||
// Gnome.CanvasWidget.custom - Gnome CanvasWidget class customizations
|
||||
//
|
||||
// Author: Rachel Hestilow <hestilow@ximian.com>
|
||||
//
|
||||
// Copyright (C) 2002 Rachel Hestilow
|
||||
//
|
||||
// This code is inserted after the automatically generated code.
|
||||
//
|
||||
|
||||
public CanvasWidget (Gnome.CanvasGroup group) : base (group, Type)
|
||||
{
|
||||
}
|
||||
|
14
gnome/IconTextItem.custom
Normal file
14
gnome/IconTextItem.custom
Normal file
|
@ -0,0 +1,14 @@
|
|||
//
|
||||
// Gnome.IconTextItem.custom - Gnome IconTextItem class customizations
|
||||
//
|
||||
// Author: Rachel Hestilow <hestilow@ximian.com>
|
||||
//
|
||||
// Copyright (C) 2002 Rachel Hestilow
|
||||
//
|
||||
// This code is inserted after the automatically generated code.
|
||||
//
|
||||
|
||||
public IconTextItem (Gnome.CanvasGroup group) : base (group, Type)
|
||||
{
|
||||
}
|
||||
|
182
sample/CanvasExample.cs
Normal file
182
sample/CanvasExample.cs
Normal file
|
@ -0,0 +1,182 @@
|
|||
// Canvas.cs - port of standard GNOME canvas demo
|
||||
//
|
||||
// Author: Rachel Hestilow <hestilow@ximian.com>
|
||||
//
|
||||
// (c) 2002 Rachel Hestilow
|
||||
|
||||
namespace GtkSamples {
|
||||
|
||||
using Gnome;
|
||||
using Gtk;
|
||||
using Gdk;
|
||||
using GtkSharp;
|
||||
using System;
|
||||
|
||||
public class CanvasExample {
|
||||
private int width = 400, height = 400;
|
||||
private double remember_x = 0.0, remember_y = 0.0;
|
||||
|
||||
private Canvas canvas;
|
||||
private Random random = new Random ();
|
||||
|
||||
public CanvasExample () {
|
||||
Gtk.Window win = new Gtk.Window ("Canvas example");
|
||||
win.DeleteEvent += new DeleteEventHandler (Window_Delete);
|
||||
|
||||
VBox vbox = new VBox (false, 0);
|
||||
win.Add (vbox);
|
||||
|
||||
vbox.PackStart (new Label ("Drag - move object.\n" +
|
||||
"Double click - change color\n" +
|
||||
"Right click - delete object"),
|
||||
false, false, 0);
|
||||
|
||||
canvas = new Canvas ();
|
||||
canvas.SetSizeRequest (width, height);
|
||||
canvas.SetScrollRegion (0.0, 0.0, (double) width, (double) height);
|
||||
vbox.PackStart (canvas, false, false, 0);
|
||||
|
||||
HBox hbox = new HBox (false, 0);
|
||||
vbox.PackStart (hbox, false, false, 0);
|
||||
|
||||
Button add_button = new Button ("Add an object");
|
||||
add_button.Clicked += new EventHandler (AddObject);
|
||||
hbox.PackStart (add_button, false, false, 0);
|
||||
|
||||
Button quit_button = new Button ("Quit");
|
||||
quit_button.Clicked += new EventHandler (Quit);
|
||||
hbox.PackStart (quit_button, false, false, 0);
|
||||
|
||||
win.ShowAll ();
|
||||
}
|
||||
|
||||
void Swap (ref double a, ref double b) {
|
||||
double tmp = a;
|
||||
a = b;
|
||||
b = tmp;
|
||||
}
|
||||
|
||||
void AddObject (object obj, EventArgs args)
|
||||
{
|
||||
double x1 = random.Next (width);
|
||||
double y1 = random.Next (height);
|
||||
double x2 = random.Next (width);
|
||||
double y2 = random.Next (height);
|
||||
|
||||
if (x1 > x2)
|
||||
Swap (ref x1, ref x2);
|
||||
|
||||
if (y1 > y2)
|
||||
Swap (ref y1, ref y2);
|
||||
|
||||
if ((x2 - x1) < 10)
|
||||
x2 += 10;
|
||||
|
||||
if ((y2 - y1) < 10)
|
||||
y2 += 10;
|
||||
|
||||
CanvasRE item = null;
|
||||
if (random.Next (2) > 0)
|
||||
item = new CanvasRect (canvas.Root ());
|
||||
else
|
||||
item = new CanvasEllipse (canvas.Root ());
|
||||
|
||||
item.X1 = x1;
|
||||
item.Y1 = y1;
|
||||
item.X2 = x2;
|
||||
item.Y2 = y2;
|
||||
item.FillColor = "white";
|
||||
item.OutlineColor = "black";
|
||||
item.WidthUnits = 1.0;
|
||||
|
||||
item.CanvasEvent += new CanvasEventHandler (Item_Event);
|
||||
}
|
||||
|
||||
void ChangeItemColor (CanvasRE item)
|
||||
{
|
||||
string[] colors = new string[] {"red", "yellow", "green", "cyan", "blue", "magenta"};
|
||||
item.FillColor = colors[random.Next (colors.Length)];
|
||||
}
|
||||
|
||||
void Item_Event (object obj, CanvasEventArgs args) {
|
||||
EventButton ev = EventButton.New (args.Event.Handle);
|
||||
SignalArgs sa = (SignalArgs) args;
|
||||
CanvasRE item = (CanvasRE) obj;
|
||||
|
||||
switch (ev.type) {
|
||||
case EventType.ButtonPress:
|
||||
if (ev.button == 1) {
|
||||
remember_x = ev.x;
|
||||
remember_y = ev.y;
|
||||
sa.RetVal = true;
|
||||
return;
|
||||
} else if (ev.button == 3) {
|
||||
item.Destroy ();
|
||||
sa.RetVal = true;
|
||||
return;
|
||||
}
|
||||
case EventType.TwoButtonPress:
|
||||
ChangeItemColor (item);
|
||||
sa.RetVal = true;
|
||||
return;
|
||||
case EventType.MotionNotify:
|
||||
Gdk.ModifierType state = (Gdk.ModifierType) ev.state;
|
||||
if ((state & Gdk.ModifierType.Button1Mask) != 0) {
|
||||
double new_x = ev.x, new_y = ev.y;
|
||||
item.Move (new_x - remember_x, new_y - remember_y);
|
||||
remember_x = new_x;
|
||||
remember_y = new_y;
|
||||
sa.RetVal = true;
|
||||
return;
|
||||
}
|
||||
break;
|
||||
case EventType.EnterNotify:
|
||||
item.WidthUnits = 3.0;
|
||||
sa.RetVal = true;
|
||||
return;
|
||||
case EventType.LeaveNotify:
|
||||
item.WidthUnits = 1.0;
|
||||
sa.RetVal = true;
|
||||
return;
|
||||
}
|
||||
|
||||
sa.RetVal = false;
|
||||
return;
|
||||
}
|
||||
|
||||
void Quit (object obj, EventArgs args)
|
||||
{
|
||||
Application.Quit ();
|
||||
}
|
||||
|
||||
void Window_Delete (object obj, DeleteEventArgs args)
|
||||
{
|
||||
SignalArgs sa = (SignalArgs) args;
|
||||
Application.Quit ();
|
||||
sa.RetVal = true;
|
||||
}
|
||||
|
||||
void Quit (object obj, EventArgs args)
|
||||
{
|
||||
Application.Quit ();
|
||||
}
|
||||
|
||||
void Window_Delete (object obj, DeleteEventArgs args)
|
||||
{
|
||||
SignalArgs sa = (SignalArgs) args;
|
||||
Application.Quit ();
|
||||
sa.RetVal = true;
|
||||
}
|
||||
|
||||
public static int Main (string[] args)
|
||||
{
|
||||
Application.Init ();
|
||||
|
||||
CanvasExample example = new CanvasExample ();
|
||||
|
||||
Application.Run ();
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -2,7 +2,7 @@ MCS=mcs
|
|||
|
||||
@ENABLE_GNOME_TRUE@ GNOME_PATH=-L ../gnome
|
||||
@ENABLE_GNOME_TRUE@ GNOME_ASSEMBLY=-r gnome-sharp.dll
|
||||
@ENABLE_GNOME_TRUE@ GNOME_TARGETS=gnome-hello-world.exe
|
||||
@ENABLE_GNOME_TRUE@ GNOME_TARGETS=gnome-hello-world.exe canvas-example.exe
|
||||
|
||||
local_paths=-L ../glib -L ../pango -L ../atk -L ../gdk -L ../gtk $(GNOME_PATH)
|
||||
all_assemblies=-r glib-sharp.dll -r pango-sharp.dll -r atk-sharp.dll -r gdk-sharp.dll -r gtk-sharp.dll $(GNOME_ASSEMBLY) -r System.Drawing
|
||||
|
@ -22,6 +22,9 @@ gtk-hello-world.exe: HelloWorld.cs
|
|||
gnome-hello-world.exe: GnomeHelloWorld.cs
|
||||
$(MCS) --unsafe -o gnome-hello-world.exe $(local_paths) $(all_assemblies) GnomeHelloWorld.cs
|
||||
|
||||
canvas-example.exe: CanvasExample.cs
|
||||
$(MCS) --unsafe -o canvas-example.exe $(local_paths) $(all_assemblies) CanvasExample.cs
|
||||
|
||||
button.exe: ButtonApp.cs
|
||||
$(MCS) --unsafe -o button.exe $(local_paths) $(all_assemblies) ButtonApp.cs
|
||||
|
||||
|
|
Loading…
Reference in a new issue