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

Flu_Dual_Progress_Meter.h

00001 // $Id: Flu_Dual_Progress_Meter.h,v 1.6 2003/08/20 16:29:41 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_DUAL_PROGRESS_METER_H
00017 #define _FLU_DUAL_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_Slider.H>
00025 #include <FL/Fl_Button.H>
00026 
00027 #include "FLU/Flu_Label.h"
00028 #include "FLU/Flu_Enumerations.h"
00029 
00031 class FLU_EXPORT Flu_Dual_Progress_Meter
00032 {
00033 
00034  public:
00035 
00037   Flu_Dual_Progress_Meter( const char* t = NULL );
00038 
00040   virtual ~Flu_Dual_Progress_Meter();
00041 
00043   inline void setTitle( const char* t )
00044     { if( window ) window->label( t ); }
00045 
00047   inline const char* getTitle() const
00048     { if( window ) return window->label(); else return ""; }
00049 
00051   inline void setLabel( const char* current, const char* total )
00052     { if( currentLabel ) currentLabel->label( current ); if( totalLabel ) totalLabel->label( total ); }
00053 
00055   inline void setCurrentLabel( const char* l )
00056     { if( currentLabel ) currentLabel->label( l ); }
00057 
00059   inline void setTotalLabel( const char* l )
00060     { if( totalLabel ) totalLabel->label( l ); }
00061 
00063   inline const char* getCurrentLabel() const
00064     { if( currentLabel ) return currentLabel->label(); else return ""; }
00065 
00067   inline const char* getTotalLabel() const
00068     { if( totalLabel ) return totalLabel->label(); else return ""; }
00069 
00071 
00072   inline void setColor( Fl_Color c )
00073     { if( currentSlider ) currentSlider->selection_color( c );if( totalSlider ) totalSlider->selection_color( c );  }
00074 
00076   inline Fl_Color getColor() const
00077     { if( currentSlider ) return currentSlider->selection_color(); else return FL_BLUE; }
00078 
00080   inline bool setValue( float currentVal, float totalVal )
00081     { bool b = setCurrentValue(currentVal) | setTotalValue(totalVal); return b; }
00082 
00084 
00085   bool setCurrentValue( float v );
00086 
00088 
00089   bool setTotalValue( float v );
00090 
00092   inline static void currentValueCallback( float v, void *arg )
00093     { ((Flu_Dual_Progress_Meter*)arg)->setCurrentValue( v ); }
00094 
00096   inline static void totalValueCallbackd( double v, void *arg )
00097     { ((Flu_Dual_Progress_Meter*)arg)->setTotalValue( (float)v ); }
00098 
00100   inline float getCurrentValue() const
00101     { if( currentSlider ) return currentSlider->value(); else return 0.0f; }
00102 
00104   inline float getTotalValue() const
00105     { if( totalSlider ) return totalSlider->value(); else return 0.0f; }
00106 
00108   void show( bool cancelBtnVisible = false );
00109 
00111   inline void hide()
00112     { if( window ) window->hide(); Fl::flush(); }
00113 
00115   inline bool shown() const
00116     { if( window ) return window->shown(); else return false; }
00117 
00119   inline void cancelCallback( void (*cb)(void*), void* cbd = NULL )
00120     { _cancelCB = cb; _cancelCBD = cbd; }
00121 
00122  protected:
00123 
00124 
00125  private:
00126 
00127   void (*_cancelCB)(void*);
00128   void* _cancelCBD;
00129   bool _cancelled;
00130 
00131   static void _onCancelCB( Fl_Widget* w, void* arg )
00132     { ((Flu_Dual_Progress_Meter*)arg)->onCancel(); }
00133   void onCancel()
00134     { _cancelled = true; if( _cancelCB ) _cancelCB( _cancelCBD ); }
00135 
00136   Fl_Double_Window* window;
00137   Fl_Slider *currentSlider, *totalSlider;
00138   Fl_Button* cancel;
00139   Flu_Label *currentLabel, *totalLabel;
00140 
00141 };
00142 
00143 #endif

Generated on Mon Aug 2 10:27:46 2004 for FLTK Utility Library and Widget Collection (FLU) by doxygen 1.3.5