2 /*******************************************************************************/
3 /* Copyright (C) 2008 Jonathan Moore Liles */
5 /* This program is free software; you can redistribute it and/or modify it */
6 /* under the terms of the GNU General Public License as published by the */
7 /* Free Software Foundation; either version 2 of the License, or (at your */
8 /* option) any later version. */
10 /* This program is distributed in the hope that it will be useful, but WITHOUT */
11 /* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or */
12 /* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for */
15 /* You should have received a copy of the GNU General Public License along */
16 /* with This program; see the file COPYING. If not,write to the Free Software */
17 /* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
18 /*******************************************************************************/
22 #include <FL/Fl_Valuator.H> // for FL_HORIZONTAL and FL_VERTICAL
26 class DPM : public Meter
31 int _pixels_per_segment;
32 int _last_drawn_hi_segment;
38 return deflection( v ) * _segments;
42 static Fl_Color _gradient[];
43 static Fl_Color _dim_gradient[];
48 return _gradient[ i * 127 / _segments ];
52 dim_div_color ( int i )
54 return _dim_gradient[ i * 127 / _segments ];
60 virtual void draw_label ( void );
61 virtual void draw ( void );
62 virtual void resize ( int, int, int, int );
66 DPM ( int X, int Y, int W, int H, const char *L = 0 );
68 void value ( float v )
72 if ( pos( v ) != pos( _value ) )
79 float value ( void ) const
84 void pixels_per_segment ( int v ) { _pixels_per_segment = v; }
86 float dim ( void ) const { return _dim; }
87 void dim ( float v ) { _dim = v; redraw(); }
91 blend ( Fl_Color min, Fl_Color max )
93 for ( int i = 128; i-- ; )
94 _gradient[ i ] = fl_color_average( max, min, i / (float)128 );
96 for ( int i = 128; i-- ; )
97 _dim_gradient[ i ] = fl_color_average( FL_BLACK, _gradient[ i ], _dim );