Richard Parker / EALCD
Revision:
1:f04bcaea1d60
Child:
3:24fbf4dbd7e5
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/manager/EAHitBox.cpp	Thu Mar 04 10:54:06 2010 +0000
@@ -0,0 +1,44 @@
+#include "mbed.h"
+#include "EAHitBox.h"
+
+EAHitBox::EAHitBox()
+:   _next(NULL),
+    _widget(NULL),
+    _width(0),
+    _height(0),
+    _x(0),
+    _y(0),
+    _action(NULL)
+{
+}
+
+EAHitBox::~EAHitBox()
+{
+}
+
+bool EAHitBox::checkContains(short x, short y)
+{
+    bool result = false;
+    
+    if  (
+            (x > this->x())
+            &&
+            (x < this->x() + width())
+            &&
+            (y > this->y())
+            &&
+            (y < this->y() + height())
+        )
+    {
+        // This is a hit.
+        result = true;
+    }
+       
+    if ((result == true) && (_action != NULL))
+    {
+        // Hit inside and an action is defined.
+        _action(this, x, y);
+    }
+    
+    return result;
+}