Next: Slider Remarks, Previous: Other Slider Routines, Up: Slider Object [Contents][Index]

#### 17.1.5 Slider Attributes

Never use `FL_NO_BOX` as the boxtype for a slider. For `FL_VERT_NICE_SLIDER`s and `FL_HOR_NICE_SLIDER`s it’s best to use a `FL_FLAT_BOX` in the color of the background to get the nicest effect.

The first color argument (`col1`) to `fl_set_object_color()` controls the color of the background of the slider, the second (`col2`) the color of the slider itself.

You can control the size of the slider inside the box using the routine

    void fl_set_slider_size(FL_OBJECT *obj, double size);

`size` should be a floating point value between 0.0 and 1.0. The default is `FL_SLIDER_WIDTH`, which is 0.1 for regular sliders and 0.15 for browser sliders. With a value for `size` of 1.0, the slider covers the box completely and can no longer be moved. This function does nothing if applied to sliders of type `NICE_SLIDER` and `FILL_SLIDER`.

To obtain the current setting of the slider size use

    double fl_get_slider_size(FL_OBJECT *obj);

The routine

    void fl_set_slider_precision(FL_OBJECT *obj, int prec);

sets the precision with which the value of the slider is shown. This only applies to sliders showing their value, i.e., valsliders. The argument must be between 0 and `FL_SLIDER_MAX_PREC` (currently set to 10).

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

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

where `value` and `prec` are the slider value and precision respectively. The filter function `filter` should return a string that is to be shown. 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;
    }

Next: Slider Remarks, Previous: Other Slider Routines, Up: Slider Object [Contents][Index]