[GUI] Are windows just ordinary widgets?

Wolfgang Thaller wolfgang.thaller@gmx.net
Mon, 28 Apr 2003 19:30:16 +0200


Glynn Clements wrote:

> Wolfgang Thaller wrote:
>
>> Now perhaps we want a common datatype "Widget" with functions
>>      toWidget :: Widget w => w -> Widget
>> and fromWidget :: Widget w => Widget -> Maybe w
>>
>> Perhaps we want a datatype "Pane" (or "Control" or whatever) with
>> 	toPane :: Pane p => p -> Pane
>> and so on.
>
> I don't see the point in this. If you have classes, then surely you
> don't need the types?

The example implementation already had a "Widget" type; a Widget type 
would be necessary when you want to have heterogenous lists of widgets.
That's why somebody brought up the idea of having the toWidget and 
fromWidget functions; Nobody protested when the idea was first 
proposed, so I assumed that it was agreed.
If such a generic type is used, that has certain implications for the 
implementation; the fltk-based example uses one generic type "Widget" 
along with specialized types "Window", "Button" and "Box", each of 
which is an instance of Widget (with methods toWidget and fromWidget).
I was just pointing out that this specific choice of just one generic 
type for both Windows and other Widgets was impractical for the Mac OS 
implementation.

Cheers,

Wolfgang