nim_duilib/duilib/Utils/Delegate.h
jiajia_deng 4933d1f2bc Remove dependency on shared
Signed-off-by: jiajia_deng <2894220@gmail.com>
2019-09-20 16:27:58 +08:00

36 lines
596 B
C++

#ifndef UI_UTILS_DELEGATE_H_
#define UI_UTILS_DELEGATE_H_
#pragma once
#include "Core/Define.h"
namespace ui
{
typedef std::function<bool(ui::EventArgs*)> EventCallback;
class CEventSource : public std::vector<EventCallback>
{
public:
CEventSource& operator += (const EventCallback& item)
{
push_back(item);
return *this;
}
bool operator() (ui::EventArgs* param) const
{
for (auto it = this->begin(); it != this->end(); it++) {
if(!(*it)(param)) return false;
}
return true;
}
};
typedef std::map<EventType, CEventSource> EventMap;
}
#endif // UI_UTILS_DELEGATE_H_