File indexing completed on 2024-04-28 13:45:53
0001 /* 0002 This file is part of the Okteta Gui library, made within the KDE community. 0003 0004 SPDX-FileCopyrightText: 2008-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 #include "bytearrayrowcolumnrenderer.hpp" 0010 #include "bytearrayrowcolumnrenderer_p.hpp" 0011 0012 // lib 0013 #include "coord.hpp" 0014 0015 namespace Okteta { 0016 0017 ByteArrayRowColumnRenderer::ByteArrayRowColumnRenderer(AbstractColumnStylist* stylist, 0018 AbstractByteArrayModel* byteArrayModel, ByteArrayTableLayout* layout, ByteArrayTableRanges* ranges) 0019 : AbstractColumnRenderer(new ByteArrayRowColumnRendererPrivate(this, stylist, byteArrayModel, layout, ranges)) 0020 { 0021 } 0022 0023 ByteArrayRowColumnRenderer::~ByteArrayRowColumnRenderer() = default; 0024 0025 AbstractByteArrayView::CodingTypes ByteArrayRowColumnRenderer::visibleCodings() const 0026 { 0027 Q_D(const ByteArrayRowColumnRenderer); 0028 0029 return d->visibleCodings(); 0030 } 0031 0032 PixelX ByteArrayRowColumnRenderer::byteWidth() const 0033 { 0034 Q_D(const ByteArrayRowColumnRenderer); 0035 0036 return d->byteWidth(); 0037 } 0038 0039 PixelX ByteArrayRowColumnRenderer::digitWidth() const 0040 { 0041 Q_D(const ByteArrayRowColumnRenderer); 0042 0043 return d->digitWidth(); 0044 } 0045 0046 PixelX ByteArrayRowColumnRenderer::byteSpacingWidth() const 0047 { 0048 Q_D(const ByteArrayRowColumnRenderer); 0049 0050 return d->byteSpacingWidth(); 0051 } 0052 0053 PixelX ByteArrayRowColumnRenderer::groupSpacingWidth() const 0054 { 0055 Q_D(const ByteArrayRowColumnRenderer); 0056 0057 return d->groupSpacingWidth(); 0058 } 0059 0060 PixelY ByteArrayRowColumnRenderer::digitHeight() const 0061 { 0062 Q_D(const ByteArrayRowColumnRenderer); 0063 0064 return d->digitHeight(); 0065 } 0066 0067 Size ByteArrayRowColumnRenderer::noOfGroupedBytes() const 0068 { 0069 Q_D(const ByteArrayRowColumnRenderer); 0070 0071 return d->noOfGroupedBytes(); 0072 } 0073 0074 LinePosition ByteArrayRowColumnRenderer::firstLinePos() const 0075 { 0076 Q_D(const ByteArrayRowColumnRenderer); 0077 0078 return d->firstLinePos(); 0079 } 0080 0081 LinePosition ByteArrayRowColumnRenderer::lastLinePos() const 0082 { 0083 Q_D(const ByteArrayRowColumnRenderer); 0084 0085 return d->lastLinePos(); 0086 } 0087 0088 LinePositionRange ByteArrayRowColumnRenderer::visibleLinePositions() const 0089 { 0090 Q_D(const ByteArrayRowColumnRenderer); 0091 0092 return d->visibleLinePositions(); 0093 } 0094 0095 const ByteArrayTableLayout* ByteArrayRowColumnRenderer::layout() const 0096 { 0097 Q_D(const ByteArrayRowColumnRenderer); 0098 0099 return d->layout(); 0100 } 0101 0102 void ByteArrayRowColumnRenderer::setCharCodec(const CharCodec* charCodec) 0103 { 0104 Q_D(ByteArrayRowColumnRenderer); 0105 0106 d->setCharCodec(charCodec); 0107 } 0108 0109 void ByteArrayRowColumnRenderer::setByteTypeColored(bool byteTypeColored) 0110 { 0111 Q_D(ByteArrayRowColumnRenderer); 0112 0113 d->setByteTypeColored(byteTypeColored); 0114 } 0115 0116 bool ByteArrayRowColumnRenderer::isByteTypeColored() const 0117 { 0118 Q_D(const ByteArrayRowColumnRenderer); 0119 0120 return d->isByteTypeColored(); 0121 } 0122 0123 PixelX ByteArrayRowColumnRenderer::binaryGapWidth() const 0124 { 0125 Q_D(const ByteArrayRowColumnRenderer); 0126 0127 return d->binaryGapWidth(); 0128 } 0129 0130 bool ByteArrayRowColumnRenderer::isShowingNonprinting() const 0131 { 0132 Q_D(const ByteArrayRowColumnRenderer); 0133 0134 return d->isShowingNonprinting(); 0135 } 0136 0137 QChar ByteArrayRowColumnRenderer::substituteChar() const 0138 { 0139 Q_D(const ByteArrayRowColumnRenderer); 0140 0141 return d->substituteChar(); 0142 } 0143 0144 QChar ByteArrayRowColumnRenderer::undefinedChar() const 0145 { 0146 Q_D(const ByteArrayRowColumnRenderer); 0147 0148 return d->undefinedChar(); 0149 } 0150 0151 bool ByteArrayRowColumnRenderer::setSubstituteChar(QChar substituteChar) 0152 { 0153 Q_D(ByteArrayRowColumnRenderer); 0154 0155 return d->setSubstituteChar(substituteChar); 0156 } 0157 0158 bool ByteArrayRowColumnRenderer::setUndefinedChar(QChar undefinedChar) 0159 { 0160 Q_D(ByteArrayRowColumnRenderer); 0161 0162 return d->setUndefinedChar(undefinedChar); 0163 } 0164 0165 bool ByteArrayRowColumnRenderer::setShowingNonprinting(bool showingNonprinting) 0166 { 0167 Q_D(ByteArrayRowColumnRenderer); 0168 0169 return d->setShowingNonprinting(showingNonprinting); 0170 } 0171 0172 AbstractByteArrayView::CodingTypeId ByteArrayRowColumnRenderer::codingIdofY(PixelY y) const 0173 { 0174 Q_D(const ByteArrayRowColumnRenderer); 0175 0176 return d->codingIdofY(y); 0177 } 0178 0179 PixelY ByteArrayRowColumnRenderer::rowHeight() const 0180 { 0181 Q_D(const ByteArrayRowColumnRenderer); 0182 0183 return d->rowHeight(); 0184 } 0185 0186 PixelY ByteArrayRowColumnRenderer::yOfCodingId(AbstractByteArrayView::CodingTypeId codingId) const 0187 { 0188 Q_D(const ByteArrayRowColumnRenderer); 0189 0190 return d->yOfCodingId(codingId); 0191 } 0192 0193 void ByteArrayRowColumnRenderer::set(AbstractByteArrayModel* byteArrayModel) 0194 { 0195 Q_D(ByteArrayRowColumnRenderer); 0196 0197 d->set(byteArrayModel); 0198 } 0199 0200 void ByteArrayRowColumnRenderer::resetXBuffer() 0201 { 0202 Q_D(ByteArrayRowColumnRenderer); 0203 0204 d->resetXBuffer(); 0205 } 0206 0207 void ByteArrayRowColumnRenderer::setVisibleCodings(int visibleCodings) 0208 { 0209 Q_D(ByteArrayRowColumnRenderer); 0210 0211 d->setVisibleCodings(visibleCodings); 0212 } 0213 0214 void ByteArrayRowColumnRenderer::setFontMetrics(const QFontMetrics& fontMetrics) 0215 { 0216 Q_D(ByteArrayRowColumnRenderer); 0217 0218 d->setFontMetrics(fontMetrics); 0219 } 0220 0221 bool ByteArrayRowColumnRenderer::setSpacing(PixelX byteSpacingWidth, Size noOfGroupedBytes, PixelX groupSpacingWidth) 0222 { 0223 Q_D(ByteArrayRowColumnRenderer); 0224 0225 return d->setSpacing(byteSpacingWidth, noOfGroupedBytes, groupSpacingWidth); 0226 } 0227 0228 bool ByteArrayRowColumnRenderer::setByteSpacingWidth(PixelX byteSpacingWidth) 0229 { 0230 Q_D(ByteArrayRowColumnRenderer); 0231 0232 return d->setByteSpacingWidth(byteSpacingWidth); 0233 } 0234 0235 bool ByteArrayRowColumnRenderer::setNoOfGroupedBytes(Size noOfGroupedBytes) 0236 { 0237 Q_D(ByteArrayRowColumnRenderer); 0238 0239 return d->setNoOfGroupedBytes(noOfGroupedBytes); 0240 } 0241 0242 bool ByteArrayRowColumnRenderer::setGroupSpacingWidth(PixelX groupSpacingWidth) 0243 { 0244 Q_D(ByteArrayRowColumnRenderer); 0245 0246 return d->setGroupSpacingWidth(groupSpacingWidth); 0247 } 0248 0249 void ByteArrayRowColumnRenderer::setValueCodec(ValueCoding valueCoding, const ValueCodec* valueCodec) 0250 { 0251 Q_D(ByteArrayRowColumnRenderer); 0252 0253 d->setValueCodec(valueCoding, valueCodec); 0254 } 0255 0256 bool ByteArrayRowColumnRenderer::setBinaryGapWidth(PixelX binaryGapWidth) 0257 { 0258 Q_D(ByteArrayRowColumnRenderer); 0259 0260 return d->setBinaryGapWidth(binaryGapWidth); 0261 } 0262 0263 // perhaps sometimes there will be a grammar 0264 void ByteArrayRowColumnRenderer::renderEditedByte(QPainter* painter, Byte byte, const QString& editBuffer) 0265 { 0266 Q_D(ByteArrayRowColumnRenderer); 0267 0268 d->renderEditedByte(painter, byte, editBuffer); 0269 } 0270 0271 // TODO: why are inlined functions not available as symbols when defined before their use 0272 // TODO: works not precisely for the byte rects but includes spacing and left and right 0273 /*inline*/ LinePosition ByteArrayRowColumnRenderer::linePositionOfX(PixelX PX) const 0274 { 0275 Q_D(const ByteArrayRowColumnRenderer); 0276 0277 return d->linePositionOfX(PX); 0278 } 0279 0280 LinePosition ByteArrayRowColumnRenderer::magneticLinePositionOfX(PixelX PX) const 0281 { 0282 Q_D(const ByteArrayRowColumnRenderer); 0283 0284 return d->magneticLinePositionOfX(PX); 0285 } 0286 0287 LinePositionRange ByteArrayRowColumnRenderer::linePositionsOfX(PixelX x, PixelX width) const 0288 { 0289 Q_D(const ByteArrayRowColumnRenderer); 0290 0291 return d->linePositionsOfX(x, width); 0292 } 0293 0294 PixelX ByteArrayRowColumnRenderer::xOfLinePosition(LinePosition linePosition) const 0295 { 0296 Q_D(const ByteArrayRowColumnRenderer); 0297 0298 return d->xOfLinePosition(linePosition); 0299 } 0300 0301 PixelX ByteArrayRowColumnRenderer::rightXOfLinePosition(LinePosition linePosition) const 0302 { 0303 Q_D(const ByteArrayRowColumnRenderer); 0304 0305 return d->rightXOfLinePosition(linePosition); 0306 } 0307 0308 LinePosition ByteArrayRowColumnRenderer::linePositionOfColumnX(PixelX PX) const 0309 { 0310 Q_D(const ByteArrayRowColumnRenderer); 0311 0312 return d->linePositionOfColumnX(PX); 0313 } 0314 0315 LinePositionRange ByteArrayRowColumnRenderer::linePositionsOfColumnXs(PixelX pixelX, PixelX pixelWidth) const 0316 { 0317 Q_D(const ByteArrayRowColumnRenderer); 0318 0319 return d->linePositionsOfColumnXs(pixelX, pixelWidth); 0320 } 0321 0322 PixelX ByteArrayRowColumnRenderer::columnXOfLinePosition(LinePosition linePosition) const 0323 { 0324 Q_D(const ByteArrayRowColumnRenderer); 0325 0326 return d->columnXOfLinePosition(linePosition); 0327 } 0328 0329 PixelX ByteArrayRowColumnRenderer::columnRightXOfLinePosition(LinePosition linePosition) const 0330 { 0331 Q_D(const ByteArrayRowColumnRenderer); 0332 0333 return d->columnRightXOfLinePosition(linePosition); 0334 } 0335 0336 PixelXRange ByteArrayRowColumnRenderer::xsOfLinePositionsInclSpaces(const LinePositionRange& linePositions) const 0337 { 0338 Q_D(const ByteArrayRowColumnRenderer); 0339 0340 return d->xsOfLinePositionsInclSpaces(linePositions); 0341 } 0342 0343 PixelXRange ByteArrayRowColumnRenderer::columnXsOfLinePositionsInclSpaces(const LinePositionRange& linePositions) const 0344 { 0345 Q_D(const ByteArrayRowColumnRenderer); 0346 0347 return d->columnXsOfLinePositionsInclSpaces(linePositions); 0348 } 0349 0350 QRect ByteArrayRowColumnRenderer::byteRect(Coord coord) const 0351 { 0352 Q_D(const ByteArrayRowColumnRenderer); 0353 0354 return d->byteRect(coord); 0355 } 0356 0357 QRect ByteArrayRowColumnRenderer::byteRect(Coord coord, AbstractByteArrayView::CodingTypeId codingId) const 0358 { 0359 Q_D(const ByteArrayRowColumnRenderer); 0360 0361 return d->byteRect(coord, codingId); 0362 } 0363 0364 void ByteArrayRowColumnRenderer::prepareRendering(const PixelXRange& Xs) 0365 { 0366 Q_D(ByteArrayRowColumnRenderer); 0367 0368 d->prepareRendering(Xs); 0369 } 0370 0371 void ByteArrayRowColumnRenderer::renderFirstLine(QPainter* painter, const PixelXRange& Xs, Line firstLineIndex) 0372 { 0373 Q_D(ByteArrayRowColumnRenderer); 0374 0375 d->renderFirstLine(painter, Xs, firstLineIndex); 0376 } 0377 0378 void ByteArrayRowColumnRenderer::renderNextLine(QPainter* painter) 0379 { 0380 Q_D(ByteArrayRowColumnRenderer); 0381 0382 d->renderNextLine(painter); 0383 } 0384 0385 void ByteArrayRowColumnRenderer::renderByte(QPainter* painter, 0386 Address byteIndex, AbstractByteArrayView::CodingTypeId codingId) 0387 { 0388 Q_D(ByteArrayRowColumnRenderer); 0389 0390 d->renderByte(painter, byteIndex, codingId); 0391 } 0392 0393 // TODO: think about making framestyle a enum of a class ByteArrayColumnCursor 0394 void ByteArrayRowColumnRenderer::renderFramedByte(QPainter* painter, 0395 Address byteIndex, AbstractByteArrayView::CodingTypeId codingId, 0396 FrameStyle frameStyle) 0397 { 0398 Q_D(ByteArrayRowColumnRenderer); 0399 0400 d->renderFramedByte(painter, byteIndex, codingId, frameStyle); 0401 } 0402 0403 void ByteArrayRowColumnRenderer::renderCursor(QPainter* painter, Address byteIndex, AbstractByteArrayView::CodingTypeId codingId) 0404 { 0405 Q_D(ByteArrayRowColumnRenderer); 0406 0407 d->renderCursor(painter, byteIndex, codingId); 0408 } 0409 0410 0411 }