Flu_Button.H 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. // $Id: Flu_Button.h,v 1.11 2003/12/21 15:58:31 jbryan Exp $
  2. /***************************************************************
  3. * FLU - FLTK Utility Widgets
  4. * Copyright (C) 2002 Ohio Supercomputer Center, Ohio State University
  5. *
  6. * This file and its content is protected by a software license.
  7. * You should have received a copy of this license with this file.
  8. * If not, please contact the Ohio Supercomputer Center immediately:
  9. * Attn: Jason Bryan Re: FLU 1224 Kinnear Rd, Columbus, Ohio 43212
  10. *
  11. ***************************************************************/
  12. #ifndef _FLU_BUTTON_H
  13. #define _FLU_BUTTON_H
  14. #include <FL/Fl_Button.H>
  15. #include <FL/Fl_Image.H>
  16. #include <stdlib.h>
  17. #include <string.h>
  18. #include <stdio.h>
  19. #include "FLU/flu_export.h"
  20. //! This class extends Fl_Button to make a more attractive alternative that hilights as the mouse enters/leaves and automatically grayscales any image for deactivation
  21. class FLU_EXPORT Flu_Button : public Fl_Button
  22. {
  23. public:
  24. //! Normal FLTK widget constructor
  25. Flu_Button( int X,int Y,int W,int H,const char *l = 0 );
  26. //! Default destructor
  27. virtual ~Flu_Button();
  28. //! Override of Fl_Widget::color()
  29. inline void color( unsigned c )
  30. { col = (Fl_Color)c; Fl_Button::color(col); }
  31. //! Override of Fl_Widget::color()
  32. inline Fl_Color color() const
  33. { return col; }
  34. //! Override of Fl_Widget::selection_color()
  35. inline void selection_color( unsigned c )
  36. { sCol = (Fl_Color)c; Fl_Button::selection_color(sCol); }
  37. //! Override of Fl_Widget::selection_color()
  38. inline Fl_Color selection_color() const
  39. { return sCol; }
  40. //! Set the box to use when the mouse is over the button. If this is \c FL_NO_BOX, then the regular box() is used
  41. inline void enter_box( Fl_Boxtype b )
  42. { eBox = b; }
  43. //! Get the box to use when the mouse enters
  44. inline Fl_Boxtype enter_box() const
  45. { return eBox; }
  46. //! Override of Fl_Widget::image()
  47. void image( Fl_Image *i );
  48. //! Override of Fl_Widget::image()
  49. inline void image( Fl_Image &i )
  50. { image( &i ); }
  51. //! Override of Fl_Button::handle()
  52. int handle( int event );
  53. // Override of Fl_Button::draw()
  54. void draw();
  55. DECLARE_CLASS_CHEAP_RTTI_2(Flu_Button, Fl_Button)
  56. protected:
  57. bool retBtn, linkBtn, overLink;
  58. private:
  59. void checkLink();
  60. int labelSize[4];
  61. bool hover;
  62. Fl_Color col, sCol;
  63. Fl_Image *inactiveImg;
  64. Fl_Boxtype eBox;
  65. };
  66. #endif