E:/Download/ois-1.0RC1/includes/OISMouse.h

Go to the documentation of this file.
00001 /*
00002 The zlib/libpng License
00003 
00004 Copyright (c) 2006 Phillip Castaneda (pjcast -- www.wreckedgames.com)
00005 
00006 This software is provided 'as-is', without any express or implied warranty. In no event will
00007 the authors be held liable for any damages arising from the use of this software.
00008 
00009 Permission is granted to anyone to use this software for any purpose, including commercial
00010 applications, and to alter it and redistribute it freely, subject to the following
00011 restrictions:
00012 
00013     1. The origin of this software must not be misrepresented; you must not claim that
00014                 you wrote the original software. If you use this software in a product,
00015                 an acknowledgment in the product documentation would be appreciated but is
00016                 not required.
00017 
00018     2. Altered source versions must be plainly marked as such, and must not be
00019                 misrepresented as being the original software.
00020 
00021     3. This notice may not be removed or altered from any source distribution.
00022 */
00023 #ifndef OIS_Mouse_H
00024 #define OIS_Mouse_H
00025 #include "OISObject.h"
00026 #include "OISEvents.h"
00027 
00028 namespace OIS
00029 {
00031         enum MouseButtonID
00032         {
00033                 MB_Left = 0, MB_Right, MB_Middle,
00034                 MB_Button3, MB_Button4, MB_Button5, MB_Button6, MB_Button7
00035         };
00036 
00041         struct _OISExport MouseState
00042         {
00043                 MouseState() : width(50), height(50), buttons(0) {};
00044 
00048                 mutable int width, height;
00049 
00051                 Axis X;
00052 
00054                 Axis Y;
00055 
00057                 Axis Z;
00058 
00060                 int buttons;
00061 
00063                 inline bool buttonDown( MouseButtonID button ) const
00064                 {
00065                         return ((buttons & ( 1L << button )) == 0) ? false : true;
00066                 }
00067 
00069                 void clear()
00070                 {
00071                         X.clear();
00072                         Y.clear();
00073                         Z.clear();
00074                         buttons = 0;
00075                 }
00076         };
00077 
00079         class _OISExport MouseEvent : public EventArg
00080         {
00081         public:
00082                 MouseEvent( Object *obj, const MouseState &ms ) : EventArg(obj), state(ms) {}
00083                 virtual ~MouseEvent() {}
00084 
00086                 const MouseState &state;
00087         };
00088 
00093         class _OISExport MouseListener
00094         {
00095         public:
00096                 virtual ~MouseListener() {}
00097                 virtual bool mouseMoved( const MouseEvent &arg ) = 0;
00098                 virtual bool mousePressed( const MouseEvent &arg, MouseButtonID id ) = 0;
00099                 virtual bool mouseReleased( const MouseEvent &arg, MouseButtonID id ) = 0;
00100         };
00101 
00106         class _OISExport Mouse : public Object
00107         {
00108         public:
00109                 virtual ~Mouse() {}
00110 
00118                 virtual void setEventCallback( MouseListener *mouseListener ) {listener = mouseListener;}
00119 
00121                 MouseListener* getEventCallback() {return listener;}
00122 
00124                 const MouseState& getMouseState() const { return mState; }
00125 
00126         protected:
00127                 Mouse() : listener(0) {}
00129                 MouseState mState;
00130 
00132                 MouseListener *listener;
00133         };
00134 }
00135 #endif

Generated on Sat Dec 1 20:13:51 2007 for OIS by  doxygen 1.5.4