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();
~YBarGraphMultiUpdate()
Destructor.
YBarGraphMultiUpdate(YBarGraph *barGraph)
Constructor.
One segment of a YBarGraph.
A graph showing partitioning of a whole.
virtual const YPropertySet & propertySet()
Return this class's property set.
virtual bool setProperty(const std::string &propertyName, const YPropertyValue &val)
Set a property.
const YBarGraphSegment & segment(int segmentIndex) const
Return the segment with the specified index (from 0 on).
void setValue(int segmentIndex, int newValue)
Set the value of the segment with the specifie index (from 0 on).
virtual void doUpdate()=0
Perform a display update after any change to any of the segments.
virtual ~YBarGraph()
Destructor.
void addSegment(const YBarGraphSegment &segment)
Add one segment.
int segments()
Return the current number of segments.
void setTextColor(int segmentIndex, const YColor &color)
Set the text color of the segment with the specified index (from 0 on).
void deleteAllSegments()
Delete all segments.
YBarGraph(YWidget *parent)
Constructor.
virtual YPropertyValue getProperty(const std::string &propertyName)
Get a property.
void setSegmentColor(int segmentIndex, const YColor &color)
Set the background color of the segment with the specified index (from 0 on).
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.
bool isUndefined() const
Return 'true' if this color is undefined.
A set of properties to check names and types against.
void check(const std::string &propertyName) const
Check if a property 'propertyName' exists in this property set.
bool isEmpty() const
Returns 'true' if this property set does not contain anything.
void add(const YProperty &prop)
Add a property to this property set.
Transport class for the value of simple properties.
YPropertyType type() const
Returns the type of this property value.
Class for widget properties.
Base class for UI Exceptions.