aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--graphics/macgui/mactext.cpp8
-rw-r--r--graphics/macgui/mactext.h2
-rw-r--r--graphics/macgui/mactextwindow.cpp4
-rw-r--r--graphics/macgui/mactextwindow.h4
4 files changed, 13 insertions, 5 deletions
diff --git a/graphics/macgui/mactext.cpp b/graphics/macgui/mactext.cpp
index 7316e5a680..45e5249bc7 100644
--- a/graphics/macgui/mactext.cpp
+++ b/graphics/macgui/mactext.cpp
@@ -445,7 +445,7 @@ void MacText::removeLastLine() {
_textMaxHeight -= h;
}
-void MacText::getRowCol(int x, int y, int *col, int *row) {
+void MacText::getRowCol(int x, int y, int *sx, int *sy, int *row, int *col) {
CLIP(y, 0, _textMaxHeight);
// FIXME: We should use bsearch() here
@@ -454,6 +454,8 @@ void MacText::getRowCol(int x, int y, int *col, int *row) {
while (*row < _textLines.size() - 1 && _textLines[*row].y < y)
(*row)++;
+ *sy = _textLines[*row].y;
+
*col = 0;
int width = 0, pwidth = 0;
@@ -476,8 +478,10 @@ void MacText::getRowCol(int x, int y, int *col, int *row) {
*col = mcol;
for (int i = str.size(); i >= 0; i--) {
- if (_textLines[*row].chunks[chunk].getFont()->getStringWidth(str) + pwidth < x) {
+ int strw = _textLines[*row].chunks[chunk].getFont()->getStringWidth(str);
+ if (strw + pwidth < x) {
*col = mcol + i;
+ *sx = strw + pwidth;
break;
}
diff --git a/graphics/macgui/mactext.h b/graphics/macgui/mactext.h
index fe5c583ca2..ffc8c8dc71 100644
--- a/graphics/macgui/mactext.h
+++ b/graphics/macgui/mactext.h
@@ -113,7 +113,7 @@ public:
void render();
Graphics::ManagedSurface *getSurface() { return _surface; }
- void getRowCol(int x, int y, int *col, int *row);
+ void getRowCol(int x, int y, int *sx, int *sy, int *row, int *col);
private:
void splitString(Common::String &s);
diff --git a/graphics/macgui/mactextwindow.cpp b/graphics/macgui/mactextwindow.cpp
index 0da37523e4..a5f7b05822 100644
--- a/graphics/macgui/mactextwindow.cpp
+++ b/graphics/macgui/mactextwindow.cpp
@@ -266,7 +266,7 @@ void MacTextWindow::startMarking(int x, int y) {
y += _scrollPos;
- _mactext->getRowCol(x, y, &_selectedText.startX, &_selectedText.startY);
+ _mactext->getRowCol(x, y, &_selectedText.endX, &_selectedText.endY, &_selectedText.endRow, &_selectedText.endCol);
_selectedText.endY = -1;
@@ -279,7 +279,7 @@ void MacTextWindow::updateTextSelection(int x, int y) {
y += _scrollPos;
- _mactext->getRowCol(x, y, &_selectedText.endX, &_selectedText.endY);
+ _mactext->getRowCol(x, y, &_selectedText.endX, &_selectedText.endY, &_selectedText.endRow, &_selectedText.endCol);
_contentIsDirty = true;
}
diff --git a/graphics/macgui/mactextwindow.h b/graphics/macgui/mactextwindow.h
index d1ee3c1b2e..b3d9ba8592 100644
--- a/graphics/macgui/mactextwindow.h
+++ b/graphics/macgui/mactextwindow.h
@@ -31,10 +31,14 @@ namespace Graphics {
struct SelectedText {
int startX, startY;
int endX, endY;
+ int startRow, startCol;
+ int endRow, endCol;
SelectedText() {
startX = startY = 0;
endX = endY = 0;
+ startRow = startCol = 0;
+ endRow = endCol = 0;
}
bool needsRender() {