diff --git a/code/nel/tools/3d/object_viewer_widget/src/object_viewer_widget.cpp b/code/nel/tools/3d/object_viewer_widget/src/object_viewer_widget.cpp index 83dec01e1..dadb2435d 100644 --- a/code/nel/tools/3d/object_viewer_widget/src/object_viewer_widget.cpp +++ b/code/nel/tools/3d/object_viewer_widget/src/object_viewer_widget.cpp @@ -51,6 +51,14 @@ along with this program. If not, see . Q_EXPORT_PLUGIN2(object_viewer_widget_qt, NLQT::CObjectViewerWidget) #endif +#if defined(NL_OS_WINDOWS) + typedef bool (*winProc)(NL3D::IDriver *driver, HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam); +#elif defined(NL_OS_MAC) + typedef bool (*cocoaProc)(NL3D::IDriver*, const void* e); +#else + typedef bool (*x11Proc)(NL3D::IDriver *drv, XEvent *e); +#endif + using namespace NLMISC; using namespace NL3D; using namespace std; @@ -735,11 +743,38 @@ namespace NLQT _Scene->animate ( fdelta); } +#ifdef USE_QT5 + + bool CObjectViewerWidget::nativeEvent(const QByteArray &eventType, void *message, long *result) + { + if (getDriver() && getDriver()->isActive()) + { + NL3D::IDriver *driver = dynamic_cast(getDriver())->getDriver(); + if (driver) + { + // see what to do with result +#if defined(NL_OS_WINDOWS) + MSG *msg = (MSG*)message; + winProc proc = (winProc)driver->getWindowProc(); + return proc(driver, msg->hwnd, msg->message, msg->wParam, msg->lParam); +#elif defined(NL_OS_MAC) + cocoaProc proc = (cocoaProc)driver->getWindowProc(); + return proc(driver, message); +#else + x11Proc proc = (x11Proc)driver->getWindowProc(); + return proc(driver, message); +#endif + } + } + + return false; + } + +#else + #if defined(NL_OS_WINDOWS) - typedef bool (*winProc)(NL3D::IDriver *driver, HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam); - - bool CObjectViewerWidget::winEvent(MSG * message, long * result) + bool CObjectViewerWidget::winEvent(MSG *message, long *result) { if (getDriver() && getDriver()->isActive()) { @@ -756,8 +791,6 @@ namespace NLQT #elif defined(NL_OS_MAC) - typedef bool (*cocoaProc)(NL3D::IDriver*, const void* e); - bool CObjectViewerWidget::macEvent(EventHandlerCallRef caller, EventRef event) { if(caller) @@ -778,8 +811,6 @@ namespace NLQT #elif defined(NL_OS_UNIX) - typedef bool (*x11Proc)(NL3D::IDriver *drv, XEvent *e); - bool CObjectViewerWidget::x11Event(XEvent *event) { if (getDriver() && getDriver()->isActive()) @@ -796,4 +827,6 @@ namespace NLQT } #endif +#endif + } /* namespace NLQT */ diff --git a/code/nel/tools/3d/object_viewer_widget/src/object_viewer_widget.h b/code/nel/tools/3d/object_viewer_widget/src/object_viewer_widget.h index fb6656679..cb40abfd9 100644 --- a/code/nel/tools/3d/object_viewer_widget/src/object_viewer_widget.h +++ b/code/nel/tools/3d/object_viewer_widget/src/object_viewer_widget.h @@ -166,12 +166,18 @@ namespace NLQT virtual QString name() const {return ("ObjectViewerWidget");} protected: +#ifdef USE_QT5 + virtual bool nativeEvent(const QByteArray &eventType, void *message, long *result); +#else + #if defined(NL_OS_WINDOWS) virtual bool winEvent(MSG * message, long * result); #elif defined(NL_OS_MAC) virtual bool macEvent(EventHandlerCallRef caller, EventRef event); #elif defined(NL_OS_UNIX) virtual bool x11Event(XEvent *event); +#endif + #endif private Q_SLOTS: diff --git a/code/nel/tools/3d/object_viewer_widget/src/stdpch.h b/code/nel/tools/3d/object_viewer_widget/src/stdpch.h index 34aaaa7d0..2c5b38f92 100644 --- a/code/nel/tools/3d/object_viewer_widget/src/stdpch.h +++ b/code/nel/tools/3d/object_viewer_widget/src/stdpch.h @@ -56,4 +56,12 @@ along with this program. If not, see . #include #include +#if defined(NL_OS_WINDOWS) +#define NOMINMAX +#include +#elif defined(NL_OS_MAC) +#else +#include +#endif + #endif