1 //
2 //   Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010,
3 //   2011 Free Software Foundation, Inc
4 //
5 // This program is free software; you can redistribute it and/or modify
6 // it under the terms of the GNU General Public License as published by
7 // the Free Software Foundation; either version 3 of the License, or
8 // (at your option) any later version.
9 //
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 // GNU General Public License for more details.
14 //
15 // You should have received a copy of the GNU General Public License
16 // along with this program; if not, write to the Free Software
17 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
18 
19 #ifndef GNASH_KDESUP_H
20 #define GNASH_KDESUP_H
21 
22 #ifdef HAVE_CONFIG_H
23 #include "gnashconfig.h"
24 #endif
25 
26 #include "gui.h"
27 
28 #include <qapplication.h>
29 #include <qpopupmenu.h>
30 
31 #ifdef RENDERER_OPENGL
32 # include <qgl.h>
33 # include "kde_glue_opengl.h"
34 # define WIDGETCLASS QGLWidget
35 # define GLUE KdeOpenGLGlue
36 #elif defined(RENDERER_CAIRO)
37 // #include <cairo.h>
38 // #include "kde_glue_cairo.h"
39 # error "Cairo not supported yet for KDE!"
40 #elif defined(RENDERER_AGG)
41 # include "kde_glue_agg.h"
42 # define WIDGETCLASS QWidget
43 # define GLUE KdeAggGlue
44 #endif
45 
46 
47 namespace gnash
48 {
49 
50 
51 class KdeGui;
52 
53 class qwidget : public WIDGETCLASS
54 {
55     Q_OBJECT
56 public:
57     qwidget(KdeGui* godfather);
58     void setInterval(unsigned int interval);
59 protected:
60 #if QT_VERSION > 2312
61     void contextMenuEvent(QContextMenuEvent *event);
62 #endif
63     void mousePressEvent(QMouseEvent *event);
64     void mouseReleaseEvent( QMouseEvent * );
65     void mouseMoveEvent(QMouseEvent *event);
66     void keyPressEvent(QKeyEvent *event);
67     void keyReleaseEvent(QKeyEvent *event);
68     void timerEvent(QTimerEvent *);
69     void resizeEvent(QResizeEvent *event);
70     void paintEvent (QPaintEvent *event);
71 public slots:
72     void menuitem_restart_callback();
73     void menuitem_refresh_callback();
74     void menuitem_quit_callback();
75     void menuitem_play_callback();
76     void menuitem_pause_callback();
77     void menuitem_stop_callback();
78 private:
79     QPopupMenu    _qmenu;
80     KdeGui*       _godfather;
81 };
82 
83 
84 class DSOEXPORT KdeGui :  public Gui
85 {
86 
87 public:
88     KdeGui(unsigned long xid, float scale, bool loop, RunResources& r);
89     virtual ~KdeGui();
90     virtual bool init(int argc, char **argv[]);
91     virtual bool createWindow(const char* windowtitle, int width, int height,
92                               int xPosition = 0, int yPosition = 0);
93     virtual bool run();
94     virtual bool createMenu();
95     virtual bool setupEvents();
96     virtual void renderBuffer();
97     virtual void setInterval(unsigned int interval);
98     virtual void setTimeout(unsigned int timeout);
99     virtual void handleKeyEvent(QKeyEvent *event, bool down);
100     virtual void setCursor(gnash_cursor_type newcursor);
101     void setInvalidatedRegions(const InvalidatedRanges& ranges);
102     void resize(int width, int height);
103     void quitUI();
104  private:
105     std::unique_ptr<QApplication>  _qapp;
106     std::unique_ptr<qwidget>       _qwidget;
107     GLUE                         _glue;
108 
109     gnash::key::code qtToGnashKey(QKeyEvent *event);
110     int qtToGnashModifier(Qt::ButtonState state);
111 };
112 
113 // end of namespace gnash
114 }
115 
116 // end of __KDESUP_H__
117 #endif
118