Linux multi-monitor fullscreen support
[ryzomcore.git] / studio / src / plugins / example / qnel_widget.h
blob795a0b7a757f420428a8b35302a1d988e212b990
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 //
7 // This program is free software: you can redistribute it and/or modify
8 // it under the terms of the GNU Affero General Public License as
9 // published by the Free Software Foundation, either version 3 of the
10 // License, or (at your option) any later version.
12 // This program is distributed in the hope that it will be useful,
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 // GNU Affero General Public License for more details.
17 // You should have received a copy of the GNU Affero General Public License
18 // along with this program. If not, see <http://www.gnu.org/licenses/>.
20 #ifndef QNEL_WIDGET_H
21 #define QNEL_WIDGET_H
23 // NeL includes
24 #include <nel/misc/types_nl.h>
25 #include <nel/misc/rgba.h>
26 #include <nel/misc/event_emitter.h>
28 // Qt includes
29 #include <QtOpenGL/QGLWidget>
30 #include <QtGui/QWidget>
32 class QAction;
34 /* TODO every platform should use QWidget */
35 #if defined(NL_OS_WINDOWS)
36 typedef QWidget QNeLWidget;
37 #elif defined(NL_OS_MAC)
38 typedef QWidget QNeLWidget;
39 #elif defined(NL_OS_UNIX)
40 typedef QGLWidget QNeLWidget;
41 #endif // NL_OS_UNIX
43 namespace NL3D
45 class UDriver;
46 class UScene;
49 namespace NLQT
52 /**
53 @class QNLWidget
54 @brief Responsible for interaction between Qt and NeL.
55 @details Automatically begins to update the render if the widget is visible
56 or suspends the updating of render if the widget is hidden.
58 class QNLWidget : public QNeLWidget
60 Q_OBJECT
62 public:
63 QNLWidget(QWidget *parent);
64 virtual ~QNLWidget();
66 /// Set the update interval renderer
67 void setInterval(int msec);
69 /// Set the background color.
70 void setBackgroundColor(NLMISC::CRGBA backgroundColor);
72 float fps() const
74 return m_fps;
77 inline NLMISC::CRGBA backgroundColor() const
79 return m_backgroundColor;
82 NL3D::UDriver *driver() const
84 return m_driver;
87 virtual QPaintEngine *paintEngine() const
89 return NULL;
91 Q_SIGNALS:
92 void updateData();
93 void updatePreRender();
94 void updatePostRender();
96 private Q_SLOTS:
97 void updateRender();
99 protected:
100 virtual void showEvent(QShowEvent *showEvent);
101 virtual void hideEvent(QHideEvent *hideEvent);
103 #if defined(NL_OS_WINDOWS)
104 virtual bool winEvent(MSG *message, long *result);
105 #elif defined(NL_OS_MAC)
106 virtual bool macEvent(EventHandlerCallRef caller, EventRef event);
107 #elif defined(NL_OS_UNIX)
108 virtual bool x11Event(XEvent *event);
109 #endif
111 private:
112 void init();
113 void release();
115 QNLWidget(const QNLWidget &);
116 QNLWidget &operator=(const QNLWidget &);
118 NL3D::UDriver *m_driver;
119 NLMISC::CRGBA m_backgroundColor;
121 QTimer *m_mainTimer;
123 bool m_initialized;
124 int m_interval;
125 float m_fps;
127 }; /* class QNLWidget */
129 } /* namespace NLQT */
132 #endif // QNEL_WIDGET_H