New lua versions
[ryzomcore.git] / studio / src / plugins / zone_painter / qnel_widget.h
blob77ecf6da36ff2da4a9be7c8d7890b3db3d1d172d
1 // Object Viewer Qt - MMORPG Framework <http://dev.ryzom.com/projects/nel/>
2 // Copyright (C) 2011 Dzmitry KAMIAHIN (dnk-88) <dnk-88@tut.by>
3 //
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>
7 //
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/>.
21 #ifndef QNEL_WIDGET_H
22 #define QNEL_WIDGET_H
24 // NeL includes
25 #include <nel/misc/types_nl.h>
26 #include <nel/misc/rgba.h>
27 #include <nel/misc/event_emitter.h>
29 // Qt includes
30 #include <QtOpenGL/QGLWidget>
31 #include <QtGui/QWidget>
33 class QAction;
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;
42 #endif // NL_OS_UNIX
44 namespace NL3D
46 class UDriver;
47 class UScene;
50 namespace NLQT
53 /**
54 @class QNLWidget
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
61 Q_OBJECT
63 public:
64 QNLWidget(QWidget *parent);
65 virtual ~QNLWidget();
67 /// Set the update interval renderer
68 void setInterval(int msec);
70 /// Set the background color.
71 void setBackgroundColor(NLMISC::CRGBA backgroundColor);
73 float fps() const
75 return m_fps;
78 inline NLMISC::CRGBA backgroundColor() const
80 return m_backgroundColor;
83 NL3D::UDriver *driver() const
85 return m_driver;
88 virtual QPaintEngine* paintEngine() const
90 return NULL;
92 Q_SIGNALS:
93 void updateData();
94 void updatePreRender();
95 void updatePostRender();
97 private Q_SLOTS:
98 void updateRender();
100 protected:
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);
110 #endif
112 private:
113 void init();
114 void release();
116 QNLWidget(const QNLWidget &);
117 QNLWidget &operator=(const QNLWidget &);
119 NL3D::UDriver *m_driver;
120 NLMISC::CRGBA m_backgroundColor;
122 QTimer *m_mainTimer;
124 bool m_initialized;
125 int m_interval;
126 float m_fps;
128 }; /* class QNLWidget */
130 } /* namespace NLQT */
133 #endif // QNEL_WIDGET_H