Laxkit  0.0.7.1
Public Member Functions | Public Attributes
Laxkit::TimerInfo Struct Reference

The TimerInfo class is used with anXApp. More...

List of all members.

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
anXWindowwin

Detailed Description

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().

Todo:
for mouse button down timers, maybe use info field set to which button pressed, if it was a mouse timer, for instance, then have app check when the button is up, and remove the timer then?

Constructor & Destructor Documentation

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().


Member Function Documentation

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.


The documentation for this struct was generated from the following files:

Mon Feb 17 2014 11:52:58, Laxkit