Other Timer Routines (XForms (Forms Library) - Version 1.2 (Rev. 4) A Graphical User Interface Toolkit for X)

Next: Timer Attributes, Previous: Timer Interaction, Up: Timer Object [Contents][Index]

#### 21.1.4 Other Timer Routines

To set the timer to a particular value use

    void fl_set_timer(FL_OBJECT *obj, double delay);

`delay` gives the number of seconds the timer should run. Use 0.0 to reset/de-blink the timer.

To obtain the time left in the timer use

    double fl_get_timer(FL_OBJECT *obj);

By default, a timer counts down toward zero and the value shown (for `FL_VALUE_TIMER`s) is the time left until the timer expires. You can change this default so the timer counts up and shows elapsed time by calling

    void fl_set_timer_countup(FL_OBJECT *obj, int yes_no);

with a true value for the argument `yes_no`.

A timer can be temporarily suspended (stopwatch) using the following routine

    void fl_suspend_timer(FL_OBJECT *obj);

and later be resumed by

    void fl_resume_timer(FL_OBJECT *obj);

Unlike `fl_set_timer()` a suspended timer keeps its internal state (total delay, time left etc.), so when it is resumed, it starts from where it was suspended.

Finally there is a routine that allows the application program to change the way the time is presented in `FL_VALUE_TIMER`:

    typedef char *(FL_TIMER_FILTER)(FL_OBJECT *obj, double secs);
    FL_TIMER_FILTER fl_set_timer_filter(FL_OBJECT *obj,
                                        FL_TIMER_FILTER filter);

The function `filter` receives the timer ID and the time left for count-down timers and the elapsed time for up-counting timers (in units of seconds) and should return a string representation of the time. The default filter returns the time in a `hour:minutes:seconds.fraction` format.

Next: Timer Attributes, Previous: Timer Interaction, Up: Timer Object [Contents][Index]