Gnash  0.8.11dev
gtk_glue.h
Go to the documentation of this file.
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:
43  GtkGlue() : _drawing_area(nullptr), _needs_area(false) { }
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;
49  virtual void setRenderHandlerSize(int /*width*/, int /*height*/) {}
50  virtual void render() = 0;
51  virtual void render(int /*minx*/, int /*miny*/, int /*maxx*/, int /*maxy*/)
52  {
53  render();
54  }
55 
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 
75  virtual void beforeRendering(movie_root*) {};
76 
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:
virtual void configure(GtkWidget *const widget, GdkEventConfigure *const event)=0
virtual void setRenderHandlerSize(int, int)
Definition: gtk_glue.h:49
virtual Renderer * createRenderHandler()=0
GtkWidget * _drawing_area
Definition: gtk_glue.h:77
GtkGlue()
Definition: gtk_glue.h:43
Anonymous namespace for callbacks, local functions, event handlers etc.
Definition: dbus_ext.cpp:40
virtual ~GtkGlue()
Definition: gtk_glue.h:44
Definition: DeviceGlue.h:37
Base class for render handlers.
Definition: Renderer.h:188
Definition: GnashKey.h:164
virtual bool needsDrawingArea()
Definition: gtk_glue.h:77
Definition: gtk_glue.h:40
virtual void prepDrawingArea(GtkWidget *drawing_area)=0
virtual bool init(int argc, char **argv[])=0
virtual void beforeRendering(movie_root *)
Definition: gtk_glue.h:75
virtual void render(int, int, int, int)
Definition: gtk_glue.h:51
Definition: GnashKey.h:155
virtual void render()=0
bool _needs_area
Definition: gtk_glue.h:81
virtual void render(GdkRegion *const region)
Definition: gtk_glue.h:56
This class represents the &#39;Stage&#39; and top-level movie.
Definition: movie_root.h:150