Manoj wrote:
> Now it's ok but there is still some problem in drawing.
> Problem is that sometimes redraw function doesn't call
> the draw function. Since i'm doing everything in draw
> so sometimes i dont see correct data.

        Note: redraw() doesn't call draw(), it schedules FLTK to
        call draw() on the next iteration of the FLTK event loop.

> I dont draw the rectangle everytime. I'm drawing rectangle on mouse move 
> event.

        Hmm, you /shouldn't/ be calling drawing functions from within
        the event loop.. that's outside the draw() function.
        Drawing functions should only be called from within draw().

        It's up to you to have all your drawing code in the draw()
        function, and have your event loop set things up so your
        draw() function knows what to draw later, eg:

void SetSpecialRect(int x, int y, int w, int h) {
    special_rect[0] = x;
    special_rect[1] = y;
    special_rect[2] = w;
    special_rect[3] = h;
    do_rect = 1;
    redraw();
}
// YOUR EVENT HANDLER
int handle(int e) {
         if ( a ) { SetSpecialRect(0,0,20,200); }
    else if ( b ) { SetSpecialRect(21,0,20,200); }
    else if ( c ) { SetSpecialRect(21,0,20,200); }
}
// YOUR DRAW HANDLER
void draw() {
    if ( do_rect ) {
        fl_rect(special_rect[0],
                special_rect[1],
                special_rect[2],
                special_rect[3]);
        do_rect = 0;
    }
}

> And when y >300 or y <200 then no rectangle should be drawn.
> So in mouse move function when y<200 i need to call redraw
> so that previous rectangle will erase.

        You should maybe look at:
        http://seriss.com/people/erco/fltk/#DrawCoords

> And one more problem is that program takes some time to draw a rectangle.

        It should draw /very/ fast.
_______________________________________________
fltk mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk

Reply via email to