2019-08-19 16:03:27 +08:00
|
|
|
#ifndef GUILITE_CORE_INCLUDE_CMD_TARGET_H
|
|
|
|
#define GUILITE_CORE_INCLUDE_CMD_TARGET_H
|
2017-12-06 21:43:47 +08:00
|
|
|
|
|
|
|
class c_cmd_target;
|
|
|
|
|
|
|
|
#define MSG_TYPE_INVALID 0xFFFF
|
|
|
|
#define MSG_TYPE_WND 0x0001
|
|
|
|
#define MSG_TYPE_USR 0x0002
|
2019-03-13 11:11:29 +08:00
|
|
|
#define USR_MSG_MAX 32
|
2017-12-06 21:43:47 +08:00
|
|
|
|
2019-12-17 10:45:15 +08:00
|
|
|
typedef void (c_cmd_target::*msgCallback)(int, int);
|
2017-12-06 21:43:47 +08:00
|
|
|
|
2018-12-02 22:39:43 +08:00
|
|
|
struct GL_MSG_ENTRY
|
2017-12-06 21:43:47 +08:00
|
|
|
{
|
|
|
|
unsigned int msgType;
|
|
|
|
unsigned int msgId;
|
2019-12-17 10:45:15 +08:00
|
|
|
c_cmd_target* object;
|
|
|
|
msgCallback callBack;
|
2017-12-06 21:43:47 +08:00
|
|
|
};
|
|
|
|
|
2018-12-02 22:39:43 +08:00
|
|
|
#define ON_GL_USER_MSG(msgId, func) \
|
2019-12-17 10:45:15 +08:00
|
|
|
{MSG_TYPE_USR, msgId, 0, msgCallback(&func)},
|
2017-12-06 21:43:47 +08:00
|
|
|
|
2018-12-02 22:39:43 +08:00
|
|
|
#define GL_DECLARE_MESSAGE_MAP() \
|
2017-12-06 21:43:47 +08:00
|
|
|
protected: \
|
2019-12-17 10:45:15 +08:00
|
|
|
virtual const GL_MSG_ENTRY* get_msg_entries() const;\
|
2017-12-06 21:43:47 +08:00
|
|
|
private: \
|
2019-12-17 10:45:15 +08:00
|
|
|
static const GL_MSG_ENTRY m_msg_entries[];
|
2017-12-06 21:43:47 +08:00
|
|
|
|
2018-12-02 22:39:43 +08:00
|
|
|
#define GL_BEGIN_MESSAGE_MAP(theClass) \
|
2019-12-17 10:45:15 +08:00
|
|
|
const GL_MSG_ENTRY* theClass::get_msg_entries() const \
|
2017-12-06 21:43:47 +08:00
|
|
|
{ \
|
2019-12-17 10:45:15 +08:00
|
|
|
return theClass::m_msg_entries; \
|
2017-12-06 21:43:47 +08:00
|
|
|
} \
|
2019-12-17 10:45:15 +08:00
|
|
|
const GL_MSG_ENTRY theClass::m_msg_entries[] = \
|
2017-12-06 21:43:47 +08:00
|
|
|
{
|
|
|
|
|
2018-12-02 22:39:43 +08:00
|
|
|
#define GL_END_MESSAGE_MAP() \
|
2019-12-17 10:45:15 +08:00
|
|
|
{MSG_TYPE_INVALID, 0, 0, 0}};
|
2017-12-06 21:43:47 +08:00
|
|
|
|
|
|
|
class c_cmd_target
|
|
|
|
{
|
|
|
|
public:
|
2019-12-17 10:45:15 +08:00
|
|
|
static int handle_usr_msg(int msg_id, int resource_id, int param);
|
2017-12-06 21:43:47 +08:00
|
|
|
protected:
|
|
|
|
void load_cmd_msg();
|
2019-12-17 10:45:15 +08:00
|
|
|
const GL_MSG_ENTRY* find_msg_entry(const GL_MSG_ENTRY *pEntry, int msgType, int msgId);
|
2017-12-06 21:43:47 +08:00
|
|
|
private:
|
2018-12-02 22:39:43 +08:00
|
|
|
static GL_MSG_ENTRY ms_usr_map_entries[USR_MSG_MAX];
|
2017-12-06 21:43:47 +08:00
|
|
|
static unsigned short ms_user_map_size;
|
2018-12-02 22:39:43 +08:00
|
|
|
GL_DECLARE_MESSAGE_MAP()
|
2017-12-06 21:43:47 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|