Flu_Output.H 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. // $Id: Flu_Output.h,v 1.8 2003/08/20 16:29:42 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_OUTPUT_H
  13. #define _FLU_OUTPUT_H
  14. #include <FL/Fl_Output.H>
  15. #include <stdlib.h>
  16. #include <string.h>
  17. #include <stdio.h>
  18. #include "FLU/Flu_Enumerations.H"
  19. //! This class simply extends Fl_Output to allow getting/setting the widget value as integers and floats in addition to strings
  20. class FLU_EXPORT Flu_Output : public Fl_Output
  21. {
  22. DECLARE_CLASS_CHEAP_RTTI_2(Flu_Output, Fl_Output)
  23. public:
  24. //! Normal FLTK widget constructor
  25. Flu_Output( int X,int Y,int W,int H,const char *l = 0 );
  26. //! Default destructor
  27. ~Flu_Output();
  28. //! \return the value of the widget as an integer
  29. inline int ivalue() const { return atoi( value() ); }
  30. //! Set the value of the widget as an integer using the given \c printf style format string
  31. inline void ivalue( int v, const char *format = "%d" ) { char buf[32]; sprintf(buf,format,v); value(buf); }
  32. //! \return the value of the widget as a float
  33. inline float fvalue() const { return atof( value() ); }
  34. //! Set the value of the widget as a float using the given \c printf style format string
  35. inline void fvalue( float v, const char *format = "%.2f" ) { char buf[32]; sprintf(buf,format,v); value(buf); }
  36. };
  37. #endif