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: 2003, 2007-2010 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_BYTEARRAYCOLUMNVIEW_P_HPP 0010 #define OKTETA_BYTEARRAYCOLUMNVIEW_P_HPP 0011 0012 // lib 0013 #include "bytearraycolumnview.hpp" 0014 #include "abstractbytearrayview_p.hpp" 0015 #include "valuebytearraycolumnrenderer.hpp" 0016 #include "charbytearraycolumnrenderer.hpp" 0017 0018 namespace Okteta { 0019 class Coord; 0020 0021 class ByteArrayColumnViewPrivate : public AbstractByteArrayViewPrivate 0022 { 0023 Q_DECLARE_PUBLIC(ByteArrayColumnView) 0024 0025 public: 0026 explicit ByteArrayColumnViewPrivate(ByteArrayColumnView* parent); 0027 ~ByteArrayColumnViewPrivate() override; 0028 0029 public: 0030 void init(); 0031 0032 public: 0033 // value column 0034 int /*PixelX*/ byteSpacingWidth() const; 0035 int noOfGroupedBytes() const; 0036 int /*PixelX*/ groupSpacingWidth() const; 0037 int /*PixelX*/ binaryGapWidth() const; 0038 0039 // char column 0040 bool showsNonprinting() const; 0041 QChar substituteChar() const; 0042 QChar undefinedChar() const; 0043 0044 bool isByteTypeColored() const; 0045 0046 public: // logic value service 0047 QSize minimumSizeHint() const; 0048 0049 public: // modification access 0050 void setByteArrayModel(AbstractByteArrayModel* byteArrayModel); 0051 // void repaintByte( int row, int column, bool Erase = true ); 0052 // void updateByte( int row, int column ); 0053 // void ensureByteVisible( int row, int column ); 0054 0055 public: // AbstractByteArrayViewPrivate API 0056 void ensureVisible(const AddressRange& range, bool ensureStartVisible) override; 0057 void ensureCursorVisible() override; 0058 void placeCursor(QPoint point) override; 0059 QRect cursorRect() const override; 0060 Address indexByPoint(QPoint point) const override; 0061 void blinkCursor() override; 0062 0063 public: 0064 // value column parameters 0065 void setByteSpacingWidth(int /*PixelX*/ byteSpacingWidth); 0066 void setNoOfGroupedBytes(int noOfGroupedBytes); 0067 void setGroupSpacingWidth(int /*PixelX*/ groupSpacingWidth); 0068 void setBinaryGapWidth(int binaryGapWidth); 0069 void setBufferSpacing(/*PixelX*/ int byteSpacingWidth, int noOfGroupedBytes, /*PixelX*/ int groupSpacingWidth); 0070 void setValueCoding(AbstractByteArrayView::ValueCoding valueCoding); 0071 // char column parameters 0072 void setShowsNonprinting(bool showsNonprinting = true); 0073 void setSubstituteChar(QChar substituteChar); 0074 void setUndefinedChar(QChar undefinedChar); 0075 void setCharCoding(AbstractByteArrayView::CharCoding charCoding); 0076 void setCharCoding(const QString& charCodingName); 0077 void setByteTypeColored(bool isColored); 0078 0079 private: // drawing related operations 0080 /** recreates the cursor pixmaps and paints active and inactive cursors if doable */ 0081 void createCursorPixmaps(); 0082 /** draws the blinking cursor or removes it */ 0083 void drawActiveCursor(QPainter* painter); 0084 void drawInactiveCursor(QPainter* painter); 0085 void updateCursor(const AbstractByteArrayColumnRenderer& column); 0086 0087 private: // partial operations 0088 void changeEvent(QEvent* event); 0089 0090 private: 0091 /** recalcs a layout due to the resize style that fits into the view size 0092 * and updates the dependent values 0093 */ 0094 void ensureVisible(const AbstractByteArrayColumnRenderer& column, Coord coord); 0095 void renderColumns(QPainter* painter, int cx, int cy, int cw, int ch); 0096 0097 protected: // AbstractByteArrayViewPrivate API 0098 // cursor control 0099 void pauseCursor() override; 0100 void updateCursors() override; 0101 0102 void setActiveCoding(AbstractByteArrayView::CodingTypeId codingId) override; 0103 void setVisibleCodings(int visibleCodings) override; 0104 0105 protected: // AbstractByteArrayViewPrivate API 0106 AbstractByteArrayView::CodingTypeId activeCoding() const override; 0107 AbstractByteArrayView::CodingTypes visibleCodings() const override; 0108 int fittingBytesPerLine() const override; 0109 void adjustToLayoutNoOfBytesPerLine() override; 0110 void updateChanged() override; 0111 0112 private: 0113 ValueByteArrayColumnRenderer* mValueColumn; 0114 BorderColumnRenderer* mMiddleBorderColumn; 0115 CharByteArrayColumnRenderer* mCharColumn; 0116 0117 /** points to the column with keyboard focus */ 0118 AbstractByteArrayColumnRenderer* mActiveColumn; 0119 /** points to the column without keyboard focus (if there is) */ 0120 AbstractByteArrayColumnRenderer* mInactiveColumn; 0121 }; 0122 0123 inline PixelX ByteArrayColumnViewPrivate::byteSpacingWidth() const { return mValueColumn->byteSpacingWidth(); } 0124 inline int ByteArrayColumnViewPrivate::noOfGroupedBytes() const { return mValueColumn->noOfGroupedBytes(); } 0125 inline PixelX ByteArrayColumnViewPrivate::groupSpacingWidth() const { return mValueColumn->groupSpacingWidth(); } 0126 inline PixelX ByteArrayColumnViewPrivate::binaryGapWidth() const { return mValueColumn->binaryGapWidth(); } 0127 inline bool ByteArrayColumnViewPrivate::showsNonprinting() const { return mCharColumn->isShowingNonprinting(); } 0128 inline QChar ByteArrayColumnViewPrivate::substituteChar() const { return mCharColumn->substituteChar(); } 0129 inline QChar ByteArrayColumnViewPrivate::undefinedChar() const { return mCharColumn->undefinedChar(); } 0130 inline bool ByteArrayColumnViewPrivate::isByteTypeColored() const { return mValueColumn->isByteTypeColored(); } 0131 0132 } 0133 0134 #endif