libyui
 
Loading...
Searching...
No Matches
YBarGraph.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: YBarGraph.h
20
21 Author: Stefan Hundhammer <shundhammer@suse.de>
22
23/-*/
24
25#ifndef YBarGraph_h
26#define YBarGraph_h
27
28#include "YWidget.h"
29#include "YColor.h"
30
31
34
40class YBarGraph : public YWidget
41{
42 friend class YBarGraphMultiUpdate;
43
44protected:
49
50public:
54 virtual ~YBarGraph();
55
60 virtual const char * widgetClass() const { return "YBarGraph"; }
61
73 void addSegment( const YBarGraphSegment & segment );
74
78 void deleteAllSegments();
79
83 int segments() const;
84
90 const YBarGraphSegment & segment( int segmentIndex ) const;
91
100 void setValue( int segmentIndex, int newValue );
101
111 void setLabel( int segmentIndex, const std::string & newLabel );
112
120 void setSegmentColor( int segmentIndex, const YColor & color );
121
129 void setTextColor( int segmentIndex, const YColor & color );
130
141 virtual bool setProperty( const std::string & propertyName,
142 const YPropertyValue & val );
143
150 virtual YPropertyValue getProperty( const std::string & propertyName );
151
158 virtual const YPropertySet & propertySet();
159
160
161protected:
167 virtual void doUpdate() = 0;
168
169
170private:
174 void updateDisplay();
175
177};
178
179
180
181
187{
188public:
205 const std::string & label = std::string(),
206 const YColor & segmentColor = YColor(),
207 const YColor & textColor = YColor() )
208 : _value( value )
209 , _label( label )
210 , _segmentColor( segmentColor )
211 , _textColor( textColor )
212 {}
213
217 int value() const { return _value; }
218
222 void setValue( int newValue ) { _value = newValue; }
223
228 std::string label() const { return _label; }
229
234 void setLabel( const std::string & newLabel ) { _label = newLabel; }
235
239 YColor segmentColor() const { return _segmentColor; }
240
246 bool hasSegmentColor() const { return _segmentColor.isDefined(); }
247
251 void setSegmentColor( const YColor & color ) { _segmentColor = color; }
252
256 YColor textColor() const { return _textColor; }
257
263 bool hasTextColor() const { return _textColor.isDefined(); }
264
268 void setTextColor( const YColor & color ) { _textColor = color; }
269
270
271private:
272
273 int _value;
274 std::string _label;
275 YColor _segmentColor;
276 YColor _textColor;
277};
278
279
280
286{
287public:
309 YBarGraphMultiUpdate( YBarGraph * barGraph );
310
318
319private:
320
321 YBarGraph * _barGraph;
322};
323
324
325#endif // YBarGraph_h
Definition ImplPtr.h:43
~YBarGraphMultiUpdate()
Definition YBarGraph.cc:236
YBarGraphMultiUpdate(YBarGraph *barGraph)
Definition YBarGraph.cc:227
Definition YBarGraph.h:187
YBarGraphSegment(int value=0, const std::string &label=std::string(), const YColor &segmentColor=YColor(), const YColor &textColor=YColor())
Definition YBarGraph.h:204
bool hasSegmentColor() const
Definition YBarGraph.h:246
YColor segmentColor() const
Definition YBarGraph.h:239
void setValue(int newValue)
Definition YBarGraph.h:222
std::string label() const
Definition YBarGraph.h:228
void setLabel(const std::string &newLabel)
Definition YBarGraph.h:234
YColor textColor() const
Definition YBarGraph.h:256
void setSegmentColor(const YColor &color)
Definition YBarGraph.h:251
int value() const
Definition YBarGraph.h:217
bool hasTextColor() const
Definition YBarGraph.h:263
void setTextColor(const YColor &color)
Definition YBarGraph.h:268
Definition YBarGraph.h:41
virtual const char * widgetClass() const
Definition YBarGraph.h:60
virtual const YPropertySet & propertySet()
Definition YBarGraph.cc:175
virtual bool setProperty(const std::string &propertyName, const YPropertyValue &val)
Definition YBarGraph.cc:196
const YBarGraphSegment & segment(int segmentIndex) const
Definition YBarGraph.cc:113
void setValue(int segmentIndex, int newValue)
Definition YBarGraph.cc:129
virtual void doUpdate()=0
virtual ~YBarGraph()
Definition YBarGraph.cc:77
int segments() const
Definition YBarGraph.cc:122
void addSegment(const YBarGraphSegment &segment)
Definition YBarGraph.cc:97
void setTextColor(int segmentIndex, const YColor &color)
Definition YBarGraph.cc:162
void deleteAllSegments()
Definition YBarGraph.cc:105
YBarGraph(YWidget *parent)
Definition YBarGraph.cc:68
virtual YPropertyValue getProperty(const std::string &propertyName)
Definition YBarGraph.cc:212
void setSegmentColor(int segmentIndex, const YColor &color)
Definition YBarGraph.cc:149
void setLabel(int segmentIndex, const std::string &newLabel)
Definition YBarGraph.cc:139
Definition YColor.h:35
Definition YProperty.h:198
Definition YProperty.h:105
YWidget(YWidget *parent)
Definition YWidget.cc:106
YWidget * parent() const
Definition YWidget.cc:277
Definition YBarGraph.cc:54