[Scummvm-git-logs] scummvm master -> ffea222f5bfda8383cb52480b48998c9d0093911
sev-
sev at scummvm.org
Fri Dec 16 19:47:26 CET 2016
This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
ffea222f5b GRAPHICS: Added stubs for pasting text to MacText
Commit: ffea222f5bfda8383cb52480b48998c9d0093911
https://github.com/scummvm/scummvm/commit/ffea222f5bfda8383cb52480b48998c9d0093911
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-12-16T19:47:19+01:00
Commit Message:
GRAPHICS: Added stubs for pasting text to MacText
Changed paths:
graphics/macgui/mactext.cpp
graphics/macgui/mactext.h
diff --git a/graphics/macgui/mactext.cpp b/graphics/macgui/mactext.cpp
index fde79f9..b674532 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 4add394..65e93ca 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;
More information about the Scummvm-git-logs
mailing list