29 #define YUILogComponent "ui"
32 #include "YUISymbols.h"
33 #include "YBarGraph.h"
38 #define CHECK_INDEX(index) \
42 (index) >= (int) priv->segments.size() ) \
44 YUI_THROW( YUIIndexOutOfRangeException( \
47 (int) priv->segments.size() - 1 ) ); \
56 : updatesPending(
false )
57 , postponeUpdates(
false )
60 std::vector<YBarGraphSegment> segments;
72 YUI_CHECK_NEW( priv );
84 YBarGraph::updateDisplay()
86 priv->updatesPending =
true;
88 if ( ! priv->postponeUpdates )
91 priv->updatesPending =
false;
99 priv->segments.push_back(
segment );
107 priv->segments.clear();
115 CHECK_INDEX( segmentIndex );
117 return priv->segments[ segmentIndex ];
124 return (
int) priv->segments.size();
131 CHECK_INDEX( segmentIndex );
133 priv->segments[ segmentIndex ].setValue( newValue );
141 CHECK_INDEX( segmentIndex );
143 priv->segments[ segmentIndex ].setLabel( newLabel );
151 CHECK_INDEX( segmentIndex );
156 priv->segments[ segmentIndex ].setSegmentColor( color );
164 CHECK_INDEX( segmentIndex );
169 priv->segments[ segmentIndex ].setTextColor( color );
186 propSet.
add(
YProperty( YUIProperty_Values, YOtherProperty ) );
187 propSet.
add(
YProperty( YUIProperty_Labels, YOtherProperty ) );
200 if ( propertyName == YUIProperty_Values )
return false;
201 else if ( propertyName == YUIProperty_Labels )
return false;
216 if ( propertyName == YUIProperty_Values )
return YPropertyValue( YOtherProperty );
217 else if ( propertyName == YUIProperty_Labels )
return YPropertyValue( YOtherProperty );
228 : _barGraph ( barGraph )
230 YUI_CHECK_PTR( barGraph );
232 _barGraph->priv->postponeUpdates =
true;
238 _barGraph->priv->postponeUpdates =
false;
240 if ( _barGraph->priv->updatesPending )
241 _barGraph->updateDisplay();
void add(const YProperty &prop)
Add a property to this property set.
void addSegment(const YBarGraphSegment &segment)
Add one segment.
virtual bool setProperty(const std::string &propertyName, const YPropertyValue &val)
Set a property.
void setLabel(int segmentIndex, const std::string &newLabel)
Set the label of the segment with the specified index (from 0 on).
const YBarGraphSegment & segment(int segmentIndex) const
Return the segment with the specified index (from 0 on).
void deleteAllSegments()
Delete all segments.
void setValue(int segmentIndex, int newValue)
Set the value of the segment with the specifie index (from 0 on).
void setTextColor(int segmentIndex, const YColor &color)
Set the text color of the segment with the specified index (from 0 on).
Helper class to define an RGB color.
A set of properties to check names and types against.
virtual void doUpdate()=0
Perform a display update after any change to any of the segments.
bool isEmpty() const
Returns 'true' if this property set does not contain anything.
A graph showing partitioning of a whole.
YBarGraph(YWidget *parent)
Constructor.
virtual YPropertyValue getProperty(const std::string &propertyName)
Get a property.
YPropertyType type() const
Returns the type of this property value.
Class for widget properties.
YBarGraphMultiUpdate(YBarGraph *barGraph)
Constructor.
int segments()
Return the current number of segments.
virtual ~YBarGraph()
Destructor.
bool isUndefined() const
Return 'true' if this color is undefined.
void check(const std::string &propertyName) const
Check if a property 'propertyName' exists in this property set.
Transport class for the value of simple properties.
One segment of a YBarGraph.
virtual const YPropertySet & propertySet()
Return this class's property set.
void setSegmentColor(int segmentIndex, const YColor &color)
Set the background color of the segment with the specified index (from 0 on).
Base class for UI Exceptions.
~YBarGraphMultiUpdate()
Destructor.