2018-10-03 09:34:39 +00:00
|
|
|
#ifndef slic3r_Events_hpp_
|
|
|
|
#define slic3r_Events_hpp_
|
|
|
|
|
2018-10-08 14:27:38 +00:00
|
|
|
#include <array>
|
2018-10-03 09:34:39 +00:00
|
|
|
#include <wx/event.h>
|
|
|
|
|
|
|
|
|
|
|
|
namespace Slic3r {
|
|
|
|
|
|
|
|
namespace GUI {
|
|
|
|
|
|
|
|
|
|
|
|
struct SimpleEvent : public wxEvent
|
|
|
|
{
|
2018-10-03 12:07:10 +00:00
|
|
|
SimpleEvent(wxEventType type, wxObject* origin = nullptr) : wxEvent(0, type)
|
|
|
|
{
|
2018-10-03 14:27:02 +00:00
|
|
|
m_propagationLevel = wxEVENT_PROPAGATE_MAX;
|
2018-10-03 12:07:10 +00:00
|
|
|
SetEventObject(origin);
|
|
|
|
}
|
2018-10-03 09:34:39 +00:00
|
|
|
|
|
|
|
virtual wxEvent* Clone() const
|
|
|
|
{
|
2018-10-03 12:07:10 +00:00
|
|
|
return new SimpleEvent(GetEventType(), GetEventObject());
|
2018-10-03 09:34:39 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
template<class T, size_t N> struct ArrayEvent : public wxEvent
|
|
|
|
{
|
|
|
|
std::array<T, N> data;
|
|
|
|
|
2018-10-03 12:07:10 +00:00
|
|
|
ArrayEvent(wxEventType type, std::array<T, N> data, wxObject* origin = nullptr)
|
|
|
|
: wxEvent(0, type), data(std::move(data))
|
|
|
|
{
|
2018-10-03 14:27:02 +00:00
|
|
|
m_propagationLevel = wxEVENT_PROPAGATE_MAX;
|
2018-10-03 12:07:10 +00:00
|
|
|
SetEventObject(origin);
|
|
|
|
}
|
2018-10-03 09:34:39 +00:00
|
|
|
|
|
|
|
virtual wxEvent* Clone() const
|
|
|
|
{
|
2018-10-03 12:07:10 +00:00
|
|
|
return new ArrayEvent<T, N>(GetEventType(), data, GetEventObject());
|
2018-10-03 09:34:39 +00:00
|
|
|
}
|
|
|
|
};
|
2020-03-06 14:10:58 +00:00
|
|
|
|
|
|
|
template<class T> struct Event : public wxEvent
|
2018-10-03 09:34:39 +00:00
|
|
|
{
|
|
|
|
T data;
|
|
|
|
|
2020-03-06 14:10:58 +00:00
|
|
|
Event(wxEventType type, const T &data, wxObject* origin = nullptr)
|
|
|
|
: wxEvent(0, type), data(std::move(data))
|
|
|
|
{
|
|
|
|
m_propagationLevel = wxEVENT_PROPAGATE_MAX;
|
|
|
|
SetEventObject(origin);
|
|
|
|
}
|
|
|
|
|
|
|
|
Event(wxEventType type, T&& data, wxObject* origin = nullptr)
|
2018-10-03 12:07:10 +00:00
|
|
|
: wxEvent(0, type), data(std::move(data))
|
|
|
|
{
|
2018-10-03 14:27:02 +00:00
|
|
|
m_propagationLevel = wxEVENT_PROPAGATE_MAX;
|
2018-10-03 12:07:10 +00:00
|
|
|
SetEventObject(origin);
|
|
|
|
}
|
2018-10-03 09:34:39 +00:00
|
|
|
|
|
|
|
virtual wxEvent* Clone() const
|
|
|
|
{
|
2020-03-06 14:10:58 +00:00
|
|
|
return new Event<T>(GetEventType(), data, GetEventObject());
|
2018-10-03 09:34:39 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif // slic3r_Events_hpp_
|