I should have commit when I knew what changes I made.
This commit is contained in:
@@ -0,0 +1,11 @@
|
||||
#ifndef _EVENT_H_
|
||||
#define _EVENT_H_
|
||||
|
||||
/*** Custom Header Files ***/
|
||||
|
||||
/*** DLL Header File ***/
|
||||
#include "dllExport.h"
|
||||
|
||||
#define CLASS(X)
|
||||
|
||||
#endif/// END IFNDEF _EVENT_H_
|
||||
@@ -0,0 +1,20 @@
|
||||
#include "cButtonEvent.hpp"
|
||||
|
||||
#include "../../MathEngine/cInside.hpp"
|
||||
|
||||
using GUIEventEngine::cButtonEvent;
|
||||
|
||||
/// protected:
|
||||
cButtonEvent::cButtonEvent( const unsigned int id )
|
||||
: cGUIEvent(GUIHelpers::eEventType::BUTTON, id)
|
||||
{}
|
||||
|
||||
/*virtual*/ cButtonEvent::~cButtonEvent()
|
||||
{}
|
||||
|
||||
/// public:
|
||||
/*virtual*/ void cButtonEvent::OnLButtonDown( int mX, int mY )
|
||||
{
|
||||
// if (MathEngine::cInside::isInside(mX, mY, m_button->getArea()) == true)
|
||||
// ;
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
#ifndef _CBUTTONEVENT_HPP_
|
||||
#define _CBUTTONEVENT_HPP_
|
||||
|
||||
/*** Custom Header Files ***/
|
||||
#include "../../EventEngine/cEvent.hpp"
|
||||
|
||||
//#include "../cButton.hpp"
|
||||
#include "cGUIEvent.hpp"
|
||||
|
||||
|
||||
/*** DLL Header File ***/
|
||||
#include "dllExport.h"
|
||||
|
||||
namespace GUIEventEngine {
|
||||
class EXPORT_FROM_MYDLL cButtonEvent : public cGUIEvent
|
||||
{
|
||||
public:
|
||||
cButtonEvent( const unsigned int id );
|
||||
virtual ~cButtonEvent();
|
||||
|
||||
//bool operator == ( const cButtonEvent& other );
|
||||
|
||||
public:
|
||||
/// Functions
|
||||
virtual void OnLButtonDown( int mX, int mY );
|
||||
|
||||
/// Sets
|
||||
|
||||
/// Gets
|
||||
|
||||
private:
|
||||
/// Variables
|
||||
//GUIEngine::cButton* m_button;
|
||||
};/// END CLASS DEFINITION cButtonEvent
|
||||
}/// END NAMESPACE DEFINITION GUIEventEngine
|
||||
#endif/// END IFNDEF _CBUTTONEVENT_HPP_
|
||||
@@ -0,0 +1,297 @@
|
||||
#include "cGUIEvent.hpp"
|
||||
|
||||
using GUIEventEngine::cGUIEvent;
|
||||
|
||||
cGUIEvent::cGUIEvent( const GUIHelpers::eEventType eventType, const unsigned int id )
|
||||
: m_eventType(eventType), m_id(id)
|
||||
{
|
||||
}
|
||||
|
||||
/*virtual*/ cGUIEvent::~cGUIEvent()
|
||||
{
|
||||
}
|
||||
|
||||
/*virtual*/ void cGUIEvent::OnEvent(const SDL_Event& event)
|
||||
{
|
||||
switch (event.type)
|
||||
{
|
||||
case SDL_WINDOWEVENT:
|
||||
OnWindowsEvent(event);
|
||||
break;
|
||||
case SDL_KEYDOWN:
|
||||
OnKeyDown(event.key.keysym.sym, event.key.keysym.mod);// , Event->key.keysym.unicode);
|
||||
break;
|
||||
case SDL_KEYUP:
|
||||
OnKeyUp(event.key.keysym.sym, event.key.keysym.mod);//, Event->key.keysym.unicode);
|
||||
break;
|
||||
case SDL_MOUSEMOTION:
|
||||
OnMouseMove(event.motion.x, event.motion.y, event.motion.xrel, event.motion.yrel, (event.motion.state&SDL_BUTTON(SDL_BUTTON_LEFT)) != 0, (event.motion.state&SDL_BUTTON(SDL_BUTTON_RIGHT)) != 0, (event.motion.state&SDL_BUTTON(SDL_BUTTON_MIDDLE)) != 0);
|
||||
break;
|
||||
case SDL_MOUSEBUTTONDOWN:
|
||||
OnMouseButtonDown(event);
|
||||
break;
|
||||
case SDL_MOUSEBUTTONUP:
|
||||
OnMouseButtonUp(event);
|
||||
break;
|
||||
case SDL_JOYAXISMOTION:
|
||||
OnJoyAxis(event.jaxis.which, event.jaxis.axis, event.jaxis.value);
|
||||
break;
|
||||
case SDL_JOYBALLMOTION:
|
||||
OnJoyBall(event.jball.which, event.jball.ball, event.jball.xrel, event.jball.yrel);
|
||||
break;
|
||||
case SDL_JOYHATMOTION:
|
||||
OnJoyHat(event.jhat.which, event.jhat.hat, event.jhat.value);
|
||||
break;
|
||||
case SDL_JOYBUTTONDOWN:
|
||||
OnJoyButtonDown(event.jbutton.which, event.jbutton.button);
|
||||
break;
|
||||
case SDL_JOYBUTTONUP:
|
||||
OnJoyButtonUp(event.jbutton.which, event.jbutton.button);
|
||||
break;
|
||||
case SDL_QUIT:
|
||||
OnExit();
|
||||
break;
|
||||
case SDL_SYSWMEVENT:
|
||||
//Ignore
|
||||
break;
|
||||
default:
|
||||
OnUser(event.user.type, event.user.code, event.user.data1, event.user.data2);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/*virtual*/ void cGUIEvent::OnInputFocus()
|
||||
{
|
||||
//Pure virtual, do nothing
|
||||
}
|
||||
|
||||
/*virtual*/ void cGUIEvent::OnInputBlur()
|
||||
{
|
||||
//Pure virtual, do nothing
|
||||
}
|
||||
|
||||
/*virtual*/ void cGUIEvent::OnKeyDown(SDL_Keycode sym, Uint16 mod)//, Uint16 unicode)
|
||||
{
|
||||
sym, mod;
|
||||
//Pure virtual, do nothing
|
||||
}
|
||||
|
||||
/*virtual*/ void cGUIEvent::OnKeyUp(SDL_Keycode sym, Uint16 mod)//, Uint16 unicode)
|
||||
{
|
||||
sym, mod;
|
||||
//Pure virtual, do nothing
|
||||
}
|
||||
|
||||
/*virtual*/ void cGUIEvent::OnMouseFocus()
|
||||
{
|
||||
//Pure virtual, do nothing
|
||||
}
|
||||
|
||||
/*virtual*/ void cGUIEvent::OnMouseBlur()
|
||||
{
|
||||
//Pure virtual, do nothing
|
||||
}
|
||||
|
||||
/*virtual*/ void cGUIEvent::OnMouseMove(int mX, int mY, int relX, int relY, bool Left, bool Right, bool Middle)
|
||||
{
|
||||
mX, mY, relX, relY, Left, Right, Middle;
|
||||
//Pure virtual, do nothing
|
||||
}
|
||||
|
||||
/*virtual*/ void cGUIEvent::OnMouseWheel(bool Up, bool Down)
|
||||
{
|
||||
Up, Down;
|
||||
//Pure virtual, do nothing
|
||||
}
|
||||
|
||||
/*virtual*/ void cGUIEvent::OnLButtonDown(int mX, int mY)
|
||||
{
|
||||
mX, mY;
|
||||
//Pure virtual, do nothing
|
||||
}
|
||||
|
||||
/*virtual*/ void cGUIEvent::OnLButtonUp(int mX, int mY)
|
||||
{
|
||||
mX, mY;
|
||||
//Pure virtual, do nothing
|
||||
}
|
||||
|
||||
/*virtual*/ void cGUIEvent::OnRButtonDown(int mX, int mY)
|
||||
{
|
||||
mX, mY;
|
||||
//Pure virtual, do nothing
|
||||
}
|
||||
|
||||
/*virtual*/ void cGUIEvent::OnRButtonUp(int mX, int mY)
|
||||
{
|
||||
mX, mY;
|
||||
//Pure virtual, do nothing
|
||||
}
|
||||
|
||||
/*virtual*/ void cGUIEvent::OnMButtonDown(int mX, int mY)
|
||||
{
|
||||
mX, mY;
|
||||
//Pure virtual, do nothing
|
||||
}
|
||||
|
||||
/*virtual*/ void cGUIEvent::OnMButtonUp(int mX, int mY)
|
||||
{
|
||||
mX, mY;
|
||||
//Pure virtual, do nothing
|
||||
}
|
||||
|
||||
/*virtual*/ void cGUIEvent::OnJoyAxis(SDL_JoystickID which, Uint8 axis, Sint16 value)
|
||||
{
|
||||
which, axis, value;
|
||||
//Pure virtual, do nothing
|
||||
}
|
||||
|
||||
/*virtual*/ void cGUIEvent::OnJoyButtonDown(SDL_JoystickID which, Uint8 button)
|
||||
{
|
||||
which, button;
|
||||
//Pure virtual, do nothing
|
||||
}
|
||||
|
||||
/*virtual*/ void cGUIEvent::OnJoyButtonUp(SDL_JoystickID which, Uint8 button)
|
||||
{
|
||||
which, button;
|
||||
//Pure virtual, do nothing
|
||||
}
|
||||
|
||||
/*virtual*/ void cGUIEvent::OnJoyHat(SDL_JoystickID which, Uint8 hat, Uint8 value)
|
||||
{
|
||||
which, hat, value;
|
||||
//Pure virtual, do nothing
|
||||
}
|
||||
|
||||
/*virtual*/ void cGUIEvent::OnJoyBall(SDL_JoystickID which, Uint8 ball, Sint16 xrel, Sint16 yrel)
|
||||
{
|
||||
which, ball, xrel, yrel;
|
||||
//Pure virtual, do nothing
|
||||
}
|
||||
|
||||
/*virtual*/ void cGUIEvent::OnMinimize()
|
||||
{
|
||||
//Pure virtual, do nothing
|
||||
}
|
||||
|
||||
/*virtual*/ void cGUIEvent::OnRestore()
|
||||
{
|
||||
//Pure virtual, do nothing
|
||||
}
|
||||
|
||||
/*virtual*/ void cGUIEvent::OnResize(int w, int h)
|
||||
{
|
||||
w, h;
|
||||
//Pure virtual, do nothing
|
||||
}
|
||||
|
||||
/*virtual*/ void cGUIEvent::OnExpose()
|
||||
{
|
||||
//Pure virtual, do nothing
|
||||
}
|
||||
|
||||
/*virtual*/ void cGUIEvent::OnExit()
|
||||
{
|
||||
//Pure virtual, do nothing
|
||||
}
|
||||
|
||||
/*virtual*/ void cGUIEvent::OnUser(Uint32 type, int code, void* data1, void* data2)
|
||||
{
|
||||
type, code, data1, data2;
|
||||
//Pure virtual, do nothing
|
||||
}
|
||||
|
||||
/*virtual*/ void cGUIEvent::OnWindowsEvent(const SDL_Event& event)
|
||||
{
|
||||
switch (event.window.event)
|
||||
{
|
||||
case SDL_WINDOWEVENT_SHOWN:
|
||||
SDL_Log("Window %d shown", event.window.windowID);
|
||||
break;
|
||||
case SDL_WINDOWEVENT_HIDDEN:
|
||||
SDL_Log("Window %d hidden", event.window.windowID);
|
||||
break;
|
||||
case SDL_WINDOWEVENT_EXPOSED:
|
||||
SDL_Log("Window %d exposed", event.window.windowID);
|
||||
break;
|
||||
case SDL_WINDOWEVENT_MOVED:
|
||||
SDL_Log("Window %d moved to %d,%d",
|
||||
event.window.windowID, event.window.data1,
|
||||
event.window.data2);
|
||||
break;
|
||||
case SDL_WINDOWEVENT_RESIZED:
|
||||
SDL_Log("Window %d resized to %dx%d",
|
||||
event.window.windowID, event.window.data1,
|
||||
event.window.data2);
|
||||
break;
|
||||
case SDL_WINDOWEVENT_SIZE_CHANGED:
|
||||
SDL_Log("Window %d size changed to %dx%d",
|
||||
event.window.windowID, event.window.data1,
|
||||
event.window.data2);
|
||||
break;
|
||||
case SDL_WINDOWEVENT_MINIMIZED:
|
||||
SDL_Log("Window %d minimized", event.window.windowID);
|
||||
break;
|
||||
case SDL_WINDOWEVENT_MAXIMIZED:
|
||||
SDL_Log("Window %d maximized", event.window.windowID);
|
||||
break;
|
||||
case SDL_WINDOWEVENT_RESTORED:
|
||||
SDL_Log("Window %d restored", event.window.windowID);
|
||||
break;
|
||||
case SDL_WINDOWEVENT_ENTER:
|
||||
SDL_Log("Mouse entered window %d",
|
||||
event.window.windowID);
|
||||
break;
|
||||
case SDL_WINDOWEVENT_LEAVE:
|
||||
SDL_Log("Mouse left window %d", event.window.windowID);
|
||||
break;
|
||||
case SDL_WINDOWEVENT_FOCUS_GAINED:
|
||||
SDL_Log("Window %d gained keyboard focus",
|
||||
event.window.windowID);
|
||||
break;
|
||||
case SDL_WINDOWEVENT_FOCUS_LOST:
|
||||
SDL_Log("Window %d lost keyboard focus",
|
||||
event.window.windowID);
|
||||
break;
|
||||
case SDL_WINDOWEVENT_CLOSE:
|
||||
SDL_Log("Window %d closed", event.window.windowID);
|
||||
break;
|
||||
default:
|
||||
SDL_Log("Window %d got unknown event %d",
|
||||
event.window.windowID, event.window.event);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/*virtual*/ void cGUIEvent::OnMouseButtonDown(const SDL_Event& event)
|
||||
{
|
||||
switch (event.button.button)
|
||||
{
|
||||
case SDL_BUTTON_LEFT:
|
||||
OnLButtonDown(event.button.x, event.button.y);
|
||||
break;
|
||||
case SDL_BUTTON_RIGHT:
|
||||
OnRButtonDown(event.button.x, event.button.y);
|
||||
break;
|
||||
case SDL_BUTTON_MIDDLE:
|
||||
OnMButtonDown(event.button.x, event.button.y);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/*virtual*/ void cGUIEvent::OnMouseButtonUp(const SDL_Event& event)
|
||||
{
|
||||
switch (event.button.button)
|
||||
{
|
||||
case SDL_BUTTON_LEFT:
|
||||
OnLButtonUp(event.button.x, event.button.y);
|
||||
break;
|
||||
case SDL_BUTTON_RIGHT:
|
||||
OnRButtonUp(event.button.x, event.button.y);
|
||||
break;
|
||||
case SDL_BUTTON_MIDDLE:
|
||||
OnMButtonUp(event.button.x, event.button.y);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,86 @@
|
||||
#ifndef _CGUIEVENT_HPP_
|
||||
#define _CGUIEVENT_HPP_
|
||||
|
||||
/*** Custom Header Files ***/
|
||||
#include "../../EventEngine/cEvent.hpp"
|
||||
#include "../GUIHelpers/Enums.hpp"
|
||||
|
||||
/*** DLL Header File ***/
|
||||
#include "dllExport.h"
|
||||
|
||||
#include "../GUIHelpers/cObject.hpp"
|
||||
|
||||
namespace GUIEventEngine {
|
||||
class EXPORT_FROM_MYDLL cGUIEvent : public EventEngine::cEvent
|
||||
{
|
||||
public:
|
||||
cGUIEvent( const GUIHelpers::eEventType eventType, const unsigned int id );
|
||||
virtual ~cGUIEvent();
|
||||
|
||||
bool operator == (const cGUIEvent& other);
|
||||
|
||||
/// Functions
|
||||
virtual void OnEvent(const SDL_Event& event);
|
||||
|
||||
virtual void OnInputFocus();
|
||||
|
||||
virtual void OnInputBlur();
|
||||
|
||||
virtual void OnKeyDown(SDL_Keycode sym, Uint16 mod);//, Uint16 unicode);
|
||||
|
||||
virtual void OnKeyUp(SDL_Keycode sym, Uint16 mod);//, Uint16 unicode);
|
||||
|
||||
virtual void OnMouseFocus();
|
||||
|
||||
virtual void OnMouseBlur();
|
||||
|
||||
virtual void OnMouseMove(int mX, int mY, int relX, int relY, bool Left, bool Right, bool Middle);
|
||||
|
||||
virtual void OnMouseWheel(bool Up, bool Down); //Not implemented
|
||||
|
||||
virtual void OnLButtonDown(int mX, int mY);
|
||||
|
||||
virtual void OnLButtonUp(int mX, int mY);
|
||||
|
||||
virtual void OnRButtonDown(int mX, int mY);
|
||||
|
||||
virtual void OnRButtonUp(int mX, int mY);
|
||||
|
||||
virtual void OnMButtonDown(int mX, int mY);
|
||||
|
||||
virtual void OnMButtonUp(int mX, int mY);
|
||||
|
||||
virtual void OnJoyAxis(SDL_JoystickID which, Uint8 axis, Sint16 value);
|
||||
|
||||
virtual void OnJoyButtonDown(SDL_JoystickID which, Uint8 button);
|
||||
|
||||
virtual void OnJoyButtonUp(SDL_JoystickID which, Uint8 button);
|
||||
|
||||
virtual void OnJoyHat(SDL_JoystickID which, Uint8 hat, Uint8 value);
|
||||
|
||||
virtual void OnJoyBall(SDL_JoystickID which, Uint8 ball, Sint16 xrel, Sint16 yrel);
|
||||
|
||||
virtual void OnMinimize();
|
||||
|
||||
virtual void OnRestore();
|
||||
|
||||
virtual void OnResize(int w, int h);
|
||||
|
||||
virtual void OnExpose();
|
||||
|
||||
virtual void OnExit();
|
||||
|
||||
virtual void OnUser(Uint32 type, int code, void* data1, void* data2);
|
||||
|
||||
private:
|
||||
void OnWindowsEvent(const SDL_Event& event);
|
||||
void OnMouseButtonDown(const SDL_Event& event);
|
||||
void OnMouseButtonUp(const SDL_Event& event);
|
||||
|
||||
private:
|
||||
/// Variables
|
||||
signed int m_id;// = 0
|
||||
GUIHelpers::eEventType m_eventType;
|
||||
};/// END CLASS DEFINITION cGUIEvent
|
||||
}/// END NAMESPACE DEFINITION GUIEventEngine
|
||||
#endif/// END IFNDEF _CGUIEVENT_HPP_
|
||||
@@ -0,0 +1,42 @@
|
||||
#include "cGUIEventHandler.hpp"
|
||||
|
||||
using GUIEventEngine::cGUIEventHandler;
|
||||
|
||||
cGUIEventHandler::cGUIEventHandler()
|
||||
{
|
||||
}
|
||||
|
||||
cGUIEventHandler::~cGUIEventHandler()
|
||||
{
|
||||
for (unsigned int i = 0; i < m_events.size(); ++i) {
|
||||
delete m_events[i];
|
||||
m_events[i] = nullptr;
|
||||
}
|
||||
m_events.clear();
|
||||
}
|
||||
|
||||
/// Functions
|
||||
void cGUIEventHandler::CheckEvents()
|
||||
{
|
||||
SDL_Event event;
|
||||
while (SDL_PollEvent(&event)) {
|
||||
std::vector<GUIEventEngine::cGUIEvent*>::iterator it;
|
||||
|
||||
for (it = m_events.begin(); it < m_events.end(); it++) {
|
||||
(*it)->OnEvent(event);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void cGUIEventHandler::AddEvents(GUIEventEngine::cGUIEvent* event )
|
||||
{
|
||||
m_events.push_back(event);
|
||||
}
|
||||
|
||||
/// Sets
|
||||
|
||||
/// Gets
|
||||
std::vector<GUIEventEngine::cGUIEvent*>& cGUIEventHandler::getEvents()
|
||||
{
|
||||
return m_events;
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
#ifndef _CGUIEVENTHANDLER_HPP_
|
||||
#define _CGUIEVENTHANDLER_HPP_
|
||||
|
||||
/*** C++ STL Files ***/
|
||||
#include <vector>
|
||||
|
||||
/*** Custom Header Files ***/
|
||||
#include "../GUIHelpers/Enums.hpp"
|
||||
|
||||
/*** DLL Header File ***/
|
||||
#include "dllExport.h"
|
||||
|
||||
#include "cGUIEvent.hpp"
|
||||
|
||||
namespace GUIEventEngine {
|
||||
class EXPORT_FROM_MYDLL cGUIEventHandler
|
||||
{
|
||||
public:
|
||||
cGUIEventHandler();
|
||||
virtual ~cGUIEventHandler();
|
||||
|
||||
bool operator == (const cGUIEventHandler& other);
|
||||
|
||||
/// Functions
|
||||
virtual void CheckEvents();
|
||||
|
||||
void AddEvents( GUIEventEngine::cGUIEvent* event );
|
||||
|
||||
/// Sets
|
||||
|
||||
/// Gets
|
||||
std::vector<GUIEventEngine::cGUIEvent*>& getEvents();
|
||||
|
||||
|
||||
|
||||
private:
|
||||
/// Variables
|
||||
std::vector<GUIEventEngine::cGUIEvent*> m_events;
|
||||
};/// END CLASS DEFINITION cGUIEvent
|
||||
}/// END NAMESPACE DEFINITION GUIEventEngine
|
||||
#endif/// END IFNDEF _CGUIEVENTHANDLER_HPP_
|
||||
Reference in New Issue
Block a user