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_GTK_GLUE_H
20 #define GNASH_GTK_GLUE_H
21 
22 #include <cassert>
23 
24 #include <gtk/gtk.h>
25 #if !defined(_WIN32) && !defined(__APPLE__)
26 #include <gdk/gdkx.h>
27 #else
28 #include <gdk/gdk.h>
29 #endif
30 
31 #include "DeviceGlue.h"
32 
33 namespace gnash {
34     class Renderer;
35     class movie_root;
36 }
37 
38 namespace gnash {
39 
40 class GtkGlue : public DeviceGlue
41 {
42   public:
GtkGlue()43     GtkGlue() : _drawing_area(nullptr), _needs_area(false) { }
~GtkGlue()44     virtual ~GtkGlue() { }
45     virtual bool init(int argc, char **argv[]) = 0;
46 
47     virtual void prepDrawingArea(GtkWidget *drawing_area) = 0;
48     virtual Renderer* createRenderHandler() = 0;
setRenderHandlerSize(int,int)49     virtual void setRenderHandlerSize(int /*width*/, int /*height*/) {}
50     virtual void render() = 0;
render(int,int,int,int)51     virtual void render(int /*minx*/, int /*miny*/, int /*maxx*/, int /*maxy*/)
52     {
53         render();
54     }
55 
render(GdkRegion * const region)56     virtual void render(GdkRegion * const region)
57     {
58         GdkRectangle* rects;
59         gint num_rects;
60 
61         gdk_region_get_rectangles(region, &rects, &num_rects);
62         assert(num_rects);
63 
64         for (gint i = 0; i < num_rects; ++i) {
65             GdkRectangle const & r = rects[i];
66             render(r.x, r.y, r.x + r.width, r.y + r.height);
67         }
68 
69         g_free(rects);
70     }
71 
72     virtual void configure(GtkWidget *const widget,
73             GdkEventConfigure *const event) = 0;
74 
beforeRendering(movie_root *)75     virtual void beforeRendering(movie_root*) {};
76 
needsDrawingArea()77     virtual bool needsDrawingArea() { return _needs_area; };
78 
79   protected:
80     GtkWidget *_drawing_area;
81     bool      _needs_area;
82 };
83 
84 } // namespace gnash
85 
86 // end of GNASH_GTK_GLUE_H
87 #endif
88 
89 // Local Variables:
90 // mode: C++
91 // indent-tabs-mode: nil
92 // End:
93