Merge branch 'master' into release_0_8_9
[gnash.git] / gui / gtk / gtksup.h
blob621ef4db3d6f6808351d5a78686f1de5a0ad9e02
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
19 #ifndef GNASH_GTKSUP_H
20 #define GNASH_GTKSUP_H
22 #ifdef HAVE_CONFIG_H
23 #include "gnashconfig.h"
24 #endif
26 #include <string>
27 #include <utility>
28 #include <gdk/gdk.h>
29 #include <gtk/gtk.h>
31 #include "gui.h"
32 #include "gtk_glue.h"
34 namespace gnash {
36 class GtkGui : public Gui
38 public:
40 GtkGui(unsigned long xid, float scale, bool loop, RunResources& r);
42 virtual ~GtkGui();
44 /// GUI interface implementation
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);
52 virtual bool run();
54 virtual void quitUI();
56 virtual bool createMenu();
58 virtual bool createMenuAlt(); //an alternative popup menu
60 /// Set up callbacks for key, mouse and other GTK events.
62 /// Must be called after the drawing area has been added to
63 /// a top level window, as it calls setupWindowEvents() to
64 /// add key event callbacks to the top level window.
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);
71 virtual void setFullscreen();
72 virtual void unsetFullscreen();
74 virtual void hideMenu();
76 /// For System.capabilities information.
77 virtual double getPixelAspectRatio() const;
78 virtual std::pair<int, int> screenResolution() const;
79 virtual double getScreenDPI() const;
81 virtual void setClipboard(const std::string& copy);
83 bool watchFD(int fd);
85 /// Grab focus so to receive all key events
87 /// Might become a virtual in the base class
88 ///
89 void grabFocus();
91 /// Create a menu bar for the application, attach to our window.
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);
101 // Display a properties dialogue
102 void showPropertiesDialog();
104 // Display a preferences dialogue
105 void showPreferencesDialog();
107 // Display an About dialogue
108 void showAboutDialog();
110 void expose(const GdkRegion* region);
112 void setInvalidatedRegions(const InvalidatedRanges& ranges);
114 bool want_multiple_regions() { return true; }
116 virtual void setCursor(gnash_cursor_type newcursor);
118 virtual bool showMouse(bool show);
120 virtual void showMenu(bool show);
122 virtual void error(const std::string& msg);
124 bool checkX11Extension(const std::string& ext);
126 virtual bool visible() { return _visible; }
128 void setVisible(bool visible) { _visible = visible; }
130 private:
132 GtkWidget* _window;
133 GtkWidget* _resumeButton;
135 // A window only for rendering the plugin as fullscreen.
136 GtkWidget* _overlay;
138 // The area rendered into by Gnash
139 GtkWidget* _canvas;
140 bool _visible;
142 GtkMenu* _popup_menu;
143 GtkMenu* _popup_menu_alt;
144 GtkWidget* _menubar;
145 GtkWidget* _vbox;
148 /// Add key press events to the toplevel window.
150 /// The plugin fullscreen creates a new top level
151 /// window, so this function must be called every time
152 /// the drawing area is reparented.
153 void setupWindowEvents();
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
160 void stopHook();
161 void playHook();
163 guint _advanceSourceTimer;
165 void startAdvanceTimer();
167 void stopAdvanceTimer();
170 } // namespace gnash
172 #endif