2012-04-19 14:35:52 +08:00
|
|
|
/****************************************************************************
|
|
|
|
Copyright (c) 2010 cocos2d-x.org
|
|
|
|
|
|
|
|
http://www.cocos2d-x.org
|
|
|
|
|
|
|
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
|
of this software and associated documentation files (the "Software"), to deal
|
|
|
|
in the Software without restriction, including without limitation the rights
|
|
|
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
|
|
copies of the Software, and to permit persons to whom the Software is
|
|
|
|
furnished to do so, subject to the following conditions:
|
|
|
|
|
|
|
|
The above copyright notice and this permission notice shall be included in
|
|
|
|
all copies or substantial portions of the Software.
|
|
|
|
|
|
|
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
|
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
|
|
THE SOFTWARE.
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#ifndef __CCKEYPAD_DISPATCHER_H__
|
|
|
|
#define __CCKEYPAD_DISPATCHER_H__
|
|
|
|
|
|
|
|
#include "CCKeypadDelegate.h"
|
2012-06-19 13:50:11 +08:00
|
|
|
#include "cocoa/CCArray.h"
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
NS_CC_BEGIN
|
|
|
|
|
2012-06-20 18:09:11 +08:00
|
|
|
/**
|
|
|
|
* @addtogroup input
|
|
|
|
* @{
|
|
|
|
*/
|
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
typedef enum {
|
|
|
|
// the back key clicked msg
|
|
|
|
kTypeBackClicked = 1,
|
|
|
|
kTypeMenuClicked,
|
|
|
|
} ccKeypadMSGType;
|
|
|
|
|
|
|
|
struct _ccCArray;
|
|
|
|
/**
|
2013-06-20 14:13:12 +08:00
|
|
|
@class KeypadDispatcher
|
2012-04-19 14:35:52 +08:00
|
|
|
@brief Dispatch the keypad message from the phone
|
|
|
|
*/
|
2013-06-20 14:13:12 +08:00
|
|
|
class CC_DLL KeypadDispatcher : public Object
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
|
|
|
public:
|
2013-09-13 16:46:31 +08:00
|
|
|
/**
|
|
|
|
* @js ctor
|
|
|
|
*/
|
2013-06-20 14:13:12 +08:00
|
|
|
KeypadDispatcher();
|
2013-09-13 13:52:42 +08:00
|
|
|
/**
|
|
|
|
* @js NA
|
|
|
|
* @lua NA
|
|
|
|
*/
|
2013-06-20 14:13:12 +08:00
|
|
|
~KeypadDispatcher();
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
@brief add delegate to concern keypad msg
|
|
|
|
*/
|
2013-06-20 14:13:12 +08:00
|
|
|
void addDelegate(KeypadDelegate* pDelegate);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
@brief remove the delegate from the delegates who concern keypad msg
|
|
|
|
*/
|
2013-06-20 14:13:12 +08:00
|
|
|
void removeDelegate(KeypadDelegate* pDelegate);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
@brief force add the delegate
|
|
|
|
*/
|
2013-06-20 14:13:12 +08:00
|
|
|
void forceAddDelegate(KeypadDelegate* pDelegate);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
@brief force remove the delegate
|
|
|
|
*/
|
2013-06-20 14:13:12 +08:00
|
|
|
void forceRemoveDelegate(KeypadDelegate* pDelegate);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
@brief dispatch the key pad msg
|
|
|
|
*/
|
|
|
|
bool dispatchKeypadMSG(ccKeypadMSGType nMsgType);
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
2013-06-20 14:13:12 +08:00
|
|
|
Array* _delegates;
|
2013-06-15 14:03:30 +08:00
|
|
|
bool _locked;
|
|
|
|
bool _toAdd;
|
|
|
|
bool _toRemove;
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-06-15 14:03:30 +08:00
|
|
|
struct _ccCArray *_handlersToAdd;
|
|
|
|
struct _ccCArray *_handlersToRemove;
|
2012-04-19 14:35:52 +08:00
|
|
|
};
|
|
|
|
|
2012-06-20 18:09:11 +08:00
|
|
|
// end of input group
|
|
|
|
/// @}
|
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
NS_CC_END
|
|
|
|
|
|
|
|
#endif //__CCKEYPAD_DISPATCHER_H__
|