aboutsummaryrefslogtreecommitdiff
path: root/graphics/macgui/mactext.cpp
diff options
context:
space:
mode:
authorEugene Sandulenko2016-12-14 19:37:45 +0100
committerEugene Sandulenko2016-12-14 20:10:32 +0100
commitaecc17e5a5726206c39f7f2a773788f64c103b1e (patch)
treeb931ac7664769285dabb8ec03ceabf51625ece0a /graphics/macgui/mactext.cpp
parent34a9c588b001e137243f12ae8de3bc82d692de27 (diff)
downloadscummvm-rg350-aecc17e5a5726206c39f7f2a773788f64c103b1e.tar.gz
scummvm-rg350-aecc17e5a5726206c39f7f2a773788f64c103b1e.tar.bz2
scummvm-rg350-aecc17e5a5726206c39f7f2a773788f64c103b1e.zip
GRAPHICS: Further work on MacText class
Diffstat (limited to 'graphics/macgui/mactext.cpp')
-rw-r--r--graphics/macgui/mactext.cpp49
1 files changed, 49 insertions, 0 deletions
diff --git a/graphics/macgui/mactext.cpp b/graphics/macgui/mactext.cpp
index 20b2ef686b..7e937de9dc 100644
--- a/graphics/macgui/mactext.cpp
+++ b/graphics/macgui/mactext.cpp
@@ -20,6 +20,7 @@
*/
#include "graphics/macgui/mactext.h"
+#include "graphics/font.h"
namespace Graphics {
@@ -27,6 +28,54 @@ MacText::MacText(Common::String s, Graphics::Font *font, int maxWidth) {
_str = s;
_font = font;
_maxWidth = maxWidth;
+ _interLinear = 2; // 2 pixels by default
+
+ _textMaxWidth = -1;
+
+ splitString();
+}
+
+void MacText::splitString() {
+ const char *s = _str.c_str();
+
+ Common::String tmp;
+ bool prevCR;
+
+ while (*s) {
+ if (*s == '\n' && prevCR) { // trean \r\n as one
+ prevCR = false;
+ continue;
+ }
+
+ if (*s == '\r')
+ prevCR = true;
+
+ if (*s == '\r' || *s == '\n') {
+ _text.push_back(tmp);
+ _widths.push_back(_font->getStringWidth(tmp));
+
+ tmp.clear();
+
+ continue;
+ }
+
+ tmp += *s;
+ }
+
+ calcMaxWidth();
+}
+
+void MacText::calcMaxWidth() {
+ int max = -1;
+
+ for (uint i = 0; i < _widths.size(); i++)
+ if (max < _widths[i])
+ max = _widths[i];
+
+ _textMaxWidth = max;
+}
+
+void MacText::render() {
}
} // End of namespace Graphics