Added has_timeout() and has_idle() calls as suggested by Eric Sven Ristad.

git-svn-id: file:///fltk/svn/fltk/branches/branch-1.0@1214 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
This commit is contained in:
Bill Spitzak 2000-06-16 07:28:03 +00:00
parent 084b19e305
commit 4dd096e7b5
4 changed files with 36 additions and 7 deletions

View File

@ -1,5 +1,5 @@
// //
// "$Id: Fl.H,v 1.8.2.6 2000/06/05 21:20:18 mike Exp $" // "$Id: Fl.H,v 1.8.2.7 2000/06/16 07:27:57 bill Exp $"
// //
// Main header file for the Fast Light Tool Kit (FLTK). // Main header file for the Fast Light Tool Kit (FLTK).
// //
@ -91,12 +91,14 @@ public:
static FL_EXPORT int run(); static FL_EXPORT int run();
static FL_EXPORT Fl_Widget* readqueue(); static FL_EXPORT Fl_Widget* readqueue();
static FL_EXPORT void add_timeout(double t, Fl_Timeout_Handler,void* = 0); static FL_EXPORT void add_timeout(double t, Fl_Timeout_Handler,void* = 0);
static FL_EXPORT int has_timeout(Fl_Timeout_Handler, void* = 0);
static FL_EXPORT void remove_timeout(Fl_Timeout_Handler, void* = 0); static FL_EXPORT void remove_timeout(Fl_Timeout_Handler, void* = 0);
static FL_EXPORT void add_fd(int fd, int when, void (*cb)(int,void*),void* =0); static FL_EXPORT void add_fd(int fd, int when, void (*cb)(int,void*),void* =0);
static FL_EXPORT void add_fd(int fd, void (*cb)(int, void*), void* = 0); static FL_EXPORT void add_fd(int fd, void (*cb)(int, void*), void* = 0);
static FL_EXPORT void remove_fd(int, int when); static FL_EXPORT void remove_fd(int, int when);
static FL_EXPORT void remove_fd(int); static FL_EXPORT void remove_fd(int);
static FL_EXPORT void add_idle(void (*cb)(void*), void* = 0); static FL_EXPORT void add_idle(void (*cb)(void*), void* = 0);
static FL_EXPORT int has_idle(void (*cb)(void*), void* = 0);
static FL_EXPORT void remove_idle(void (*cb)(void*), void* = 0); static FL_EXPORT void remove_idle(void (*cb)(void*), void* = 0);
static FL_EXPORT int damage() {return damage_;} static FL_EXPORT int damage() {return damage_;}
static FL_EXPORT void redraw(); static FL_EXPORT void redraw();
@ -211,5 +213,5 @@ public:
#endif #endif
// //
// End of "$Id: Fl.H,v 1.8.2.6 2000/06/05 21:20:18 mike Exp $". // End of "$Id: Fl.H,v 1.8.2.7 2000/06/16 07:27:57 bill Exp $".
// //

View File

