From 36d289986c2fe1b1d966fa0d67d15166b8c317ec Mon Sep 17 00:00:00 2001 From: Johannes Roith Date: Tue, 5 Nov 2002 15:29:57 +0000 Subject: [PATCH] add tutorial file svn path=/trunk/gtk-sharp/; revision=8835 --- sample/tutorial/table/Makefile | 11 ++++ sample/tutorial/table/table.cs | 112 +++++++++++++++++++++++++++++++++ 2 files changed, 123 insertions(+) create mode 100644 sample/tutorial/table/Makefile create mode 100644 sample/tutorial/table/table.cs diff --git a/sample/tutorial/table/Makefile b/sample/tutorial/table/Makefile new file mode 100644 index 000000000..036041a63 --- /dev/null +++ b/sample/tutorial/table/Makefile @@ -0,0 +1,11 @@ + +CSC = mcs + +DLLS = -r glib-sharp.dll \ + -r gtk-sharp.dll \ + -r System.Drawing.dll + +all: + $(CSC) /unsafe $(DLLS) table.cs +clean: + rm -f *.exe \ No newline at end of file diff --git a/sample/tutorial/table/table.cs b/sample/tutorial/table/table.cs new file mode 100644 index 000000000..4aa6b9f91 --- /dev/null +++ b/sample/tutorial/table/table.cs @@ -0,0 +1,112 @@ +// table.cs - Gtk# Tutorial example +// +// Author: Johannes Roith +// +// (c) 2002 Johannes Roith + +namespace GtkSharpTutorial { + + + using Gtk; + using GtkSharp; + using System; + using System.Drawing; + + + public class table + { + + /* Our new improved callback. The data passed to this function + * is printed to stdout. */ + + static void callback( object obj, EventArgs args) + { + Button mybutton = (Button) obj; + Console.WriteLine("Hello again - {0} was pressed", (string) mybutton.Label); + // Have to figure out, how to recieve button name + } + + /* another event */ + static void delete_event (object obj, DeleteEventArgs args) + { + Application.Quit(); + } + + static void exit_event (object obj, EventArgs args) + { + Application.Quit(); + } + + public static void Main(string[] args) + { + + + + Application.Init (); + + + /* Create a new window */ + Window window = new Window ("Table"); + + + /* Set a handler for delete_event that immediately + * exits GTK. */ + window.DeleteEvent += new DeleteEventHandler (delete_event); + + /* Sets the border width of the window. */ + window.BorderWidth= 20; + + /* Create a 2x2 table */ + Table table = new Table (2, 2, true); + + /* Put the table in the main window */ + window.Add(table); + + /* Create first button */ + Button button = new Button("button 1"); + + /* When the button is clicked, we call the "callback" function + * with a pointer to "button 1" as its argument */ + button.Clicked += new EventHandler (callback); + + + /* Insert button 1 into the upper left quadrant of the table */ + table.Attach(button, 0, 1, 0, 1); + + button.Show(); + + /* Create second button */ + + Button button2 = new Button("button 2"); + + /* When the button is clicked, we call the "callback" function + * with a pointer to "button 2" as its argument */ + + button2.Clicked += new EventHandler (callback); + + /* Insert button 2 into the upper right quadrant of the table */ + table.Attach(button2, 1, 2, 0, 1); + + button2.Show(); + + /* Create "Quit" button */ + Button quitbutton = new Button("Quit"); + + /* When the button is clicked, we call the "delete_event" function + * and the program exits */ + quitbutton.Clicked += new EventHandler (exit_event); + + /* Insert the quit button into the both + * lower quadrants of the table */ + table.Attach(quitbutton, 0, 2, 1, 2); + + quitbutton.Show(); + + table.Show(); + window.ShowAll(); + + Application.Run(); + + } + } +} \ No newline at end of file