FLTK 1.4.4

Loading...
Searching...
No Matches
Fl_Valuator.H
1//
2// Valuator header file for the Fast Light Tool Kit (FLTK).
3//
4// Copyright 1998-2022 by Bill Spitzak and others.
5//
6// This library is free software. Distribution and use rights are outlined in
7// the file "COPYING" which should have been included with this file. If this
8// file is missing or damaged, see the license at:
9//
10// https://www.fltk.org/COPYING.php
11//
12// Please see the following page on how to report bugs and issues:
13//
14// https://www.fltk.org/bugs.php
15//
16
17/* \file
18 Fl_Valuator widget . */
19
20#ifndef Fl_Valuator_H
21#define Fl_Valuator_H
22
23#ifndef Fl_Widget_H
24#include "Fl_Widget.H"
25#endif
26
27// shared type() values for classes that work in both directions:
28#define FL_VERTICAL 0
29#define FL_HORIZONTAL 1
30
47 class FL_EXPORT Fl_Valuator : public Fl_Widget {
48
49 double value_;
50 double previous_value_;
51 double min, max; // truncates to this range *after* rounding
52 double A; int B; // rounds to multiples of A/B, or no rounding if A is zero
53
54 protected:
56 int horizontal() const {return type()& FL_HORIZONTAL;}
57 Fl_Valuator(int X, int Y, int W, int H, const char* L);
58
60 double previous_value() const {return previous_value_;}
62 void handle_push() {previous_value_ = value_;}
63 double softclamp(double);
64 void handle_drag(double newvalue);
65 void handle_release(); // use drag() value
66 virtual void value_damage(); // cause damage() due to value() changing
68 void set_value(double v) {value_ = v;}
69
70 public:
71
73 ~Fl_Valuator() FL_OVERRIDE { }
75 void bounds(double a, double b) {min=a; max=b;}
77 double minimum() const {return min;}
79 void minimum(double a) {min = a;}
81 double maximum() const {return max;}
83 void maximum(double a) {max = a;}
104 void range(double a, double b) {min = a; max = b;}
106 void step(int a) {A = a; B = 1;}
108 void step(double a, int b) {A = a; B = b;}
109 void step(double s);
121 double step() const {return A/B;}
122 void precision(int digits);
123
125 double value() const {return value_;}
126 int value(double);
127
128 virtual int format(char*);
129 double round(double); // round to nearest multiple of step
130 double clamp(double); // keep in range
131 double increment(double, int); // add n*step to value
132};
133
134#endif
Fl_Widget.H
Fl_Widget and Fl_Label classes.
Fl_Valuator
The Fl_Valuator class controls a single floating-point value and provides a consistent interface to s...
Definition Fl_Valuator.H:47
Fl_Valuator::step
double step() const
Gets or sets the step value.
Definition Fl_Valuator.H:121
Fl_Valuator::value
double value() const
Gets the floating point(double) value.
Definition Fl_Valuator.H:125
Fl_Valuator::set_value
void set_value(double v)
Sets the current floating point value.
Definition Fl_Valuator.H:68
Fl_Valuator::step
void step(int a)
See double Fl_Valuator::step() const.
Definition Fl_Valuator.H:106
Fl_Valuator::Fl_Valuator
Fl_Valuator(int X, int Y, int W, int H, const char *L)
Creates a new Fl_Valuator widget using the given position, size, and label string.
Definition Fl_Valuator.cxx:26
Fl_Valuator::minimum
double minimum() const
Gets the minimum value for the valuator.
Definition Fl_Valuator.H:77
Fl_Valuator::range
void range(double a, double b)
Sets the minimum and maximum values for the valuator.
Definition Fl_Valuator.H:104
Fl_Valuator::~Fl_Valuator
~Fl_Valuator() FL_OVERRIDE
Destructor is accessible despite protected constructor.
Definition Fl_Valuator.H:73
Fl_Valuator::handle_push
void handle_push()
Stores the current value in the previous value.
Definition Fl_Valuator.H:62
Fl_Valuator::previous_value
double previous_value() const
Gets the previous floating point value before an event changed it.
Definition Fl_Valuator.H:60
Fl_Valuator::maximum
double maximum() const
Gets the maximum value for the valuator.
Definition Fl_Valuator.H:81
Fl_Valuator::minimum
void minimum(double a)
Sets the minimum value for the valuator.
Definition Fl_Valuator.H:79
Fl_Valuator::maximum
void maximum(double a)
Sets the maximum value for the valuator.
Definition Fl_Valuator.H:83
Fl_Valuator::bounds
void bounds(double a, double b)
Sets the minimum (a) and maximum (b) values for the valuator widget.
Definition Fl_Valuator.H:75
Fl_Valuator::step
void step(double a, int b)
See double Fl_Valuator::step() const.
Definition Fl_Valuator.H:108
Fl_Valuator::horizontal
int horizontal() const
Tells if the valuator is an FL_HORIZONTAL one.
Definition Fl_Valuator.H:56
Fl_Widget::type
uchar type() const
Gets the widget type.
Definition Fl_Widget.H:351
FL_OVERRIDE
#define FL_OVERRIDE
This macro makes it safe to use the C++11 keyword override with older compilers.
Definition fl_attr.h:46