1 #ifndef slic3r_Events_hpp_ 2 #define slic3r_Events_hpp_ 3 4 #include <array> 5 #include <wx/event.h> 6 7 8 namespace Slic3r { 9 10 namespace GUI { 11 12 13 struct SimpleEvent : public wxEvent 14 { SimpleEventSlic3r::GUI::SimpleEvent15 SimpleEvent(wxEventType type, wxObject* origin = nullptr) : wxEvent(0, type) 16 { 17 m_propagationLevel = wxEVENT_PROPAGATE_MAX; 18 SetEventObject(origin); 19 } 20 CloneSlic3r::GUI::SimpleEvent21 virtual wxEvent* Clone() const 22 { 23 return new SimpleEvent(GetEventType(), GetEventObject()); 24 } 25 }; 26 27 template<class T, size_t N> struct ArrayEvent : public wxEvent 28 { 29 std::array<T, N> data; 30 ArrayEventSlic3r::GUI::ArrayEvent31 ArrayEvent(wxEventType type, std::array<T, N> data, wxObject* origin = nullptr) 32 : wxEvent(0, type), data(std::move(data)) 33 { 34 m_propagationLevel = wxEVENT_PROPAGATE_MAX; 35 SetEventObject(origin); 36 } 37 CloneSlic3r::GUI::ArrayEvent38 virtual wxEvent* Clone() const 39 { 40 return new ArrayEvent<T, N>(GetEventType(), data, GetEventObject()); 41 } 42 }; 43 44 template<class T> struct Event : public wxEvent 45 { 46 T data; 47 EventSlic3r::GUI::Event48 Event(wxEventType type, const T &data, wxObject* origin = nullptr) 49 : wxEvent(0, type), data(std::move(data)) 50 { 51 m_propagationLevel = wxEVENT_PROPAGATE_MAX; 52 SetEventObject(origin); 53 } 54 EventSlic3r::GUI::Event55 Event(wxEventType type, T&& data, wxObject* origin = nullptr) 56 : wxEvent(0, type), data(std::move(data)) 57 { 58 m_propagationLevel = wxEVENT_PROPAGATE_MAX; 59 SetEventObject(origin); 60 } 61 CloneSlic3r::GUI::Event62 virtual wxEvent* Clone() const 63 { 64 return new Event<T>(GetEventType(), data, GetEventObject()); 65 } 66 }; 67 68 } 69 } 70 71 #endif // slic3r_Events_hpp_ 72