Flu_Dual_Progress_Meter.cpp 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. // $Id: Flu_Dual_Progress_Meter.cpp,v 1.4 2003/08/20 16:29:45 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. #include "FLU/Flu_Dual_Progress_Meter.H"
  13. Flu_Dual_Progress_Meter :: Flu_Dual_Progress_Meter( const char* t )
  14. {
  15. window = new Fl_Double_Window( 350, 250, t );
  16. currentLabel = new Flu_Label( 10, 5, 330, 65 );
  17. currentLabel->align( currentLabel->align() | FL_ALIGN_WRAP );
  18. currentSlider = new Fl_Slider( 10, 70, 330, 30 );
  19. totalLabel = new Flu_Label( 10, 105, 330, 65 );
  20. totalLabel->align( totalLabel->align() | FL_ALIGN_WRAP );
  21. totalSlider = new Fl_Slider( 10, 170, 330, 30 );
  22. cancel = new Fl_Button( window->w()/2-30, window->h()-40, 60, 30, "Cancel" );
  23. window->end();
  24. window->hide();
  25. currentSlider->deactivate();
  26. currentSlider->align( FL_ALIGN_TOP | FL_ALIGN_LEFT );
  27. currentSlider->type( FL_HOR_FILL_SLIDER );
  28. currentSlider->range( 0, 1 );
  29. currentSlider->selection_color( FL_BLUE );
  30. totalSlider->deactivate();
  31. totalSlider->align( FL_ALIGN_TOP | FL_ALIGN_LEFT );
  32. totalSlider->type( FL_HOR_FILL_SLIDER );
  33. totalSlider->range( 0, 1 );
  34. totalSlider->selection_color( FL_BLUE );
  35. cancel->callback( _onCancelCB, this );
  36. _cancelled = false;
  37. _cancelCB = NULL;
  38. _cancelCBD = NULL;
  39. }
  40. Flu_Dual_Progress_Meter :: ~Flu_Dual_Progress_Meter()
  41. {
  42. if( window )
  43. window->hide();
  44. }
  45. bool Flu_Dual_Progress_Meter :: setCurrentValue( float v )
  46. {
  47. if( currentSlider )
  48. {
  49. currentSlider->value( v );
  50. if( window->visible() )
  51. currentSlider->redraw();
  52. Fl::wait(0);
  53. }
  54. return _cancelled;
  55. }
  56. bool Flu_Dual_Progress_Meter :: setTotalValue( float v )
  57. {
  58. if( totalSlider )
  59. {
  60. totalSlider->value( v );
  61. if( window->visible() )
  62. totalSlider->redraw();
  63. Fl::wait(0);
  64. }
  65. return _cancelled;
  66. }
  67. void Flu_Dual_Progress_Meter :: show( bool cancelBtnVisible )
  68. {
  69. _cancelled = false;
  70. if( _cancelCB || cancelBtnVisible )
  71. cancel->show();
  72. else
  73. cancel->hide();
  74. if( window )
  75. {
  76. window->set_modal();
  77. window->show();
  78. }
  79. Fl::flush();
  80. }