From 165762c94cb7200ce048816babdf57743ca09111 Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Sat, 21 Jul 2012 18:55:43 +0200 Subject: [PATCH] CHANGED: #1471 added the winEvent, macEvent, x11Event handlers from Dnk's Nel widget to my own, and now the GUI widget resizes the rendered image as the widget is resized. --HG-- branch : gsoc2012-gui-editor --- .../src/plugins/gui_editor/nel3d_widget.cpp | 68 +++++++++++++++++++ .../src/plugins/gui_editor/nel3d_widget.h | 11 +++ 2 files changed, 79 insertions(+) diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/nel3d_widget.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/nel3d_widget.cpp index 089158913..8b39fb98b 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/nel3d_widget.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/nel3d_widget.cpp @@ -18,9 +18,14 @@ #include "nel3d_widget.h" #include "nel/3d/u_driver.h" #include "nel/3d/text_context.h" +#include "nel/3d/driver_user.h" #include "nel/misc/rgba.h" #include "nel/misc/path.h" +#ifdef NL_OS_WINDOWS +#include +#endif + namespace GUIEditor { @@ -94,6 +99,69 @@ namespace GUIEditor driver->clearBuffers( NLMISC::CRGBA::Black ); driver->swapBuffers(); } + + +#if defined ( NL_OS_WINDOWS ) + + typedef bool ( *winProc )( NL3D::IDriver *driver, HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam ); + + bool Nel3DWidget::winEvent( MSG *message, long *result ) + { + if( driver != NULL ) + { + NL3D::IDriver *iDriver = dynamic_cast< NL3D::CDriverUser* >( driver )->getDriver(); + if( iDriver != NULL ) + { + winProc proc = (winProc)iDriver->getWindowProc(); + return proc( iDriver, message->hwnd, message->message, message->wParam, message->lParam ); + } + } + + return false; + } + +#elif defined( NL_OS_MAC ) + + typedef bool ( *cocoaProc )( NL3D::IDriver *, const void *e ); + + bool Nel3DWidget::macEvent( EventHandlerCallRef caller, EventRef event ) + { + if( caller ) + nlerror( "You are using QtCarbon! Only QtCocoa supported, please upgrade Qt" ); + + if( driver != NULL ) + { + NL3D::IDriver *iDriver = dynamic_cast< NL3D::CDriverUser* >( driver )->getDriver(); + if( iDriver != NULL ) + { + cocoaProc proc = ( cocoaProc )iDriver->getWindowProc(); + return proc( iDriver, event ); + } + } + + return false; + } + +#elif defined( NL_OS_UNIX ) + + typedef bool ( *x11Proc )( NL3D::IDriver *drv, XEvent *e ); + + bool Nel3DWidget::x11Event( XEvent *event ) + { + if( driver != NULL ) + { + NL3D::IDriver *iDriver = dynamic_cast< NL3D::CDriverUser* >( driver )->getDriver(); + if( driver != NULL ) + { + x11Proc proc = ( x11Proc )iDriver->getWindowProc(); + return proc( iDriver, event ); + } + } + + return false; + } +#endif + } diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/nel3d_widget.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/nel3d_widget.h index 7779ed389..2b1edc7e4 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/nel3d_widget.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/nel3d_widget.h @@ -19,6 +19,7 @@ #define NEL3D_WIDGET_H #include +#include "nel/misc/types_nl.h" #include namespace NL3D @@ -52,6 +53,16 @@ namespace GUIEditor public Q_SLOTS: void clear(); + protected: + +#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 + private: NL3D::UDriver *driver; NL3D::UTextContext *textContext;