@ -230,8 +230,10 @@ but <TT>Fl::ready()</TT> does not.</P>
something that calls <TT>Fl::wait()</TT> or <TT>Fl::check()</TT> (such something that calls <TT>Fl::wait()</TT> or <TT>Fl::check()</TT> (such
as a message pop-up) you should first remove the idle callback so that as a message pop-up) you should first remove the idle callback so that
it does not recurse. </P> it does not recurse. </P>
<H3><A name=add_timeout>static void Fl::add_timeout(float t, void <H3><A name=add_timeout>static void Fl::add_timeout(float t, void
(*cb)(void *),void *v=0)</A></H3> (*cb)(void *),void *v=0)</A></H3>
Add a one-shot timeout callback. The timeout will happen as soon as Add a one-shot timeout callback. The timeout will happen as soon as
possible after <TT>t</TT> seconds after the last time <TT>wait()</TT> possible after <TT>t</TT> seconds after the last time <TT>wait()</TT>
was called. The optional <TT>void *</TT> argument is passed to the was called. The optional <TT>void *</TT> argument is passed to the
@ -657,9 +659,22 @@ while (!calculation_done()) {
</UL> </UL>
<H3><A name=redraw>static void Fl::redraw()</A></H3> <H3><A name=redraw>static void Fl::redraw()</A></H3>
Redraws all widgets. Redraws all widgets.
<H3><A name=has_idle>static int Fl::has_idle(void (*cb)(void *),
void *= 0)</A></H3>
Returns true if the specified idle callback is currently installed.
<H3><A name=remove_idle>static void Fl::remove_idle(void (*cb)(void *), <H3><A name=remove_idle>static void Fl::remove_idle(void (*cb)(void *),
void *= 0)</A></H3> void *= 0)</A></H3>
Removes the specified idle callback.
Removes the specified idle callback, if it is installed.
<H3><A name=has_timeout>static int Fl::has_timeout(void
(*cb)(void *), void *= 0)</A></H3>
Returns true if the timeout exists and has not been called yet.
<H3><A name=remove_timeout>static void Fl::remove_timeout(void <H3><A name=remove_timeout>static void Fl::remove_timeout(void
(*cb)(void *), void *= 0)</A></H3> (*cb)(void *), void *= 0)</A></H3>
Removes a timeout callback. It is harmless to remove a timeout Removes a timeout callback. It is harmless to remove a timeout

View File

@ -1,5 +1,5 @@
// //
// "$Id: Fl.cxx,v 1.24.2.25 2000/06/10 21:30:59 bill Exp $" // "$Id: Fl.cxx,v 1.24.2.26 2000/06/16 07:28:02 bill Exp $"
// //
// Main event handling code for the Fast Light Tool Kit (FLTK). // Main event handling code for the Fast Light Tool Kit (FLTK).
// //
@ -102,6 +102,12 @@ void Fl::add_timeout(double t, Fl_Timeout_Handler cb, void *v) {
numtimeouts++; numtimeouts++;
} }
int Fl::has_timeout(void (*cb)(void *), void *v) {
for (int i=0; i<numtimeouts; i++)
if (timeout[i].cb == cb && timeout[i].arg==v) return 1;
return 0;
}
void Fl::remove_timeout(Fl_Timeout_Handler cb, void *v) { void Fl::remove_timeout(Fl_Timeout_Handler cb, void *v) {
int i,j; int i,j;
for (i=j=0; i<numtimeouts; i++) { for (i=j=0; i<numtimeouts; i++) {
@ -721,5 +727,5 @@ void Fl_Window::flush() {
} }
// //
// End of "$Id: Fl.cxx,v 1.24.2.25 2000/06/10 21:30:59 bill Exp $". // End of "$Id: Fl.cxx,v 1.24.2.26 2000/06/16 07:28:02 bill Exp $".
// //

View File

@ -1,5 +1,5 @@
// //
// "$Id: Fl_add_idle.cxx,v 1.4.2.3 2000/06/05 21:21:00 mike Exp $" // "$Id: Fl_add_idle.cxx,v 1.4.2.4 2000/06/16 07:28:03 bill Exp $"
// //
// Idle routine support for the Fast Light Tool Kit (FLTK). // Idle routine support for the Fast Light Tool Kit (FLTK).
// //
@ -63,6 +63,12 @@ void Fl::add_idle(void (*cb)(void*), void* data) {
} }
} }
int Fl::has_idle(void (*cb)(void*), void* data) {
for (idle_cb* p = first; p != last; p = p->next)
if (p->cb == cb && p->data == data) return 1;
return 0;
}
void Fl::remove_idle(void (*cb)(void*), void* data) { void Fl::remove_idle(void (*cb)(void*), void* data) {
idle_cb* p = first; idle_cb* p = first;
if (!p) return; if (!p) return;
@ -84,5 +90,5 @@ void Fl::remove_idle(void (*cb)(void*), void* data) {
} }
// //
// End of "$Id: Fl_add_idle.cxx,v 1.4.2.3 2000/06/05 21:21:00 mike Exp $". // End of "$Id: Fl_add_idle.cxx,v 1.4.2.4 2000/06/16 07:28:03 bill Exp $".
// //