File indexing completed on 2024-05-12 04:20:44

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