|
Boost : |
From: Vladimir Prus (ghost_at_[hidden])
Date: 2004-03-04 09:49:41
Peter Dimov wrote:
> > window make_graph_widget()
> > {
> > windows w;
> > w.on_draw = &draw_the_graph;
> > w.on_mouse_click = &handle_click;
> > w.on_mouse_right_click = &handle_right_click;
> > return w;
> > }
> > and isn't this too complex a solution?
>
> No. The alternative solution is comparable in complexity,
Well, except for impicit *this pointer, which makes member function a bit
easier to write.
> and as soon as
> you add another graph widget that has different left or right click
> behaviors, or make w change its appearance dynamically on response to a
> combo box cb (by just assigning different drawing functions to w.on_draw in
> cb.on_change), you'll see why the event-based model is superior.
Good point. Okay, if I ever get to implement my graph drawer and the proposed
library will be mature enough, I'll see how this approach works out.
> It's not a
> new invention, just look at Delphi.
Last time I tried, a click on event created a method linked to that event.
Ah... nothing prevents me to implement 'on_draw' as member functions bound to
the signal. Yes, that's definititely similiar.
- Volodya
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk