> Here's another approach, in outline (nb uncompiled/untested),
> that you can consider.
>
> class Control {
> public:
>     virtual void set_value(int) = 0;
>     virtual int get_value() const = 0;
> };
> class Slider : public Fl_Slider, public Control {
> public:
>     Slider(int x, int y, int w, int h, char const* label = 0)
>         : Fl_Slider(x, y, w, h, label)
>     {;}
>     void set_value(int v) { Fl_Slider::value(v); }
>     int get_value() const { return Fl_Slider::value(); }
> };
>
> // similarly for other classes of interest
>
> Then, store a container of Control*, and proceed as Ian
> and others have suggested.
>
> To me it's more attractive than switch/case logic, but of course
> decide for yourself.
>
> HTH,
> Stan

Hey Stan,

I am wondering if you meant Slider* when you said "Then, store a container of 
Control*,...". Container would be an array right? Do you mean i should have two 
containers, one for the Control* and one for the Slider*? I think I am coming 
closer to understand this approach. I just have no idea what i should do with 
an container of Control*. :)

I mean, as far as i understand, if I use your approach, and create an array of 
10 Sliders, I could do array[id]->set_value. So what would I need a container 
of Control* for?

Jan
_______________________________________________
fltk mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk

Reply via email to