Laxkit
0.0.7.1
|
The TimerInfo class is used with anXApp. More...
Public Member Functions | |
TimerInfo (anXWindow *nwin, int duration, int firstt, int tickt, int nid, long ninfo) | |
int | checktime (clock_t tm) |
Check if a tick needs to be sent, and call win->Idle(id) if necessary. |
Public Attributes | |
int | id |
long | info |
clock_t | endtime |
clock_t | firsttick |
clock_t | ticktime |
clock_t | nexttime |
anXWindow * | win |
The TimerInfo class is used with anXApp.
Timers can be added to any window, by calling anXApp::addtimer() or anXApp::addmousetimer(), and if they don't automatically expire, are deleted with anXApp::removetimer(). Users shouldn't actually have to deal with TimerInfo structs directly. addtimer returns a timerid, which is later passed to anXWindow::Idle().
Laxkit::TimerInfo::TimerInfo | ( | anXWindow * | nwin, |
int | duration, | ||
int | firstt, | ||
int | tickt, | ||
int | nid, | ||
long | ninfo | ||
) |
All the time values are passed in as milliseconds, but internally, they are converted to clock ticks. If duration==-1, then duration is taken to be 1 million, which is 1000 hours.
For the span of the timer, win->Idle(timer->id) is called every tickt milliseconds (the first tick is sent after firstt milliseconds), until the time is after the current time plus duration.
Please not that if the current time is several ticks ahead of the last tick, then only one tick is sent to Idle().
int Laxkit::TimerInfo::checktime | ( | clock_t | tm | ) |
Check if a tick needs to be sent, and call win->Idle(id) if necessary.
Updates nexttime, which is the next time at which a tick should occur. Returns -1 if the timer has expired, else return the number of ticks that have happened. Thus, 0 means a tick has not occured. If a window.Idle(id) returns nonzero, then anXApp removes the timer.