File indexing completed on 2024-05-12 15:54:28

0001 /*
0002  * Copyright (C) 2020 Dag Andersen <dag.andersen@kdemail.net>
0003  *
0004  * This file is part of the KGantt library.
0005  *
0006  * This program is free software; you can redistribute it and/or
0007  * modify it under the terms of the GNU General Public License as
0008  * published by the Free Software Foundation; either version 2 of
0009  * the License, or (at your option) any later version.
0010  *
0011  * This program 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
0014  * GNU General Public License for more details.
0015  *
0016  * You should have received a copy of the GNU General Public License
0017  * along with this program.  If not, see <https://www.gnu.org/licenses/>.
0018  */
0019 
0020 #ifndef KGANTTPRINTINGCONTEXT_H
0021 #define KGANTTPRINTINGCONTEXT_H
0022 
0023 #include "kganttglobal.h"
0024 
0025 #include <QRectF>
0026 
0027 class QPainter;
0028 class QPrinter;
0029 
0030 namespace KGantt
0031 {
0032     /*!\class KGantt::PrintingContext kganttprintingcontext.h KGanttPrintingContext
0033      * \ingroup KGantt
0034      * \brief The PrintingContext class provides options for printing the gantt chart.
0035      * 
0036      * \since 2.8.0
0037      */
0038     class KGANTT_EXPORT PrintingContext
0039     {
0040     public:
0041         /*! Create a default context */
0042         PrintingContext();
0043         /*! Copy the \a other context into this */
0044         PrintingContext(const PrintingContext &other);
0045         /*! Copy the \a other context into this */
0046         PrintingContext &operator=(const PrintingContext &other);
0047         /*! Destroy this context */
0048         ~PrintingContext();
0049 
0050         /*! \enum KGantt::PrintingContext::Fitting
0051          * Specifies how the diagram shall be fitted
0052          * to the printed pages.
0053          */
0054         enum Fitting {
0055             NoFitting = 1,     ///< No scaling, print as many pages as needed
0056             FitSinglePage = 2, ///< Scale diagram to fit on a single page
0057             FitPageHeight = 4  ///< Scale diagram height to fit one page
0058         };
0059 
0060         /*! \return scene rect
0061          */
0062         QRectF sceneRect() const;
0063 
0064         /*! Set sceneRect to \a rect
0065          * Setting a  null() rect means the whole diagram (default).
0066          */
0067         void setSceneRect(const QRectF &rect);
0068 
0069         /*! \return print scaling
0070          */
0071         Fitting fitting() const;
0072         /*! Set print scaling to \a value
0073          */
0074         void setFitting(const Fitting &value);
0075 
0076         /*! \return if the the row labels shall be printed 
0077          */
0078         bool drawRowLabels() const;
0079 
0080         /*! Set if the row labels shall be printed to @p state
0081          * The row labels are printed to the left of the chart.
0082          */
0083         void setDrawRowLabels(bool state);
0084 
0085         /*! \return if the the column labels shall be printed 
0086          */
0087         bool drawColumnLabels() const;
0088 
0089         /*! Set if the column labels shall be printed to @p state.
0090          */
0091         void setDrawColumnLabels(bool state);
0092 
0093         /*! \return position in the diagram to start printing
0094          */
0095         qreal left() const;
0096 
0097         /*! Set left position to start printing to @p left
0098          * 
0099          * The default is 0.0, meaning the left of the chart.
0100          * 
0101          * To print a certain range of a chart with a DateTimeGrid, use
0102          * qreal DateTimeGrid::mapFromDateTime( const QDateTime& dt) const
0103          * to figure out the values for @p left.
0104          */
0105         void setLeft(qreal left);
0106 
0107         /*! \return top position in the diagram to start printing
0108          */
0109         qreal top() const;
0110 
0111         /*! Set the top position to start printing to @p top
0112          */
0113         void setTop(qreal top);
0114 
0115         /*! \return position in the diagram to end printing
0116          */
0117         qreal right() const;
0118 
0119         /*! Set right position to right printing to @p right
0120          * 
0121          * The default is 0.0, meaning the right of the chart.
0122          * 
0123          * To print a certain range of a chart with a DateTimeGrid, use
0124          * qreal DateTimeGrid::mapFromDateTime( const QDateTime& dt) const
0125          * to figure out the values for @p right.
0126          */
0127         void setRight(qreal right);
0128 
0129         /*! \return bottom position in the diagram to end printing
0130          */
0131         qreal bottom() const;
0132 
0133         /*! Set bottom position to end printing to @p right
0134          */
0135         void setBottom(qreal bottom);
0136 
0137     private:
0138         class Private;
0139         Private *d;
0140     };
0141 
0142 } // namespace KGantt
0143 
0144 #ifndef QT_NO_DEBUG_STREAM
0145 QDebug KGANTT_EXPORT operator<<( QDebug dbg, const KGantt::PrintingContext::Fitting &f);
0146 QDebug KGANTT_EXPORT operator<<( QDebug dbg, const KGantt::PrintingContext &ctx);
0147 #endif
0148 
0149 #endif