1 /* 2 * This program is free software; you can redistribute it and/or 3 * modify it under the terms of the GNU General Public License 4 * as published by the Free Software Foundation; either version 2 5 * of the License, or (at your option) any later version. 6 * 7 * This program is distributed in the hope that it will be useful, 8 * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 * GNU General Public License for more details. 11 * 12 * You should have received a copy of the GNU General Public License 13 * along with this program; if not, write to the Free Software Foundation, 14 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 15 */ 16 17 #pragma once 18 19 /** \file 20 * \ingroup freestyle 21 * \brief Class to encapsulate a progress bar 22 */ 23 24 #include <string> 25 26 #ifdef WITH_CXX_GUARDEDALLOC 27 # include "MEM_guardedalloc.h" 28 #endif 29 30 using namespace std; 31 32 namespace Freestyle { 33 34 class ProgressBar { 35 public: ProgressBar()36 inline ProgressBar() 37 { 38 _numtotalsteps = 0; 39 _progress = 0; 40 } 41 ~ProgressBar()42 virtual ~ProgressBar() 43 { 44 } 45 reset()46 virtual void reset() 47 { 48 _numtotalsteps = 0; 49 _progress = 0; 50 } 51 setTotalSteps(unsigned n)52 virtual void setTotalSteps(unsigned n) 53 { 54 _numtotalsteps = n; 55 } 56 setProgress(unsigned i)57 virtual void setProgress(unsigned i) 58 { 59 _progress = i; 60 } 61 setLabelText(const string & s)62 virtual void setLabelText(const string &s) 63 { 64 _label = s; 65 } 66 67 /*! accessors */ getTotalSteps()68 inline unsigned int getTotalSteps() const 69 { 70 return _numtotalsteps; 71 } 72 getProgress()73 inline unsigned int getProgress() const 74 { 75 return _progress; 76 } 77 getLabelText()78 inline string getLabelText() const 79 { 80 return _label; 81 } 82 83 protected: 84 unsigned _numtotalsteps; 85 unsigned _progress; 86 string _label; 87 88 #ifdef WITH_CXX_GUARDEDALLOC 89 MEM_CXX_CLASS_ALLOC_FUNCS("Freestyle:ProgressBar") 90 #endif 91 }; 92 93 } /* namespace Freestyle */ 94