FLTK 1.4.0
Loading...
Searching...
No Matches
Fl_Spinner.H
1//
2// Spinner widget 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_Spinner widget . */
19
20#ifndef Fl_Spinner_H
21#define Fl_Spinner_H
22
23#include <FL/Enumerations.H>
24#include <FL/Fl_Group.H>
25#include <FL/Fl_Input.H>
26#include <FL/Fl_Repeat_Button.H>
27
37class FL_EXPORT Fl_Spinner : public Fl_Group {
38
39 double value_; // Current value
40 double minimum_; // Minimum value
41 double maximum_; // Maximum value
42 double step_; // Amount to add/subtract for up/down
43 const char *format_; // Format string for input field
44 int wrap_; // wrap around at bounds (1/0)
45
46private:
47
48 static void sb_cb(Fl_Widget *w, Fl_Spinner *sb); // internal callback
49 void update(); // update input field
50
51protected:
52
53 // This class works like Fl_Input but ignores FL_Up and FL_Down key
54 // presses so they are handled by its parent, the Fl_Spinner widget.
55 // See STR #2989.
56
57 class FL_EXPORT Fl_Spinner_Input : public Fl_Input {
58 public:
59 Fl_Spinner_Input(int X, int Y, int W, int H)
60 : Fl_Input(X, Y, W, H) {}
61 int handle(int event) FL_OVERRIDE; // implemented in src/Fl_Spinner.cxx
62 };
63
64 Fl_Spinner_Input input_; // Input field for the value
66 up_button_, // Up button
67 down_button_; // Down button
68
69 void draw() FL_OVERRIDE;
70
71public:
72
73 // Constructor
74 Fl_Spinner(int X, int Y, int W, int H, const char *L = 0);
75 // Event handling
76 int handle(int event) FL_OVERRIDE;
77 // Resize group and subwidgets
78 void resize(int X, int Y, int W, int H) FL_OVERRIDE;
79
81 const char *format() const { return (format_); }
82
84 void format(const char *f) { format_ = f; update(); }
85
87 double maximum() const { return (maximum_); }
88
90 void maximum(double m) { maximum_ = m; }
91
93 double minimum() const { return (minimum_); }
94
96 void minimum(double m) { minimum_ = m; }
97
99 void range(double a, double b) { minimum_ = a; maximum_ = b; }
100
101 // Sets the amount to change the value when the user clicks a button.
102 // Docs in src/Fl_Spinner.cxx
103 void step(double s);
104
109 double step() const { return (step_); }
110
133 void wrap(int set) { wrap_ = set ? 1 : 0; }
134
139 int wrap() const { return wrap_; }
140
142 Fl_Color textcolor() const { return (input_.textcolor()); }
143
145 void textcolor(Fl_Color c) { input_.textcolor(c); }
146
148 Fl_Font textfont() const { return (input_.textfont()); }
149
151 void textfont(Fl_Font f) { input_.textfont(f); }
152
154 Fl_Fontsize textsize() const { return (input_.textsize()); }
155
157 void textsize(Fl_Fontsize s) { input_.textsize(s); }
158
159 // Sets the numeric representation in the input field.
160 // Docs see src/Fl_Spinner.cxx
161 void type(uchar v);
162
166 uchar type() const { return (input_.type()); }
167
169 double value() const { return (value_); }
170
176 void value(double v) { value_ = v; update(); }
177
181 void color(Fl_Color v) { input_.color(v); }
182
186 Fl_Color color() const { return(input_.color()); }
187
191 void selection_color(Fl_Color val) { input_.selection_color(val); }
192
196 Fl_Color selection_color() const { return input_.selection_color(); }
197
201 void maximum_size(int m) { if (m > 0) input_.maximum_size(m); }
202
206 int maximum_size() const { return input_.maximum_size(); }
207};
208
209#endif // !Fl_Spinner_H
This file contains type definitions and general enumerations.
int Fl_Font
A font number is an index into the internal font table.
Definition Enumerations.H:1044
unsigned int Fl_Color
An FLTK color value; see also Colors
Definition Enumerations.H:1101
int Fl_Fontsize
Size of a font in pixels.
Definition Enumerations.H:1073
Fl_Group and Fl_End classes.
The Fl_Group class is the FLTK container widget.
Definition Fl_Group.H:56
int handle(int) FL_OVERRIDE
Handles the specified event.
Definition Fl_Group.cxx:145
void draw() FL_OVERRIDE
Draws the widget.
Definition Fl_Group.cxx:926
int maximum_size() const
Gets the maximum length of the input field in characters.
Definition Fl_Input_.H:289
Fl_Font textfont() const
Gets the font of the text in the input field.
Definition Fl_Input_.H:427
Fl_Color textcolor() const
Gets the color of the text in the input field.
Definition Fl_Input_.H:446
Fl_Fontsize textsize() const
Gets the size of the text in the input field.
Definition Fl_Input_.H:436
This is the FLTK text input widget.
Definition Fl_Input.H:220
The Fl_Repeat_Button is a subclass of Fl_Button that generates a callback when it is pressed and then...
Definition Fl_Repeat_Button.H:31
Definition Fl_Spinner.H:57
This widget is a combination of a numerical input widget and repeat buttons.
Definition Fl_Spinner.H:37
Fl_Font textfont() const
Gets the font of the text in the input field.
Definition Fl_Spinner.H:148
void textcolor(Fl_Color c)
Sets the color of the text in the input field.
Definition Fl_Spinner.H:145
double value() const
Gets the current value of the widget.
Definition Fl_Spinner.H:169
void selection_color(Fl_Color val)
Sets the selection color of the spinner widget's input field.
Definition Fl_Spinner.H:191
void maximum_size(int m)
Sets the maximum width of the input field.
Definition Fl_Spinner.H:201
void textsize(Fl_Fontsize s)
Sets the size of the text in the input field.
Definition Fl_Spinner.H:157
double minimum() const
Gets the minimum value of the widget.
Definition Fl_Spinner.H:93
void maximum(double m)
Sets the maximum value of the widget.
Definition Fl_Spinner.H:90
Fl_Color color() const
Returns the background color of the spinner widget's input field.
Definition Fl_Spinner.H:186
void minimum(double m)
Sets the minimum value of the widget.
Definition Fl_Spinner.H:96
uchar type() const
Gets the numeric representation in the input field.
Definition Fl_Spinner.H:166
int wrap() const
Gets the wrap mode of the Fl_Spinner widget.
Definition Fl_Spinner.H:139
void textfont(Fl_Font f)
Sets the font of the text in the input field.
Definition Fl_Spinner.H:151
Fl_Color selection_color() const
Returns the selection color of the spinner widget's input field.
Definition Fl_Spinner.H:196
Fl_Fontsize textsize() const
Gets the size of the text in the input field.
Definition Fl_Spinner.H:154
void format(const char *f)
Sets the format string for the value.
Definition Fl_Spinner.H:84
int maximum_size() const
Returns the maximum width of the input field.
Definition Fl_Spinner.H:206
void range(double a, double b)
Sets the minimum and maximum values for the widget.
Definition Fl_Spinner.H:99
double step() const
Gets the amount to change the value when the user clicks a button.
Definition Fl_Spinner.H:109
double maximum() const
Gets the maximum value of the widget.
Definition Fl_Spinner.H:87
void value(double v)
Sets the current value of the input widget.
Definition Fl_Spinner.H:176
void wrap(int set)
Sets whether the spinner wraps around at upper and lower bounds.
Definition Fl_Spinner.H:133
void color(Fl_Color v)
Sets the background color of the spinner widget's input field.
Definition Fl_Spinner.H:181
Fl_Color textcolor() const
Gets the color of the text in the input field.
Definition Fl_Spinner.H:142
Fl_Widget is the base class for all widgets in FLTK.
Definition Fl_Widget.H:104
Fl_Color color() const
Gets the background color of the widget.
Definition Fl_Widget.H:447
Fl_Color selection_color() const
Gets the selection color.
Definition Fl_Widget.H:465
uchar type() const
Gets the widget type.
Definition Fl_Widget.H:343
#define FL_OVERRIDE
This macro makes it safe to use the C++11 keyword override with older compilers.
Definition fl_attr.h:46
unsigned char uchar
unsigned char
Definition fl_types.h:30