aboutsummaryrefslogtreecommitdiff
path: root/graphics
diff options
context:
space:
mode:
authorEugene Sandulenko2016-12-16 19:37:33 +0100
committerEugene Sandulenko2016-12-16 19:47:19 +0100
commitffea222f5bfda8383cb52480b48998c9d0093911 (patch)
treed86a9f25e35b90be622120f499855faf5c147234 /graphics
parent5f46bbff728025aedc7d4d6c83b23c3a59912e96 (diff)
downloadscummvm-rg350-ffea222f5bfda8383cb52480b48998c9d0093911.tar.gz
scummvm-rg350-ffea222f5bfda8383cb52480b48998c9d0093911.tar.bz2
scummvm-rg350-ffea222f5bfda8383cb52480b48998c9d0093911.zip
GRAPHICS: Added stubs for pasting text to MacText
Diffstat (limited to 'graphics')
-rw-r--r--graphics/macgui/mactext.cpp31
-rw-r--r--graphics/macgui/mactext.h4
2 files changed, 27 insertions, 8 deletions
diff --git a/graphics/macgui/mactext.cpp b/graphics/macgui/mactext.cpp
index fde79f910e..b674532890 100644
--- a/graphics/macgui/mactext.cpp
+++ b/graphics/macgui/mactext.cpp
@@ -38,19 +38,17 @@ MacText::MacText(Common::String s, Graphics::Font *font, int fgcolor, int bgcolo
else
_textMaxWidth = -1;
- splitString();
+ splitString(_str);
_fullRefresh = true;
}
-void MacText::splitString() {
- const char *s = _str.c_str();
+void MacText::splitString(Common::String &str) {
+ const char *s = str.c_str();
Common::String tmp;
bool prevCR;
- _text.clear();
-
while (*s) {
if (*s == '\n' && prevCR) { // trean \r\n as one
prevCR = false;
@@ -75,10 +73,19 @@ void MacText::splitString() {
_maxWidth = MIN(_font->wordWrapText(tmp, _maxWidth, _text), _maxWidth);
}
+void MacText::reallocSurface() {
+ int lineHeight = _font->getFontHeight() + _interLinear;
+ int requiredHeight = (_text.size() + (_text.size() * 10 + 9) / 10) * lineHeight;
+
+ if (_surface.w < requiredHeight) {
+ // realloc surface
+ _surface.create(_maxWidth == -1 ? _textMaxWidth : _maxWidth, requiredHeight);
+ }
+}
+
void MacText::render() {
if (_fullRefresh) {
- _surface.create(_maxWidth == -1 ? _textMaxWidth : _maxWidth,
- _text.size() * (_font->getFontHeight() + _interLinear));
+ reallocSurface();
_surface.clear(_bgcolor);
@@ -105,4 +112,14 @@ void MacText::draw(ManagedSurface *g, int x, int y, int w, int h, int xoff, int
MIN<int>(_surface.w, x + w), MIN<int>(_surface.w, y + w)), Common::Point(xoff, yoff));
}
+void MacText::appendText(Common::String str) {
+ //int oldLen = _text.size();
+
+ splitString(str);
+
+ reallocSurface();
+
+ //render(oldLen + 1, _text.size());
+}
+
} // End of namespace Graphics
diff --git a/graphics/macgui/mactext.h b/graphics/macgui/mactext.h
index 4add3948fa..65e93ca5c3 100644
--- a/graphics/macgui/mactext.h
+++ b/graphics/macgui/mactext.h
@@ -35,12 +35,14 @@ public:
void setInterLinear(int interLinear) { _interLinear = interLinear; }
void draw(ManagedSurface *g, int x, int y, int w, int h, int xoff, int yoff);
+ void appendText(Common::String str);
private:
- void splitString();
+ void splitString(Common::String &s);
void render();
void calcMaxWidth();
+ void reallocSurface();
private:
Common::String _str;