PrusaSlicer-NonPlainar/src/slic3r/GUI/Event.hpp

67 lines
1.4 KiB
C++
Raw Normal View History

#ifndef slic3r_Events_hpp_
#define slic3r_Events_hpp_
#include <array>
#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);
}
virtual wxEvent* Clone() const
{
2018-10-03 12:07:10 +00:00
return new SimpleEvent(GetEventType(), GetEventObject());
}
};
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);
}
virtual wxEvent* Clone() const
{
2018-10-03 12:07:10 +00:00
return new ArrayEvent<T, N>(GetEventType(), data, GetEventObject());
}
};
template<class T> struct ArrayEvent<T, 1> : public wxEvent
{
T data;
2018-10-03 12:07:10 +00:00
ArrayEvent(wxEventType type, T 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);
}
virtual wxEvent* Clone() const
{
2018-10-03 12:07:10 +00:00
return new ArrayEvent<T, 1>(GetEventType(), data, GetEventObject());
}
};
template <class T> using Event = ArrayEvent<T, 1>;
}
}
#endif // slic3r_Events_hpp_