@@ -158,7 +158,7 @@ void QHexEdit::setCursorPosition(qint64 position)
158158 _pxCursorX = x / 2 * _pxCharWidth + _pxPosAsciiX;
159159 _cursorPosition = position & 0xFFFFFFFFFFFFFFFE ;
160160 } else {
161- _pxCursorX = (((x / 2 ) * 3 ) + (x % 2 ) + 1 ) * _pxCharWidth + _pxPosHexX;
161+ _pxCursorX = (((x / 2 ) * 3 ) + (x % 2 )) * _pxCharWidth + _pxPosHexX;
162162 _cursorPosition = position;
163163 }
164164
@@ -438,9 +438,7 @@ void QHexEdit::setFont(const QFont &font)
438438 _pxCharWidth = metrics.width (QLatin1Char (' 2' ));
439439#endif
440440 _pxCharHeight = metrics.height ();
441- _pxGapAdr = _pxCharWidth / 2 ;
442- _pxGapAdrHex = _pxCharWidth;
443- _pxGapHexAscii = 2 * _pxCharWidth;
441+ _pxAreaMargin = _pxCharWidth / 2 ;
444442 _pxCursorWidth = _pxCharHeight / 7 ;
445443 _pxSelectionSub = _pxCharHeight / 5 ;
446444 viewport ()->update ();
@@ -861,9 +859,9 @@ void QHexEdit::paintEvent(QPaintEvent *event)
861859 {
862860 painter.fillRect (
863861 QRect (
864- pxPosAsciiX2,
862+ pxPosAsciiX2 - _pxAreaMargin ,
865863 event->rect ().top (),
866- _pxCharWidth * _bytesPerLine,
864+ _pxCharWidth * _bytesPerLine + 2 * _pxAreaMargin ,
867865 height ()
868866 ),
869867 _colorManager->notMarked (Area::Ascii).areaStyle ()
@@ -875,7 +873,7 @@ void QHexEdit::paintEvent(QPaintEvent *event)
875873 {
876874 QByteArray hex;
877875 qint64 bPosLine = row * _bytesPerLine;
878- int pxPosX = _pxPosHexX - pxOfsX + _pxCharWidth ;
876+ int pxPosX = _pxPosHexX - pxOfsX;
879877 int pxPosAsciiX2 = _pxPosAsciiX - pxOfsX;
880878
881879 // *** address info
@@ -987,17 +985,17 @@ void QHexEdit::resizeEvent(QResizeEvent *)
987985 {
988986 int pxFixGaps = 0 ;
989987 if (_addressArea)
990- pxFixGaps = addressWidth () * _pxCharWidth + _pxGapAdr ;
991- pxFixGaps += _pxGapAdrHex ;
988+ pxFixGaps = addressWidth () * _pxCharWidth + 2 * _pxAreaMargin ;
989+ pxFixGaps += 2 * _pxAreaMargin ;
992990 if (_asciiArea)
993- pxFixGaps += _pxGapHexAscii ;
991+ pxFixGaps += 2 * _pxAreaMargin ;
994992
995993 // +1 because the last hex value do not have space. so it is effective one char more
996994 int charWidth = (viewport ()->width () - pxFixGaps ) / _pxCharWidth + 1 ;
997995
998996 // 2 hex alfa-digits 1 space 1 ascii per byte = 4; if ascii is disabled then 3
999997 // to prevent devision by zero use the min value 1
1000- setBytesPerLine (std::max (charWidth / (_asciiArea ? 4 : 3 ),1 ));
998+ setBytesPerLine (std::max (charWidth / (_asciiArea ? 4 : 3 ), 1 ));
1001999 }
10021000 adjust ();
10031001}
@@ -1094,12 +1092,12 @@ void QHexEdit::adjust()
10941092 if (_addressArea)
10951093 {
10961094 _addrDigits = addressWidth ();
1097- _pxPosHexX = _pxGapAdr + _addrDigits*_pxCharWidth + _pxGapAdrHex ;
1095+ _pxPosHexX = _pxAreaMargin + _addrDigits*_pxCharWidth + 2 * _pxAreaMargin ;
10981096 }
10991097 else
1100- _pxPosHexX = _pxGapAdrHex ;
1101- _pxPosAdrX = _pxGapAdr ;
1102- _pxPosAsciiX = _pxPosHexX + _hexCharsInLine * _pxCharWidth + _pxGapHexAscii ;
1098+ _pxPosHexX = _pxAreaMargin ;
1099+ _pxPosAdrX = _pxAreaMargin ;
1100+ _pxPosAsciiX = _pxPosHexX + _hexCharsInLine * _pxCharWidth + 2 * _pxAreaMargin ;
11031101
11041102 // set horizontalScrollBar()
11051103 int pxWidth = _pxPosAsciiX;
0 commit comments