[GUI] ByeDemo

Daan Leijen daanleijen@xs4all.nl
Sun, 2 Feb 2003 17:13:12 +0100


This is a multi-part message in MIME format.

------=_NextPart_000_005E_01C2CADE.5E112E90
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

> I propose a simple program which pops up a window saying
> 'Hello World' with a button saying 'Bye' which you click and it =
changes
> the message to 'Goodbye'. if you click the button again the program
> exits.

I have been thinkering with the wxWindows library
and made a small Haskell binding to it that just supports this
example. It was an interesting exercise since the wxWindows library
is a large object-oriented C++ library. (but very portable, well =
supported,
efficient and with lots of super widgets, like an openGL canvas and a =
HTML=20
renderer)

Anyhow, I think it comes out rather nicely and I am quite surprised how
well the wxWindows library lends itself to Haskell access.=20

-- Daan.


-----------------------------------------------------------------
main   =3D wxRun $    do w <- wxCreateFrame wxFRAME_DEFAULT_STYLE       =
wxSetWindowBackgroundColor w white       wxSetWindowSize w (Size 100 80) =
      wxSetFrameTitle w "Bye!"       l <- wxCreateLabel w "Hello World"  =
     wxSetWindowPosition l (Point 10 5)       b <- wxCreateButton w =
"Bye"       wxSetWindowPosition b (Point 10 25)       =
wxSetButtonOnCommand b (bye w b l)       wxShowWindow w  where    bye w =
b l      =3D do wxSetControlLabel l "Goodbye"           =
wxSetButtonOnCommand b (wxWindowClose w False)
------=_NextPart_000_005E_01C2CADE.5E112E90
Content-Type: text/html;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Diso-8859-1">
<META content=3D"MSHTML 6.00.2800.1126" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY>
<DIV><FONT face=3DArial size=3D2>&gt; I propose a simple program which =
pops up a=20
window saying<BR>&gt; 'Hello World' with a button saying 'Bye' which you =
click=20
and it changes<BR>&gt; the message to 'Goodbye'. if you click the button =
again=20
the program<BR>&gt; exits.<BR></FONT></DIV>
<DIV><FONT face=3DArial size=3D2>I have been thinkering with the =
wxWindows=20
library</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>and made a small Haskell binding to it =
that just=20
supports this</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>example. It was an interesting exercise =
since the=20
wxWindows library</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>is a large object-oriented C++ library. =
(but very=20
portable, well supported,</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>efficient and with lots of super =
widgets, like an=20
openGL canvas and a HTML </FONT></DIV>
<DIV><FONT face=3DArial size=3D2>renderer)</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Anyhow, I think it comes out rather =
nicely and I am=20
quite surprised how</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>well the wxWindows library lends itself =
to Haskell=20
access. </FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT><FONT face=3DArial =
size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>-- Daan.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial=20
size=3D2>----------------------------------------------------------------=
-</FONT></DIV><PRE>main <BR>&nbsp; =3D wxRun $<BR>&nbsp;&nbsp;&nbsp; do =
w &lt;- wxCreateFrame =
wxFRAME_DEFAULT_STYLE<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
wxSetWindowBackgroundColor w =
white<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; wxSetWindowSize w (Size =
100 80)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; wxSetFrameTitle w =
"Bye!"<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; l &lt;- wxCreateLabel w =
"Hello World"<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
wxSetWindowPosition l (Point 10 =
5)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; b &lt;- wxCreateButton w =
"Bye"<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; wxSetWindowPosition b =
(Point 10 25)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
wxSetButtonOnCommand b (bye w b =
l)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; wxShowWindow w<BR>&nbsp; =
where<BR>&nbsp;&nbsp;&nbsp; bye w b l<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
=3D do wxSetControlLabel l =
"Goodbye"<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=
 wxSetButtonOnCommand b (wxWindowClose w False)</PRE>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV></BODY></HTML>

------=_NextPart_000_005E_01C2CADE.5E112E90--