2 // "$Id: Fl_Value_Output.cxx 7903 2010-11-28 21:06:39Z matt $"
4 // Value output widget for the Fast Light Tool Kit (FLTK).
6 // Copyright 1998-2010 by Bill Spitzak and others.
8 // This library is free software; you can redistribute it and/or
9 // modify it under the terms of the GNU Library General Public
10 // License as published by the Free Software Foundation; either
11 // version 2 of the License, or (at your option) any later version.
13 // This library is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 // Library General Public License for more details.
18 // You should have received a copy of the GNU Library General Public
19 // License along with this library; if not, write to the Free Software
20 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
23 // Please report all bugs and problems on the following page:
25 // http://www.fltk.org/str.php
28 // Fltk widget for drag-adjusting a floating point value.
29 // This is much lighter than Fl_Value_Input because it has no text editor
30 // If step() is zero then it can be used to display a floating-point value
33 #include <FL/Fl_Value_Output.H>
34 #include <FL/fl_draw.H>
36 void Fl_Value_Output::draw() {
37 Fl_Boxtype b
= box() ? box() : FL_DOWN_BOX
;
38 int X
= x()+Fl::box_dx(b
);
39 int Y
= y()+Fl::box_dy(b
);
40 int W
= w()-Fl::box_dw(b
);
41 int H
= h()-Fl::box_dh(b
);
42 if (damage()&~FL_DAMAGE_CHILD
)
50 fl_color(active_r() ? textcolor() : fl_inactive(textcolor()));
51 fl_font(textfont(), textsize());
52 fl_draw(buf
,X
,Y
,W
,H
,FL_ALIGN_LEFT
);
55 int Fl_Value_Output::handle(int event
) {
56 if (!step()) return 0;
59 int mx
= Fl::event_x();
64 drag
= Fl::event_button();
68 delta
= Fl::event_x()-ix
;
69 if (delta
> 5) delta
-= 5;
70 else if (delta
< -5) delta
+= 5;
73 case 3: v
= increment(previous_value(),delta
*100); break;
74 case 2: v
= increment(previous_value(),delta
*10); break;
75 default:v
= increment(previous_value(),delta
); break;
78 handle_drag(soft()?softclamp(v
):clamp(v
));;
92 Creates a new Fl_Value_Output widget using the given
93 position, size, and label string. The default boxtype is FL_NO_BOX.
94 <P> Inherited destructor destroys the Valuator.
96 Fl_Value_Output::Fl_Value_Output(int X
, int Y
, int W
, int H
,const char *l
)
97 : Fl_Valuator(X
,Y
,W
,H
,l
) {
100 textfont_
= FL_HELVETICA
;
101 textsize_
= FL_NORMAL_SIZE
;
102 textcolor_
= FL_FOREGROUND_COLOR
;
107 // End of "$Id: Fl_Value_Output.cxx 7903 2010-11-28 21:06:39Z matt $".