Files
OrcaSlicer/src/slic3r/GUI/Event.hpp
T
HanifKoh 1a5f91d727 Add Missing Includes Across src/slic3r/GUI (#16048)
* Add Missing Includes Across src/slic3r/GUI

Every GUI source and header now directly includes the headers declaring what it uses, rather than relying on the precompiled header or transitive includes. Generated with clang-tidy misc-include-cleaner, plus one hand edit making CalibrationPanel.hpp self-contained.

* Drop the OS-Specific Includes Added Outside Their Platform Guards

GLib, GTK, D-Bus and POSIX headers are only used inside platform #if blocks, which already include them. Added unconditionally at the top of the file they broke the Windows build.

* Add the clang-tidy Configuration That Generated These Includes

Only misc-include-cleaner's missing-include check, with the headers it must never suggest: per-platform, internal and OS-specific ones that would break other platforms or are not meant to be included directly.

* Match Windows Paths in the clang-tidy Ignore List

Header paths use backslashes on Windows, so every / in a pattern is now [/\\]. The Windows SDK headers are ignored alongside the other OS-specific ones, and the list is one pattern per line. Suggested by @raistlin7447 from a Windows clang-cl run.
2026-10-02 14:56:56 +08:00

117 lines
2.6 KiB
C++

#ifndef slic3r_Events_hpp_
#define slic3r_Events_hpp_
#include <array>
#include <cstddef>
#include <wx/debug.h>
#include <wx/event.h>
#include <wx/object.h>
namespace Slic3r {
namespace GUI {
struct SimpleEvent : public wxEvent
{
SimpleEvent(wxEventType type, wxObject* origin = nullptr) : wxEvent(0, type)
{
m_propagationLevel = wxEVENT_PROPAGATE_MAX;
SetEventObject(origin);
}
virtual wxEvent* Clone() const
{
return new SimpleEvent(GetEventType(), GetEventObject());
}
};
struct IntEvent : public wxEvent
{
public:
IntEvent(wxEventType type, int data, wxObject* origin = nullptr) : wxEvent(0, type)
{
m_propagationLevel = wxEVENT_PROPAGATE_MAX;
SetEventObject(origin);
m_data = data;
}
virtual wxEvent* Clone() const
{
return new IntEvent(GetEventType(), m_data, GetEventObject());
}
int get_data() { return m_data; }
private:
int m_data;
};
template<class T, size_t N> struct ArrayEvent : public wxEvent
{
std::array<T, N> data;
ArrayEvent(wxEventType type, std::array<T, N> data, wxObject* origin = nullptr)
: wxEvent(0, type), data(std::move(data))
{
m_propagationLevel = wxEVENT_PROPAGATE_MAX;
SetEventObject(origin);
}
virtual wxEvent* Clone() const
{
return new ArrayEvent<T, N>(GetEventType(), data, GetEventObject());
}
};
template<class T> struct Event : public wxEvent
{
T data;
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)
: wxEvent(0, type), data(std::move(data))
{
m_propagationLevel = wxEVENT_PROPAGATE_MAX;
SetEventObject(origin);
}
virtual wxEvent* Clone() const
{
return new Event<T>(GetEventType(), data, GetEventObject());
}
};
class LoadPrinterViewEvent : public wxCommandEvent
{
public:
LoadPrinterViewEvent(wxEventType commandType = wxEVT_NULL, int winid = 0)
: wxCommandEvent(commandType, winid)
{ }
LoadPrinterViewEvent(const LoadPrinterViewEvent& event)
: wxCommandEvent(event)
{ m_APIkey = event.m_APIkey; }
const wxString& GetAPIkey() const { return m_APIkey; }
void SetAPIkey(const wxString& apikey) { m_APIkey = apikey; }
virtual wxEvent *Clone() const wxOVERRIDE { return new LoadPrinterViewEvent(*this); }
private:
wxString m_APIkey;
};
}
}
#endif // slic3r_Events_hpp_