From 201d5dda51c40ccaf5230aff382544080de6cc77 Mon Sep 17 00:00:00 2001
From: James Turk <james.p.turk@gmail.com>
Date: Sun, 21 Sep 2003 03:28:53 +0000
Subject: [PATCH] MouseInRect

---
 changelog.txt        |  3 ++-
 include/ZE_ZEngine.h | 17 ++++++++++++++---
 src/ZE_ZEngine.cpp   |  8 +++++++-
 3 files changed, 23 insertions(+), 5 deletions(-)

diff --git a/changelog.txt b/changelog.txt
index 4c3eb97..57ec378 100644
--- a/changelog.txt
+++ b/changelog.txt
@@ -1,5 +1,5 @@
 ZEngine Version Log for Version 0.8.5
-$Id: changelog.txt,v 1.47 2003/09/09 02:55:01 cozman Exp $
+$Id: changelog.txt,v 1.48 2003/09/21 03:28:53 cozman Exp $
 
 Changes are marked with symbols that describe them:
 ! is code that breaks backwards compatibility (used after 0.8.0-rc1, previous versions broke compatibility)
@@ -11,6 +11,7 @@ Changes are marked with symbols that describe them:
 (Note: Depreciated code (that marked with a *) is likely to disappear completely at the next major version.)
 
 0.8.5
+    + ZRect overload for ZEngine::MouseInRect.
     + ZE_main as new entrypoint instead of main, ZE_main entrypoint allows ZEngine to initialize PhysFS and release itself.
     + New Draw,DrawRotated, and DrawClipped overloads with vertex coloring parameter for advanced needs.
     + Addition of Dev-C++ project files and more Dev-C++ support.
diff --git a/include/ZE_ZEngine.h b/include/ZE_ZEngine.h
index 7d91284..8aa1c7f 100644
--- a/include/ZE_ZEngine.h
+++ b/include/ZE_ZEngine.h
@@ -13,7 +13,7 @@
     \brief Definition file for core ZEngine class.
 
     ZEngine Game Engine core Engine definition.
-    <br>$Id: ZE_ZEngine.h,v 1.48 2003/09/09 02:49:10 cozman Exp $<br>
+    <br>$Id: ZE_ZEngine.h,v 1.49 2003/09/21 03:28:53 cozman Exp $<br>
     \author James Turk
 **/
 
@@ -35,6 +35,8 @@
 namespace ZE
 {
 
+class ZRect;
+
 /*!
     \brief Main ZEngine Singleton Class
 
@@ -139,7 +141,7 @@ class ZEngine
         /*!
             \brief Release Instance (obsolete as of 0.8.5).
 
-            Release memory held by instance of engine and closes window.  
+            Release memory held by instance of engine and closes window.
             If you are using ZE_main (new in 0.8.5) this needs not ever be called.
         **/
         static void ReleaseInstance();
@@ -465,12 +467,21 @@ class ZEngine
         /*!
             \brief Check if mouse is in given rectangle.
 
-            Return status of mouse in current rectangle (used for buttons)
+            Return status of mouse in current rectangle (eg. GUI buttons).
             \param rect Rectangle to check if mouse is in.
             \return true if mouse is in rectangle, false otherwise
         **/
         bool MouseInRect(SDL_Rect *rect);
 
+        /*!
+            \brief Check if mouse is in given rectangle.
+
+            Return status of mouse in current rectangle (eg. GUI buttons).
+            \param rect Rectangle to check if mouse is in.
+            \return true if mouse is in rectangle, false otherwise
+        **/
+        bool MouseInRect(ZRect rect);
+
         /*!
             \brief Check for Activation, Window Manager, and Quit Events.
 
diff --git a/src/ZE_ZEngine.cpp b/src/ZE_ZEngine.cpp
index b50ec19..e6ca2ac 100644
--- a/src/ZE_ZEngine.cpp
+++ b/src/ZE_ZEngine.cpp
@@ -13,11 +13,12 @@
     \brief Central source file for ZEngine.
 
     Actual implementation of ZEngine singleton class, the core of ZEngine.
-    <br>$Id: ZE_ZEngine.cpp,v 1.57 2003/08/08 04:03:32 cozman Exp $<br>
+    <br>$Id: ZE_ZEngine.cpp,v 1.58 2003/09/21 03:28:53 cozman Exp $<br>
     \author James Turk
 **/
 
 #include "ZE_ZEngine.h"
+#include "ZE_ZRect.h"
 
 namespace ZE
 {
@@ -489,6 +490,11 @@ bool ZEngine::MouseInRect(SDL_Rect *rect)
         mMouseY >= rect->y && mMouseY <= rect->y+rect->h);
 }
 
+bool ZEngine::MouseInRect(ZRect rect)
+{
+    return rect.Contains(static_cast<float>(mMouseX),static_cast<float>(mMouseY));
+}
+
 void ZEngine::CheckEvents()
 {
     SDL_Event event;