[Scummvm-cvs-logs] CVS: scummvm/gui widget.h,1.23,1.24 object.h,1.1,1.2 dialog.cpp,1.33,1.34 ListWidget.cpp,1.27,1.28 PopUpWidget.cpp,1.20,1.21 EditTextWidget.cpp,1.17,1.18

Max Horn fingolfin at users.sourceforge.net
Sun Nov 2 09:42:11 CET 2003


Update of /cvsroot/scummvm/scummvm/gui
In directory sc8-pr-cvs1:/tmp/cvs-serv14599

Modified Files:
	widget.h object.h dialog.cpp ListWidget.cpp PopUpWidget.cpp 
	EditTextWidget.cpp 
Log Message:
make coordinate calculation based on position of parent -> needed for nested widgets

Index: widget.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/gui/widget.h,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -d -r1.23 -r1.24
--- widget.h	2 Nov 2003 14:50:44 -0000	1.23
+++ widget.h	2 Nov 2003 17:41:01 -0000	1.24
@@ -47,7 +47,8 @@
 	kCheckboxWidget		= 'CHKB',
 	kSliderWidget		= 'SLDE',
 	kListWidget			= 'LIST',
-	kScrollBarWidget	= 'SCRB'
+	kScrollBarWidget	= 'SCRB',
+	kTabWidget			= 'TABW'
 };
 
 enum {
@@ -74,6 +75,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) {}

Index: object.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/gui/object.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- object.h	2 Nov 2003 14:50:44 -0000	1.1
+++ object.h	2 Nov 2003 17:41:01 -0000	1.2
@@ -62,10 +62,10 @@
 
 	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;

Index: dialog.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/gui/dialog.cpp,v
retrieving revision 1.33
retrieving revision 1.34
diff -u -d -r1.33 -r1.34
--- dialog.cpp	2 Nov 2003 14:50:44 -0000	1.33
+++ dialog.cpp	2 Nov 2003 17:41:01 -0000	1.34
@@ -137,7 +137,7 @@
 	}
 
 	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 @@
 	}
 
 	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 @@
 	
 	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 @@
 			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 @@
 		return;
 	}
 	
-	w->handleMouseMoved(x - w->_x, y - w->_y, button);
+	w->handleMouseMoved(x - (w->getAbsX() - _x), y - (w->getAbsY() - _y), button);
 }
 
 void Dialog::handleTickle() {

Index: ListWidget.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/gui/ListWidget.cpp,v
retrieving revision 1.27
retrieving revision 1.28
diff -u -d -r1.27 -r1.28
--- ListWidget.cpp	2 Nov 2003 14:50:44 -0000	1.27
+++ ListWidget.cpp	2 Nov 2003 17:41:01 -0000	1.28
@@ -294,8 +294,8 @@
 
 	// 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;

Index: PopUpWidget.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/gui/PopUpWidget.cpp,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -d -r1.20 -r1.21
--- PopUpWidget.cpp	2 Nov 2003 14:50:44 -0000	1.20
+++ PopUpWidget.cpp	2 Nov 2003 17:41:01 -0000	1.21
@@ -81,8 +81,8 @@
 	_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 @@
 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;

Index: EditTextWidget.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/gui/EditTextWidget.cpp,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -d -r1.17 -r1.18
--- EditTextWidget.cpp	2 Nov 2003 14:50:43 -0000	1.17
+++ EditTextWidget.cpp	2 Nov 2003 17:41:01 -0000	1.18
@@ -170,8 +170,8 @@
 		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;





More information about the Scummvm-git-logs mailing list