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>&gt; I propose a simple program which pops up a window =
saying<BR>&gt;=20
'Hello World' with a button saying 'Bye' which you click and it =
changes<BR>&gt;=20
the message to 'Goodbye'. if you click the button again the =
program<BR>&gt;=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&nbsp;GoodBye demo&nbsp;for the Port library.&nbsp; =
(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&nbsp;gui library like Port. It also =
shows that=20
Port is still at a </DIV>
<DIV>reasonably high-level from a&nbsp;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>&nbsp;&nbsp;&nbsp;=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&nbsp;&nbsp;&nbsp; -- setup =
gui<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
start&nbsp;&nbsp; -- start event loop<BR>&nbsp;<BR>demo :: IO ()<BR>demo =
<BR>&nbsp; =3D do w &lt;- =
createWindow<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; registerWindow =
w&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&=
nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; -- register for proper shutdown when =
the window is closed<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
registerWindowDismiss w (closeWindow =
w)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; -- close when the user =
dismisses the window<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
registerWindowPaint w (\can upd -&gt; fillRect upd can) -- fill the =
background with some color<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
setWindowDomainSize w (Size 0 =
0)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp=
;&nbsp;&nbsp; -- no scroll bars =
needed<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; setWindowViewSize w (Size =
80 =
40)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs=
p;&nbsp;&nbsp; -- guess some size as Port has no layout =
manager<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; setWindowTitle w =
"Bye!"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&=
nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
-- set the title bar text<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; l &lt;- createLabel =
w<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; setLabelText l "Hello =
World!"<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; lsize &lt;- =
getLabelRequestSize =
l&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=
&nbsp;&nbsp;&nbsp;&nbsp; -- get the minimal size of the =
label<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; moveResizeControl l =
(rectAt (Point 0 0) lsize) -- position in upperleft =
corner</PRE><PRE>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; b &lt;- =
createButton w<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; setButtonText b =
"Bye"<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; bsize &lt;- =
getButtonRequestSize =
b&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=
&nbsp;&nbsp;&nbsp; -- get the minimal size of the =
button<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; moveResizeControl b =
(rectAt (Point 0 (sh lsize)) bsize)&nbsp; -- position under the =
label</PRE><PRE>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; registerButtonClick =
b (bye w l =
b)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp=
;&nbsp; -- register event =
handler<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; showWindow =
w&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&=
nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; -- show it =
all<BR>&nbsp; where<BR>&nbsp;&nbsp;&nbsp; -- called on the first click =
with the window, label, and button as arguments.<BR>&nbsp;&nbsp;&nbsp; =
bye w l b<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =3D do setLabelText l =
"Goodbye"<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=
 registerButtonClick b (closeWindow w)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; -- =
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--