1 // Object Viewer Qt - MMORPG Framework <http://dev.ryzom.com/projects/nel/>
2 // Copyright (C) 2011 Dzmitry KAMIAHIN (dnk-88) <dnk-88@tut.by>
4 // This source file has been modified by the following contributors:
5 // Copyright (C) 2010 Winch Gate Property Limited
6 // Copyright (C) 2011 Matt RAYKOWSKI (sfb) <matt.raykowski@gmail.com>
8 // This program is free software: you can redistribute it and/or modify
9 // it under the terms of the GNU Affero General Public License as
10 // published by the Free Software Foundation, either version 3 of the
11 // License, or (at your option) any later version.
13 // This program is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 // GNU Affero General Public License for more details.
18 // You should have received a copy of the GNU Affero General Public License
19 // along with this program. If not, see <http://www.gnu.org/licenses/>.
25 #include <nel/misc/types_nl.h>
26 #include <nel/misc/rgba.h>
27 #include <nel/misc/event_emitter.h>
30 #include <QtOpenGL/QGLWidget>
31 #include <QtGui/QWidget>
35 /* TODO every platform should use QWidget */
36 #if defined(NL_OS_WINDOWS)
37 typedef QWidget QNeLWidget
;
38 #elif defined(NL_OS_MAC)
39 typedef QWidget QNeLWidget
;
40 #elif defined(NL_OS_UNIX)
41 typedef QGLWidget QNeLWidget
;
55 @brief Responsible for interaction between Qt and NeL.
56 @details Automatically begins to update the render if the widget is visible
57 or suspends the updating of render if the widget is hidden.
59 class QNLWidget
: public QNeLWidget
64 QNLWidget(QWidget
*parent
);
67 /// Set the update interval renderer
68 void setInterval(int msec
);
70 /// Set the background color.
71 void setBackgroundColor(NLMISC::CRGBA backgroundColor
);
78 inline NLMISC::CRGBA
backgroundColor() const
80 return m_backgroundColor
;
83 NL3D::UDriver
*driver() const
88 virtual QPaintEngine
* paintEngine() const
94 void updatePreRender();
95 void updatePostRender();
101 virtual void showEvent(QShowEvent
*showEvent
);
102 virtual void hideEvent(QHideEvent
*hideEvent
);
104 #if defined(NL_OS_WINDOWS)
105 virtual bool winEvent(MSG
*message
, long *result
);
106 #elif defined(NL_OS_MAC)
107 virtual bool macEvent(EventHandlerCallRef caller
, EventRef event
);
108 #elif defined(NL_OS_UNIX)
109 virtual bool x11Event(XEvent
*event
);
116 QNLWidget(const QNLWidget
&);
117 QNLWidget
&operator=(const QNLWidget
&);
119 NL3D::UDriver
*m_driver
;
120 NLMISC::CRGBA m_backgroundColor
;
128 }; /* class QNLWidget */
130 } /* namespace NLQT */
133 #endif // QNEL_WIDGET_H