> int Fl_Graphic::handle (int e)
> {
> int ret = Fl_Box::handle(e);
> switch (e)
> {
> case FL_PUSH:
> pushes++;
> draw_point ();
> return(1);
> }
> return(ret);
> }
>
> I don't know if that will fix your problem, but either way
> it needs to be fixed.
>
> You have to pass events down to the class you're deriving from
> so it can handle the events you don't. There are many events,
> including stuff to do with window reveals and focus that have
> to be passed down for things to work correctly.
>
> Note too, the return value from handle() is supposed to be
> 0 or 1, not the event itself.
I ran your program ('How to Draw an X') and it worked correctly.
Then, I modified it. Now the program draws a vertical line everytime I click on
it. So, the issue appeared again. If I move a window of another program over my
window, the last vertical lines are not redrawn.
Thanks again.
// DEMONSTRATE HOW TO DRAW vertical lines IN FLTK
#include <FL/Fl.H>
#include <FL/fl_draw.H>
#include <FL/Fl_Double_Window.H>
// SIMPLE WIDGET THAT DRAWS (Now vertical lines)
class DrawX : public Fl_Widget {
private:
int lines;
public:
DrawX(int X, int Y, int W, int H, const char*L=0) : lines (0),
Fl_Widget(X,Y,W,H,L) {
}
void draw() {
// DRAW BLACK vertical lines
fl_color(FL_BLACK);
int x1 = x();
int y1 = y(), y2 = y()+h()-1;
for (int i = 1; i <= lines; i++)
{
fl_line(x1 + 10 * i, y1, x1 + 10 * i, y2);
}
}
int handle (int e) {
// DRAW vertical lines
int ret = Fl_Widget::handle (e);
switch (e) {
case FL_PUSH:
lines++;
int x1 = x();
int y1 = y(), y2 = y()+h()-1;
fl_line(x1 + 10 * lines, y1, x1 + 10 * lines, y2);
return (1);
}
return (ret);
}
};
int main() {
Fl_Double_Window win(200,200,"Draw vertical lines");
DrawX draw_x(0, 0, win.w(), win.h());
win.resizable(draw_x);
win.show();
return(Fl::run());
}
_______________________________________________
fltk mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk