libyui
3.0.10
|
00001 /* 00002 Copyright (C) 2000-2012 Novell, Inc 00003 This library is free software; you can redistribute it and/or modify 00004 it under the terms of the GNU Lesser General Public License as 00005 published by the Free Software Foundation; either version 2.1 of the 00006 License, or (at your option) version 3.0 of the License. This library 00007 is distributed in the hope that it will be useful, but WITHOUT ANY 00008 WARRANTY; without even the implied warranty of MERCHANTABILITY or 00009 FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 00010 License for more details. You should have received a copy of the GNU 00011 Lesser General Public License along with this library; if not, write 00012 to the Free Software Foundation, Inc., 51 Franklin Street, Fifth 00013 Floor, Boston, MA 02110-1301 USA 00014 */ 00015 00016 00017 /*-/ 00018 00019 File: YMultiProgressMeter.h 00020 00021 Author: Stefan Hundhammer <sh@suse.de> 00022 00023 /-*/ 00024 00025 #ifndef YMultiProgressMeter_h 00026 #define YMultiProgressMeter_h 00027 00028 #include "YWidget.h" 00029 #include <vector> 00030 00031 class YMultiProgressMeterPrivate; 00032 00033 00034 /** 00035 * MultiProgressMeter: Progress bar with several segments that can indicate 00036 * progress individually. This is useful to display progress of several 00037 * activities that might not necessarily all be done in sequence. 00038 * 00039 * A common example is installing packages from several CDs: Each CD would get 00040 * a separate segment. Each segment's size would be proportional to the amount 00041 * of data to be installed from that CD. This visualizes at the same time 00042 * (a) how many CDs are involved 00043 * (b) how much in proportion is to be expected from each CD 00044 * (c) whether or not a specific CD is finished. 00045 * 00046 * Visual example (horizontal MultiProgressMeter): 00047 * 00048 * [=============...] [===] [......] [.] 00049 * 00050 * This corresponds to 4 CDs: 00051 * 00052 * CD #1: A lot of packages are to be installed from this CD, and a fair amount 00053 * of those are already installed, but some are still missing. 00054 * CD #2: Some packages were installed from this, but this CD is finished. 00055 * CD #3: Quite some packages are to be installed from this CD. 00056 * CD #4: Very few packages are to be installed from this CD. 00057 * 00058 * As can be seen from this simple example, this widget can visualize a lot of 00059 * complex information at the same time in a very natural way. 00060 * 00061 * 00062 * This is an optional widget, i.e. not all UIs support it. 00063 **/ 00064 class YMultiProgressMeter : public YWidget 00065 { 00066 protected: 00067 /** 00068 * Constructor 00069 **/ 00070 YMultiProgressMeter( YWidget * parent, 00071 YUIDimension dim, 00072 const std::vector<float> & maxValues ); 00073 00074 public: 00075 /** 00076 * Destructor. 00077 **/ 00078 virtual ~YMultiProgressMeter(); 00079 00080 /** 00081 * Return a descriptive name of this widget class for logging, 00082 * debugging etc. 00083 **/ 00084 virtual const char * widgetClass() const { return "YMultiProgressMeter"; } 00085 00086 /** 00087 * Return the orientation of the MultiProgressBar. 00088 **/ 00089 YUIDimension dimension() const; 00090 00091 /** 00092 * Return 'true' if the orientation is horizontal. 00093 **/ 00094 bool horizontal() const; 00095 00096 /** 00097 * Return 'true' if the orientation is vertical. 00098 **/ 00099 bool vertical() const; 00100 00101 /** 00102 * Return the number of segments. 00103 **/ 00104 int segments() const; 00105 00106 /** 00107 * Return the maximum value for the specified segment (counting from 0). 00108 **/ 00109 float maxValue( int segment ) const; 00110 00111 /** 00112 * Return the current value for the specified segment (counting from 0). 00113 * If no value has been set yet, -1 is returned. 00114 **/ 00115 float currentValue( int segment ) const; 00116 00117 /** 00118 * Set the current value for the specified segment. 00119 * This must be in the range 0..maxValue( segment ). 00120 * 00121 * Remember to call doUpdate() after all changed values are set! 00122 **/ 00123 void setCurrentValue( int segment, float value ); 00124 00125 /** 00126 * Set all current values and call doUpdate(). 00127 **/ 00128 void setCurrentValues( const std::vector<float> & values ); 00129 00130 /** 00131 * Set a property. 00132 * Reimplemented from YWidget. 00133 * 00134 * This function may throw YUIPropertyExceptions. 00135 * 00136 * This function returns 'true' if the value was successfully set and 00137 * 'false' if that value requires special handling (not in error cases: 00138 * those are covered by exceptions). 00139 **/ 00140 virtual bool setProperty( const std::string & propertyName, 00141 const YPropertyValue & val ); 00142 00143 /** 00144 * Get a property. 00145 * Reimplemented from YWidget. 00146 * 00147 * This method may throw YUIPropertyExceptions. 00148 **/ 00149 virtual YPropertyValue getProperty( const std::string & propertyName ); 00150 00151 /** 00152 * Return this class's property set. 00153 * This also initializes the property upon the first call. 00154 * 00155 * Reimplemented from YWidget. 00156 **/ 00157 virtual const YPropertySet & propertySet(); 00158 00159 /** 00160 * Notification that values have been updated and the widget needs to be 00161 * redisplayed. Derived classes need to reimplement this. 00162 **/ 00163 virtual void doUpdate() = 0; 00164 00165 00166 private: 00167 00168 ImplPtr<YMultiProgressMeterPrivate> priv; 00169 00170 }; 00171 00172 00173 #endif // YMultiProgressMeter_h