gtksup.h

Go to the documentation of this file.
00001 // 
00002 //   Copyright (C) 2005, 2006 Free Software Foundation, Inc.
00003 // 
00004 // This program is free software; you can redistribute it and/or modify
00005 // it under the terms of the GNU General Public License as published by
00006 // the Free Software Foundation; either version 2 of the License, or
00007 // (at your option) any later version.
00008 // 
00009 // This program is distributed in the hope that it will be useful,
00010 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00011 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012 // GNU General Public License for more details.
00013 // You should have received a copy of the GNU General Public License
00014 // along with this program; if not, write to the Free Software
00015 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
00016 
00017 // 
00018 //
00019 
00020 #ifndef __GTKSUP_H__
00021 #define __GTKSUP_H__
00022 
00023 #ifdef HAVE_CONFIG_H
00024 #include "config.h"
00025 #endif
00026 
00027 #include "gnash.h"
00028 #include "tu_config.h"
00029 
00030 #include <gdk/gdkx.h>
00031 #include <gtk/gtk.h>
00032 
00033 #ifdef RENDERER_OPENGL
00034 #include <gtk/gtkgl.h>
00035 #include "gtk_glue_gtkglext.h"
00036 #elif defined(RENDERER_CAIRO)
00037 #include <cairo.h>
00038 #include "gtk_glue_cairo.h"
00039 #elif defined(RENDERER_AGG)
00040 #include "gtk_glue_agg.h"
00041 #endif
00042 
00043 #include <gtk/gtk.h>
00044 
00045 #include "gui.h"
00046 
00047 
00048 namespace gnash
00049 {
00050 
00051 //typedef void (*callback_t)(int x);
00052 
00053 class DSOEXPORT GtkGui : public Gui
00054 {
00055  public:
00056     GtkGui(unsigned long xid, float scale, bool loop, unsigned int depth);
00057     virtual ~GtkGui();
00058     virtual bool init(int argc, char **argv[]);
00059     virtual bool createWindow(int width, int height);
00060     virtual bool createWindow(const char *title, int width, int height);
00061     virtual bool run();    
00062     virtual bool createMenu();
00063     virtual bool setupEvents();
00064     virtual void renderBuffer();
00065     virtual void setInterval(unsigned int interval);
00066     virtual void setTimeout(unsigned int timeout);
00067 
00068     // Menu Item callbacks
00069 
00070     static void menuitem_sound_callback(GtkMenuItem *menuitem,
00071                                    gpointer instance);
00072     static void menuitem_restart_callback(GtkMenuItem *menuitem,
00073                                    gpointer instance);
00074     static void menuitem_quit_callback(GtkMenuItem *menuitem,
00075                                        gpointer instance);
00076     static void menuitem_play_callback(GtkMenuItem *menuitem,
00077                                        gpointer instance);
00078     static void menuitem_pause_callback(GtkMenuItem *menuitem,
00079                                         gpointer instance);
00080     static void menuitem_stop_callback(GtkMenuItem *menuitem,
00081                                        gpointer instance);
00082     static void menuitem_step_forward_callback(GtkMenuItem *menuitem,
00083                                         gpointer instance);
00084     static void menuitem_step_backward_callback(GtkMenuItem *menuitem,
00085                                          gpointer instance);
00086     static void menuitem_jump_forward_callback(GtkMenuItem *menuitem,
00087                                         gpointer instance);
00088     static void menuitem_jump_backward_callback(GtkMenuItem *menuitem,
00089                                          gpointer instance);
00090 
00091     // GTK Event handlers
00092     static gboolean unrealize_event(GtkWidget *widget, GdkEvent *event,
00093                                     gpointer data);
00094     static gboolean realize_event(GtkWidget *widget, GdkEvent *event,
00095                                   gpointer data);
00096     static gboolean delete_event(GtkWidget *widget, GdkEvent *event,
00097                                  gpointer data);
00098     static gboolean expose_event(GtkWidget *widget, GdkEventExpose *event,
00099                                  gpointer data);
00100     static gboolean configure_event(GtkWidget *widget, GdkEventConfigure *event,
00101                                     gpointer data);
00102     static gboolean key_press_event(GtkWidget *widget, GdkEventKey *event,
00103                                     gpointer data);
00104     static gboolean key_release_event(GtkWidget *widget, GdkEventKey *event,
00105                                     gpointer data);
00106     static gboolean button_press_event(GtkWidget *widget, GdkEventButton *event,
00107                                        gpointer data);
00108     static gboolean button_release_event(GtkWidget *widget, GdkEventButton *event,
00109                                          gpointer data);
00110     static gboolean motion_notify_event(GtkWidget *widget, GdkEventMotion *event,
00111                                         gpointer data);
00112     static gint popup_handler(GtkWidget *widget, GdkEvent *event);    
00113 
00114     void add_pixmap_directory(const gchar *directory);
00115 
00116     gchar* find_pixmap_file(const gchar *filename);
00117 
00118     GdkPixbuf* create_pixbuf(const gchar *filename);
00119     
00120     void set_invalidated_region(const rect& bounds);
00121 
00122     virtual void setCursor(gnash_cursor_type newcursor);
00123     
00124  private:
00125     GtkWidget   *_window;
00126     GdkPixbuf   *_window_icon_pixbuf;
00127     GtkWidget   *_drawing_area;    
00128     GtkMenu     *_popup_menu;
00129     int                                 m_draw_minx;
00130     int                                 m_draw_miny;
00131     int                                 m_draw_maxx;
00132     int                                 m_draw_maxy;
00133 
00134         int valid_coord(int coord, int max);
00135 #ifdef RENDERER_CAIRO
00136     cairo_t     *_cairo_handle;
00137     GtkCairoGlue glue;
00138 #elif defined(RENDERER_OPENGL)
00139     GdkGLConfig *_glconfig;
00140     GtkGlExtGlue glue;
00141 #elif defined(RENDERER_AGG)
00142     GtkAggGlue  glue;
00143 #endif
00144     static gnash::key::code gdk_to_gnash_key(guint key);
00145 };
00146 
00147 
00148 // end of namespace gnash 
00149 }
00150 
00151 // end of __GTKSUP_H__
00152 #endif

Generated on Thu Nov 23 22:31:31 2006 for Gnash by  doxygen 1.4.6