|
Boost : |
From: David Turner (dkturner_at_[hidden])
Date: 2004-03-04 02:40:42
Hi
Thorsten wrote:
> "David Turner" <dkturner_at_[hidden]> wrote in message
> news:30053.165.165.239.17.1078382983.squirrel_at_webmail.telkomsa.net...
> [snip]
>> The only real problem with "why not" is that gui widgets have shallow
>> copy
>> semantics.
>
> And why is that a problem?
Because it's surprising to the user (I think).
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. If I were to use the "why not"
syntax, I would have to pass in the owner window as the first parameter of
the constructor, as in:
window w;
button b(w, "Click here");
w.contain(b);
Now consider creating a popup window. The natural syntax is:
window w;
window p(w);
But now I've invoked the copy constructor of p, which isn't what I wanted.
The way to make it work properly is to force new windows to be
constructed with a title:
window w("Example Window");
window p(w, "Popup Window");
This is probably the "best" approach, but it still leaves some room for
user error.
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