aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMax Horn2003-11-02 17:41:01 +0000
committerMax Horn2003-11-02 17:41:01 +0000
commitf0d2a1b91cee2c81a618b36cf58e2990153ddd00 (patch)
treec23c99d313045bc0333d0bc78a6fa96f29818f85
parent2adc1476000c43b66521f61b74f8659147ccb28a (diff)
downloadscummvm-rg350-f0d2a1b91cee2c81a618b36cf58e2990153ddd00.tar.gz
scummvm-rg350-f0d2a1b91cee2c81a618b36cf58e2990153ddd00.tar.bz2
scummvm-rg350-f0d2a1b91cee2c81a618b36cf58e2990153ddd00.zip
make coordinate calculation based on position of parent -> needed for nested widgets
svn-id: r11058
-rw-r--r--gui/EditTextWidget.cpp4
-rw-r--r--gui/ListWidget.cpp4
-rw-r--r--gui/PopUpWidget.cpp6
-rw-r--r--gui/dialog.cpp12
-rw-r--r--gui/object.h8
-rw-r--r--gui/widget.h6
6 files changed, 23 insertions, 17 deletions
diff --git a/gui/EditTextWidget.cpp b/gui/EditTextWidget.cpp
index ade3e0ec8d..0e1781393f 100644
--- a/gui/EditTextWidget.cpp
+++ b/gui/EditTextWidget.cpp
@@ -170,8 +170,8 @@ void EditTextWidget::drawCaret(bool erase) {
return;
int16 color = erase ? g_gui._bgcolor : g_gui._textcolorhi;
- int x = _x + _boss->getX() + 2;
- int y = _y + _boss->getY() + 1;
+ int x = getAbsX() + 2;
+ int y = getAbsY() + 1;
int width = getCaretPos();
x += width;
diff --git a/gui/ListWidget.cpp b/gui/ListWidget.cpp
index 2216b06a43..d83042bf04 100644
--- a/gui/ListWidget.cpp
+++ b/gui/ListWidget.cpp
@@ -294,8 +294,8 @@ void ListWidget::drawCaret(bool erase) {
// The item is selected, thus _bgcolor is used to draw the caret and _textcolorhi to erase it
int16 color = erase ? gui->_textcolorhi : gui->_bgcolor;
- int x = _x + _boss->getX() + 3;
- int y = _y + _boss->getY() + 1;
+ int x = getAbsX() + 3;
+ int y = getAbsY() + 1;
Common::String buffer;
y += (_selectedItem - _currentPos) * kLineHeight;
diff --git a/gui/PopUpWidget.cpp b/gui/PopUpWidget.cpp
index c53598c772..bb1a4ac565 100644
--- a/gui/PopUpWidget.cpp
+++ b/gui/PopUpWidget.cpp
@@ -81,8 +81,8 @@ PopUpDialog::PopUpDialog(PopUpWidget *boss, int clickX, int clickY)
_selection = _popUpBoss->_selectedItem;
// Calculate real popup dimensions
- _x = _popUpBoss->_boss->getX() + _popUpBoss->_x;
- _y = _popUpBoss->_boss->getY() + _popUpBoss->_y - _popUpBoss->_selectedItem * kLineHeight;
+ _x = _popUpBoss->getAbsX();
+ _y = _popUpBoss->getAbsY() - _popUpBoss->_selectedItem * kLineHeight;
_h = _popUpBoss->_entries.size() * kLineHeight + 2;
_w = _popUpBoss->_w - 10;
@@ -282,7 +282,7 @@ PopUpWidget::PopUpWidget(GuiObject *boss, int x, int y, int w, int h)
void PopUpWidget::handleMouseDown(int x, int y, int button, int clickCount) {
if (isEnabled()) {
- PopUpDialog popupDialog(this, x + _x + _boss->getX(), y + _y + _boss->getY());
+ PopUpDialog popupDialog(this, x + getAbsX(), y + getAbsY());
int newSel = popupDialog.runModal();
if (newSel != -1 && _selectedItem != newSel) {
_selectedItem = newSel;
diff --git a/gui/dialog.cpp b/gui/dialog.cpp
index 856e9a9960..401f84549d 100644
--- a/gui/dialog.cpp
+++ b/gui/dialog.cpp
@@ -137,7 +137,7 @@ void Dialog::handleMouseDown(int x, int y, int button, int clickCount) {
}
if (w && w == _focusedWidget)
- _focusedWidget->handleMouseDown(x - _focusedWidget->_x, y - _focusedWidget->_y, button, clickCount);
+ _focusedWidget->handleMouseDown(x - (_focusedWidget->getAbsX() - _x), y - (_focusedWidget->getAbsY() - _y), button, clickCount);
}
void Dialog::handleMouseUp(int x, int y, int button, int clickCount) {
@@ -156,7 +156,7 @@ void Dialog::handleMouseUp(int x, int y, int button, int clickCount) {
}
if (w)
- w->handleMouseUp(x - w->_x, y - w->_y, button, clickCount);
+ w->handleMouseUp(x - (w->getAbsX() - _x), y - (w->getAbsY() - _y), button, clickCount);
}
void Dialog::handleMouseWheel(int x, int y, int direction) {
@@ -213,10 +213,12 @@ void Dialog::handleMouseMoved(int x, int y, int button) {
if (_focusedWidget) {
w = _focusedWidget;
+ int wx = w->getAbsX() - _x;
+ int wy = w->getAbsY() - _y;
// We still send mouseEntered/Left messages to the focused item
// (but to no other items).
- bool mouseInFocusedWidget = (x >= w->_x && x < w->_x + w->_w && y >= w->_y && y < w->_y + w->_h);
+ bool mouseInFocusedWidget = (x >= wx && x < wx + w->_w && y >= wy && y < wy + w->_h);
if (mouseInFocusedWidget && _mouseWidget != w) {
_mouseWidget = w;
w->handleMouseEntered(button);
@@ -225,7 +227,7 @@ void Dialog::handleMouseMoved(int x, int y, int button) {
w->handleMouseLeft(button);
}
- w->handleMouseMoved(x - w->_x, y - w->_y, button);
+ w->handleMouseMoved(x - wx, y - wy, button);
}
w = findWidget(x, y);
@@ -242,7 +244,7 @@ void Dialog::handleMouseMoved(int x, int y, int button) {
return;
}
- w->handleMouseMoved(x - w->_x, y - w->_y, button);
+ w->handleMouseMoved(x - (w->getAbsX() - _x), y - (w->getAbsY() - _y), button);
}
void Dialog::handleTickle() {
diff --git a/gui/object.h b/gui/object.h
index 72401af0cf..8393acf671 100644
--- a/gui/object.h
+++ b/gui/object.h
@@ -62,10 +62,10 @@ public:
virtual bool isVisible() const = 0;
- int16 getX() const { return _x; }
- int16 getY() const { return _y; }
- uint16 getW() const { return _w; }
- uint16 getH() const { return _h; }
+ virtual int16 getAbsX() const { return _x; }
+ virtual int16 getAbsY() const { return _y; }
+ virtual uint16 getWidth() const { return _w; }
+ virtual uint16 getHeight() const { return _h; }
protected:
virtual void releaseFocus() = 0;
diff --git a/gui/widget.h b/gui/widget.h
index c4ce1b9abd..08e519558f 100644
--- a/gui/widget.h
+++ b/gui/widget.h
@@ -47,7 +47,8 @@ enum {
kCheckboxWidget = 'CHKB',
kSliderWidget = 'SLDE',
kListWidget = 'LIST',
- kScrollBarWidget = 'SCRB'
+ kScrollBarWidget = 'SCRB',
+ kTabWidget = 'TABW'
};
enum {
@@ -75,6 +76,9 @@ public:
Widget(GuiObject *boss, int x, int y, int w, int h);
virtual ~Widget() {}
+ virtual int16 getAbsX() const { return _x + _boss->getAbsX(); }
+ virtual int16 getAbsY() const { return _y + _boss->getAbsY(); }
+
virtual void handleMouseDown(int x, int y, int button, int clickCount) {}
virtual void handleMouseUp(int x, int y, int button, int clickCount) {}
virtual void handleMouseEntered(int button) {}