Boost logo

Boost :

From: David Turner (dkturner_at_[hidden])
Date: 2004-03-04 04:30:30


Thorsten wrote:
>
>>
>> Because it's surprising to the user (I think).
>
> more surprising than hiding the type of window?
>

Perhaps. At any rate, I'm busy changing the implementation to be more
conventional.

>> More to the point, there is a very real problem with creating popup
>> windows. Remember that the window acts as a factory for all other
>> widgets, including popup (child) windows.
>
> Hm...maybe I don't understand why it has to be that way?
[snip]
> why can't we say
>
> window w;
> w.add( button( "Click me" ) ); (*)
>

As I explained in an earlier post to Peter Dimov, there are technical
reasons why this isn't possible. Widgets have to be rooted in an owning
window, and it's not possible to transfer widgets from one window to
another. Therefore, button has to take an owner-window parameter in its
constructor.

There is a precedent for this: look at the W3C DOM.

The syntax I'm currently considering would make it:

window w("Example Window");
w.contain(button(w, "Click me"));

The inner w seems redundant at first, but bear in mind that the button
isn't necessarily going to be contained directly in the owning window. A
more usual case would be:

window w("Example Window");
grid g(w, 2, 2);
g.contain(button(w, "Click me"), 1, 1);
w.contain(g);

I could even make it:

window w("Example Window");
w.contain(w.button("Click me"));

But I think that's pushing it...

>
> window.add( new button( "Click me" ) );
>
> ?

This is even more problematic... who now owns the button?

Regards
David Turner


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk