File indexing completed on 2024-04-28 17:07:10
0001 /* 0002 This file is part of the Okteta Gui library, made within the KDE community. 0003 0004 SPDX-FileCopyrightText: 2003, 2007-2009 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 OKTETA_ABSTRACTCOLUMNRENDERER_HPP 0010 #define OKTETA_ABSTRACTCOLUMNRENDERER_HPP 0011 0012 // lib 0013 #include "oktetagui_export.hpp" 0014 #include "pixelmetrics.hpp" 0015 // Qt 0016 #include <QScopedPointer> 0017 0018 class QPainter; 0019 0020 namespace Okteta { 0021 0022 class AbstractColumnStylist; 0023 0024 class AbstractColumnRendererPrivate; 0025 0026 /** base class for columns of the ColumnsView 0027 * 0028 * 0029 * @author Friedrich W. H. Kossebau 0030 */ 0031 0032 class OKTETAGUI_EXPORT AbstractColumnRenderer 0033 { 0034 // friend class ColumnsView; 0035 0036 protected: 0037 OKTETAGUI_NO_EXPORT explicit AbstractColumnRenderer(AbstractColumnRendererPrivate* d); 0038 0039 public: 0040 explicit AbstractColumnRenderer(AbstractColumnStylist* stylist); 0041 AbstractColumnRenderer(const AbstractColumnRenderer&) = delete; 0042 0043 virtual ~AbstractColumnRenderer(); 0044 0045 AbstractColumnRenderer& operator=(const AbstractColumnRenderer&) = delete; 0046 0047 public: // API to be reimplemented in the subclasses 0048 /** Before an update of the columns view each column that intersects with the area to be painted 0049 * will be called with this function. As often multiple lines of a column are affected 0050 * for each lines the same values (like first and last char positions) might be calculated. 0051 * This function enables a one-time-calculation for such data that must be stored in some 0052 * class members, though. 0053 * @param painter painter variable 0054 * @param xSpan 0055 * @param firstLineIndex no of the first of the range of lines to paint 0056 */ 0057 virtual void renderFirstLine(QPainter* painter, const PixelXRange& xSpan, int firstLineIndex); 0058 /** the actual painting call for a column's line. 0059 * The default implementation simply paints the background 0060 */ 0061 virtual void renderNextLine(QPainter* painter); 0062 0063 /** */ 0064 virtual void renderColumn(QPainter* painter, const PixelXRange& xSpan, const PixelYRange& ySpan); 0065 /** */ 0066 virtual void renderEmptyColumn(QPainter* painter, const PixelXRange& xSpan, const PixelYRange& ySpan); 0067 0068 public: // modification access 0069 /** sets starting point of the column */ 0070 void setX(PixelX x); 0071 /** sets visibily */ 0072 void setVisible(bool isVisible); 0073 /** buffer actual line height in column */ 0074 void setLineHeight(PixelY lineHeight); 0075 0076 public: // value access 0077 /** */ 0078 AbstractColumnStylist* stylist() const; 0079 /** left offset x in pixel */ 0080 PixelX x() const; 0081 /** total width in pixel */ 0082 PixelX width() const; 0083 /** right offset x in pixel */ 0084 PixelX rightX() const; 0085 /** should Column be displayed? */ 0086 bool isVisible() const; 0087 /** convenience: returns width if visible else 0 */ 0088 PixelX visibleWidth() const; 0089 /** */ 0090 PixelY lineHeight() const; 0091 0092 public: // functional logic 0093 /** true if column overlaps with pixels between x-positions x1, x2 */ 0094 bool overlaps(const PixelXRange& xSpan) const; 0095 0096 protected: 0097 /** sets width of the column */ 0098 void setWidth(PixelX width); 0099 /** */ 0100 void restrictToXSpan(PixelXRange* xSpan) const; 0101 /** */ 0102 void renderBlankLine(QPainter* painter) const; 0103 0104 protected: 0105 const QScopedPointer<AbstractColumnRendererPrivate> d_ptr; 0106 0107 private: 0108 Q_DECLARE_PRIVATE(AbstractColumnRenderer) 0109 }; 0110 0111 } 0112 0113 #endif