[Mono-list] GTK# tutorial examples

Alejandro Sánchez Acosta raciel@x0und.net
07 Nov 2002 19:34:28 +0000


--=-rmPMmO09KKzP/KvvV4+i
Content-Type: multipart/mixed; boundary="=-Ho0KvVNR56DeYuUjYJWw"


--=-Ho0KvVNR56DeYuUjYJWw
Content-Type: text/plain
Content-Transfer-Encoding: quoted-printable

Here I have a samples about the missing widgets for the GTK# tutorial:

- togglebutton
- checkbutton
- label

Now with the help of cesar, we are working in other examples like
adjustment, rulers ...

Soon we have the mayority of widgets samples made.

Anybody can commit it?

Cheers

-- Alex


--=-Ho0KvVNR56DeYuUjYJWw
Content-Disposition: attachment; filename=checkbuttons.cs
Content-Type: text/plain; name=checkbuttons.cs; charset=ISO-8859-15
Content-Transfer-Encoding: quoted-printable

// checkbuttons.cs - GTK# Tutorial example
//
// Authors: Alejandro Sanchez Acosta <raciel@es.gnu.org>
//          Cesar Octavio Lopez Nataren <cesar@ciencias.unam.mx>
//
// (C) 2002 Alejandro Sanchez Acosta <raciel@es.gnu.org>
//          Cesar Octavio Lopez Nataren <cesar@ciencias.unam.mx>

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();
		=09
			HBox hbox =3D new HBox(false, 0);
			hbox.BorderWidth =3D 2;
		=09
			CheckButton cb1 =3D new CheckButton ("CheckButton 1");
			cb1.Clicked +=3D new EventHandler (clickedCallback);

			CheckButton cb2 =3D new CheckButton ("CheckButton 2");
			cb2.Clicked +=3D new EventHandler (clickedCallback);

			hbox.PackStart(cb1, false, false, 3);
			hbox.PackStart(cb2, false, false, 3);

			Window window =3D new Window ("Check buttons");
			window.BorderWidth =3D 10;
			window.DeleteEvent  +=3D new DeleteEventHandler (delete_event);

			window.Add(hbox);
			window.ShowAll();
			Application.Run();
		}
	}
}

--=-Ho0KvVNR56DeYuUjYJWw
Content-Disposition: attachment; filename=Makefile
Content-Type: text/x-makefile; name=Makefile; charset=ISO-8859-15
Content-Transfer-Encoding: quoted-printable

=0D
CSC  =3D	mcs=0D
=0D
DLLS =3D	-r glib-sharp.dll     \=0D
	-r gtk-sharp.dll      \
	-r System.Drawing.dll=0D
=0D
all:=0D
	$(CSC) /unsafe $(DLLS) checkbuttons.cs=0D
clean:=20=0D
	rm -f *.exe

--=-Ho0KvVNR56DeYuUjYJWw
Content-Disposition: attachment; filename=togglebutton.cs
Content-Type: text/plain; name=togglebutton.cs; charset=ISO-8859-15
Content-Transfer-Encoding: quoted-printable

// togglebuttons.cs - Gtk# Tutorial example=0D
//=0D
// Author: Alejandro S=E1nchez Acosta <raciel@es.gnu.org>
// 	   Cesar Octavio Lopez Nataren <cesar@ciencias.unam.mx>
//
// (c) 2002 Alejandro S=E1nchez 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)=0D
		{

			Application.Init();  =20
     =20
  =20
			Window window =3D new Window("toggle buttons");
			 =20
			window.DeleteEvent +=3D new DeleteEventHandler (delete_event);
		=09
			window.BorderWidth =3D 0;
		=09
			VBox box1 =3D new VBox (false, 0);
			window.Add(box1);
			box1.Show();
		=09
			VBox box2 =3D new VBox (false, 10);
			box2.BorderWidth =3D 10;
			box1.PackStart(box2, true, true, 0);
			box2.Show();
		=09
			ToggleButton togglebutton =3D new ToggleButton  ("button1");
			box2.PackStart(togglebutton, true, true, 0);
			togglebutton.Show();
			ToggleButton togglebutton2 =3D new ToggleButton("button2");
			togglebutton2.Active =3D true;
			box2.PackStart(togglebutton2, true, true, 0);
			togglebutton2.Show();
		=09
			HSeparator separator =3D new HSeparator ();
			box1.PackStart (separator,false, true, 0);
			separator.Show();
		=09
			VBox box3 =3D new VBox(false, 10);
			box3.BorderWidth =3D 10;
			box1.PackStart(box3,false, true, 0);
			box3.Show();
		=09
			Button button =3D new Button ("close");
			button.Clicked +=3D new EventHandler (exitbutton_event);
		=09
			box3.PackStart(button, true, true, 0);
			button.CanDefault =3D true;
			button.GrabDefault();
			button.Show();
			 =20
			window.ShowAll();
			    =20
			Application.Run();
		=09
		}
	}
}

