diff --git a/sample/tutorial/checkbuttons/Makefile b/sample/tutorial/checkbuttons/Makefile new file mode 100644 index 000000000..e0e34c646 --- /dev/null +++ b/sample/tutorial/checkbuttons/Makefile @@ -0,0 +1,11 @@ + +CSC = mcs + +DLLS = -r glib-sharp.dll \ + -r gtk-sharp.dll \ + -r System.Drawing.dll + +all: + $(CSC) /unsafe $(DLLS) checkbuttons.cs +clean: + rm -f *.exe \ No newline at end of file diff --git a/sample/tutorial/checkbuttons/checkbuttons.cs b/sample/tutorial/checkbuttons/checkbuttons.cs new file mode 100644 index 000000000..f9a0ca177 --- /dev/null +++ b/sample/tutorial/checkbuttons/checkbuttons.cs @@ -0,0 +1,59 @@ +// checkbuttons.cs - GTK# Tutorial example +// +// Authors: Alejandro Sanchez Acosta +// Cesar Octavio Lopez Nataren +// +// (C) 2002 Alejandro Sanchez Acosta +// Cesar Octavio Lopez Nataren + +namespace GtkSharpTutorial { + + + using Gtk; + using GtkSharp; + using System; + using System.Drawing; + + + public class checkbuttons + { + static void delete_event(object obj, DeleteEventArgs args) + { + Application.Quit(); + } + + static void clickedCallback(object obj, EventArgs args) + { + if (((CheckButton) obj).Active) + Console.WriteLine ("CheckButton clicked, I'm activating"); + else + Console.WriteLine ("CheckButton clicked, I'm desactivating"); + } + + + public static void Main(string[] args) + { + Application.Init(); + + HBox hbox = new HBox(false, 0); + hbox.BorderWidth = 2; + + CheckButton cb1 = new CheckButton ("CheckButton 1"); + cb1.Clicked += new EventHandler (clickedCallback); + + CheckButton cb2 = new CheckButton ("CheckButton 2"); + cb2.Clicked += new EventHandler (clickedCallback); + + hbox.PackStart(cb1, false, false, 3); + hbox.PackStart(cb2, false, false, 3); + + Window window = new Window ("Check buttons"); + window.BorderWidth = 10; + window.DeleteEvent += new DeleteEventHandler (delete_event); + + window.Add(hbox); + window.ShowAll(); + Application.Run(); + } + } +} diff --git a/sample/tutorial/label/Makefile b/sample/tutorial/label/Makefile new file mode 100644 index 000000000..7cb08ccd2 --- /dev/null +++ b/sample/tutorial/label/Makefile @@ -0,0 +1,11 @@ + +CSC = mcs + +DLLS = -r glib-sharp.dll \ + -r gtk-sharp.dll \ + -r System.Drawing.dll + +all: + $(CSC) /unsafe $(DLLS) label.cs +clean: + rm -f *.exe \ No newline at end of file diff --git a/sample/tutorial/label/label.cs b/sample/tutorial/label/label.cs new file mode 100644 index 000000000..dcbfc225f --- /dev/null +++ b/sample/tutorial/label/label.cs @@ -0,0 +1,133 @@ +// label.cs - Gtk# Tutorial example +// +// Author: Alejandro Sánchez Acosta +// Cesar Octavio Lopez Nataren +// +// (c) 2002 Alejandro Sánchez Acosta + +namespace GtkSharpTutorial { + + using Gtk; + using GtkSharp; + using System; + using System.Drawing; + + public class label + { + + static void delete_event (object obj, DeleteEventArgs args) + { + Application.Quit(); + } + + static void exitbutton_event (object obj, EventArgs args) + { + Application.Quit(); + } + + public static void Main (string[] args) + { + + Widget widget; + Window window; + HBox hbox; + VBox vbox; + Frame frame; + Label label; + + Application.Init (); + + + window = new Window ("Label sample"); + + window.DeleteEvent += new DeleteEventHandler (delete_event); + + window.Title = "Label"; + + hbox = new HBox (false, 5); + vbox = new VBox (false, 5); + + window.Add (hbox); + hbox.PackStart (vbox, false, false, 0); + + window.BorderWidth = 5; + + frame = new Frame ("Normal Label"); + label = new Label ("This is a normal label"); + + frame.Add (label); + vbox.PackStart (frame, false, false, 0); + + frame = new Frame ("Multiline Label"); + label = new Label ("This is a Multi-line label\nSecond Line\nThird Line"); + + frame.Add (label); + vbox.PackStart (frame, false, false, 0); + + frame = new Frame ("Left Justified Label"); + label = new Label ("This is a Left-Justified\n" + "Multi-line label.\n" + "Third line"); + label.Justify = Justification.Left; + + frame.Add (label); + vbox.PackStart (frame, false, false, 0); + + frame = new Frame ("Right Justified Label"); + label = new Label ("This is a Right Justified\nMulti-line label.\n" + "Fourth Line, (j/k)"); + label.Justify = Justification.Right; + frame.Add (label); + vbox.PackStart (frame, false, false, 0); + + vbox = new VBox (false, 5); + hbox.PackStart(vbox, false, false, 0); + + frame = new Frame ("Line wrapped Label"); + label = new Label ("This is an example of a line-wrapped label. It " + + "should not be taking up the entire " /* big space to test spacing */ + + "width allocated to it, but automatically " + + "wraps the words to fit. " + + "The time has come, for all good men, to come to " + + "the aid of their party. " + + "The sixth sheik's six sheep's sick.\n" + + " It supports multiple paragraphs correctly, " + + "and correctly adds " + + "many extra spaces. "); + + label.LineWrap = true; + + frame.Add (label); + vbox.PackStart(frame, false, false, 0); + + frame = new Frame ("Filled wrapped label"); + label = new Label ("This is an example of a line-wrapped, filled label. " + + "It should be taking " + + "up the entire width allocated to it. " + + "Here is a sentence to prove " + + "my point. Here is another sentence. " + + "Here comes the sun, do de do de do.\n" + + " This is a new paragraph.\n" + + " This is another newer, longer, better " + + "paragraph. It is coming to an end, "+ + "unfortunately."); + + label.Justify = Justification.Fill; + label.Wrap = true; + frame.Add (label); + vbox.PackStart (frame, false, false, 0); + + + frame = new Frame ("Underlined label"); + + label = new Label ("This label is underlined!\n" + "This one is underlined in quite a funky fastion"); + + label.Justify = Justification.Left; + label.Pattern = "_________________________ _ _________ _ ______ __ _______ ___"; + + frame.Add (label); + vbox.PackStart (frame, false, false, 0); + + window.ShowAll (); + + Application.Run (); + } + } +} diff --git a/sample/tutorial/togglebutton/Makefile b/sample/tutorial/togglebutton/Makefile new file mode 100644 index 000000000..2f9241565 --- /dev/null +++ b/sample/tutorial/togglebutton/Makefile @@ -0,0 +1,11 @@ + +CSC = mcs + +DLLS = -r glib-sharp.dll \ + -r gtk-sharp.dll \ + -r System.Drawing.dll + +all: + $(CSC) /unsafe $(DLLS) togglebutton.cs +clean: + rm -f *.exe \ No newline at end of file diff --git a/sample/tutorial/togglebutton/togglebutton.cs b/sample/tutorial/togglebutton/togglebutton.cs new file mode 100644 index 000000000..95190ca96 --- /dev/null +++ b/sample/tutorial/togglebutton/togglebutton.cs @@ -0,0 +1,80 @@ +// togglebuttons.cs - Gtk# Tutorial example +// +// Author: Alejandro Sánchez Acosta +// Cesar Octavio Lopez Nataren +// +// (c) 2002 Alejandro Sánchez Acosta + +namespace GtkSharpTutorial { + + using Gtk; + using GtkSharp; + using System; + using System.Drawing; + + public class checkbuttons + { + + static void delete_event (object obj, DeleteEventArgs args) + { + Application.Quit(); + } + + static void exitbutton_event (object obj, EventArgs args) + { + Application.Quit(); + } + + public static void Main(string[] args) + { + + Application.Init(); + + + Window window = new Window("toggle buttons"); + + window.DeleteEvent += new DeleteEventHandler (delete_event); + + window.BorderWidth = 0; + + VBox box1 = new VBox (false, 0); + window.Add(box1); + box1.Show(); + + VBox box2 = new VBox (false, 10); + box2.BorderWidth = 10; + box1.PackStart(box2, true, true, 0); + box2.Show(); + + ToggleButton togglebutton = new ToggleButton ("button1"); + box2.PackStart(togglebutton, true, true, 0); + togglebutton.Show(); + ToggleButton togglebutton2 = new ToggleButton("button2"); + togglebutton2.Active = true; + box2.PackStart(togglebutton2, true, true, 0); + togglebutton2.Show(); + + HSeparator separator = new HSeparator (); + box1.PackStart (separator,false, true, 0); + separator.Show(); + + VBox box3 = new VBox(false, 10); + box3.BorderWidth = 10; + box1.PackStart(box3,false, true, 0); + box3.Show(); + + Button button = new Button ("close"); + button.Clicked += new EventHandler (exitbutton_event); + + box3.PackStart(button, true, true, 0); + button.CanDefault = true; + button.GrabDefault(); + button.Show(); + + window.ShowAll(); + + Application.Run(); + + } + } +}