File indexing completed on 2024-04-21 05:53:49
0001 /* 0002 This file is part of the Okteta Kasten module, made within the KDE community. 0003 0004 SPDX-FileCopyrightText: 2007 Friedrich W. H. Kossebau <kossebau@kde.org> 0005 0006 SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL 0007 */ 0008 0009 #ifndef FRAMESPRINT_HEADERFOOTERFRAMERENDERER_HPP 0010 #define FRAMESPRINT_HEADERFOOTERFRAMERENDERER_HPP 0011 0012 // lib 0013 #include "abstractframerenderer.hpp" 0014 // Qt 0015 #include <QStringList> 0016 #include <QFont> 0017 #include <QColor> 0018 #include <QUrl> 0019 0020 class QString; 0021 0022 class PrintInfo 0023 { 0024 public: 0025 PrintInfo() = default; 0026 PrintInfo(const PrintInfo&) = delete; 0027 0028 PrintInfo& operator=(const PrintInfo&) = delete; 0029 0030 public: 0031 QUrl url() const; 0032 int noOfPages() const; 0033 0034 public: 0035 void setUrl(const QUrl& url); 0036 void setNoOfPages(int noOfPages); 0037 0038 private: 0039 QUrl mUrl; 0040 int mNoOfPages; 0041 }; 0042 0043 inline QUrl PrintInfo::url() const { return mUrl; } 0044 inline int PrintInfo::noOfPages() const { return mNoOfPages; } 0045 inline void PrintInfo::setUrl(const QUrl& url) { mUrl = url; } 0046 inline void PrintInfo::setNoOfPages(int noOfPages) { mNoOfPages = noOfPages; } 0047 0048 class HeaderFooterFrameRenderer : public AbstractFrameRenderer 0049 { 0050 public: 0051 enum BoxStyle 0052 { 0053 NoLines = 0, 0054 NoBackground = 0, 0055 NoBox = NoLines | NoBackground, 0056 BackgroundDrawn = 1, 0057 LineAbove = 2, LineBelow = 4, LinesAtSide = 8, 0058 Box = LineAbove | LineBelow | LinesAtSide 0059 }; 0060 0061 public: 0062 explicit HeaderFooterFrameRenderer(const PrintInfo* info); 0063 ~HeaderFooterFrameRenderer() override; 0064 0065 public: // AbstractFrameRenderer API 0066 // make this flags? 0067 // virtual bool hasFixedWidth() const; 0068 // virtual bool hasFixedHeight() const; 0069 int height() const override; 0070 int width() const override; 0071 // virtual QSize sizeHint( const QSize &maxSize ) const; 0072 // only vertical for now... 0073 // virtual int framesCount() const; 0074 0075 void prepare() override; 0076 void renderFrame(QPainter* painter, int frameIndex) override; 0077 0078 public: 0079 void setWidth(int width); 0080 void setTexts(const QString& leftText, const QString& centerText, const QString& rightText); 0081 void setBoxStyle(int boxStyle); 0082 0083 private: 0084 void calculateHeight(); 0085 0086 private: 0087 const PrintInfo* mInfo; 0088 0089 int mHeight = 0; 0090 int mWidth = 0; 0091 0092 int mBoxStyle = NoBox; 0093 // int mLineWidth = 1; 0094 // int mBoxMargin = 6; 0095 QColor mLineColor; 0096 QColor mBgColor = {Qt::lightGray}; 0097 QColor mFgColor = {Qt::black}; 0098 QFont mFont; 0099 0100 QStringList mOriginalTextList = {QString(), QString(), QString()}; 0101 QStringList mGloballyReplacedTextList; 0102 }; 0103 0104 #endif