File indexing completed on 2025-01-05 05:23:53

0001 /*
0002     This file is part of the Okteta Kasten module, made within the KDE community.
0003 
0004     SPDX-FileCopyrightText: 2003, 2008 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 KASTEN_ABSTRACTBYTEARRAYCOLUMNTEXTRENDERER_HPP
0010 #define KASTEN_ABSTRACTBYTEARRAYCOLUMNTEXTRENDERER_HPP
0011 
0012 // lib
0013 #include "abstractcolumntextrenderer.hpp"
0014 // Okteta gui
0015 #include <Okteta/CoordRange>
0016 
0017 namespace Okteta {
0018 class AbstractByteArrayModel;
0019 }
0020 
0021 namespace Kasten {
0022 
0023 // TODO: offset should be set in renderFirstLine, calculated using coordRange,
0024 // in constructor instead take startOffset
0025 class AbstractByteArrayColumnTextRenderer : public AbstractColumnTextRenderer
0026 {
0027 private:
0028     static constexpr int DefaultTRByteSpacingWidth = 1;
0029     static constexpr int TRGroupSpacingWidth = 2;
0030 
0031 public:
0032     AbstractByteArrayColumnTextRenderer(const Okteta::AbstractByteArrayModel* byteArrayModel, Okteta::Address offset,
0033                                         const Okteta::CoordRange& coordRange,
0034                                         int noOfBytesPerLine);
0035     ~AbstractByteArrayColumnTextRenderer() override;
0036 
0037 public: // AbstractColumnTextRenderer API
0038     void renderFirstLine(QTextStream* stream, int lineIndex) const override;
0039     void renderNextLine(QTextStream* stream, bool isSubline) const override;
0040 
0041 protected: // API to be reimplemented by subclasses
0042     virtual void renderLine(QTextStream* stream, bool isSubline) const = 0;
0043 
0044 protected:
0045     void setWidths(int byteWidth, int byteSpacingWidth, int noOfGroupedBytes);
0046 
0047 protected:
0048     const Okteta::AbstractByteArrayModel* mByteArrayModel;
0049 
0050     const Okteta::CoordRange mCoordRange;
0051 
0052     const int mNoOfBytesPerLine;
0053 
0054     /** Line to print */
0055     mutable int mRenderLine;
0056     /** Data to print */
0057     mutable Okteta::Address mOffset;
0058 
0059     /** buffered value of how many chars a line needs */
0060     int mNoOfCharsPerLine = 0;
0061     // positions where to paint the
0062     int* const mLinePositions;
0063 };
0064 
0065 }
0066 
0067 #endif