[GUI] Common GUI API : What would the code look like?

David Sankel camio@yahoo.com
Wed, 5 Mar 2003 09:51:21 -0800 (PST)

--- Glynn Clements <glynn.clements@virgin.net> wrote:
> David Sankel wrote:
> > Questions ::
> > 1) How does the interface look in
> Test_midlevel.hs? 
> > Is there any critiques in
> >   regard to using this style in CGA (Common GUI
> API)?
> 1. Widgets aren't being given names. This makes it
> impossible to refer
> to them from outside of the code. It also eliminates
> the possibility
> of implementing a useable Xt (e.g. Motif) backend.
> Toolkits which
> don't name widgets can just ignore the name.

I'm sorry, I don't understand what you mean by
"impossible to refer to them from outside of the
code".  Can you give me an example of what you are
talking about.

> 2. Widget properties (label, position, dimension)
> are being embedded
> in the code, which is a bad idea. This point is
> closely tied in with
> point 1.

Where should this be in your opinion?

> 3. Personally, I would prefer a generic widget
> creation function,
> rather than a different function for each type of
> widget. E.g. Xt has
> XtCreateWidget(), with the widget class being passed
> as an argument.
> A more Haskell-ish approach would be to use
> typeclasses, e.g.:
> 	class Widget a where
> 		create :: String -> a -> [Property] -> IO a
> 	--	create name parent properties = ...

Why would you prefer this over the other method?  One
problem with this method seems to be runtime errors
for nonexistant classes.

David J. Sankel