summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/CMakeLists.txt1
-rw-r--r--src/Makefile.am1
-rw-r--r--src/gui/gui.cpp11
-rw-r--r--src/gui/widgets/mouseevent.h47
4 files changed, 57 insertions, 3 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 0b1575ffc..4e12bcc21 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -166,6 +166,7 @@ SET(SRCS
gui/widgets/linkhandler.h
gui/widgets/listbox.cpp
gui/widgets/listbox.h
+ gui/widgets/mouseevent.h
gui/widgets/passwordfield.cpp
gui/widgets/passwordfield.h
gui/widgets/playerbox.cpp
diff --git a/src/Makefile.am b/src/Makefile.am
index 4ff75d1a0..09533b114 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -57,6 +57,7 @@ manaplus_SOURCES = gui/widgets/avatarlistbox.cpp \
gui/widgets/linkhandler.h \
gui/widgets/listbox.cpp \
gui/widgets/listbox.h \
+ gui/widgets/mouseevent.h \
gui/widgets/passwordfield.cpp \
gui/widgets/passwordfield.h \
gui/widgets/playerbox.cpp \
diff --git a/src/gui/gui.cpp b/src/gui/gui.cpp
index 984b9ea1a..937a102f7 100644
--- a/src/gui/gui.cpp
+++ b/src/gui/gui.cpp
@@ -27,6 +27,7 @@
#include "gui/theme.h"
#include "gui/truetypefont.h"
+#include "gui/widgets/mouseevent.h"
#include "gui/widgets/window.h"
#include "gui/widgets/windowcontainer.h"
@@ -331,6 +332,10 @@ void Gui::distributeMouseEvent(gcn::Widget* source, int type, int button,
return;
}
+ MouseEvent mouseEvent(source, mShiftPressed, mControlPressed,
+ mAltPressed, mMetaPressed, type, button,
+ x, y, mClickCount);
+
while (parent != NULL)
{
// If the widget has been removed due to input
@@ -340,14 +345,14 @@ void Gui::distributeMouseEvent(gcn::Widget* source, int type, int button,
parent = (gcn::Widget*)widget->getParent();
+
if (widget->isEnabled() || force)
{
int widgetX, widgetY;
widget->getAbsolutePosition(widgetX, widgetY);
- gcn::MouseEvent mouseEvent(source, mShiftPressed, mControlPressed,
- mAltPressed, mMetaPressed, type, button,
- x - widgetX, y - widgetY, mClickCount);
+ mouseEvent.setX(x - widgetX);
+ mouseEvent.setY(y - widgetY);
std::list<gcn::MouseListener*> mouseListeners
= widget->_getMouseListeners();
diff --git a/src/gui/widgets/mouseevent.h b/src/gui/widgets/mouseevent.h
new file mode 100644
index 000000000..7951e41ca
--- /dev/null
+++ b/src/gui/widgets/mouseevent.h
@@ -0,0 +1,47 @@
+/*
+ * The Mana Client
+ * Copyright (C) 2009-2010 The Mana Developers
+ *
+ * This file is part of The Mana Client.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef GUI_MOUSEEVENT_H
+#define GUI_MOUSEEVENT_H
+
+#include <guichan/mouseevent.hpp>
+#include <guichan/widget.hpp>
+
+class MouseEvent : public gcn::MouseEvent
+{
+ public:
+ MouseEvent(gcn::Widget* source, bool isShiftPressed,
+ bool isControlPressed, bool isAltPressed, bool isMetaPressed,
+ unsigned int type, unsigned int button, int x, int y,
+ int clickCount) :
+ gcn::MouseEvent(source, isShiftPressed, isControlPressed,
+ isAltPressed, isMetaPressed, type, button, x, y,
+ clickCount)
+ {
+ }
+
+ void setX(int n)
+ { mX = n; }
+
+ void setY(int n)
+ { mY = n; }
+};
+
+#endif