File indexing completed on 2024-04-28 05:52:37
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_P_HPP 0010 #define OKTETA_ABSTRACTCOLUMNRENDERER_P_HPP 0011 0012 #include "abstractcolumnrenderer.hpp" 0013 0014 // lib 0015 #include "abstractcolumnstylist.hpp" 0016 // Qt 0017 #include <QPainter> 0018 #include <QPalette> 0019 0020 namespace Okteta { 0021 0022 class AbstractColumnRendererPrivate 0023 { 0024 public: 0025 explicit AbstractColumnRendererPrivate(AbstractColumnStylist* stylist); 0026 AbstractColumnRendererPrivate(const AbstractColumnRendererPrivate&) = delete; 0027 0028 virtual ~AbstractColumnRendererPrivate(); 0029 0030 AbstractColumnRendererPrivate& operator=(const AbstractColumnRendererPrivate&) = delete; 0031 0032 public: 0033 void renderBlankLine(QPainter* painter) const; 0034 void renderEmptyColumn(QPainter* painter, const PixelXRange& xSpan, const PixelYRange& ySpan) const; 0035 0036 public: // general column data 0037 /** pointer to the view */ 0038 AbstractColumnStylist* mStylist; 0039 /** should Column be displayed? */ 0040 bool mIsVisible = true; // TODO: would false be better? 0041 0042 /** buffered value */ 0043 PixelY mLineHeight = 0; 0044 0045 /** span of the column in pixel */ 0046 PixelXRange mXSpan = PixelXRange::fromWidth(0, 0); 0047 }; 0048 0049 inline AbstractColumnRendererPrivate::AbstractColumnRendererPrivate(AbstractColumnStylist* stylist) 0050 : mStylist(stylist) 0051 { 0052 } 0053 0054 inline AbstractColumnRendererPrivate::~AbstractColumnRendererPrivate() = default; 0055 0056 inline void AbstractColumnRendererPrivate::renderBlankLine(QPainter* painter) const 0057 { 0058 if (mLineHeight > 0) { 0059 painter->fillRect(0, 0, mXSpan.width(), mLineHeight, 0060 mStylist->palette().brush(QPalette::Base)); 0061 } 0062 } 0063 0064 inline void AbstractColumnRendererPrivate::renderEmptyColumn(QPainter* painter, const PixelXRange& _xSpan, const PixelYRange& ySpan) const 0065 { 0066 PixelXRange xSpan(_xSpan); 0067 xSpan.restrictTo(mXSpan); 0068 0069 painter->fillRect(xSpan.start(), ySpan.start(), xSpan.width(), ySpan.width(), 0070 mStylist->palette().brush(QPalette::Base)); 0071 } 0072 0073 } 0074 0075 #endif