Gnash  0.8.11dev
gtksup.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_GTKSUP_H
20 #define GNASH_GTKSUP_H
21 
22 #ifdef HAVE_CONFIG_H
23 #include "gnashconfig.h"
24 #endif
25 
26 #include <string>
27 #include <utility>
28 #include <gdk/gdk.h>
29 #include <gtk/gtk.h>
30 
31 #include "gui.h"
32 #include "gtk_glue.h"
33 
34 namespace gnash {
35 
36 class GtkGui : public Gui
37 {
38 public:
39 
40  GtkGui(unsigned long xid, float scale, bool loop, RunResources& r);
41 
42  virtual ~GtkGui();
43 
45 
46  virtual bool init(int argc, char **argv[]);
47  virtual bool createWindow(int width, int height);
48  virtual bool createWindow(const char *title, int width, int height,
49  int xPosition = 0, int yPosition = 0);
50  virtual void resizeWindow(int width, int height);
51 
52  virtual bool run();
53 
54  virtual void quitUI();
55 
56  virtual bool createMenu();
57 
58  virtual bool createMenuAlt(); //an alternative popup menu
59 
61  //
65  virtual bool setupEvents();
66  virtual void beforeRendering();
67  virtual void renderBuffer();
68  virtual void setInterval(unsigned int interval);
69  virtual void setTimeout(unsigned int timeout);
70 
71  virtual void setFullscreen();
72  virtual void unsetFullscreen();
73 
74  virtual void hideMenu();
75 
76  virtual bool yesno(const std::string& question);
77 
79  virtual double getPixelAspectRatio() const;
80  virtual std::pair<int, int> screenResolution() const;
81  virtual double getScreenDPI() const;
82 
83  virtual void setClipboard(const std::string& copy);
84 
86  //
89  void grabFocus();
90 
92  // This should only appear in the standalone player.
93  bool createMenuBar();
94  void createFileMenu(GtkWidget *obj);
95  void createEditMenu(GtkWidget *obj);
96  void createViewMenu(GtkWidget *obj);
97  void createQualityMenu(GtkWidget *obj);
98  void createHelpMenu(GtkWidget *obj);
99  void createControlMenu(GtkWidget *obj);
100 
101  // Display a properties dialogue
102  void showPropertiesDialog();
103 
104  // Display a preferences dialogue
105  void showPreferencesDialog();
106 
107  // Display an About dialogue
108  void showAboutDialog();
109 
110  void expose(const GdkRegion* region);
111 
112  void setInvalidatedRegions(const InvalidatedRanges& ranges);
113 
114  bool want_multiple_regions() { return true; }
115 
116  virtual void setCursor(gnash_cursor_type newcursor);
117 
118  virtual bool showMouse(bool show);
119 
120  virtual void showMenu(bool show);
121 
122  virtual void error(const std::string& msg);
123 
124  bool checkX11Extension(const std::string& ext);
125 
126  virtual bool visible() { return _visible; }
127 
128  void setVisible(bool visible) { _visible = visible; }
129 
130 private:
131 
132  GtkWidget* _window;
133  GtkWidget* _resumeButton;
134 
135  // A window only for rendering the plugin as fullscreen.
136  GtkWidget* _overlay;
137 
138  // The area rendered into by Gnash
139  GtkWidget* _canvas;
140  bool _visible;
141 
142  GtkMenu* _popup_menu;
143  GtkMenu* _popup_menu_alt;
144  GtkWidget* _menubar;
145  GtkWidget* _vbox;
146 
147 
149  //
153  void setupWindowEvents();
154 
155 #ifdef USE_SWFTREE
156  // Create a tree model for displaying movie info
157  GtkTreeModel* makeTreeModel(std::auto_ptr<movie_root::InfoTree> tree);
158 #endif
159 
160  void stopHook();
161  void playHook();
162 
163  guint _advanceSourceTimer;
164 
165  void startAdvanceTimer();
166 
167  void stopAdvanceTimer();
168 };
169 
170 } // namespace gnash
171 
172 #endif
173 
174 // Local Variables:
175 // mode: C++
176 // indent-tabs-mode: nil
177 // End: