FLTK 1.3.0
Fl_Button.H
00001 //
00002 // "$Id: Fl_Button.H 7903 2010-11-28 21:06:39Z matt $"
00003 //
00004 // Button header file for the Fast Light Tool Kit (FLTK).
00005 //
00006 // Copyright 1998-2010 by Bill Spitzak and others.
00007 //
00008 // This library is free software; you can redistribute it and/or
00009 // modify it under the terms of the GNU Library General Public
00010 // License as published by the Free Software Foundation; either
00011 // version 2 of the License, or (at your option) any later version.
00012 //
00013 // This library is distributed in the hope that it will be useful,
00014 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00015 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00016 // Library General Public License for more details.
00017 //
00018 // You should have received a copy of the GNU Library General Public
00019 // License along with this library; if not, write to the Free Software
00020 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
00021 // USA.
00022 //
00023 // Please report all bugs and problems on the following page:
00024 //
00025 //     http://www.fltk.org/str.php
00026 //
00027 
00028 /* \file
00029    Fl_Button widget . */
00030 
00031 #ifndef Fl_Button_H
00032 #define Fl_Button_H
00033 
00034 #ifndef Fl_Widget_H
00035 #include "Fl_Widget.H"
00036 #endif
00037 
00038 // values for type()
00039 #define FL_NORMAL_BUTTON        0   
00041 #define FL_TOGGLE_BUTTON        1   ///< value() toggles between 0 and 1 at every click of the button
00042 #define FL_RADIO_BUTTON         (FL_RESERVED_TYPE+2) 
00045 #define FL_HIDDEN_BUTTON        3   ///< for Forms compatibility
00046 
00047 extern FL_EXPORT Fl_Shortcut fl_old_shortcut(const char*);
00048 
00049 class Fl_Widget_Tracker;
00050 
00084 class FL_EXPORT Fl_Button : public Fl_Widget {
00085 
00086   int shortcut_;
00087   char value_;
00088   char oldval;
00089   uchar down_box_;
00090 
00091 protected:
00092 
00093   static Fl_Widget_Tracker *key_release_tracker;
00094   static void key_release_timeout(void*);
00095   void simulate_key_action();
00096   
00097   virtual void draw();
00098 
00099 public:
00100 
00101   virtual int handle(int);
00102 
00103   Fl_Button(int X, int Y, int W, int H, const char *L = 0);
00104 
00105   int value(int v);
00106 
00110   char value() const {return value_;}
00111 
00116   int set() {return value(1);}
00117 
00122   int clear() {return value(0);}
00123 
00124   void setonly(); // this should only be called on FL_RADIO_BUTTONs
00125 
00130   int shortcut() const {return shortcut_;}
00131 
00151   void shortcut(int s) {shortcut_ = s;}
00152 
00157   Fl_Boxtype down_box() const {return (Fl_Boxtype)down_box_;}
00158 
00164   void down_box(Fl_Boxtype b) {down_box_ = b;}
00165 
00167   void shortcut(const char *s) {shortcut(fl_old_shortcut(s));}
00168 
00170   Fl_Color down_color() const {return selection_color();}
00171 
00173   void down_color(unsigned c) {selection_color(c);}
00174 };
00175 
00176 #endif
00177 
00178 //
00179 // End of "$Id: Fl_Button.H 7903 2010-11-28 21:06:39Z matt $".
00180 //