> If you draw the line first, then the rectangle, the line will not be
> entirely visible. The rectangle will draw over it.
Yes it's true i should draw the rectangle first otherwise line will not be
visible. 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.
I dont draw the rectangle everytime. I'm drawing rectangle on mouse move event.
Let me explain it.
suppose current mouse position we take in x and y
My window size is (0,0,200,300) and line/rectangle drawing area is
(0,0,200,200). i want when i move the mouse where y>200 then rectangle should
be drawn in line area. Also i divide the x range by difference of 20. So there
will be total 10 rectangles. like
if(y > 200 && y < 300) // x/y is mouse position
{
if(x<20)
draw rectangle at (0,0,20,200)
else if x<40
draw rectangle at (21,0,20,200)
else if x<60
draw rectangle at (41,0,20,200)
......
}
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. and when y>200 and y<300 again i call redraw to draw the
rectangle. Also when x move from 20 to 21 (or 40 to 41) i again call redraw so
that rectangle at (0,0,20,200) should be erase otherwise it'll still apeear.
So in mouse move function i check x and y coordinates and pass to member of
class and call the redraw function which will call draw function of class where
line and rectangle are drawn.
For that i create a class from Fl_Double_Window And in its draw function first
i draw rectangle then line. But for rectangle i check the y value.
When i move the mouse for y>200 && y<300 then rectangle is drawn. And when
y<200 it's not drawn.
But when y>200 && y<300
suppose x<20 then rectangle draw at (0,0,20,200). but when i move the mouse
where x<40 and x>20 then rectangle at (21,0,20,200) is draw but previous
rectangle still appear because when mouse is moved from 20(x) to 21(x) the draw
function is not called by redraw. While in mouse move function i'm checking if
previous x value was less then 20 and current value is greater than 20 then i
call the redraw function.
when y<200 or y>300 then redraw calls draw function.
And one more problem is that program takes some time to draw a rectangle.
> > Either some problem in my code or something else. Let me try to
> > draw rectangle before line.
Please wait for that i'll send it ASAP.
Thanks
_______________________________________________
fltk mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk