File indexing completed on 2024-03-24 17:26:50
0001 /* 0002 This file is part of the Okteta Gui library, made within the KDE community. 0003 0004 SPDX-FileCopyrightText: 2003, 2008, 2019 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_VALUEBYTEARRAYCOLUMNRENDERER_P_HPP 0010 #define OKTETA_VALUEBYTEARRAYCOLUMNRENDERER_P_HPP 0011 0012 // lib 0013 #include "valuebytearraycolumnrenderer.hpp" 0014 #include "abstractbytearraycolumnrenderer_p.hpp" 0015 #include "oktetagui.hpp" 0016 0017 namespace Okteta { 0018 0019 class ValueByteArrayColumnRendererPrivate : public AbstractByteArrayColumnRendererPrivate 0020 { 0021 public: 0022 ValueByteArrayColumnRendererPrivate(ValueByteArrayColumnRenderer* q, 0023 AbstractColumnStylist* stylist, 0024 AbstractByteArrayModel* byteArrayModel, 0025 ByteArrayTableLayout* layout, 0026 ByteArrayTableRanges* ranges); 0027 0028 ~ValueByteArrayColumnRendererPrivate() override; 0029 0030 public: 0031 void renderEditedByte(QPainter* painter, Byte byte, const QString& editBuffer); 0032 0033 public: // modification access 0034 void setValueCodec(ValueCoding valueCoding, const ValueCodec* valueCodec); 0035 /** sets the spacing in the middle of a binary byte in the value column 0036 * @param binaryGapWidth spacing in the middle of a binary in pixels 0037 * returns true if there was a change 0038 */ 0039 bool setBinaryGapWidth(PixelX binaryGapWidth); 0040 0041 public: // value access 0042 PixelX binaryGapWidth() const; 0043 0044 protected: // AbstractByteArrayColumnRendererPrivate API 0045 void renderByteText(QPainter* painter, Byte byte, Character byteChar, const QColor& color) const override; 0046 void recalcByteWidth() override; 0047 0048 protected: 0049 void renderCode(QPainter* painter, const QString& code, const QColor& color) const; 0050 0051 private: // settings 0052 /** */ 0053 ValueCoding mValueCoding; 0054 /** */ 0055 const ValueCodec* mValueCodec = nullptr; 0056 /** */ 0057 PixelX mBinaryGapWidth; 0058 0059 private: // buffered data 0060 /** buffer to hold the formatted valueCoding */ 0061 mutable QString mDecodedByteText; 0062 /** calculated: Offset in pixels of the second half of the binary */ 0063 PixelX mBinaryHalfOffset; 0064 0065 private: 0066 Q_DECLARE_PUBLIC(ValueByteArrayColumnRenderer) 0067 }; 0068 0069 0070 inline ValueByteArrayColumnRendererPrivate::ValueByteArrayColumnRendererPrivate(ValueByteArrayColumnRenderer* q, 0071 AbstractColumnStylist* stylist, 0072 AbstractByteArrayModel* byteArrayModel, 0073 ByteArrayTableLayout* layout, 0074 ByteArrayTableRanges* ranges) 0075 : AbstractByteArrayColumnRendererPrivate(q, stylist, byteArrayModel, layout, ranges) 0076 , mBinaryGapWidth(DefaultBinaryGapWidth) 0077 { 0078 } 0079 0080 inline ValueByteArrayColumnRendererPrivate::~ValueByteArrayColumnRendererPrivate() = default; 0081 0082 inline PixelX ValueByteArrayColumnRendererPrivate::binaryGapWidth() const { return mBinaryGapWidth; } 0083 0084 } 0085 0086 #endif