--=-Ho0KvVNR56DeYuUjYJWw
Content-Disposition: attachment; filename=Makefile
Content-Type: text/x-makefile; name=Makefile; charset=ISO-8859-15
Content-Transfer-Encoding: quoted-printable

=0D
CSC  =3D	mcs=0D
=0D
DLLS =3D	-r glib-sharp.dll     \=0D
	-r gtk-sharp.dll      \
	-r gdk-sharp.dll      \
	-r System.Drawing.dll=0D
=0D
all:=0D
	$(CSC) /unsafe $(DLLS) togglebutton.cs=0D
clean:=20=0D
	rm -f *.exe

--=-Ho0KvVNR56DeYuUjYJWw
Content-Disposition: attachment; filename=label.cs
Content-Type: text/plain; name=label.cs; charset=ISO-8859-15
Content-Transfer-Encoding: quoted-printable

// label.cs - Gtk# Tutorial example
//
// Author: Alejandro S=E1nchez Acosta <raciel@es.gnu.org>
// 	   Cesar Octavio Lopez Nataren <cesar@ciencias.unam.mx>
//
// (c) 2002 Alejandro S=E1nchez 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)
		{
	=09
			Widget widget;
			Window window;
			HBox hbox;
			VBox vbox;
			Frame frame;
			Label label;
		=09
			Application.Init ();  =20
     =20
  =20
			window =3D new Window ("Label sample");
			 =20
			window.DeleteEvent +=3D new DeleteEventHandler (delete_event);

			window.Title =3D "Label";
		=09
			hbox =3D new HBox (false, 5);
			vbox =3D new VBox (false, 5);

			window.Add (hbox);
			hbox.PackStart (vbox, false, false, 0);

			window.BorderWidth =3D 5;

			frame =3D new Frame ("Normal Label");
			label =3D new Label ("This is a normal label");
		=09
			frame.Add (label);
			vbox.PackStart (frame, false, false, 0);
		=09
		        frame =3D new Frame ("Multiline Label");
			label =3D new Label ("This is a Multi-line label\nSecond Line\nThird Lin=
e");
=09
			frame.Add (label);
			vbox.PackStart (frame, false, false, 0);
		=09
			frame =3D new Frame ("Left Justified Label");
			label =3D new Label ("This is a Left-Justified\n" + "Multi-line label.\n=
" + "Third      line");
			label.Justify =3D Justification.Left;

			frame.Add (label);
			vbox.PackStart (frame, false, false, 0);
=09
			frame =3D new Frame ("Right Justified Label");		=09
			label =3D new Label ("This is a Right Justified\nMulti-line label.\n" + =
"Fourth Line, (j/k)");
			label.Justify =3D Justification.Right;
			frame.Add (label);
			vbox.PackStart (frame, false, false, 0);

			vbox =3D new VBox (false, 5);
			hbox.PackStart(vbox, false, false, 0);
		=09
			frame =3D new Frame ("Line wrapped Label");
			label =3D 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. ");
		=09
			label.LineWrap =3D true;
	=09
			frame.Add (label);
			vbox.PackStart(frame, false, false, 0);
		=09
			frame =3D new Frame ("Filled wrapped label");
			label =3D 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.");
		=09
			label.Justify =3D Justification.Fill;
			label.Wrap =3D true;
			frame.Add (label);
			vbox.PackStart (frame, false, false, 0);


			frame =3D new Frame ("Underlined label");
		=09
			label =3D new Label ("This label is underlined!\n" + "This one is underl=
ined in quite a funky fastion");

			label.Justify =3D Justification.Left;
			label.Pattern =3D "_________________________ _ _________ _ ______     __=
 _______ ___";

			frame.Add (label);
			vbox.PackStart (frame, false, false, 0);

			window.ShowAll ();

			Application.Run ();
		}
	}
}

--=-Ho0KvVNR56DeYuUjYJWw
Content-Disposition: attachment; filename=Makefile
Content-Type: text/x-makefile; name=Makefile; charset=ISO-8859-15
Content-Transfer-Encoding: quoted-printable

CSC  =3D	mcs

DLLS =3D	-r glib-sharp.dll     \
	-r gtk-sharp.dll      \
	-r System.Drawing.dll

all:
	$(CSC) /unsafe $(DLLS) label.cs
clean:=20
	rm -f *.exe

--=-Ho0KvVNR56DeYuUjYJWw--

--=-rmPMmO09KKzP/KvvV4+i
Content-Type: application/pgp-signature; name=signature.asc
Content-Description: Esta parte del mensaje esta firmada digitalmente

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.0 (GNU/Linux)

iD8DBQA9ysBEsgoaWknonh4RAnzRAJ0d+BHmpFJkv1DJ/zA205II6Rn/KACgtLBz
6+dTqUH6XnEG9blI9OPwRRA=
=JKHL
-----END PGP SIGNATURE-----

--=-rmPMmO09KKzP/KvvV4+i--