Fw: Terminology (Re: [GUI] Re: Know you backends)
Daan Leijen
daanleijen@xs4all.nl
Fri, 31 Jan 2003 22:50:24 +0100
This is a multi-part message in MIME format.
------=_NextPart_000_009E_01C2C97B.2441D610
Content-Type: multipart/alternative;
boundary="----=_NextPart_001_009F_01C2C97B.2441D610"
------=_NextPart_001_009F_01C2C97B.2441D610
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.
Hi all,
Here is the GoodBye demo for the Port library. (a portable =
core-functionality library).
I think that it nicely shows the difference between a library with a =
nice convenience
layer, like GIO, and a bare gui library like Port. It also shows that =
Port is still at a=20
reasonably high-level from a gui perspective: writing this example with =
just the Win32=20
library for example is much more work.
All the best,
Daan.
-------------------------------------------------------------------------=
-------
{------------------------------------------------------------------------=
--------This program implements the "goodbye" demo as posted by John =
Meacham onthe Haskell GUI mailing list. =
-------------------------------------------------------------------------=
-------}module Main whereimport Graphics.UI.Portmain =3D do demo -- =
setup gui start -- start event loop demo :: IO ()demo =3D =
do w <- createWindow registerWindow w =
-- register for proper shutdown when the window is closed =
registerWindowDismiss w (closeWindow w) -- close when the user =
dismisses the window registerWindowPaint w (\can upd -> fillRect =
upd can) -- fill the background with some color =
setWindowDomainSize w (Size 0 0) -- no scroll bars needed =
setWindowViewSize w (Size 80 40) -- guess some size =
as Port has no layout manager setWindowTitle w "Bye!" =
-- set the title bar text l <- createLabel w =
setLabelText l "Hello World!" lsize <- getLabelRequestSize l =
-- get the minimal size of the label moveResizeControl =
l (rectAt (Point 0 0) lsize) -- position in upperleft corner b <- =
createButton w setButtonText b "Bye" bsize <- =
getButtonRequestSize b -- get the minimal size of the =
button moveResizeControl b (rectAt (Point 0 (sh lsize)) bsize) -- =
position under the label registerButtonClick b (bye w l b) =
-- register event handler showWindow w =
-- show it all where -- called on the first click with =
the window, label, and button as arguments. bye w l b =3D do =
setLabelText l "Goodbye" registerButtonClick b (closeWindow w) =
-- overwrite the old event handler
------=_NextPart_001_009F_01C2C97B.2441D610
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 bgColor=3D#ffffff>
<DIV>> I propose a simple program which pops up a window =
saying<BR>>=20
'Hello World' with a button saying 'Bye' which you click and it =
changes<BR>>=20
the message to 'Goodbye'. if you click the button again the =
program<BR>>=20
exits.<BR><BR>Hi all,</DIV><FONT face=3DArial size=3D2></FONT><FONT =
face=3DArial=20
size=3D2></FONT>
<DIV><BR>Here is the GoodBye demo for the Port library. =
(a=20
portable core-functionality library).</DIV>
<DIV>I think that it nicely shows the difference between a library with =
a nice=20
convenience</DIV>
<DIV>layer, like GIO, and a bare gui library like Port. It also =
shows that=20
Port is still at a </DIV>
<DIV>reasonably high-level from a gui perspective: writing this =
example=20
with just the Win32 </DIV>
<DIV>library for example is much more work.</DIV>
<DIV><FONT face=3DArial size=3D2></FONT><BR>All the =
best,<BR> =20
Daan.<BR></DIV>
<DIV>
<HR>
</DIV><PRE>{-------------------------------------------------------------=
-------------------<BR>This program implements the "goodbye" demo as =
posted by John Meacham on<BR>the Haskell GUI mailing list. =
<BR>---------------------------------------------------------------------=
-----------}<BR>module Main where</PRE><PRE>import =
Graphics.UI.Port</PRE><PRE>main =3D do demo -- setup =
gui<BR> =
start -- start event loop<BR> <BR>demo :: IO ()<BR>demo =
<BR> =3D do w <- =
createWindow<BR> registerWindow =
w =
&=
nbsp; -- register for proper shutdown when =
the window is closed<BR> =
registerWindowDismiss w (closeWindow =
w) -- close when the user =
dismisses the window<BR> =
registerWindowPaint w (\can upd -> fillRect upd can) -- fill the =
background with some color<BR> =
setWindowDomainSize w (Size 0 =
0)  =
; -- no scroll bars =
needed<BR> setWindowViewSize w (Size =
80 =
40) &nbs=
p; -- guess some size as Port has no layout =
manager<BR> setWindowTitle w =
"Bye!" &=
nbsp; =
-- set the title bar text<BR> =
<BR> l <- createLabel =
w<BR> setLabelText l "Hello =
World!"<BR> lsize <- =
getLabelRequestSize =
l =
-- get the minimal size of the =
label<BR> moveResizeControl l =
(rectAt (Point 0 0) lsize) -- position in upperleft =
corner</PRE><PRE> b <- =
createButton w<BR> setButtonText b =
"Bye"<BR> bsize <- =
getButtonRequestSize =
b =
-- get the minimal size of the =
button<BR> moveResizeControl b =
(rectAt (Point 0 (sh lsize)) bsize) -- position under the =
label</PRE><PRE> registerButtonClick =
b (bye w l =
b)  =
; -- register event =
handler<BR> showWindow =
w =
&=
nbsp; -- show it =
all<BR> where<BR> -- called on the first click =
with the window, label, and button as arguments.<BR> =
bye w l b<BR> =3D do setLabelText l =
"Goodbye"<BR> =
registerButtonClick b (closeWindow w) -- =
overwrite the old event handler<BR></PRE></BODY></HTML>
------=_NextPart_001_009F_01C2C97B.2441D610--
------=_NextPart_000_009E_01C2C97B.2441D610
Content-Type: application/octet-stream;
name="ByeDemo.hs"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: attachment;
filename="ByeDemo.hs"
{------------------------------------------------------------------------=
--------=0A=
This program implements the "goodbye" demo as posted by John Meacham on=0A=
the Haskell GUI mailing list. The program is specified as:=0A=
=0A=
I propose a simple program which pops up a window saying 'Hello World' =0A=
with a button saying 'Bye' which you click and it changes the message =0A=
to 'Goodbye'. if you click the button again the program exits.=0A=
-------------------------------------------------------------------------=
-------}=0A=
module Main where=0A=
=0A=
import Graphics.UI.Port=0A=
=0A=
main =3D do demo -- setup gui=0A=
start -- start event loop=0A=
=0A=
demo :: IO ()=0A=
demo =0A=
=3D do w <- createWindow=0A=
registerWindow w -- register for =
proper shutdown=0A=
registerWindowDismiss w (closeWindow w) -- close when the =
user dismisses the window=0A=
registerWindowPaint w (\can upd -> fillRect upd can) -- fill the =
background with some color=0A=
setWindowDomainSize w (Size 0 0) -- no scroll bars =
needed=0A=
setWindowViewSize w (Size 80 40) -- guess some size =
as Port has no layout manager=0A=
setWindowTitle w "Bye!" -- set the title =
bar text=0A=
=0A=
l <- createLabel w=0A=
setLabelText l "Hello World!"=0A=
lsize <- getLabelRequestSize l -- get the minimal =
size of the label=0A=
moveResizeControl l (rectAt (Point 0 0) lsize) -- position in =
upperleft corner=0A=
=0A=
b <- createButton w=0A=
setButtonText b "Bye"=0A=
bsize <- getButtonRequestSize b -- get the minimal =
size of the button=0A=
moveResizeControl b (rectAt (Point 0 (sh lsize)) bsize) -- =
position under the label=0A=
=0A=
registerButtonClick b (bye w l b) -- register event =
handler=0A=
showWindow w -- show it all=0A=
where=0A=
-- called on the first click with the window, label, and button as =
arguments.=0A=
bye w l b=0A=
=3D do setLabelText l "Goodbye"=0A=
registerButtonClick b (closeWindow w) -- overwrite the =
old event handler=0A=
------=_NextPart_000_009E_01C2C97B.2441D610--