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 /*******************************************************************************/
20 #include <FL/Fl_Button.H>
23 /* Kind of like Fl_Light_Button except that the whole thing is the
24 * indicator and it can optionally blink */
26 class Fl_Blink_Button : public Fl_Button
29 float _blink_interval;
35 ((Fl_Blink_Button*)v)->update_cb();
41 Fl::repeat_timeout( _blink_interval, update_cb, this );
50 static const float SLOW = 0.5f;
51 static const float MEDIUM = 0.3f;
52 static const float FAST = 0.1f;
53 static const float DEFAULT = 0.5f;
55 Fl_Blink_Button ( int X, int Y, int W, int H, const char *L )
56 : Fl_Button( X, Y, W, H, L )
61 _blink_interval = DEFAULT;
63 type( FL_TOGGLE_BUTTON );
70 Fl::remove_timeout( update_cb, this );
80 bool blink ( void ) const
86 blink_interval ( float v )
91 Fl::remove_timeout( update_cb, this );
92 Fl::add_timeout( _blink_interval, update_cb, this );
96 virtual void value ( float v )
101 Fl::add_timeout( _blink_interval, update_cb, this );
102 Fl_Button::value( v );
107 Fl_Button::value( v );
108 Fl::remove_timeout( update_cb, this );
114 virtual float value ( void ) { return Fl_Button::value(); }
119 draw_box( value() ? box() : down_box(), x(), y(), w(), h(), ( value() != 0 && _on ) ? selection_color() : color() );