aboutsummaryrefslogtreecommitdiff
path: root/graphics/macgui
diff options
context:
space:
mode:
authorEugene Sandulenko2019-10-15 23:57:08 +0200
committerEugene Sandulenko2019-10-15 23:58:00 +0200
commit695ba470636ac079bb12e58297b4723c87b630d1 (patch)
tree7a68decee45ddd599f8231a09b6d83d614d506dd /graphics/macgui
parent1a76b548e5a50b774646b5e7d959d4fdc083ae8c (diff)
downloadscummvm-rg350-695ba470636ac079bb12e58297b4723c87b630d1.tar.gz
scummvm-rg350-695ba470636ac079bb12e58297b4723c87b630d1.tar.bz2
scummvm-rg350-695ba470636ac079bb12e58297b4723c87b630d1.zip
GRAPHICS: MACGUI: Added possibility to create read only text windows
Diffstat (limited to 'graphics/macgui')
-rw-r--r--graphics/macgui/mactextwindow.cpp21
-rw-r--r--graphics/macgui/mactextwindow.h5
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;