libyui
|
00001 /************************************************************************** 00002 Copyright (C) 2000 - 2010 Novell, Inc. 00003 All Rights Reserved. 00004 00005 This program is free software; you can redistribute it and/or modify 00006 it under the terms of the GNU General Public License as published by 00007 the Free Software Foundation; either version 2 of the License, or 00008 (at your option) any later version. 00009 00010 This program is distributed in the hope that it will be useful, 00011 but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00013 GNU General Public License for more details. 00014 00015 You should have received a copy of the GNU General Public License along 00016 with this program; if not, write to the Free Software Foundation, Inc., 00017 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 00018 00019 **************************************************************************/ 00020 00021 00022 /*---------------------------------------------------------------------\ 00023 | | 00024 | __ __ ____ _____ ____ | 00025 | \ \ / /_ _/ ___|_ _|___ \ | 00026 | \ V / _` \___ \ | | __) | | 00027 | | | (_| |___) || | / __/ | 00028 | |_|\__,_|____/ |_| |_____| | 00029 | | 00030 | core system | 00031 | (C) SuSE GmbH | 00032 \----------------------------------------------------------------------/ 00033 00034 File: YBarGraph.h 00035 00036 Author: Stefan Hundhammer <sh@suse.de> 00037 00038 /-*/ 00039 00040 #ifndef YBarGraph_h 00041 #define YBarGraph_h 00042 00043 #include "YWidget.h" 00044 #include "YColor.h" 00045 00046 00047 class YBarGraphPrivate; 00048 class YBarGraphSegment; 00049 00050 00051 class YBarGraph : public YWidget 00052 { 00053 friend class YBarGraphMultiUpdate; 00054 00055 protected: 00059 YBarGraph( YWidget * parent ); 00060 00061 public: 00065 virtual ~YBarGraph(); 00066 00071 virtual const char * widgetClass() const { return "YBarGraph"; } 00072 00084 void addSegment( const YBarGraphSegment & segment ); 00085 00089 void deleteAllSegments(); 00090 00094 int segments(); 00095 00101 const YBarGraphSegment & segment( int segmentIndex ) const; 00102 00111 void setValue( int segmentIndex, int newValue ); 00112 00122 void setLabel( int segmentIndex, const string & newLabel ); 00123 00131 void setSegmentColor( int segmentIndex, const YColor & color ); 00132 00140 void setTextColor( int segmentIndex, const YColor & color ); 00141 00152 virtual bool setProperty( const string & propertyName, 00153 const YPropertyValue & val ); 00154 00161 virtual YPropertyValue getProperty( const string & propertyName ); 00162 00169 virtual const YPropertySet & propertySet(); 00170 00171 00172 protected: 00178 virtual void doUpdate() = 0; 00179 00180 00181 private: 00185 void updateDisplay(); 00186 00187 ImplPtr<YBarGraphPrivate> priv; 00188 }; 00189 00190 00191 00192 00196 class YBarGraphSegment 00197 { 00198 public: 00214 YBarGraphSegment( int value = 0, 00215 const string & label = string(), 00216 const YColor & segmentColor = YColor(), 00217 const YColor & textColor = YColor() ) 00218 : _value( value ) 00219 , _label( label ) 00220 , _segmentColor( segmentColor ) 00221 , _textColor( textColor ) 00222 {} 00223 00227 int value() const { return _value; } 00228 00232 void setValue( int newValue ) { _value = newValue; } 00233 00238 string label() const { return _label; } 00239 00244 void setLabel( const string & newLabel ) { _label = newLabel; } 00245 00249 YColor segmentColor() const { return _segmentColor; } 00250 00256 bool hasSegmentColor() const { return _segmentColor.isDefined(); } 00257 00261 void setSegmentColor( const YColor & color ) { _segmentColor = color; } 00262 00266 YColor textColor() const { return _textColor; } 00267 00273 bool hasTextColor() const { return _textColor.isDefined(); } 00274 00278 void setTextColor( const YColor & color ) { _textColor = color; } 00279 00280 00281 private: 00282 00283 int _value; 00284 string _label; 00285 YColor _segmentColor; 00286 YColor _textColor; 00287 }; 00288 00289 00290 00295 class YBarGraphMultiUpdate 00296 { 00297 public: 00319 YBarGraphMultiUpdate( YBarGraph * barGraph ); 00320 00327 ~YBarGraphMultiUpdate(); 00328 00329 private: 00330 00331 YBarGraph * _barGraph; 00332 }; 00333 00334 00335 #endif // YBarGraph_h