diff options
author | Eugene Sandulenko | 2016-12-14 20:09:08 +0100 |
---|---|---|
committer | Eugene Sandulenko | 2016-12-14 20:10:32 +0100 |
commit | 6329f73c9ee3b30e04da89b7ac0b98c581e72c0c (patch) | |
tree | f80d3872bf3e9b723743ecfc8ca42d054daf3303 /graphics | |
parent | aecc17e5a5726206c39f7f2a773788f64c103b1e (diff) | |
download | scummvm-rg350-6329f73c9ee3b30e04da89b7ac0b98c581e72c0c.tar.gz scummvm-rg350-6329f73c9ee3b30e04da89b7ac0b98c581e72c0c.tar.bz2 scummvm-rg350-6329f73c9ee3b30e04da89b7ac0b98c581e72c0c.zip |
GRAPHICS: Implemented basic rendering for MacText
Diffstat (limited to 'graphics')
-rw-r--r-- | graphics/macgui/mactext.cpp | 27 | ||||
-rw-r--r-- | graphics/macgui/mactext.h | 8 |
2 files changed, 32 insertions, 3 deletions
diff --git a/graphics/macgui/mactext.cpp b/graphics/macgui/mactext.cpp index 7e937de9dc..f7b2ed9b27 100644 --- a/graphics/macgui/mactext.cpp +++ b/graphics/macgui/mactext.cpp @@ -24,15 +24,20 @@ namespace Graphics { -MacText::MacText(Common::String s, Graphics::Font *font, int maxWidth) { +MacText::MacText(Common::String s, Graphics::Font *font, int fgcolor, int bgcolor, int maxWidth) { _str = s; _font = font; + _fgcolor = fgcolor; + _bgcolor = bgcolor; _maxWidth = maxWidth; - _interLinear = 2; // 2 pixels by default + + _interLinear = 0; // 0 pixels between the lines by default _textMaxWidth = -1; splitString(); + + _fullRefresh = true; } void MacText::splitString() { @@ -62,6 +67,9 @@ void MacText::splitString() { tmp += *s; } + if (_text.size()) + _text.push_back(tmp); + calcMaxWidth(); } @@ -76,6 +84,21 @@ void MacText::calcMaxWidth() { } void MacText::render() { + if (_fullRefresh) { + _surface.create(_textMaxWidth, _text.size() * (_font->getFontHeight() + _interLinear)); + + _surface.clear(_bgcolor); + + int y = 0; + + for (uint i = 0; i < _text.size(); i++) { + _font->drawString(&_surface, _text[i], 0, y, _textMaxWidth, _fgcolor); + + y += _font->getFontHeight() + _interLinear; + } + + _fullRefresh = false; + } } } // End of namespace Graphics diff --git a/graphics/macgui/mactext.h b/graphics/macgui/mactext.h index 6f49133d57..cf975849b7 100644 --- a/graphics/macgui/mactext.h +++ b/graphics/macgui/mactext.h @@ -24,12 +24,13 @@ #define GRAPHICS_MACGUI_MACTEXT_H #include "graphics/fontman.h" +#include "graphics/managed_surface.h" namespace Graphics { class MacText { public: - MacText(Common::String s, Graphics::Font *font, int maxWidth = -1); + MacText(Common::String s, Graphics::Font *font, int fgcolor, int bgcolor, int maxWidth = -1); void setInterLinear(int interLinear) { _interLinear = interLinear; } @@ -41,6 +42,8 @@ private: private: Common::String _str; Graphics::Font *_font; + int _fgcolor, _bgcolor; + int _maxWidth; int _interLinear; @@ -48,6 +51,9 @@ private: Common::Array<int> _widths; int _textMaxWidth; + + Graphics::ManagedSurface _surface; + bool _fullRefresh; }; } // End of namespace Graphics |