00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030 #ifndef KDCHARTLEGEND_H
00031 #define KDCHARTLEGEND_H
00032
00033 #include "KDChartAbstractAreaWidget.h"
00034 #include "KDChartPosition.h"
00035 #include "KDChartMarkerAttributes.h"
00036
00037 class QTextTable;
00038
00039 namespace KDChart {
00040
00041 class AbstractDiagram;
00042 typedef QList<AbstractDiagram*> DiagramList;
00043 typedef QList<const AbstractDiagram*> ConstDiagramList;
00044
00062 class KDCHART_EXPORT Legend : public AbstractAreaWidget
00063 {
00064 Q_OBJECT
00065
00066 Q_DISABLE_COPY( Legend )
00067 KDCHART_DECLARE_PRIVATE_DERIVED_QWIDGET( Legend )
00068
00069 public:
00070 explicit Legend( QWidget* parent = 0 );
00071 explicit Legend( KDChart::AbstractDiagram* diagram, QWidget* parent );
00072 virtual ~Legend();
00073
00074
00075 enum LegendStyle { MarkersOnly = 0,
00076 LinesOnly = 1,
00077 MarkersAndLines = 2 };
00078
00079
00080 void setLegendStyle( LegendStyle style );
00081 LegendStyle legendStyle() const;
00082
00083
00084 virtual Legend * clone() const;
00085
00089 bool compare( const Legend* other )const;
00090
00091
00092 virtual void resizeEvent( QResizeEvent * event );
00093
00094 virtual void paint( QPainter* painter );
00095 virtual void setVisible( bool visible );
00096
00112 void setReferenceArea( const QWidget* area );
00120 const QWidget* referenceArea() const;
00121
00128 KDChart::AbstractDiagram* diagram() const;
00129
00136 DiagramList diagrams() const;
00137
00141 ConstDiagramList constDiagrams() const;
00142
00149 void addDiagram( KDChart::AbstractDiagram* newDiagram );
00150
00156 void removeDiagram( KDChart::AbstractDiagram* oldDiagram );
00157
00163 void removeDiagrams();
00164
00179 void replaceDiagram( KDChart::AbstractDiagram* newDiagram,
00180 KDChart::AbstractDiagram* oldDiagram = 0 );
00181
00190 void setDiagram( KDChart::AbstractDiagram* newDiagram );
00191
00200 void setPosition( Position position );
00201
00206 Position position() const;
00207
00216 void setAlignment( Qt::Alignment );
00217
00222 Qt::Alignment alignment() const;
00223
00268 void setFloatingPosition( const RelativePosition& relativePosition );
00269
00274 const RelativePosition floatingPosition() const;
00275
00276 void setOrientation( Qt::Orientation orientation );
00277 Qt::Orientation orientation() const;
00278
00279 void setShowLines( bool legendShowLines );
00280 bool showLines() const;
00281
00282 void resetTexts();
00283 void setText( uint dataset, const QString& text );
00284 QString text( uint dataset ) const;
00285 const QMap<uint,QString> texts() const;
00286
00287 uint datasetCount() const;
00288
00289 void setDefaultColors();
00290 void setRainbowColors();
00291 void setSubduedColors( bool ordered = false );
00292
00293 void setBrushesFromDiagram( KDChart::AbstractDiagram* diagram );
00294
00300 void setColor( uint dataset, const QColor& color );
00301
00302 void setBrush( uint dataset, const QBrush& brush );
00303 QBrush brush( uint dataset ) const;
00304 const QMap<uint,QBrush> brushes() const;
00305
00306 void setPen( uint dataset, const QPen& pen );
00307 QPen pen( uint dataset ) const;
00308 const QMap<uint,QPen> pens() const;
00309
00315 void setMarkerAttributes( uint dataset, const MarkerAttributes& );
00316 MarkerAttributes markerAttributes( uint dataset ) const;
00317 const QMap<uint, MarkerAttributes> markerAttributes() const;
00318
00326 void setUseAutomaticMarkerSize( bool useAutomaticMarkerSize );
00327 bool useAutomaticMarkerSize() const;
00328
00329 void setTextAttributes( const TextAttributes &a );
00330 TextAttributes textAttributes() const;
00331
00332 void setTitleText( const QString& text );
00333 QString titleText() const;
00334
00335 void setTitleTextAttributes( const TextAttributes &a );
00336 TextAttributes titleTextAttributes() const;
00337
00338
00339 void setSpacing( uint space );
00340 uint spacing() const;
00341
00342
00343 virtual void forceRebuild();
00344
00345 virtual QSize minimumSizeHint() const;
00346 virtual QSize sizeHint() const;
00347 virtual void needSizeHint();
00348 virtual void resizeLayout( const QSize& size );
00349
00350
00351
00352
00353 Q_SIGNALS:
00354 void destroyedLegend( Legend* );
00356 void propertiesChanged();
00357
00358 private Q_SLOTS:
00359 void emitPositionChanged();
00360 void resetDiagram( AbstractDiagram* );
00361 void activateTheLayout();
00362 void setNeedRebuild();
00363 void buildLegend();
00364 };
00365
00366 }
00367
00368
00369 #endif // KDCHARTLEGEND_H