mail-archives/gtk-sharp-list/2002-June/000116.html

177 строки
5.0 KiB
HTML

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<TITLE> [Gtk-sharp-list] GtkSharp Demo
</TITLE>
<LINK REL="Index" HREF="index.html" >
<LINK REL="made" HREF="mailto:glennpierce%40connectfree.co.uk">
<META NAME="robots" CONTENT="index,nofollow">
<LINK REL="Previous" HREF="000119.html">
<LINK REL="Next" HREF="000117.html">
</HEAD>
<BODY BGCOLOR="#ffffff">
<H1>[Gtk-sharp-list] GtkSharp Demo
</H1>
<B>Glenn Pierce
</B>
<A HREF="mailto:glennpierce%40connectfree.co.uk"
TITLE="[Gtk-sharp-list] GtkSharp Demo">glennpierce@connectfree.co.uk
</A><BR>
<I>21 Jun 2002 20:36:26 +0000</I>
<P><UL>
<LI> Previous message: <A HREF="000119.html">[Gtk-sharp-list] GtkSharp Demon
</A></li>
<LI> Next message: <A HREF="000117.html">[Gtk-sharp-list] GtkSharp Demo
</A></li>
<LI> <B>Messages sorted by:</B>
<a href="date.html#116">[ date ]</a>
<a href="thread.html#116">[ thread ]</a>
<a href="subject.html#116">[ subject ]</a>
<a href="author.html#116">[ author ]</a>
</LI>
</UL>
<HR>
<!--beginarticle-->
<PRE>--=-I5V6KgckwGntTFsI2xob
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 ?
I'm sure it can be improved.
--=-I5V6KgckwGntTFsI2xob
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 &lt;<A HREF="mailto:glenn@connectfree.co.uk">glenn@connectfree.co.uk</A>&gt;
//
// &lt;c&gt; 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 (&quot;Button Boxes&quot;);
win.DeleteEvent +=3D new EventHandler (delete_cb);
VBox main_vbox =3D new VBox (false, 0);
Frame frame_horz =3D new Frame (&quot;Horizontal Button Boxes&quot;);
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, &quot;Spread&quot;, 40, Gtk.ButtonBoxStyle.Spre=
ad) , true, true, 5 );
vbox.PackStart (create_bbox (true, &quot;Edge&quot;, 40, Gtk.ButtonBoxStyle.Edge) =
, true, true, 5 );
vbox.PackStart (create_bbox (true, &quot;Start&quot;, 40, Gtk.ButtonBoxStyle.Start=
) , true, true, 5 );
vbox.PackStart (create_bbox (true, &quot;End&quot;, 40, Gtk.ButtonBoxStyle.End) , =
true, true, 5 );
Frame frame_vert =3D new Frame (&quot;Vertical Button Boxes&quot;);
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, &quot;Spread&quot;, 30, Gtk.ButtonBoxStyle.Spr=
ead) , true, true, 5 );
hbox.PackStart (create_bbox (false, &quot;Edge&quot;, 30, Gtk.ButtonBoxStyl=
e.Edge) , true, true, 5 );
hbox.PackStart (create_bbox (false, &quot;Start&quot;, 30, Gt=
k.ButtonBoxStyle.Start) , true, true, 5 );
hbox.PackStart (create_bbox (false, &quot;End&quot;, 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(&quot;gtk-ok&quot;);
bbox.EmitAdd(button);
=09
button =3D Button.NewFromStock(&quot;gtk-cancel&quot;);
bbox.EmitAdd(button);
button =3D Button.NewFromStock(&quot;gtk-help&quot;);
bbox.EmitAdd(button);
=09
return frame;
}
=09
}
}
--=-I5V6KgckwGntTFsI2xob--
</PRE>
<!--endarticle-->
<HR>
<P><UL>
<!--threads-->
<LI> Previous message: <A HREF="000119.html">[Gtk-sharp-list] GtkSharp Demon
</A></li>
<LI> Next message: <A HREF="000117.html">[Gtk-sharp-list] GtkSharp Demo
</A></li>
<LI> <B>Messages sorted by:</B>
<a href="date.html#116">[ date ]</a>
<a href="thread.html#116">[ thread ]</a>
<a href="subject.html#116">[ subject ]</a>
<a href="author.html#116">[ author ]</a>
</LI>
</UL>
</body></html>