|
Boost : |
From: Dirk Gerrits (dirk_at_[hidden])
Date: 2002-11-09 09:45:19
Aleksey Gurtovoy wrote:
> Dirk Gerrits wrote:
>
> >I still don't get it. Have I used to few widget libraries? ;)
>
>
> OK, we are drifting from the actual topic here, but I really don't
> like the
> fact that I can't express myself clearly tonight :). So, here we go:
>
> class widget_model
> {
> public:
> // ...
> typedef boost::function bool_arg_t;
>
> self_t& is_enabled(bool_arg_t a_enabled)
> {
> is_enabled_ = a_enabled;
> return *this;
> }
>
> bool is_enabled() const
> {
> return is_enabled_();
> }
>
> private:
> bool_arg_t is_enabled_;
> };
>
>
> class win32_widget_impl
> {
> public:
> win32_widget_impl( /* ... */)
> {
> // setup this->on_idle() to be called, well, on idle
> }
>
> void on_idle()
> {
> // sync itself with the model
> ::EnableWindow(hwnd_, model_->is_enabled());
> }
>
> private:
> HWND hwnd_;
> ref_ptr model_;
> };
>
> Since the model is passive here, everything works as per my first example
> (given 'widget' -> 'widget_model' substitution).
Ahh, now I understand. Looks cool indeed. However I'm not sure how often
this might be useful. Perhaps smarter people than I can think of more
examples?
Dirk
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk