Flu_Label.H 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. // $Id: Flu_Label.h,v 1.7 2004/03/28 14:06:57 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_LABEL_H
  13. #define _FLU_LABEL_H
  14. #include <stdlib.h>
  15. #include <string.h>
  16. #include <FL/Fl_Box.H>
  17. #include "FLU/Flu_Enumerations.H"
  18. //! This class just provides an easier interface to making labels in FLTK
  19. /*! All this class does is copy the label string to internal storage
  20. since FLTK needs non-transient memory for labels. */
  21. class FLU_EXPORT Flu_Label : public Fl_Box
  22. {
  23. DECLARE_CLASS_CHEAP_RTTI_2(Flu_Label, Fl_Box)
  24. public:
  25. //! Normal FLTK widget constructor
  26. Flu_Label( int x, int y, int w, int h, const char* l = 0 );
  27. //! Default destructor
  28. virtual ~Flu_Label();
  29. //! Overload of Fl_Box::draw()
  30. void draw();
  31. //! Set whether the label automatically resizes itself to fit the text. Default is \c false
  32. inline void auto_resize( bool b )
  33. { _autoSize = b; }
  34. //! Get whether the label automatically resizes itself to fit the text.
  35. inline bool auto_resize() const
  36. { return _autoSize; }
  37. //! Alias for label()
  38. inline void value( const char* l )
  39. { label(l); }
  40. //! \return the label
  41. inline const char* value() const
  42. { return _label; }
  43. //! Set the label to \b l
  44. void label( const char* l );
  45. //! \return the label
  46. inline const char* label() const
  47. { return _label; }
  48. protected:
  49. char* _label;
  50. bool _autoSize;
  51. };
  52. #endif