Event.hpp: Set event object

This commit is contained in:
Vojtech Kral 2018-10-03 14:07:10 +02:00
parent 770d944283
commit 83f55b608c
3 changed files with 23 additions and 14 deletions

View file

@ -1,6 +1,7 @@
#ifndef slic3r_Events_hpp_
#define slic3r_Events_hpp_
#include <wx/event.h>
@ -11,11 +12,14 @@ namespace GUI {
struct SimpleEvent : public wxEvent
{
SimpleEvent(wxEventType type, int id = 0) : wxEvent(id, type) {}
SimpleEvent(wxEventType type, wxObject* origin = nullptr) : wxEvent(0, type)
{
SetEventObject(origin);
}
virtual wxEvent* Clone() const
{
return new SimpleEvent(GetEventType(), GetId());
return new SimpleEvent(GetEventType(), GetEventObject());
}
};
@ -23,26 +27,30 @@ template<class T, size_t N> struct ArrayEvent : public wxEvent
{
std::array<T, N> data;
ArrayEvent(wxEventType type, std::array<T, N> data, int id = 0)
: wxEvent(id, type), data(std::move(data))
{}
ArrayEvent(wxEventType type, std::array<T, N> data, wxObject* origin = nullptr)
: wxEvent(0, type), data(std::move(data))
{
SetEventObject(origin);
}
virtual wxEvent* Clone() const
{
return new ArrayEvent<T, N>(GetEventType(), data, GetId());
return new ArrayEvent<T, N>(GetEventType(), data, GetEventObject());
}
};
template<class T> struct ArrayEvent<T, 1> : public wxEvent
{
T data;
ArrayEvent(wxEventType type, T data, int id = 0)
: wxEvent(id, type), data(std::move(data))
{}
ArrayEvent(wxEventType type, T data, wxObject* origin = nullptr)
: wxEvent(0, type), data(std::move(data))
{
SetEventObject(origin);
}
virtual wxEvent* Clone() const
{
return new ArrayEvent<T, 1>(GetEventType(), data, GetId());
return new ArrayEvent<T, 1>(GetEventType(), data, GetEventObject());
}
};