Jens Grunert wrote:
> How do I make the Fl_Scroll widget automatically redraw the window when I
> move the sliders?
>
> In the little program below I'm able to move the image with the sliders but
> to refresh the screen I have to resize the main window.
Widgets are responsible for their backgrounds..
be sure to draw a rectf() (and not just a rect()) for your widgets.
Note the scroller combines screen-to-screen copying to optimize
scrolling,
and only calls your draw routine to draw the little parts that are
revealed.
Here's a modified version of your app:
#include <FL/Fl.H>
#include <FL/fl_draw.H>
#include <FL/Fl_Double_Window.H>
#include <FL/Fl_Scroll.H>
class Draw : public Fl_Widget {
public:
Draw(long int x, long int y, long int w, long int h, const char *l=0) :
Fl_Widget(x, y ,w ,h, l) {}
void draw() {
fl_color(FL_RED);
fl_rectf(x(), y(), w(), h()); // *** draw your widget's background
fl_color(FL_BLACK);
fl_rect(x(), y(), w(), h());
}
};
int main() {
Fl_Double_Window win(800,800); // I changed the window size
Fl_Scroll scroll(10,10,800-20,800-20); // to be more manageable for my
screen: shouldn't matter
Draw *draw;
for(int i = 0; i < 100; i+=10) { // smaller number of widgets,
different
draw = new Draw(10+i*10,10+i*10,400,400); // logic for window placement:
shouldn't matter
}
scroll.end();
win.resizable(scroll);
win.end();
win.show();
return(Fl::run());
}
_______________________________________________
fltk mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk