Main Page | Class Hierarchy | Class List | File List | Class Members

Flu_Progress_Meter.h

00001 // $Id: Flu_Progress_Meter.h,v 1.12 2004/06/30 00:18:00 jbryan Exp $
00002 
00003 /***************************************************************
00004  *                FLU - FLTK Utility Widgets 
00005  *  Copyright (C) 2002 Ohio Supercomputer Center, Ohio State University
00006  *
00007  * This file and its content is protected by a software license.
00008  * You should have received a copy of this license with this file.
00009  * If not, please contact the Ohio Supercomputer Center immediately:
00010  * Attn: Jason Bryan Re: FLU 1224 Kinnear Rd, Columbus, Ohio 43212
00011  * 
00012  ***************************************************************/
00013 
00014 
00015 
00016 #ifndef _FLU_PROGRESS_METER_H
00017 #define _FLU_PROGRESS_METER_H
00018 
00019 #include <stdio.h>
00020 
00021 /* fltk includes */
00022 #include <FL/Fl.H>
00023 #include <FL/Fl_Double_Window.H>
00024 #include <FL/Fl_Button.H>
00025 
00026 #include "FLU/Flu_Label.h"
00027 #include "FLU/Flu_Progress.h"
00028 #include "FLU/Flu_Enumerations.h"
00029 
00030 #ifdef WIN32
00031 #include <winsock.h>
00032 #include <time.h>
00033 #else
00034 #include <sys/time.h>
00035 #endif
00036 
00038 class FLU_EXPORT Flu_Progress_Meter : public Fl_Double_Window
00039 {
00040 
00041  public:
00042 
00044   Flu_Progress_Meter( const char* t = NULL );
00045 
00047   virtual ~Flu_Progress_Meter();
00048 
00050   inline void title( const char* t )
00051     { Fl_Double_Window::label( t ); }
00052 
00054   inline const char* title() const
00055     { return Fl_Double_Window::label(); }
00056 
00058   inline void label( const char* l )
00059     { if( _label ) _label->label( l ); }
00060 
00062   inline const char* label() const
00063     { if( _label ) return _label->label(); else return ""; }
00064 
00066   inline void color( Fl_Color c )
00067     { if( progress ) progress->selection_color( c ); }
00068 
00070   inline Fl_Color color() const
00071     { if( progress ) return progress->selection_color(); else return FL_BLUE; }
00072 
00074 
00075   bool value( float v );
00076 
00078   inline float value() const
00079     { if( progress ) return progress->value(); else return 0.0f; }
00080 
00082   inline static void value_callback( float v, void *arg )
00083     { ((Flu_Progress_Meter*)arg)->value( v ); }
00084 
00086   inline static void value_callbackd( double v, void *arg )
00087     { ((Flu_Progress_Meter*)arg)->value( (float)v ); }
00088 
00090   inline static bool cvalue_callback( float v, void *arg )
00091     { return ((Flu_Progress_Meter*)arg)->value( v ); }
00092 
00094   inline static bool cvalue_callbackd( double v, void *arg )
00095     { return ((Flu_Progress_Meter*)arg)->value( (float)v ); }
00096 
00098   inline void show_completion_time( bool b )
00099     { _showETC = b; }
00100 
00102   inline bool show_completion_time() const
00103     { return _showETC; }
00104 
00106   void show( bool withCancelButton = false );
00107 
00108   void reset();
00109 
00111   void hide();
00112 
00114   inline void cancel_callback( void (*cb)(void*), void* cbd = NULL )
00115     { _cancelCB = cb; _cancelCBD = cbd; }
00116 
00117  protected:
00118 
00119 
00120  private:
00121 
00122 #ifdef WIN32
00123   inline void gettimeofday( struct timeval *t, void* )
00124     {
00125       t->tv_sec = 0;
00126       t->tv_usec = clock();
00127     }
00128 #endif
00129 
00130   timeval startT;
00131 
00132   inline static void _secondTimerCB( void *arg )
00133     { ((Flu_Progress_Meter*)arg)->secondTimerCB(); }
00134   void secondTimerCB( bool repeatTimer = true );
00135 
00136   void (*_cancelCB)(void*);
00137   void* _cancelCBD;
00138   bool _cancelled, _showETC;
00139 
00140   static void _onCancelCB( Fl_Widget* w, void* arg )
00141     { ((Flu_Progress_Meter*)arg)->onCancel(); }
00142   void onCancel()
00143     { _cancelled = true; if( _cancelCB ) _cancelCB( _cancelCBD ); }
00144 
00145   Flu_Progress* progress;
00146   Fl_Button* cancel;
00147   Flu_Label *_label, *etc;
00148 
00149 };
00150 
00151 #endif

Generated on Fri Nov 5 12:41:32 2004 for FLTK Utility Library and Widget Collection (FLU) by doxygen 1.3.5