File indexing completed on 2024-05-12 16:33:33

0001 /* This file is part of the KDE project
0002 
0003    Copyright 2007-2008 Johannes Simon <johannes.simon@gmail.com>
0004    Copyright 2010      Inge Wallin <inge@lysator.liu.se>
0005 
0006    This library is free software; you can redistribute it and/or
0007    modify it under the terms of the GNU Library General Public
0008    License as published by the Free Software Foundation; either
0009    version 2 of the License, or (at your option) any later version.
0010 
0011    This library is distributed in the hope that it will be useful,
0012    but WITHOUT ANY WARRANTY; without even the implied warranty of
0013    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0014    Library General Public License for more details.
0015 
0016    You should have received a copy of the GNU Library General Public License
0017    along with this library; see the file COPYING.LIB.  If not, write to
0018    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
0019  * Boston, MA 02110-1301, USA.
0020 */
0021 
0022 #ifndef KCHART_LEGEND_H
0023 #define KCHART_LEGEND_H
0024 
0025 // Qt
0026 #include <QObject>
0027 
0028 // Calligra
0029 #include <KoShape.h>
0030 
0031 // KoChart
0032 #include "ChartShape.h"
0033 
0034 
0035 namespace KoChart {
0036 
0037 class Legend : public QObject, public KoShape
0038 {
0039     Q_OBJECT
0040 
0041 public:
0042     explicit Legend(ChartShape *parent);
0043     ~Legend();
0044 
0045     QString title() const;
0046     QFont font() const;
0047     qreal fontSize() const;
0048     QColor fontColor() const;
0049     QFont titleFont() const;
0050     qreal titleFontSize() const;
0051     LegendExpansion expansion() const;
0052     Qt::Alignment alignment() const;
0053     Position legendPosition() const;
0054 
0055     void setTitle(const QString &title);
0056     void setFont(const QFont &font);
0057     void setFontSize(qreal size);
0058     void setFontColor(const QColor &color);
0059     void setTitleFont(const QFont &font);
0060     void setTitleFontSize(qreal size);
0061     void setExpansion(LegendExpansion expansion);
0062     void setAlignment(Qt::Alignment alignment);
0063     void setLegendPosition(Position position);
0064     void setSize(const QSizeF &size) override;
0065 
0066     void paint(QPainter &painter, const KoViewConverter &converter, KoShapePaintingContext &paintcontext) override;
0067     void paintPixmap(QPainter &painter, const KoViewConverter &converter);
0068 
0069     bool loadOdf(const KoXmlElement &legendElement, KoShapeLoadingContext &context) override;
0070     void saveOdf(KoShapeSavingContext &context) const override;
0071 
0072     KChart::Legend *kdLegend() const;
0073 
0074     void rebuild();
0075     using KoShape::update;
0076     void update() const override;
0077 
0078 Q_SIGNALS:
0079     void updateConfigWidget();
0080 
0081 private Q_SLOTS:
0082     void slotChartTypeChanged(ChartType chartType );
0083     void slotKdLegendChanged();
0084 
0085 private:
0086     class Private;
0087     Private *const d;
0088 };
0089 
0090 }
0091 
0092 #endif // KCHART_LEGEND_H
0093