Michael Tachyon wrote:
> There is this one excersize. It requires building a picture of clock
> and geting a callbacks from FLTK each second, witch will move my clock.
> I am aware the fltk has got a clock widget, but I dont wanna use it.
Maybe don't use it, but use it for reference on how to do it.
You'll find you'll want to do it a different way, but it can give you
ideas on implementation.
> I know how to draw and move object in a window, but I am clearly
> missing something fundamental here. I cant figure out how to implement
> callback
You probably want to use one of FLTK's timers which will invoke
your callback at the time interval you specify. I'd suggest trying
Fl::add_timeout(), eg:
http://fltk.org/doc-1.3/classFl.html#a23e63eb7cec3a27fa360e66c6e2b2e52
> What should recieve it ?
Your callback should receive it and should probably just call redraw(),
and let your draw() code handle drawing the clock face based on
whatever time it is currently.
If you don't understand callbacks, have a look at some of the video
tutorials on FLTK, eg:
http://seriss.com/people/erco/fltk-videos/
..I'd suggest the beginner's guide or the fluid intro.
Regarding callbacks: note that button callbacks (shown in that video)
and timer callbacks are basically the same type of mechanism;
"callbacks" are just functions you define that get called by FLTK,
based on how you configure FLTK to call them.
A button callback is called whenever the button is pressed.
A timer callback is called when the timer goes off.
Note that callbacks have very little context, so if you create
a clock 'class', and want the callback to have access to that class,
be sure to pass an instance of the class as 'user data' when you setup
the callback. See the video for details.
_______________________________________________
fltk mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk