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
00186 uint dataSetOffset( KDChart::AbstractDiagram* diagram );
00187
00196 void setDiagram( KDChart::AbstractDiagram* newDiagram );
00197
00206 void setPosition( Position position );
00207
00212 Position position() const;
00213
00222 void setAlignment( Qt::Alignment );
00223
00228 Qt::Alignment alignment() const;
00229
00235 void setTextAlignment( Qt::Alignment );
00236
00242 Qt::Alignment textAlignment() const;
00243
00288 void setFloatingPosition( const RelativePosition& relativePosition );
00289
00294 const RelativePosition floatingPosition() const;
00295
00296 void setOrientation( Qt::Orientation orientation );
00297 Qt::Orientation orientation() const;
00298
00299
00300 void setSortOrder( Qt::SortOrder order );
00301 Qt::SortOrder sortOrder() const;
00302
00303 void setShowLines( bool legendShowLines );
00304 bool showLines() const;
00305
00306 void resetTexts();
00307 void setText( uint dataset, const QString& text );
00308 QString text( uint dataset ) const;
00309 const QMap<uint,QString> texts() const;
00310
00318 void setHiddenDatasets( const QList<uint> hiddenDatasets );
00319 const QList<uint> hiddenDatasets() const;
00320 void setDatasetHidden( uint dataset, bool hidden );
00321 bool datasetIsHidden( uint dataset ) const;
00322
00323 uint datasetCount() const;
00324
00325 void setDefaultColors();
00326 void setRainbowColors();
00327 void setSubduedColors( bool ordered = false );
00328
00329 void setBrushesFromDiagram( KDChart::AbstractDiagram* diagram );
00330
00336 void setColor( uint dataset, const QColor& color );
00337
00338 void setBrush( uint dataset, const QBrush& brush );
00339 QBrush brush( uint dataset ) const;
00340 const QMap<uint,QBrush> brushes() const;
00341
00342 void setPen( uint dataset, const QPen& pen );
00343 QPen pen( uint dataset ) const;
00344 const QMap<uint,QPen> pens() const;
00345
00351 void setMarkerAttributes( uint dataset, const MarkerAttributes& );
00352 MarkerAttributes markerAttributes( uint dataset ) const;
00353 const QMap<uint, MarkerAttributes> markerAttributes() const;
00354
00362 void setUseAutomaticMarkerSize( bool useAutomaticMarkerSize );
00363 bool useAutomaticMarkerSize() const;
00364
00365 void setTextAttributes( const TextAttributes &a );
00366 TextAttributes textAttributes() const;
00367
00368 void setTitleText( const QString& text );
00369 QString titleText() const;
00370
00371 void setTitleTextAttributes( const TextAttributes &a );
00372 TextAttributes titleTextAttributes() const;
00373
00374
00375 void setSpacing( uint space );
00376 uint spacing() const;
00377
00378
00379 virtual void forceRebuild();
00380
00381 virtual QSize minimumSizeHint() const;
00382 virtual QSize sizeHint() const;
00383 virtual void needSizeHint();
00384 virtual void resizeLayout( const QSize& size );
00385
00386
00387
00388
00389 Q_SIGNALS:
00390 void destroyedLegend( Legend* );
00392 void propertiesChanged();
00393
00394 private Q_SLOTS:
00395 void emitPositionChanged();
00396 void resetDiagram( AbstractDiagram* );
00397 void activateTheLayout();
00398 void setNeedRebuild();
00399 void buildLegend();
00400 };
00401
00402 }
00403
00404
00405 #endif // KDCHARTLEGEND_H