Merge pull request #1935 from moadib/bb_eglview_event_handler

fixed #1015: Added CCEGLView::EventHandler class for Blackberry platform.
This commit is contained in:
James Chen 2013-01-30 22:31:03 -08:00
commit 9b5d0bd251
2 changed files with 28 additions and 0 deletions

View File

@ -77,6 +77,7 @@ static CCTouch *s_pTouches[MAX_TOUCHES] = { NULL };
static CCEGLView* s_pInstance = NULL; static CCEGLView* s_pInstance = NULL;
CCEGLView::CCEGLView() CCEGLView::CCEGLView()
: m_pEventHandler(NULL)
{ {
m_eglDisplay = EGL_NO_DISPLAY; m_eglDisplay = EGL_NO_DISPLAY;
m_eglContext = EGL_NO_CONTEXT; m_eglContext = EGL_NO_CONTEXT;
@ -103,7 +104,16 @@ CCEGLView::CCEGLView()
CCEGLView::~CCEGLView() CCEGLView::~CCEGLView()
{ {
}
void CCEGLView::setEventHandler(EventHandler* pHandler)
{
m_pEventHandler = pHandler;
}
const char* CCEGLView::getWindowGroupId() const
{
return m_windowGroupID;
} }
void CCEGLView::release() void CCEGLView::release()
@ -575,6 +585,9 @@ bool CCEGLView::handleEvents()
// break if no more events // break if no more events
if (event == NULL) if (event == NULL)
break; break;
if (m_pEventHandler && m_pEventHandler->HandleBPSEvent(event))
continue;
domain = bps_event_get_domain(event); domain = bps_event_get_domain(event);

View File

@ -29,15 +29,28 @@ THE SOFTWARE.
#include "platform/CCEGLViewProtocol.h" #include "platform/CCEGLViewProtocol.h"
#include "platform/CCPlatformMacros.h" #include "platform/CCPlatformMacros.h"
#include <bps/event.h>
NS_CC_BEGIN NS_CC_BEGIN
class CC_DLL CCEGLView : public CCEGLViewProtocol class CC_DLL CCEGLView : public CCEGLViewProtocol
{ {
public:
class CC_DLL EventHandler
{
public:
virtual bool HandleBPSEvent(bps_event_t* event) = 0;
virtual ~EventHandler() {}
};
public: public:
CCEGLView(); CCEGLView();
virtual ~CCEGLView(); virtual ~CCEGLView();
bool isOpenGLReady(); bool isOpenGLReady();
void setEventHandler(EventHandler* pHandler);
const char* getWindowGroupId() const;
// keep compatible // keep compatible
void end(); void end();
@ -67,6 +80,8 @@ private:
bool m_isGLInitialized; bool m_isGLInitialized;
bool m_isWindowActive; bool m_isWindowActive;
EventHandler* m_pEventHandler;
EGLDisplay m_eglDisplay; EGLDisplay m_eglDisplay;
EGLContext m_eglContext; EGLContext m_eglContext;