FLTK 1.4.5: Fl_Spinner.H Source File

FLTK 1.4.5

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
37 class 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
65 Fl_Repeat_Button
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
Enumerations.H
This file contains type definitions and general enumerations.
Fl_Font
int Fl_Font
A font number is an index into the internal font table.
Definition Enumerations.H:1063
Fl_Color
unsigned int Fl_Color
An FLTK color value; see also Colors.
Definition Enumerations.H:1120
Fl_Fontsize
int Fl_Fontsize
Size of a font in pixels.
Definition Enumerations.H:1092
Fl_Group.H
Fl_Group and Fl_End classes.
Fl_Input::Fl_Input
Fl_Input(int, int, int, int, const char *=0)
Creates a new Fl_Input widget using the given position, size, and label string.
Definition Fl_Input.cxx:794
Fl_Repeat_Button
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
Fl_Spinner::Fl_Spinner_Input
Definition Fl_Spinner.H:57
Fl_Spinner::Fl_Spinner_Input::handle
int handle(int event) FL_OVERRIDE
Handles events of Fl_Spinner's embedded input widget.
Definition Fl_Spinner.cxx:216
Fl_Spinner::textfont
Fl_Font textfont() const
Gets the font of the text in the input field.
Definition Fl_Spinner.H:148
Fl_Spinner::textcolor
void textcolor(Fl_Color c)
Sets the color of the text in the input field.
Definition Fl_Spinner.H:145
Fl_Spinner::value
double value() const
Gets the current value of the widget.
Definition Fl_Spinner.H:169
Fl_Spinner::selection_color
void selection_color(Fl_Color val)
Sets the selection color of the spinner widget's input field.
Definition Fl_Spinner.H:191
Fl_Spinner::maximum_size
void maximum_size(int m)
Sets the maximum width of the input field.
Definition Fl_Spinner.H:201
Fl_Spinner::textsize
void textsize(Fl_Fontsize s)
Sets the size of the text in the input field.
Definition Fl_Spinner.H:157
Fl_Spinner::minimum
double minimum() const
Gets the minimum value of the widget.
Definition Fl_Spinner.H:93
Fl_Spinner::maximum
void maximum(double m)
Sets the maximum value of the widget.
Definition Fl_Spinner.H:90
Fl_Spinner::color
Fl_Color color() const
Returns the background color of the spinner widget's input field.
Definition Fl_Spinner.H:186
Fl_Spinner::minimum
void minimum(double m)
Sets the minimum value of the widget.
Definition Fl_Spinner.H:96
Fl_Spinner::resize
void resize(int X, int Y, int W, int H) FL_OVERRIDE
Resizes the Fl_Group widget and all of its children.
Definition Fl_Spinner.cxx:168
Fl_Spinner::type
uchar type() const
Gets the numeric representation in the input field.
Definition Fl_Spinner.H:166
Fl_Spinner::Fl_Spinner
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.cxx:103
Fl_Spinner::wrap
int wrap() const
Gets the wrap mode of the Fl_Spinner widget.
Definition Fl_Spinner.H:139
Fl_Spinner::format
const char * format() const
Returns the format string for the value.
Definition Fl_Spinner.H:81
Fl_Spinner::textfont
void textfont(Fl_Font f)
Sets the font of the text in the input field.
Definition Fl_Spinner.H:151
Fl_Spinner::selection_color
Fl_Color selection_color() const
Returns the selection color of the spinner widget's input field.
Definition Fl_Spinner.H:196
Fl_Spinner::textsize
Fl_Fontsize textsize() const
Gets the size of the text in the input field.
Definition Fl_Spinner.H:154
Fl_Spinner::format
void format(const char *f)
Sets the format string for the value.
Definition Fl_Spinner.H:84
Fl_Spinner::maximum_size
int maximum_size() const
Returns the maximum width of the input field.
Definition Fl_Spinner.H:206
Fl_Spinner::range
void range(double a, double b)
Sets the minimum and maximum values for the widget.
Definition Fl_Spinner.H:99
Fl_Spinner::step
double step() const
Gets the amount to change the value when the user clicks a button.
Definition Fl_Spinner.H:109
Fl_Spinner::maximum
double maximum() const
Gets the maximum value of the widget.
Definition Fl_Spinner.H:87
Fl_Spinner::value
void value(double v)
Sets the current value of the input widget.
Definition Fl_Spinner.H:176
Fl_Spinner::wrap
void wrap(int set)
Sets whether the spinner wraps around at upper and lower bounds.
Definition Fl_Spinner.H:133
Fl_Spinner::color
void color(Fl_Color v)
Sets the background color of the spinner widget's input field.
Definition Fl_Spinner.H:181
Fl_Spinner::textcolor
Fl_Color textcolor() const
Gets the color of the text in the input field.
Definition Fl_Spinner.H:142
Fl_Spinner::handle
int handle(int event) FL_OVERRIDE
Handles the specified event.
Definition Fl_Spinner.cxx:145
Fl_Spinner::draw
void draw() FL_OVERRIDE
Draws the widget.
Definition Fl_Spinner.cxx:130
Fl_Widget::w
void w(int v)
Internal use only.
Definition Fl_Widget.H:154
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
uchar
unsigned char uchar
unsigned char
Definition fl_types.h:30