Gnash  0.8.10
kdesup.h
Go to the documentation of this file.
00001 // 
00002 //   Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010,
00003 //   2011 Free Software Foundation, Inc
00004 // 
00005 // This program is free software; you can redistribute it and/or modify
00006 // it under the terms of the GNU General Public License as published by
00007 // the Free Software Foundation; either version 3 of the License, or
00008 // (at your option) any later version.
00009 // 
00010 // This program is distributed in the hope that it will be useful,
00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013 // GNU General Public License for more details.
00014 // 
00015 // You should have received a copy of the GNU General Public License
00016 // along with this program; if not, write to the Free Software
00017 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
00018 
00019 #ifndef GNASH_KDESUP_H
00020 #define GNASH_KDESUP_H
00021 
00022 #ifdef HAVE_CONFIG_H
00023 #include "gnashconfig.h"
00024 #endif
00025 
00026 #include "gui.h"
00027 
00028 #include <qapplication.h>
00029 #include <qpopupmenu.h>
00030 
00031 #ifdef RENDERER_OPENGL
00032 # include <qgl.h>
00033 # include "kde_glue_opengl.h"
00034 # define WIDGETCLASS QGLWidget
00035 # define GLUE KdeOpenGLGlue
00036 #elif defined(RENDERER_CAIRO)
00037 // #include <cairo.h>
00038 // #include "kde_glue_cairo.h"
00039 # error "Cairo not supported yet for KDE!"
00040 #elif defined(RENDERER_AGG)
00041 # include "kde_glue_agg.h"
00042 # define WIDGETCLASS QWidget
00043 # define GLUE KdeAggGlue
00044 #endif
00045 
00046 
00047 namespace gnash
00048 {
00049 
00050 
00051 class KdeGui;
00052 
00053 class qwidget : public WIDGETCLASS
00054 {
00055     Q_OBJECT
00056 public:
00057     qwidget(KdeGui* godfather);
00058     void setInterval(unsigned int interval);
00059 protected:
00060 #if QT_VERSION > 2312
00061     void contextMenuEvent(QContextMenuEvent *event);
00062 #endif
00063     void mousePressEvent(QMouseEvent *event);
00064     void mouseReleaseEvent( QMouseEvent * );
00065     void mouseMoveEvent(QMouseEvent *event);
00066     void keyPressEvent(QKeyEvent *event);
00067     void keyReleaseEvent(QKeyEvent *event);
00068     void timerEvent(QTimerEvent *);
00069     void resizeEvent(QResizeEvent *event);
00070     void paintEvent (QPaintEvent *event);
00071 public slots:
00072     void menuitem_restart_callback();
00073     void menuitem_refresh_callback();
00074     void menuitem_quit_callback();
00075     void menuitem_play_callback();
00076     void menuitem_pause_callback();
00077     void menuitem_stop_callback();
00078 private:
00079     QPopupMenu    _qmenu;
00080     KdeGui*       _godfather;
00081 };
00082 
00083 
00084 class DSOEXPORT KdeGui :  public Gui
00085 {
00086 
00087 public:
00088     KdeGui(unsigned long xid, float scale, bool loop, RunResources& r);
00089     virtual ~KdeGui();
00090     virtual bool init(int argc, char **argv[]);
00091     virtual bool createWindow(const char* windowtitle, int width, int height,
00092                               int xPosition = 0, int yPosition = 0);
00093     virtual bool run();
00094     virtual bool createMenu();
00095     virtual bool setupEvents();
00096     virtual void renderBuffer();
00097     virtual void setInterval(unsigned int interval);
00098     virtual void setTimeout(unsigned int timeout);
00099     virtual void handleKeyEvent(QKeyEvent *event, bool down);
00100     virtual void setCursor(gnash_cursor_type newcursor);
00101     void setInvalidatedRegions(const InvalidatedRanges& ranges);
00102     void resize(int width, int height);
00103     void quitUI();
00104  private:
00105     std::auto_ptr<QApplication>  _qapp;
00106     std::auto_ptr<qwidget>       _qwidget;
00107     GLUE                         _glue;    
00108 
00109     gnash::key::code qtToGnashKey(QKeyEvent *event);
00110     int qtToGnashModifier(Qt::ButtonState state);
00111 };
00112 
00113 // end of namespace gnash 
00114 }
00115 
00116 // end of __KDESUP_H__
00117 #endif