File indexing completed on 2024-05-12 04:43:22

0001 /* This file is part of the KDE project
0002  * Copyright (C) 2007-2008 by Adam Pigg (adam@piggz.co.uk)
0003  *
0004  * This library is free software; you can redistribute it and/or
0005  * modify it under the terms of the GNU Lesser General Public
0006  * License as published by the Free Software Foundation; either
0007  * version 2.1 of the License, or (at your option) any later version.
0008  *
0009  * This library is distributed in the hope that it will be useful,
0010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
0011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
0012  * Lesser General Public License for more details.
0013  *
0014  * You should have received a copy of the GNU Lesser General Public
0015  * License along with this library.  If not, see <http://www.gnu.org/licenses/>.
0016  */
0017 
0018 #ifndef KRSCRIPTDRAW_H
0019 #define KRSCRIPTDRAW_H
0020 
0021 #include <QObject>
0022 #include <QPointF>
0023 
0024 class OROPage;
0025 
0026 /**
0027  @brief Helper giving access to drawing functions
0028 
0029  Contains methods for drawing shapes on a report page
0030 */
0031 class KReportScriptDraw : public QObject
0032 {
0033     Q_OBJECT
0034 public:
0035     explicit KReportScriptDraw(QObject *parent = nullptr);
0036 
0037     ~KReportScriptDraw() override;
0038     void setPage(OROPage*);
0039     void setOffset(QPointF);
0040 public Q_SLOTS:
0041     /**
0042     @brief Draw a rectangle
0043     \param x X posistion
0044     \param y Y position
0045     \param w Width
0046     \param h Height
0047     \param lc Line Color
0048     \param fc Fill Color
0049     \param lw Line Width
0050     \param o Opacity (0=transparent, 100=opaque)
0051     */
0052     void rectangle(qreal, qreal, qreal, qreal, const QString&, const QString&, qreal, int);
0053 
0054     /**
0055     @brief Draw an ellipse
0056     \param x X posistion
0057     \param y Y position
0058     \param w Width
0059     \param h Height
0060     \param lc Line Color
0061     \param fc Fill Color
0062     \param lw Line Width
0063     \param o Opacity (0=transparent, 100=opaque)
0064      */
0065     void ellipse(qreal, qreal, qreal, qreal, const QString&, const QString&, qreal, int);
0066 
0067     /**
0068     @brief Draw a line
0069     \param x1 Start X position
0070     \param y1 Start Y Position
0071     \param x2 End X position
0072     \param y2 End Y position
0073     \param lc Line Color
0074     */
0075     void line(qreal, qreal, qreal, qreal, const QString&);
0076 
0077     /**
0078     @brief Draw some text
0079     \param x X Position
0080     \param y Y Position
0081     \param txt The text
0082     \param fnt The font
0083     \param pt Point size
0084     \param fc Foreground color
0085     \param bc Background color
0086     \param lc Line color
0087     \param lw Line width
0088     \param o Opacity (0=transparent, 100=opaque)
0089     */
0090     void text(qreal, qreal, const QString &, const QString &fnt = QLatin1String("Helvetica"),
0091               int pt = 12, const QString &fc = QLatin1String("#000000"), const QString &bc = QLatin1String("#ffffff"),
0092               const QString &lc = QLatin1String("#ffffff"), qreal lw = 0, int o = 0);
0093 private:
0094     OROPage *m_curPage;
0095     QPointF m_curOffset;
0096 
0097 };
0098 
0099 #endif