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

Flu_Dual_Progress_Meter.h

00001 // $Id: Flu_Dual_Progress_Meter.h,v 1.7 2005/08/02 20:27:42 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 title( const char* t )
00044     { if( window ) window->label( t ); }
00045 
00047   inline const char* title() const
00048     { if( window ) return window->label(); else return ""; }
00049 
00051   inline void label( const char* current, const char* total )
00052     { if( currentLabel ) currentLabel->label( current ); if( totalLabel ) totalLabel->label( total ); }
00053 
00055   inline void current_label( const char* l )
00056     { if( currentLabel ) currentLabel->label( l ); }
00057 
00059   inline void total_label( const char* l )
00060     { if( totalLabel ) totalLabel->label( l ); }
00061 
00063   inline const char* current_label() const
00064     { if( currentLabel ) return currentLabel->label(); else return ""; }
00065 
00067   inline const char* total_label() const
00068     { if( totalLabel ) return totalLabel->label(); else return ""; }
00069 
00071 
00072   inline void color( Fl_Color c )
00073     { if( currentSlider ) currentSlider->selection_color( c );if( totalSlider ) totalSlider->selection_color( c );  }
00074 
00076   inline Fl_Color color() const
00077     { if( currentSlider ) return currentSlider->selection_color(); else return FL_BLUE; }
00078 
00080   inline bool value( float currentVal, float totalVal )
00081     { bool b = current_value(currentVal) | total_value(totalVal); return b; }
00082 
00084 
00085   bool current_value( float v );
00086 
00088 
00089   bool total_value( float v );
00090 
00092   inline float current_value() const
00093     { if( currentSlider ) return currentSlider->value(); else return 0.0f; }
00094 
00096   inline float total_value() const
00097     { if( totalSlider ) return totalSlider->value(); else return 0.0f; }
00098 
00100   inline static void current_value_callback( float v, void *arg )
00101     { ((Flu_Dual_Progress_Meter*)arg)->current_value( v ); }
00102 
00104   inline static void total_value_callback( float v, void *arg )
00105     { ((Flu_Dual_Progress_Meter*)arg)->total_value( (float)v ); }
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 cancel_callback( void (*cb)(void*), void* cbd = NULL )
00120     { _cancelCB = cb; _cancelCBD = cbd; }
00121 
00122   inline void set_modal()
00123     { if( window ) window->set_modal(); }
00124 
00125  protected:
00126 
00127 
00128  private:
00129 
00130   void (*_cancelCB)(void*);
00131   void* _cancelCBD;
00132   bool _cancelled;
00133 
00134   static void _onCancelCB( Fl_Widget* w, void* arg )
00135     { ((Flu_Dual_Progress_Meter*)arg)->onCancel(); }
00136   void onCancel()
00137     { _cancelled = true; if( _cancelCB ) _cancelCB( _cancelCBD ); }
00138 
00139   Fl_Double_Window* window;
00140   Fl_Slider *currentSlider, *totalSlider;
00141   Fl_Button* cancel;
00142   Flu_Label *currentLabel, *totalLabel;
00143 
00144 };
00145 
00146 #endif

Generated on Mon Sep 26 07:54:04 2005 for FLTK Utility Library and Widget Collection (FLU) by doxygen 1.3.5