libyui  3.3.2
YMultiProgressMeter.h
1 /*
2  Copyright (C) 2000-2012 Novell, Inc
3  This library is free software; you can redistribute it and/or modify
4  it under the terms of the GNU Lesser General Public License as
5  published by the Free Software Foundation; either version 2.1 of the
6  License, or (at your option) version 3.0 of the License. This library
7  is distributed in the hope that it will be useful, but WITHOUT ANY
8  WARRANTY; without even the implied warranty of MERCHANTABILITY or
9  FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
10  License for more details. You should have received a copy of the GNU
11  Lesser General Public License along with this library; if not, write
12  to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
13  Floor, Boston, MA 02110-1301 USA
14 */
15 
16 
17 /*-/
18 
19  File: YMultiProgressMeter.h
20 
21  Author: Stefan Hundhammer <sh@suse.de>
22 
23 /-*/
24 
25 #ifndef YMultiProgressMeter_h
26 #define YMultiProgressMeter_h
27 
28 #include "YWidget.h"
29 #include <vector>
30 
32 
33 
34 /**
35  * MultiProgressMeter: Progress bar with several segments that can indicate
36  * progress individually. This is useful to display progress of several
37  * activities that might not necessarily all be done in sequence.
38  *
39  * A common example is installing packages from several CDs: Each CD would get
40  * a separate segment. Each segment's size would be proportional to the amount
41  * of data to be installed from that CD. This visualizes at the same time
42  * (a) how many CDs are involved
43  * (b) how much in proportion is to be expected from each CD
44  * (c) whether or not a specific CD is finished.
45  *
46  * Visual example (horizontal MultiProgressMeter):
47  *
48  * [=============...] [===] [......] [.]
49  *
50  * This corresponds to 4 CDs:
51  *
52  * CD #1: A lot of packages are to be installed from this CD, and a fair amount
53  * of those are already installed, but some are still missing.
54  * CD #2: Some packages were installed from this, but this CD is finished.
55  * CD #3: Quite some packages are to be installed from this CD.
56  * CD #4: Very few packages are to be installed from this CD.
57  *
58  * As can be seen from this simple example, this widget can visualize a lot of
59  * complex information at the same time in a very natural way.
60  *
61  *
62  * This is an optional widget, i.e. not all UIs support it.
63  **/
65 {
66 protected:
67  /**
68  * Constructor
69  **/
71  YUIDimension dim,
72  const std::vector<float> & maxValues );
73 
74 public:
75  /**
76  * Destructor.
77  **/
78  virtual ~YMultiProgressMeter();
79 
80  /**
81  * Return a descriptive name of this widget class for logging,
82  * debugging etc.
83  **/
84  virtual const char * widgetClass() const { return "YMultiProgressMeter"; }
85 
86  /**
87  * Return the orientation of the MultiProgressBar.
88  **/
89  YUIDimension dimension() const;
90 
91  /**
92  * Return 'true' if the orientation is horizontal.
93  **/
94  bool horizontal() const;
95 
96  /**
97  * Return 'true' if the orientation is vertical.
98  **/
99  bool vertical() const;
100 
101  /**
102  * Return the number of segments.
103  **/
104  int segments() const;
105 
106  /**
107  * Return the maximum value for the specified segment (counting from 0).
108  **/
109  float maxValue( int segment ) const;
110 
111  /**
112  * Return the current value for the specified segment (counting from 0).
113  * If no value has been set yet, -1 is returned.
114  **/
115  float currentValue( int segment ) const;
116 
117  /**
118  * Set the current value for the specified segment.
119  * This must be in the range 0..maxValue( segment ).
120  *
121  * Remember to call doUpdate() after all changed values are set!
122  **/
123  void setCurrentValue( int segment, float value );
124 
125  /**
126  * Set all current values and call doUpdate().
127  **/
128  void setCurrentValues( const std::vector<float> & values );
129 
130  /**
131  * Set a property.
132  * Reimplemented from YWidget.
133  *
134  * This function may throw YUIPropertyExceptions.
135  *
136  * This function returns 'true' if the value was successfully set and
137  * 'false' if that value requires special handling (not in error cases:
138  * those are covered by exceptions).
139  **/
140  virtual bool setProperty( const std::string & propertyName,
141  const YPropertyValue & val );
142 
143  /**
144  * Get a property.
145  * Reimplemented from YWidget.
146  *
147  * This method may throw YUIPropertyExceptions.
148  **/
149  virtual YPropertyValue getProperty( const std::string & propertyName );
150 
151  /**
152  * Return this class's property set.
153  * This also initializes the property upon the first call.
154  *
155  * Reimplemented from YWidget.
156  **/
157  virtual const YPropertySet & propertySet();
158 
159  /**
160  * Notification that values have been updated and the widget needs to be
161  * redisplayed. Derived classes need to reimplement this.
162  **/
163  virtual void doUpdate() = 0;
164 
165 
166 private:
167 
169 
170 };
171 
172 
173 #endif // YMultiProgressMeter_h
virtual ~YMultiProgressMeter()
Destructor.
Transport class for the value of simple properties.
Definition: YProperty.h:104
void setCurrentValue(int segment, float value)
Set the current value for the specified segment.
A set of properties to check names and types against.
Definition: YProperty.h:197
MultiProgressMeter: Progress bar with several segments that can indicate progress individually...
YWidget * parent() const
Return this widget&#39;s parent or 0 if it doesn&#39;t have a parent.
Definition: YWidget.cc:269
float currentValue(int segment) const
Return the current value for the specified segment (counting from 0).
virtual const YPropertySet & propertySet()
Return this class&#39;s property set.
virtual void doUpdate()=0
Notification that values have been updated and the widget needs to be redisplayed.
bool horizontal() const
Return &#39;true&#39; if the orientation is horizontal.
virtual YPropertyValue getProperty(const std::string &propertyName)
Get a property.
void setCurrentValues(const std::vector< float > &values)
Set all current values and call doUpdate().
YMultiProgressMeter(YWidget *parent, YUIDimension dim, const std::vector< float > &maxValues)
Constructor.
int segments() const
Return the number of segments.
YUIDimension dimension() const
Return the orientation of the MultiProgressBar.
float maxValue(int segment) const
Return the maximum value for the specified segment (counting from 0).
virtual const char * widgetClass() const
Return a descriptive name of this widget class for logging, debugging etc.
Abstract base class of all UI widgets.
Definition: YWidget.h:54
virtual bool setProperty(const std::string &propertyName, const YPropertyValue &val)
Set a property.
bool vertical() const
Return &#39;true&#39; if the orientation is vertical.