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

#### 17.5.4 Other Counter Routines

To change the value of the counter, it’s bounds and stp size use the routines

    void fl_set_counter_value(FL_OBJECT *obj, double val);
    void fl_set_counter_bounds(FL_OBJECT *obj, double min, double max);
    void fl_set_counter_step(FL_OBJECT *obj, double small, double large);

The first routine sets the value (default is 0) of the counter, the second routine sets the minimum and maximum values that the counter will take (default are -1000000 and 1000000, respectively) and the third routine sets the sizes of the small and large steps (defaults to 0.1 and 1). (For simple counters only the small step is used.)

For conflicting settings, bounds take precedence over value, i.e., if setting a value that is outside of the current bounds, it is clamped. Also changing the bounds in a way that the current counter value isn’t within the new bounds range anymore will result in its value being adjusted to the nearest of the new limits.

To obtain the current value of the counter use

    double fl_get_counter_value(FL_OBJECT *obj);

To obtain the current bounds and steps, use the following functions

    void fl_get_counter_bounds(FL_OBJECT *obj, double *min, double *max);
    void fl_get_counter_step(FL_OBJECT *obj, double *small, double *large);

To set the precision (number of digits after the dot) with which the counter value is displayed use the routine

    void fl_set_counter_precision(FL_OBJECT *obj, int prec);

To determine the current value of the precision use

    int fl_get_counter_precision(FL_OBJECT *obj);

By default, the value shown is the counter value in floating point format. You can override the default by registering a filter function using the following routine

    void fl_set_counter_filter(FL_OBJECT *obj,
                               const char *(*filter)(FL_OBJECT *,
                                                     double value,
                                                     int prec));

where `value` and `prec` are the counter value and precision respectively. The filter function `filter` should return a string that is to be shown. Note that the default filter is equivalent to the following

    const char *filter(FL_OBJECT *obj, double value, int prec) {
        static char buf[32];

         sprintf(buf, "%.*f",prec,value);
         return buf;
    }

By default the counter value changes first slowly and the rate of change then accelerates until a final speed is reached. The default delay between value changes is 600 ms at the start and the final delay is 50 ms. You can change the initial delay by a call of the function

    void fl_set_counter_repeat(FL_OBJECT *obj, int millisec);

and the final delay by using

    void fl_set_counter_min_repeat(FL_OBJECT *obj, int millisec);

where in both cases the argument `millisec` is the delay in milli-seconds. The current settings for the initial and final delay can be obtained by calling the functions

    int fl_get_counter_repeat(FL_OBJECT *obj);
    int fl_get_counter_min_repeat(FL_OBJECT *obj);

Until version 1.0.91 of the library the delay between changes of a counter was constant (with a default value of 100 ms). To obtain this traditional behaviour simple set the initial and final delay to the same value.

As a third alternative you can also request that only the first change of the counter has a different delay from all the following ones. To achieve this call

    void fl_set_counter_speedjump(FL_OBJECT *obj, int yes_no);

with a true value for `yes_no`. The delay for the first change of the counter value will then be the one set by `fl_set_counter_repeat()` and the following delays last as long as set by `fl_set_counter_min_repeat()`.

To determine the setting for "speedjumping" call

    int fl_get_counter_speedjump(FL_OBJECT *obj);

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