39 # include <FL/Fl_Group.H>
40 # include <FL/Fl_Input.H>
41 # include <FL/Fl_Repeat_Button.H>
68 if (w == &(sb->input_)) {
70 v = atof(sb->input_.
value());
72 if (v < sb->minimum_) {
73 sb->value_ = sb->minimum_;
75 }
else if (v > sb->maximum_) {
76 sb->value_ = sb->maximum_;
78 }
else sb->value_ = v;
79 }
else if (w == &(sb->up_button_)) {
81 v = sb->value_ + sb->step_;
83 if (v > sb->maximum_) sb->value_ = sb->minimum_;
87 }
else if (w == &(sb->down_button_)) {
89 v = sb->value_ - sb->step_;
91 if (v < sb->minimum_) sb->value_ = sb->maximum_;
102 if (format_[0]==
'%'&&format_[1]==
'.'&&format_[2]==
'*') {
106 char temp[64], *sp = temp;
107 sprintf(temp,
"%.12f", step_);
110 while (sp>temp && *sp==
'0') sp--;
111 while (sp>temp && (*sp>=
'0' && *sp<=
'9')) { sp--; c++; }
112 sprintf(s, format_, c, value_);
114 sprintf(s, format_, value_);
128 input_(X, Y, W - H / 2 - 2, H),
129 up_button_(X + W - H / 2 - 2, Y, H / 2 + 2, H / 2,
"@-42<"),
130 down_button_(X + W - H / 2 - 2, Y + H - H / 2,
131 H / 2 + 2, H / 2,
"@-42>") {
143 input_.type(FL_INT_INPUT);
153 const char *
format() {
return (format_); }
155 void format(
const char *f) { format_ = f; update(); }
162 up_button_.do_callback();
165 down_button_.do_callback();
170 if (input_.take_focus())
return 1;
190 void range(
double a,
double b) { minimum_ = a; maximum_ = b; }
191 void resize(
int X,
int Y,
int W,
int H) {
194 input_.resize(X, Y, W - H / 2 - 2, H);
195 up_button_.resize(X + W - H / 2 - 2, Y, H / 2 + 2, H / 2);
196 down_button_.resize(X + W - H / 2 - 2, Y + H - H / 2,
204 double step()
const {
return (step_); }
208 if (step_ != (
int)step_) input_.type(FL_FLOAT_INPUT);
209 else input_.type(FL_INT_INPUT);
214 return (input_.textcolor());
222 return (input_.textfont());
230 return (input_.textsize());
247 if (v==FL_FLOAT_INPUT) {
255 double value()
const {
return (value_); }
261 void value(
double v) { value_ = v; update(); }
264 #endif // !Fl_Spinner_H
Do the callback when the button or key is released and the value changes.
Definition: Enumerations.H:309
void type(uchar v)
Sets the numeric representation in the input field.
Definition: Fl_Spinner.H:246
Fl_Fontsize textsize() const
Gets the size of the text in the input field.
Definition: Fl_Spinner.H:229
double step() const
Sets or returns the amount to change the value when the user clicks a button.
Definition: Fl_Spinner.H:204
void textsize(Fl_Fontsize s)
Sets the size of the text in the input field.
Definition: Fl_Spinner.H:233
double maximum() const
Gets the maximum value of the widget.
Definition: Fl_Spinner.H:180
#define FL_Up
The up arrow key.
Definition: Enumerations.H:342
This indicates an attempt to give a widget the keyboard focus.
Definition: Enumerations.H:161
uchar type() const
Gets the numeric representation in the input field.
Definition: Fl_Spinner.H:239
Do the callback when the user presses the ENTER key and the value changes.
Definition: Enumerations.H:311
void end()
Exactly the same as current(this->parent()).
Definition: Fl_Group.cxx:80
A key was pressed (FL_KEYDOWN) or released (FL_KEYUP).
Definition: Enumerations.H:188
double maxinum() const
Speling mistakes retained for source compatibility.
Definition: Fl_Spinner.H:178
int handle(int event)
Handles the specified event.
Definition: Fl_Spinner.H:157
void value(double v)
Sets the current value of the widget.
Definition: Fl_Spinner.H:261
Fl_Font textfont() const
Gets the font of the text in the input field.
Definition: Fl_Spinner.H:221
The Fl_Group class is the FLTK container widget.
Definition: Fl_Group.H:45
Fl_Color textcolor() const
Gets the color of the text in the input field.
Definition: Fl_Spinner.H:213
This file contains type definitions and general enumerations.
void textfont(Fl_Font f)
Sets the font of the text in the input field.
Definition: Fl_Spinner.H:225
int handle(int)
Handles the specified event.
Definition: Fl_Group.cxx:150
double value() const
Gets the current value of the widget.
Definition: Fl_Spinner.H:255
const char * format()
Sets or returns the format string for the value.
Definition: Fl_Spinner.H:153
void minimum(double m)
Sets the minimum value of the widget.
Definition: Fl_Spinner.H:188
double minimum() const
Gets the minimum value of the widget.
Definition: Fl_Spinner.H:186
#define FL_Down
The down arrow key.
Definition: Enumerations.H:344
int Fl_Fontsize
Size of a font in pixels.
Definition: Enumerations.H:741
This widget is a combination of the input widget and repeat buttons.
Definition: Fl_Spinner.H:51
void resize(int, int, int, int)
Resizes the Fl_Group widget and all of its children.
Definition: Fl_Group.cxx:637
void maximum(double m)
Sets the maximum value of the widget.
Definition: Fl_Spinner.H:182
unsigned int Fl_Color
an FLTK color value
Definition: Enumerations.H:769
int Fl_Font
A font number is an index into the internal font table.
Definition: Enumerations.H:712
void format(const char *f)
Sets or returns the format string for the value.
Definition: Fl_Spinner.H:155
void step(double s)
See double Fl_Spinner::step() const.
Definition: Fl_Spinner.H:206
void range(double a, double b)
Sets the minimum and maximum values for the widget.
Definition: Fl_Spinner.H:190
const Fl_Align FL_ALIGN_LEFT
Align the label at the left of the widget.
Definition: Enumerations.H:674
void textcolor(Fl_Color c)
Sets the color of the text in the input field.
Definition: Fl_Spinner.H:217
unsigned char uchar
unsigned char
Definition: fl_types.h:39
If the Fl::focus() widget is zero or ignores an FL_KEYBOARD event then FLTK tries sending this event ...
Definition: Enumerations.H:227
void resize(int X, int Y, int W, int H)
Resizes the Fl_Group widget and all of its children.
Definition: Fl_Spinner.H:191
static int event_key()
Gets which key on the keyboard was last pushed.
Definition: Fl.H:610
Fl_Spinner(int X, int Y, int W, int H, const char *L=0)
Creates a new Fl_Spinner widget using the given position, size, and label string. ...
Definition: Fl_Spinner.H:126
double mininum() const
Speling mistakes retained for source compatibility.
Definition: Fl_Spinner.H:184