On Mar 18, 2007, at 8:01 PM, imm wrote:

> Drawing into your widget outside the ::draw() method of the widget is
> not supported.

Oh, yes, Ian is right. I read only part of the post again, I'm  
afraid. The correct way to do this - and that will make my comment on  
the matrix clearer as well, is below. What you do only works because  
you have only a single window. If you had more, or opened a dialog  
box at some point, no drawing would appear any more at all. And no  
drawing would appear on any platforms either.

You draw into widgets by creating a derived widget with a custom void  
draw() function. You wil never call draw() manually, but instead call  
redraw(). FLTK will then schedule a screen refresh at a later point  
in time. You can suggest earlier drawing by calling Fl::fush(). So  
here's some code:

http://seriss.com/people/erco/fltk/#FltkX

Now if you need to have this kinfd of busy loop, just replace the  
Fl::run() with:

while (Fl_X::first) {
   wait(0.0);
   myCalculations();
}

Or, as I mentioned before, use Fl::set_idle() <http://www.fltk.org/ 
documentation.php/doc-1.1/Fl.html#Fl.set_idle> or Fl::add_timeout()  
<http://www.fltk.org/documentation.php/doc-1.1/Fl.html#Fl.add_timeout>.

Maybe it now becomes clear why the matrix is not preserved between  
individual calls to DrawX::draw(). It would mean that we have to  
store an entire matrix for each widget in your application, just in  
case you may want to manipulate it. It is much more economic to let  
the application programmer do that himself if desired, and it is  
simple, too, because the Widget is a derived class anyways, so it  
provides the interface for custom variables already.

Matthias

----
http://robowerk.com/


_______________________________________________
fltk mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk

Reply via email to