MCPcopy Create free account
hub / github.com/Simsys/qhexedit2 / paintEvent

Method paintEvent

src/qhexedit.cpp:835–982  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

833}
834
835void QHexEdit::paintEvent(QPaintEvent *event)
836{
837 QPainter painter(viewport());
838 int pxOfsX = horizontalScrollBar()->value();
839 int pxPosAsciiX2 = _pxPosAsciiX - pxOfsX;
840
841 if (event->rect() != _cursorRect)
842 {
843 int pxPosStartY = _pxCharHeight;
844
845 // *** prepare background
846 painter.fillRect(
847 event->rect(),
848 viewport()->palette().color(QPalette::Base)
849 );
850 if (_addressArea)
851 painter.fillRect(
852 QRect(
853 -pxOfsX,
854 event->rect().top(),
855 _pxCharWidth * (_addrDigits + 1),
856 height()
857 ),
858 _colorManager->notMarked(Area::Address).areaStyle()
859 );
860 if (_asciiArea)
861 {
862 painter.fillRect(
863 QRect(
864 pxPosAsciiX2 - _pxAreaMargin,
865 event->rect().top(),
866 _pxCharWidth * _bytesPerLine + 2 * _pxAreaMargin,
867 height()
868 ),
869 _colorManager->notMarked(Area::Ascii).areaStyle()
870 );
871 }
872
873 // *** paint central areas
874 for (int row = 0, pxPosY = pxPosStartY; row <= _rowsShown; row++, pxPosY +=_pxCharHeight)
875 {
876 QByteArray hex;
877 qint64 bPosLine = row * _bytesPerLine;
878 int pxPosX = _pxPosHexX - pxOfsX;
879 int pxPosAsciiX2 = _pxPosAsciiX - pxOfsX;
880
881 // *** address info
882 if (_addressArea && row * _bytesPerLine < _dataShown.size())
883 {
884 QString address = QString("%1").arg(_bPosFirst + row*_bytesPerLine + _addressOffset, _addrDigits, 16, QChar('0'));
885 ColoredArea addressArea = _colorManager->notMarked(Area::Address);
886
887 painter.setPen(addressArea.fontPen());
888 painter.drawText(_pxPosAdrX - pxOfsX, pxPosY, hexCaps() ? address.toUpper() : address);
889 }
890
891 for (int colIdx = 0; ((bPosLine + colIdx) < _dataShown.size() && (colIdx < _bytesPerLine)); colIdx++)
892 {

Callers

nothing calls this directly

Calls 5

areaStyleMethod · 0.80
sizeMethod · 0.80
fontPenMethod · 0.80
markedAreaMethod · 0.80
fontColorMethod · 0.80

Tested by

no test coverage detected