[kandinsky | code] Coding style improvement in the new font (part 1)

This commit is contained in:
Laury
2022-07-01 21:11:45 +02:00
parent 99b070a30d
commit d87c67d35b
7 changed files with 36 additions and 107 deletions

View File

@@ -111,12 +111,10 @@ protected:
m_cursorLocation = m_text.text();
}
void drawRect(KDContext * ctx, KDRect rect) const override;
void drawStringAt(KDContext * ctx, int line, int column, const char * text, int length, KDColor textColor, KDColor backgroundColor, const char * selectionStart, const char * selectionEnd, KDColor backgroundHighlightColor,bool isItalic = false) const;
void drawStringAt(KDContext * ctx, int line, int column, const char * text, int length, KDColor textColor, KDColor backgroundColor, const char * selectionStart, const char * selectionEnd, KDColor backgroundHighlightColor, bool isItalic = false) const;
virtual void drawLine(KDContext * ctx, int line, const char * text, size_t length, int fromColumn, int toColumn, const char * selectionStart, const char * selectionEnd) const = 0;
virtual void clearRect(KDContext * ctx, KDRect rect) const = 0;
KDSize minimalSizeForOptimalDisplay() const override;
KDFont * usedFont;
KDFont * ItalicFont;
void setText(char * textBuffer, size_t textBufferSize);
const char * text() const override { return m_text.text(); }
const char * editedText() const override { return m_text.text(); }

View File

@@ -516,13 +516,15 @@ void TextArea::ContentView::drawRect(KDContext * ctx, KDRect rect) const {
void TextArea::ContentView::drawStringAt(KDContext * ctx, int line, int column, const char * text, int length, KDColor textColor, KDColor backgroundColor, const char * selectionStart, const char * selectionEnd, KDColor backgroundHighlightColor, bool isItalic) const {
if (length < 0) {
return;
}
const KDFont * ItalicFont = (m_font == KDFont::LargeFont) ? KDFont::ItalicLargeFont : KDFont::ItalicSmallFont;
const KDFont * usedFont = isItalic ? ItalicFont : m_font;
}
const KDFont * usedFont = m_font;
if (isItalic) {
usedFont = m_font->toItalic();
}
KDSize glyphSize = usedFont->glyphSize();
bool drawSelection = selectionStart != nullptr && selectionEnd > text && selectionStart < text + length;
KDPoint nextPoint = ctx->drawString(
@@ -563,7 +565,7 @@ KDSize TextArea::ContentView::minimalSizeForOptimalDisplay() const {
return KDSize(
/* We take into account the space required to draw a cursor at the end of
* line by adding glyphSize.width() to the width. */
span.width() + m_font->glyphSize().width() + 4,
span.width() + m_font->glyphSize().width(),
span.height()
);
}