# KDChartWidget.h

Go to the documentation of this file.

    00001 /* -*- Mode: C++ -*-
    00002    KDChart - a multi-platform charting engine
    00003    */
    00004
    00005 /****************************************************************************
    00006  ** Copyright (C) 2001-2006 Klarälvdalens Datakonsult AB.  All rights reserved.
    00007  **
    00008  ** This file is part of the KD Chart library.
    00009  **
    00010  ** This file may be distributed and/or modified under the terms of the
    00011  ** GNU General Public License version 2 as published by the Free Software
    00012  ** Foundation and appearing in the file LICENSE.GPL included in the
    00013  ** packaging of this file.
    00014  **
    00015  ** Licensees holding valid commercial KD Chart licenses may use this file in
    00016  ** accordance with the KD Chart Commercial License Agreement provided with
    00017  ** the Software.
    00018  **
    00019  ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
    00020  ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
    00021  **
    00022  ** See http://www.kdab.net/kdchart for
    00023  **   information about KD Chart Commercial License Agreements.
    00024  **
    00025  ** Contact info@kdab.net if any conditions of this
    00026  ** licensing are not clear to you.
    00027  **
    00028  **********************************************************************/
    00029 #ifndef __KDCHARTWIDGET_H__
    00030 #define __KDCHARTWIDGET_H__
    00031
    00032 #include "KDChartGlobal.h"
    00033
    00034 #include <QWidget>
    00035
    00036 #include "KDChartEnums.h"
    00037 #include "KDChartHeaderFooter.h"
    00038
    00039 template <typename T> class QVector;
    00040 template <typename T1, typename T2> struct QPair;
    00041
    00042 namespace KDChart {
    00043
    00044     // some forward declarations
    00045     class AbstractDiagram;
    00046     class Chart;
    00047     class AbstractCoordinatePlane;
    00048     class TableModel;
    00049     class BarDiagram;
    00050     class LineDiagram;
    00051     class PieDiagram;
    00052     class RingDiagram;
    00053     class PolarDiagram;
    00054     class Legend;
    00055     class Position;
    00056
    00063     class KDCHART_EXPORT Widget : public QWidget
    00064     {
    00065         Q_OBJECT
    00066
    00067         Q_DISABLE_COPY( Widget )
    00068         KDCHART_DECLARE_PRIVATE_BASE_POLYMORPHIC_QWIDGET( Widget )
    00069
    00070     public:
    00078         explicit Widget( QWidget* parent = 0 );
    00079
    00081         ~Widget();
    00083         void setDataset( int column, const QVector< double > & data, const QString& title = QString()  );
    00086         void setDataset( int column, const QVector< QPair< double, double > > &  data, const QString& title = QString() );
    00088         void setDataCell( int row, int column, double data );
    00090         void setDataCell( int row, int column, QPair< double, double > data );
    00092         void resetData();
    00093
    00094     public Q_SLOTS:
    00096         void setGlobalLeading( int left, int top, int right, int bottom );
    00098         void setGlobalLeadingLeft( int leading );
    00100         void setGlobalLeadingTop( int leading );
    00102         void setGlobalLeadingRight( int leading );
    00104         void setGlobalLeadingBottom( int leading );
    00105
    00106     public:
    00108         int globalLeadingLeft() const;
    00110         int globalLeadingTop() const;
    00112         int globalLeadingRight() const;
    00114         int globalLeadingBottom() const;
    00115
    00117         HeaderFooter* firstHeaderFooter();
    00119         QList<HeaderFooter*> allHeadersFooters();
    00120
    00122         void addHeaderFooter( const QString& text,
    00123                               HeaderFooter::HeaderFooterType type,
    00124                               Position position );
    00125
    00130         void addHeaderFooter( HeaderFooter* header );
    00131
    00149         void replaceHeaderFooter( HeaderFooter* header,
    00150                                   HeaderFooter* oldHeader = 0 );
    00151
    00159         void takeHeaderFooter( HeaderFooter* header );
    00160
    00162         Legend* legend();
    00164         QList<Legend*> allLegends();
    00165
    00167         void addLegend( Position position );
    00169         void addLegend (Legend* legend );
    00170
    00171         void replaceLegend( Legend* legend, Legend* oldLegend = 0 );
    00172         void takeLegend( Legend* legend );
    00173
    00174
    00176         AbstractDiagram* diagram();
    00177
    00181         BarDiagram* barDiagram();
    00185         LineDiagram* lineDiagram();
    00189         PieDiagram* pieDiagram();
    00193         RingDiagram* ringDiagram();
    00197         PolarDiagram* polarDiagram();
    00198
    00200         AbstractCoordinatePlane* coordinatePlane();
    00201
    00202
    00203         enum ChartType { NoType, Bar, Line, Pie, Ring, Polar };
    00204
    00206         ChartType type() const;
    00207
    00209         enum SubType { Normal, Stacked, Percent, Rows };
    00210
    00212         SubType subType() const;
    00213
    00214     public Q_SLOTS:
    00216         void setType( ChartType chartType, SubType subType=Normal );
    00227         void setSubType( SubType subType );
    00228
    00229     private:
    00231         void justifyModelSize( int rows, int columns );
    00233         bool checkDatasetWidth( int width );
    00234     };
    00235 }
    00236
    00237 #endif // KDChartWidget_H