diff options
Diffstat (limited to 'graphics/macgui')
-rw-r--r-- | graphics/macgui/mactextwindow.cpp | 21 | ||||
-rw-r--r-- | graphics/macgui/mactextwindow.h | 5 |
2 files changed, 23 insertions, 3 deletions
diff --git a/graphics/macgui/mactextwindow.cpp b/graphics/macgui/mactextwindow.cpp index 8f1c293af9..ebd3dd2377 100644 --- a/graphics/macgui/mactextwindow.cpp +++ b/graphics/macgui/mactextwindow.cpp @@ -59,6 +59,8 @@ MacTextWindow::MacTextWindow(MacWindowManager *wm, const MacFont *font, int fgco _inTextSelection = false; _scrollPos = 0; + _editable = true; + _selectable = true; _cursorX = 0; _cursorY = 0; @@ -93,9 +95,11 @@ void MacTextWindow::appendText(Common::String str, const MacFont *macFont, bool _contentIsDirty = true; - _scrollPos = MAX(0, _mactext->getTextHeight() - getInnerDimensions().height()); + if (_editable) { + _scrollPos = MAX(0, _mactext->getTextHeight() - getInnerDimensions().height()); - updateCursorPos(); + updateCursorPos(); + } } void MacTextWindow::clearText() { @@ -280,6 +284,9 @@ bool MacTextWindow::processEvent(Common::Event &event) { WindowClick click = isInBorder(event.mouse.x, event.mouse.y); if (event.type == Common::EVENT_KEYDOWN) { + if (!_editable) + return false; + _wm->setActive(getId()); if (event.kbd.flags & (Common::KBD_ALT | Common::KBD_CTRL | Common::KBD_META)) { @@ -355,6 +362,9 @@ bool MacTextWindow::processEvent(Common::Event &event) { } if (click == kBorderInner) { + if (!_selectable) + return false; + if (event.type == Common::EVENT_LBUTTONDOWN) { startMarking(event.mouse.x, event.mouse.y); @@ -396,7 +406,12 @@ void MacTextWindow::scroll(int delta) { int oldScrollPos = _scrollPos; _scrollPos += delta * kConScrollStep; - _scrollPos = CLIP<int>(_scrollPos, 0, _mactext->getTextHeight() - kConScrollStep); + + if (_editable) + _scrollPos = CLIP<int>(_scrollPos, 0, _mactext->getTextHeight() - kConScrollStep); + else + _scrollPos = CLIP<int>(_scrollPos, 0, MAX(0, _mactext->getTextHeight() - getInnerDimensions().height())); + undrawCursor(); _cursorY -= (_scrollPos - oldScrollPos); _contentIsDirty = true; diff --git a/graphics/macgui/mactextwindow.h b/graphics/macgui/mactextwindow.h index 942fdd4fab..c236f47e47 100644 --- a/graphics/macgui/mactextwindow.h +++ b/graphics/macgui/mactextwindow.h @@ -63,6 +63,9 @@ public: void appendText(Common::String str, const MacFont *macFont, bool skipAdd = false); void clearText(); + void setEditable(bool editable) { _editable = editable; } + void setSelectable(bool selectable) { _selectable = selectable; } + void undrawCursor(); const Common::String getInput() { return _inputText; } @@ -94,6 +97,8 @@ public: bool _cursorDirty; Common::Rect *_cursorRect; bool _cursorOff; + bool _editable; + bool _selectable; int _scrollPos; |