summaryrefslogtreecommitdiff
path: root/Widgets/TextBox.cpp
diff options
context:
space:
mode:
authorAndreas Kling <awesomekling@gmail.com>2018-10-14 13:06:05 +0200
committerAndreas Kling <awesomekling@gmail.com>2018-10-14 13:06:05 +0200
commitfc1facf5c09a92cf49ce2b2db729cac51f6e75e2 (patch)
tree04c6dfbd75252593f7e13b8959b07fa1fd501a58 /Widgets/TextBox.cpp
parente5acbca0e84b0b1d350d20372016436d7708afe1 (diff)
downloadserenity-fc1facf5c09a92cf49ce2b2db729cac51f6e75e2.zip
Let widget have a font() instead of using Font::defaultFont() everywhere.
Diffstat (limited to 'Widgets/TextBox.cpp')
-rw-r--r--Widgets/TextBox.cpp12
1 files changed, 5 insertions, 7 deletions
diff --git a/Widgets/TextBox.cpp b/Widgets/TextBox.cpp
index 8107385f28..291ff83175 100644
--- a/Widgets/TextBox.cpp
+++ b/Widgets/TextBox.cpp
@@ -35,20 +35,18 @@ void TextBox::paintEvent(PaintEvent&)
Rect innerRect = rect();
innerRect.shrink(6, 6);
- auto& font = Font::defaultFont();
-
- unsigned maxCharsToPaint = innerRect.width() / font.glyphWidth();
+ unsigned maxCharsToPaint = innerRect.width() / font().glyphWidth();
int firstVisibleChar = max((int)m_cursorPosition - (int)maxCharsToPaint, 0);
unsigned charsToPaint = min(m_text.length() - firstVisibleChar, maxCharsToPaint);
- int y = innerRect.center().y() - font.glyphHeight() / 2;
+ int y = innerRect.center().y() - font().glyphHeight() / 2;
for (unsigned i = 0; i < charsToPaint; ++i) {
char ch = m_text[firstVisibleChar + i];
if (ch == ' ')
continue;
- int x = innerRect.x() + (i * font.glyphWidth());
- auto* bitmap = font.glyphBitmap(ch);
+ int x = innerRect.x() + (i * font().glyphWidth());
+ auto* bitmap = font().glyphBitmap(ch);
if (!bitmap) {
printf("TextBox: glyph missing: %02x\n", ch);
ASSERT_NOT_REACHED();
@@ -58,7 +56,7 @@ void TextBox::paintEvent(PaintEvent&)
if (isFocused() && m_cursorBlinkState) {
unsigned visibleCursorPosition = m_cursorPosition - firstVisibleChar;
- Rect cursorRect(innerRect.x() + visibleCursorPosition * font.glyphWidth(), innerRect.y(), 1, innerRect.height());
+ Rect cursorRect(innerRect.x() + visibleCursorPosition * font().glyphWidth(), innerRect.y(), 1, innerRect.height());
painter.fillRect(cursorRect, foregroundColor());
}
}