diff options
| author | 2023-07-15 17:03:58 +0200 | |
|---|---|---|
| committer | 2023-07-15 17:03:58 +0200 | |
| commit | 148d8d9e1b6530676093f660ec64f6a2ee673235 (patch) | |
| tree | 4b5cd525d1f32bdfb1c885dd910fbaa962ed4f46 /src | |
| parent | fix path for kde notifier (#2545) (diff) | |
| download | KVIrc-148d8d9e1b6530676093f660ec64f6a2ee673235.tar.gz KVIrc-148d8d9e1b6530676093f660ec64f6a2ee673235.tar.bz2 KVIrc-148d8d9e1b6530676093f660ec64f6a2ee673235.zip | |
Use floating point widths in KviIrcView: fixes overlapping texts
Diffstat (limited to 'src')
| -rw-r--r-- | src/kvirc/ui/KviIrcView.cpp | 20 | ||||
| -rw-r--r-- | src/kvirc/ui/KviIrcView.h | 4 | ||||
| -rw-r--r-- | src/kvirc/ui/KviIrcView_private.h | 8 |
3 files changed, 16 insertions, 16 deletions
diff --git a/src/kvirc/ui/KviIrcView.cpp b/src/kvirc/ui/KviIrcView.cpp index 7402f3f81..57b111463 100644 --- a/src/kvirc/ui/KviIrcView.cpp +++ b/src/kvirc/ui/KviIrcView.cpp @@ -1133,7 +1133,7 @@ void KviIrcView::paintEvent(QPaintEvent * p) // Have lines visible int curBottomCoord = widgetHeight - KVI_IRCVIEW_VERTICAL_BORDER; int maxLineWidth = widgetWidth - KVI_IRCVIEW_DOUBLEBORDER_WIDTH; - int defLeftCoord = KVI_IRCVIEW_HORIZONTAL_BORDER; + float defLeftCoord = KVI_IRCVIEW_HORIZONTAL_BORDER; int lineWrapsHeight; // if we draw an icon as a line preamble, we have to change borders geometry accordingly @@ -1200,7 +1200,7 @@ void KviIrcView::paintEvent(QPaintEvent * p) bool bacWasTransp = false; char curFore = defaultFore; char curBack = defaultBack; - int curLeftCoord = defLeftCoord; + float curLeftCoord = defLeftCoord; curBottomCoord -= m_iFontDescent; //rise up the text... // @@ -1354,7 +1354,7 @@ void KviIrcView::paintEvent(QPaintEvent * p) #define DRAW_SELECTED_TEXT(_text_str, _text_idx, _text_len, _text_width) \ SET_PEN(KVI_OPTION_MSGTYPE(KVI_OUT_SELECT).fore(), block->pChunk ? block->pChunk->customFore : QColor()); \ { \ - int theWdth = _text_width; \ + float theWdth = _text_width; \ if(theWdth < 0) \ theWdth = width() - (curLeftCoord + KVI_IRCVIEW_HORIZONTAL_BORDER + scrollbarWidth); \ pa.fillRect(curLeftCoord, curBottomCoord - m_iFontLineSpacing + m_iFontDescent, theWdth, m_iFontLineSpacing, getMircColor(KVI_OPTION_MSGTYPE(KVI_OUT_SELECT).back())); \ @@ -1443,7 +1443,7 @@ void KviIrcView::paintEvent(QPaintEvent * p) break; case KVI_IRCVIEW_BLOCK_SELECTION_ICON: { - int theWdth = block->block_width; + float theWdth = block->block_width; if(theWdth < 0) theWdth = width() - (curLeftCoord + KVI_IRCVIEW_HORIZONTAL_BORDER + scrollbarWidth); pa.fillRect(curLeftCoord, curBottomCoord - m_iFontLineSpacing + m_iFontDescent, theWdth, m_iFontLineSpacing, @@ -1457,7 +1457,7 @@ void KviIrcView::paintEvent(QPaintEvent * p) { if(block->pChunk && block->pChunk->type == KviControlCodes::Icon) goto no_selection_paint; - int wdth = block->block_width; + float wdth = block->block_width; if(wdth == 0) { // Last block before a word wrap, or a zero characters attribute block ? @@ -1479,7 +1479,7 @@ void KviIrcView::paintEvent(QPaintEvent * p) no_selection_paint: if(block->pChunk && block->pChunk->type == KviControlCodes::Icon) { - int wdth = block->block_width; + float wdth = block->block_width; if(wdth < 0) wdth = widgetWidth - (curLeftCoord + KVI_IRCVIEW_HORIZONTAL_BORDER); int imageYPos = curBottomCoord - m_iRelativePixmapY; @@ -1513,7 +1513,7 @@ void KviIrcView::paintEvent(QPaintEvent * p) } else { - int wdth = block->block_width; + float wdth = block->block_width; if(wdth < 0) wdth = widgetWidth - (curLeftCoord + KVI_IRCVIEW_HORIZONTAL_BORDER); @@ -1701,7 +1701,7 @@ void KviIrcView::calculateLineWraps(KviIrcViewLine * ptr, int maxWidth) ptr->uLineWraps = 0; // no line wraps yet unsigned int curAttrBlock = 0; // Current attribute block - int curLineWidth = 0; + float curLineWidth = 0; // init the first block ptr->pBlocks->block_start = 0; @@ -1719,7 +1719,7 @@ void KviIrcView::calculateLineWraps(KviIrcViewLine * ptr, int maxWidth) const QChar * p = unicode + ptr->pBlocks[ptr->iBlockCount].block_start; int curBlockLen = 0; - int curBlockWidth = 0; + float curBlockWidth = 0; if(ptr->pChunks[curAttrBlock].type == KviControlCodes::Icon) { @@ -2087,7 +2087,7 @@ void KviIrcView::recalcFontVariables(const QFont & font, const QFontInfo & fi) if(m_pFm) delete m_pFm; - m_pFm = new QFontMetrics(font); + m_pFm = new QFontMetricsF(font); m_iFontLineSpacing = m_pFm->lineSpacing(); diff --git a/src/kvirc/ui/KviIrcView.h b/src/kvirc/ui/KviIrcView.h index 5c85453ef..3e6a8d135 100644 --- a/src/kvirc/ui/KviIrcView.h +++ b/src/kvirc/ui/KviIrcView.h @@ -107,7 +107,7 @@ private: int m_iFontLineSpacing; int m_iFontLineWidth; int m_iFontDescent; - int m_iFontCharacterWidth[256]; //1024 bytes fixed + float m_iFontCharacterWidth[256]; bool m_bUseRealBold; int m_iWrapMargin; @@ -138,7 +138,7 @@ private: bool m_bPostedPaintEventPending; std::vector<KviIrcViewLine *> m_pMessagesStoppedWhileSelecting; KviIrcView * m_pMasterView; - QFontMetrics * m_pFm; // assume this valid only inside a paint event (may be 0 in other circumstances) + QFontMetricsF * m_pFm; // assume this valid only inside a paint event (may be 0 in other circumstances) QMouseEvent * m_pLastEvent; qint64 m_iLastMouseClickTime; diff --git a/src/kvirc/ui/KviIrcView_private.h b/src/kvirc/ui/KviIrcView_private.h index 8be1842d4..22928700b 100644 --- a/src/kvirc/ui/KviIrcView_private.h +++ b/src/kvirc/ui/KviIrcView_private.h @@ -102,7 +102,7 @@ struct KviIrcViewWrappedBlock KviIrcViewLineChunk * pChunk; // pointer to real line chunk or 0 for word wraps int block_start; // this is generally different than pAttribute->block_idx! int block_len; // length if the block in characters - int block_width; // width of the block in pixels + float block_width; // width of the block in pixels } _KVI_PACKED; struct KviIrcViewLine @@ -135,11 +135,11 @@ struct KviIrcViewWrappedBlockSelectionInfo { int selection_type; int part_1_length; - int part_1_width; + float part_1_width; int part_2_length; - int part_2_width; + float part_2_width; int part_3_length; - int part_3_width; + float part_3_width; }; #ifdef COMPILE_ON_WINDOWS |
