[GUI] Are windows just ordinary widgets?
Wolfgang Thaller
wolfgang.thaller@gmx.net
Mon, 28 Apr 2003 16:25:43 +0200
MacOS treats windows and "controls" (i.e. widgets inside a window) as
completely different things. Most other platforms treat them as
essentially the same things. Which route should the CGA go?
The situation seems to be something like this:
+ Widget
everything that occupies space within some coordinate system.
Has attributes like size.
- Window
A toplevel Window. There will be several variants of this, for
document windows, dialog boxes etc.
+ Pane
A widget "inside" a window (a window has panes -
I've seen this name somewhere, feel free to suggest a more standard
one)
- Button
- GridBox
- Label
- etc.
"Container" could be a class outside this hierarchy, implemented by
"Window", "GridBox" and a few other widgets.
A Container would only contain Panes, never other widgets.
The relationship between a window and a window-modal dialog window has
nothing to do with the relationship between a window and a button
inside that window, IMHO, so they shouldn't be expressed using the same
parent/child relationship.
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.
If I had a "Pane" datatype, I wouldn't really need the "Widget"
anymore, but of course, one can never know.
The "Pane" datatype would be the natural place to implement a lot of
functionality at least on Mac OS, so if it's there, I'm happy, and I
could then implement a Widget datatype as a simple discriminated union
datatype. If there was no Pane datatype, the implementation for the
widget datatype would become slightly ugly and inelegant on Mac OS...
Cheers,
Wolfgang