[Gtk-sharp-list] GtkSharp Demon
Glenn Pierce
glenn@fortune-cookie.com
21 Jun 2002 20:31:24 +0000
--=-uZrQKEKCAdykAsAWZyAg
Content-Type: text/plain
Content-Transfer-Encoding: 7bit
Hi I have just started looking at C# / GtkSharp and have attached a
ported version of the Button Boxes program that is taken from the
gtk-demo app if anyone is interested ?
Glenn
--=-uZrQKEKCAdykAsAWZyAg
Content-Disposition: attachment; filename=ButtonBoxes.cs
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain; name=ButtonBoxes.cs; charset=ISO-8859-1
// ButtonBoxes.cs : Button Boxes App
//
// Author: Glenn Pierce <glenn@connectfree.co.uk>
//
// <c> 2002 Glenn Pierce
namespace GtkSharp.Samples {
using System;
using Gtk;
using GtkSharp;
public class ButtonBoxApp {
public static void Main (string[] args)
{
Application.Init();
Window win =3D new Window ("Button Boxes");
win.DeleteEvent +=3D new EventHandler (delete_cb);
VBox main_vbox =3D new VBox (false, 0);
Frame frame_horz =3D new Frame ("Horizontal Button Boxes");
main_vbox.PackStart (frame_horz, true, true, 10);
VBox vbox =3D new VBox (false, 0);
vbox.BorderWidth =3D 10;
frame_horz.EmitAdd(vbox);=09
vbox.PackStart (create_bbox (true, "Spread", 40, Gtk.ButtonBoxStyle.Spre=
ad) , true, true, 5 );
vbox.PackStart (create_bbox (true, "Edge", 40, Gtk.ButtonBoxStyle.Edge) =
, true, true, 5 );
vbox.PackStart (create_bbox (true, "Start", 40, Gtk.ButtonBoxStyle.Start=
) , true, true, 5 );
vbox.PackStart (create_bbox (true, "End", 40, Gtk.ButtonBoxStyle.End) , =
true, true, 5 );
Frame frame_vert =3D new Frame ("Vertical Button Boxes");
main_vbox.PackStart (frame_vert, true, true, 10);=09
=09
HBox hbox =3D new HBox (false, 0);
hbox.BorderWidth =3D 10;
frame_vert.EmitAdd(hbox);
hbox.PackStart (create_bbox (false, "Spread", 30, Gtk.ButtonBoxStyle.Spr=
ead) , true, true, 5 );
hbox.PackStart (create_bbox (false, "Edge", 30, Gtk.ButtonBoxStyl=
e.Edge) , true, true, 5 );
hbox.PackStart (create_bbox (false, "Start", 30, Gt=
k.ButtonBoxStyle.Start) , true, true, 5 );
hbox.PackStart (create_bbox (false, "End", 30, Gtk.=
ButtonBoxStyle.End) , true, true, 5 );
=09
win.EmitAdd (main_vbox);
win.BorderWidth =3D 10;
win.ShowAll ();
Application.Run ();
}
static void delete_cb (object o, EventArgs args)
{
SignalArgs sa =3D (SignalArgs) args;
Application.Quit ();
sa.RetVal =3D true;
}
private static Frame create_bbox (bool horizontal, string title, int spac=
ing, Gtk.ButtonBoxStyle layout)
{
Frame frame;
ButtonBox bbox;
Button button;
=09
frame =3D new Frame (title);
if (horizontal)
bbox =3D new HButtonBox();
else
bbox =3D new VButtonBox();
=20
bbox.BorderWidth =3D 5;
frame.EmitAdd(bbox);
=20
bbox.LayoutStyle =3D layout;
bbox.Spacing =3D spacing;
=20
button =3D Button.NewFromStock("gtk-ok");
bbox.EmitAdd(button);
=09
button =3D Button.NewFromStock("gtk-cancel");
bbox.EmitAdd(button);
button =3D Button.NewFromStock("gtk-help");
bbox.EmitAdd(button);
=09
return frame;
}
=09
}
}
--=-uZrQKEKCAdykAsAWZyAg--