Gnash  0.8.10
gtk_glue.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_GTK_GLUE_H
00020 #define GNASH_GTK_GLUE_H
00021 
00022 #include <cassert>
00023 
00024 #include <gtk/gtk.h>
00025 #if !defined(_WIN32) && !defined(__APPLE__)
00026 #include <gdk/gdkx.h>
00027 #else
00028 #include <gdk/gdk.h>
00029 #endif
00030 
00031 #include "DeviceGlue.h"
00032 
00033 namespace gnash {
00034     class Renderer;
00035     class movie_root;
00036 }
00037 
00038 namespace gnash {
00039 
00040 class GtkGlue : public DeviceGlue
00041 {
00042   public:
00043     GtkGlue() : _drawing_area(0), _needs_area(false) { }
00044     virtual ~GtkGlue() { }
00045     virtual bool init(int argc, char **argv[]) = 0;
00046 
00047     virtual void prepDrawingArea(GtkWidget *drawing_area) = 0;
00048     virtual Renderer* createRenderHandler() = 0;
00049     virtual void setRenderHandlerSize(int /*width*/, int /*height*/) {}
00050     virtual void render() = 0;
00051     virtual void render(int /*minx*/, int /*miny*/, int /*maxx*/, int /*maxy*/)
00052     {
00053         render();       
00054     }
00055 
00056     virtual void render(GdkRegion * const region)
00057     {
00058         GdkRectangle* rects;
00059         gint num_rects;
00060 
00061         gdk_region_get_rectangles(region, &rects, &num_rects);
00062         assert(num_rects);
00063 
00064         for (gint i = 0; i < num_rects; ++i) {
00065             GdkRectangle const & r = rects[i];
00066             render(r.x, r.y, r.x + r.width, r.y + r.height);
00067         }
00068 
00069         g_free(rects);
00070     }
00071 
00072     virtual void configure(GtkWidget *const widget,
00073             GdkEventConfigure *const event) = 0;
00074     
00075     virtual void beforeRendering(movie_root*) {};
00076 
00077     virtual bool needsDrawingArea() { return _needs_area; };
00078 
00079   protected:
00080     GtkWidget *_drawing_area;
00081     bool      _needs_area;  
00082 };
00083 
00084 } // namespace gnash
00085 
00086 // end of GNASH_GTK_GLUE_H
00087 #endif
00088 
00089 // Local Variables:
00090 // mode: C++
00091 // indent-tabs-mode: nil
00092 // End: