29 #define YUILogComponent "ui" 32 #include "YUISymbols.h" 33 #include "YBarGraph.h" 37 #define CHECK_INDEX(index) \ 41 (index) >= (int) priv->segments.size() ) \ 43 YUI_THROW( YUIIndexOutOfRangeException( \ 46 (int) priv->segments.size() - 1 ) ); \ 55 : updatesPending(
false )
56 , postponeUpdates(
false )
59 std::vector<YBarGraphSegment> segments;
71 YUI_CHECK_NEW( priv );
83 YBarGraph::updateDisplay()
85 priv->updatesPending =
true;
87 if ( ! priv->postponeUpdates )
90 priv->updatesPending =
false;
98 priv->segments.push_back( segment );
106 priv->segments.clear();
114 CHECK_INDEX( segmentIndex );
116 return priv->segments[ segmentIndex ];
123 return (
int) priv->segments.size();
130 CHECK_INDEX( segmentIndex );
132 priv->segments[ segmentIndex ].setValue( newValue );
140 CHECK_INDEX( segmentIndex );
142 priv->segments[ segmentIndex ].setLabel( newLabel );
150 CHECK_INDEX( segmentIndex );
155 priv->segments[ segmentIndex ].setSegmentColor( color );
163 CHECK_INDEX( segmentIndex );
168 priv->segments[ segmentIndex ].setTextColor( color );
185 propSet.
add(
YProperty( YUIProperty_Values, YOtherProperty ) );
186 propSet.
add(
YProperty( YUIProperty_Labels, YOtherProperty ) );
199 if ( propertyName == YUIProperty_Values )
return false;
200 else if ( propertyName == YUIProperty_Labels )
return false;
215 if ( propertyName == YUIProperty_Values )
return YPropertyValue( YOtherProperty );
216 else if ( propertyName == YUIProperty_Labels )
return YPropertyValue( YOtherProperty );
227 : _barGraph ( barGraph )
229 YUI_CHECK_PTR( barGraph );
231 _barGraph->priv->postponeUpdates =
true;
237 _barGraph->priv->postponeUpdates =
false;
239 if ( _barGraph->priv->updatesPending )
240 _barGraph->updateDisplay();
One segment of a YBarGraph.
virtual bool setProperty(const std::string &propertyName, const YPropertyValue &val)
Set a property.
bool isEmpty() const
Returns 'true' if this property set does not contain anything.
virtual YPropertyValue getProperty(const std::string &propertyName)
Get a property.
bool isUndefined() const
Return 'true' if this color is undefined.
Transport class for the value of simple properties.
void add(const YProperty &prop)
Add a property to this property set.
virtual const YPropertySet & propertySet()
Return this class's property set.
A set of properties to check names and types against.
A graph showing partitioning of a whole.
void setLabel(int segmentIndex, const std::string &newLabel)
Set the label of the segment with the specified index (from 0 on).
Helper class to define an RGB color.
void setSegmentColor(int segmentIndex, const YColor &color)
Set the background color of the segment with the specified index (from 0 on).
void deleteAllSegments()
Delete all segments.
void setTextColor(int segmentIndex, const YColor &color)
Set the text color of the segment with the specified index (from 0 on).
Class for widget properties.
virtual ~YBarGraph()
Destructor.
void setValue(int segmentIndex, int newValue)
Set the value of the segment with the specifie index (from 0 on).
YBarGraph(YWidget *parent)
Constructor.
void addSegment(const YBarGraphSegment &segment)
Add one segment.
~YBarGraphMultiUpdate()
Destructor.
int segments()
Return the current number of segments.
void check(const std::string &propertyName) const
Check if a property 'propertyName' exists in this property set.
Base class for UI Exceptions.
const YBarGraphSegment & segment(int segmentIndex) const
Return the segment with the specified index (from 0 on).
virtual void doUpdate()=0
Perform a display update after any change to any of the segments.
YBarGraphMultiUpdate(YBarGraph *barGraph)
Constructor.
YPropertyType type() const
Returns the type of this property value.