Update with current status
[gnash.git] / gui / qt / Qt4Glue.cpp
blobc3245d6f5f516dc596b12b807d03b00425fb003a
1 // Qt4Glue.cpp: KDE4/Qt4 shared code to connect the various renderers to
2 // the Qt4 gui.
3 //
4 // Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010,
5 // 2011 Free Software Foundation, Inc
6 //
7 // This program is free software; you can redistribute it and/or modify
8 // it under the terms of the GNU General Public License as published by
9 // the Free Software Foundation; either version 3 of the License, or
10 // (at your option) any later version.
11 //
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 General Public License for more details.
17 // You should have received a copy of the GNU General Public License
18 // along with this program; if not, write to the Free Software
19 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
22 #ifdef HAVE_CONFIG_H
23 #include "gnashconfig.h"
24 #endif
26 #include "Qt4Glue.h"
27 #include "Qt4Glue.moc"
28 #include "Qt4Gui.h"
29 #include <QWidget>
30 #include <QPaintEvent>
31 #include <QMouseEvent>
32 #include <QWheelEvent>
34 namespace gnash {
36 /// DrawingWidget implementation
37 DrawingWidget::DrawingWidget(Qt4Gui& gui)
39 #ifdef RENDERER_OPENGL
40 _glWidget(0),
41 #endif
42 _gui(gui)
46 void
47 DrawingWidget::paintEvent(QPaintEvent *event)
49 _gui.renderWidget(event->rect());
52 void
53 DrawingWidget::timerEvent(QTimerEvent*)
55 Gui::advance_movie(&_gui);
58 void
59 DrawingWidget::wheelEvent(QWheelEvent* event)
61 _gui.notifyMouseWheel(event->delta() > 0 ? 1 : -1);
64 void
65 DrawingWidget::mouseMoveEvent(QMouseEvent *event)
67 QPoint position = event->pos();
68 _gui.notifyMouseMove(position.x(), position.y());
71 void
72 DrawingWidget::contextMenuEvent(QContextMenuEvent* event)
74 _gui.popupMenu(event->globalPos());
77 void
78 DrawingWidget::mousePressEvent(QMouseEvent* event)
80 if(Qt::LeftButton & event->button())
81 _gui.notifyMouseClick(true);
84 void
85 DrawingWidget::mouseReleaseEvent(QMouseEvent* /* event */)
87 _gui.notifyMouseClick(false);
90 void
91 DrawingWidget::keyPressEvent(QKeyEvent *event)
93 _gui.handleKeyEvent(event, true);
96 void
97 DrawingWidget::keyReleaseEvent(QKeyEvent *event)
99 _gui.handleKeyEvent(event, false);
102 void
103 DrawingWidget::resizeEvent(QResizeEvent *event)
105 _gui.resize(event->size().width(), event->size().height());
106 update();
109 void
110 DrawingWidget::properties()
112 _gui.showProperties();
115 void
116 DrawingWidget::preferences()
118 _gui.showPreferences();
121 void
122 DrawingWidget::play()
124 _gui.play();
127 void
128 DrawingWidget::pause()
130 _gui.pause();
133 void
134 DrawingWidget::restart()
136 _gui.restart();
139 void
140 DrawingWidget::stop()
142 _gui.stop();
145 void
146 DrawingWidget::refresh()
148 _gui.refreshView();
151 void
152 DrawingWidget::quit()
154 _gui.quit();
157 void
158 DrawingWidget::fullscreen(bool isFull)
160 if (isFull) {
161 _gui.setFullscreen();
163 else {
164 _gui.unsetFullscreen();