Michael Sweet wrote:
> PaoloItaly wrote:
>> FL_FLAT_BOX don't look at Fl::draw_box_active().
> In general, FL_FLAT_BOX is used to just fill with the standard
> background color, which doesn't change for inactive widgets.
>
We should also set the active/inactive flag during label/image drawings.
This would allow the user ie construction of automatic on-demand
active/inactive images like:
template <typename T>
class Fl_Double_Image: public T{
Fl_Image * inactive_image;
public:
void draw(int x, int y, int w, int h, int cx = 0, int cy = 0){
if(Fl::draw_box_active())
T::draw(x, y, w, h, cx, cy);
else{
if(!inactive_image){
inactive_image = this->copy();
inactive_image->deactivate();
}
inactive_image->draw(x, y, w, h, cx, cy);
}
}
void uncache(){
delete inactive_image;
inactive_image = 0;
T::uncache();
}
~Fl_Double_Image(){delete imactive_image;}
// All possible constructors with automatic type guess
template <typename A1> // single argument constructor
Fl_Double_Image(A1 a1):T(a1), inactive_image(0){}
template <typename A1, typename A2> // double argument constructor
Fl_Double_Image(A1 a1, A2 a2):T(a1, a2), inactive_image(0){}
template <typename A1, typename A2, typename A3> // 3 args
Fl_Double_Image(A1 a1, A2 a2, A3 a3):T(a1, a2, a3),
inactive_image(0){}
template <typename A1, typename A2, typename A3, typename A4>
Fl_Double_Image(A1 a1, A2 a2, A3 a3, A4 a4)
:T(a1, a2, a3, a4),inactive_image(0){}
template <typename A1, typename A2, typename A3, typename A4,
typename A5>
Fl_Double_Image(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5)
:T(a1, a2, a3, a4, a5),inactive_image(0){}
};
and use it in a standard way:
Fl_PNG_Image * im = new Fl_Double_Image<Fl_PNG_Image>("my/image.png");
my_widget->image(im);
which would construct internal inactive version on demand only if such a
version is required.
The better name for the function would be Fl::draw_widget_active() but
we can keep the old name for compatibility reasons.
Note that Fl_Double_Image would not be a part of the library but this
flag generalization would allow the user to make such a custom class.
Later on we could add some fltk-templated additions (ie in /contrib
subdirectory) which could include this, calback/signal/slot libs and
maybe more from "the best of baasar", preferably as pure headers - no
source object files.
R.
_______________________________________________
fltk mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk