Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes

gnash::Gui Class Reference

Parent class from which all GUI implementations will depend. More...

#include <gui.h>

Inheritance diagram for gnash::Gui:
Inheritance graph
[legend]
Collaboration diagram for gnash::Gui:
Collaboration graph
[legend]

List of all members.

Public Types

typedef std::map< std::string,
std::string > 
VariableMap

Public Member Functions

virtual ~Gui ()
virtual bool init (int argc, char **argv[])=0
 Initialise the gui and the associated renderer.
virtual void setInterval (unsigned int interval)
 Set main loop delay in milliseconds.
void setFDCallback (int fd, boost::function< void()> callback)
 Instructs the Gui to monitor a file descriptor.
void callCallback (int fd)
 Calls the callback function registered for a file descriptor.
VirtualClockgetClock ()
 Return the clock provided by this Gui.
virtual void setTimeout (unsigned int timeout)=0
 Set the time in milliseconds after which the programme should exit.
void requestScreenShots (const ScreenShotter::FrameList &l, bool last, const std::string &filename)
 Request a list of screenshots.
virtual bool createWindow (const char *title, int width, int height, int xPosition=0, int yPosition=0)=0
 Create and display our window.
virtual void resizeWindow (int width, int height)
virtual bool run ()=0
 Start main rendering loop.
void quit ()
 Always called on exit.
virtual void renderBuffer ()=0
virtual void setInvalidatedRegion (const SWFRect &bounds)
 Gives the GUI a *hint* which region of the stage should be redrawn.
virtual void setInvalidatedRegions (const InvalidatedRanges &ranges)
virtual void beforeRendering ()
virtual bool want_multiple_regions ()
virtual bool want_redraw ()
 Asks the GUI handler if the next frame should be redrawn completely.
virtual void setCursor (gnash_cursor_type newcursor)
 Sets the current mouse cursor for the Gui window.
virtual double getPixelAspectRatio ()
virtual int getScreenResX ()
virtual int getScreenResY ()
virtual double getScreenDPI ()
virtual std::string getScreenColor ()
bool loops () const
bool isFullscreen () const
void notifyMouseMove (int x, int y)
 Mouse notification callback to be called when the mouse is moved.
void notifyMouseClick (bool mouse_pressed)
 Mouse notification callback to be called when the mouse is clicked.
void notifyMouseWheel (int delta)
 Send a mouse wheel event to the stage.
void notify_key_event (gnash::key::code k, int modifier, bool pressed)
 Key event notification to be called when a key is pressed or depressed.
void resize_view (int width, int height)
 Resize the client area view and the window accordingly.
void updateStageMatrix ()
bool advanceMovie ()
 Advances the movie to the next frame. This is to take place after the interval specified in the call to setInterval().
void refreshView ()
virtual void setFullscreen ()
virtual void unsetFullscreen ()
virtual void hideMenu ()
virtual bool showMouse (bool show)
 Sets whether the gui should show the system mouse pointer.
virtual void showMenu (bool show)
 Sets whether the menus should be shown (for fscommand).
virtual void allowScale (bool allow)
 Sets whether scaling should be allowed (for fscommand).
void toggleFullscreen ()
void stop ()
 Put the application in "stop" mode.
void play ()
 Put the application in "play" mode.
void pause ()
 Toggle between "stop" and "play" mode.
void start ()
 Start the movie.
bool isStopped () const
 See stop(), play() and pause().
bool isPlugin () const
 Whether gnash is is running as a plugin.
void takeScreenShot ()
 Take a screenshot now!
void setMaxAdvances (unsigned long ul)
 Set the maximum number of frame advances before Gnash exits.
void showUpdatedRegions (bool x)
bool showUpdatedRegions () const
void restart ()
void setQuality (Quality q)
 Set rendering quality, if not locked by RC file..
Quality getQuality () const
 Get current rendering quality.
void toggleSound ()
void addFlashVars (VariableMap &vars)
 Add variables to set into instances of the top-level movie definition.
void addScriptableVar (const std::string &name, const std::string &value)
 Add a variable used by ExternalInterface.
void setMovieDefinition (movie_definition *md)
 Set the definition of top-level movie.
void setStage (movie_root *stage)
 Set the stage to advance/display.
movie_rootgetStage ()
 The root movie, or "Stage".
virtual void error (const std::string &)
 Handle error message from the core.
virtual bool yesno (const std::string &question)
 Prompt user with a question she can answer with yes/no.
float getXScale ()
 Width of a window pixel, in stage pseudopixel units.
float getYScale ()
 Height of a window pixel, in stage pseudopixel units.

Static Public Member Functions

static bool advance_movie (Gui *gui)
 Convenience static wrapper around advanceMovie for callbacks happiness.

Protected Member Functions

 Gui (RunResources &r)
 Default constructor. Initialises members to safe defaults.
 Gui (unsigned long xid, float scale, bool loop, RunResources &r)
 Expanded constructor for more control over member values.
virtual void quitUI ()
 End main rendering loop calling GUI-specific exit functions.
virtual bool watchFD (int)
 Watch a file descriptor.
virtual void stopHook ()
virtual void playHook ()
 Called by Gui::play().

Protected Attributes

bool _loop
 Determines if playback should restart after the movie ends.
unsigned long _xid
 The X Window ID to attach to. If zero, we create a new window.
geometry::Range2d< int > _validbounds
int _width
 Desired window width.
int _height
 Desired window height.
RunResources_runResources
 Desired colour depth in bits.
unsigned int _interval
 Main loop interval: the time between successive advance_movie calls.
boost::shared_ptr< Renderer_renderer
 The handler which is called to update the client area of our window.
bool _redraw_flag
bool _fullscreen
bool _mouseShown
unsigned long _maxAdvances
unsigned long _advances
 Counter to keep track of frame advances.

Detailed Description

Parent class from which all GUI implementations will depend.


Member Typedef Documentation

typedef std::map<std::string, std::string> gnash::Gui::VariableMap

Constructor & Destructor Documentation

gnash::Gui::~Gui (  )  [virtual]
gnash::Gui::Gui ( RunResources r  )  [protected]

Default constructor. Initialises members to safe defaults.

gnash::Gui::Gui ( unsigned long  xid,
float  scale,
bool  loop,
RunResources r 
) [protected]

Expanded constructor for more control over member values.

Parameters:
xid The X11 Window ID to attach to. If this is argument is zero, a new window is created.
scale The scale used to resize the window size, which has been established by extracting information from the SWF file.
loop Defines whether or not the movie should be played once or looped indefinitely.
depth Colour depth to be used in the client area of our window.

Member Function Documentation

void gnash::Gui::addFlashVars ( Gui::VariableMap from  ) 

Add variables to set into instances of the top-level movie definition.

References gnash::key::i.

void gnash::Gui::addScriptableVar ( const std::string &  name,
const std::string &  value 
)

Add a variable used by ExternalInterface.

static bool gnash::Gui::advance_movie ( Gui gui  )  [inline, static]
bool gnash::Gui::advanceMovie (  ) 
void gnash::Gui::allowScale ( bool  allow  )  [virtual]

Sets whether scaling should be allowed (for fscommand).

Parameters:
allow true if stage scaling should be allowed

References gnash::movie_root::SCALEMODE_NOSCALE, gnash::movie_root::SCALEMODE_SHOWALL, and gnash::movie_root::setStageScaleMode().

virtual void gnash::Gui::beforeRendering (  )  [inline, virtual]

Reimplemented in gnash::DumpGui, and gnash::GtkGui.

void gnash::Gui::callCallback ( int  fd  ) 

Calls the callback function registered for a file descriptor.

Parameters:
fd The file descriptor for which the registered callback should be fired.

References s2x::f.

Referenced by gnash::FDMonitor::dataReceived().

virtual bool gnash::Gui::createWindow ( const char *  title,
int  width,
int  height,
int  xPosition = 0,
int  yPosition = 0 
) [pure virtual]

Create and display our window.

Parameters:
title The window title.
width The desired window width in pixels.
height The desired window height in pixels.
xPosition The desired window X position from the top left corner.
yPosition The desired window Y position from the top left corner.

Implemented in gnash::AOS4Gui, gnash::AquaGui, gnash::DumpGui, gnash::FBGui, gnash::FltkGui, gnash::GtkGui, gnash::HaikuGui, gnash::Kde4Gui, gnash::KdeGui, gnash::NullGui, gnash::RiscosGui, and gnash::SDLGui.

virtual void gnash::Gui::error ( const std::string &   )  [inline, virtual]

Handle error message from the core.

Parameters:
msg The error message recieved

Reimplemented in gnash::GtkGui, and gnash::HaikuGui.

VirtualClock& gnash::Gui::getClock (  )  [inline]

Return the clock provided by this Gui.

The Gui clock will be paused when the gui is put in pause mode and resumed when gui playback is resumed.

virtual double gnash::Gui::getPixelAspectRatio (  )  [inline, virtual]

Reimplemented in gnash::GtkGui.

Quality gnash::Gui::getQuality (  )  const

Get current rendering quality.

References gnash::movie_root::getQuality().

virtual std::string gnash::Gui::getScreenColor (  )  [inline, virtual]
virtual double gnash::Gui::getScreenDPI (  )  [inline, virtual]

Reimplemented in gnash::GtkGui.

virtual int gnash::Gui::getScreenResX (  )  [inline, virtual]

Reimplemented in gnash::GtkGui.

virtual int gnash::Gui::getScreenResY (  )  [inline, virtual]

Reimplemented in gnash::GtkGui.

movie_root* gnash::Gui::getStage (  )  [inline]
float gnash::Gui::getXScale (  )  [inline]

Width of a window pixel, in stage pseudopixel units.

Referenced by gnash::TouchDevice::check().

float gnash::Gui::getYScale (  )  [inline]

Height of a window pixel, in stage pseudopixel units.

Referenced by gnash::TouchDevice::check().

void gnash::Gui::hideMenu (  )  [virtual]

Hide the menu bar when using standalone player

Reimplemented in gnash::GtkGui.

References _.

virtual bool gnash::Gui::init ( int  argc,
char **  argv[] 
) [pure virtual]

Initialise the gui and the associated renderer.

Parameters:
argc The commandline argument count.
argv The commandline arguments.
Returns:
True on success; false on failure.

Implemented in gnash::AOS4Gui, gnash::AquaGui, gnash::DumpGui, gnash::FltkGui, gnash::GtkGui, gnash::HaikuGui, gnash::Kde4Gui, gnash::KdeGui, gnash::RiscosGui, and gnash::SDLGui.

bool gnash::Gui::isFullscreen (  )  const [inline]
Returns:
Whether the movie is running fullscreen or not.

References _fullscreen.

Referenced by notify_key_event(), and stop().

bool gnash::Gui::isPlugin (  )  const [inline]

Whether gnash is is running as a plugin.

References _xid.

bool gnash::Gui::isStopped (  )  const [inline]

See stop(), play() and pause().

Referenced by advanceMovie().

bool gnash::Gui::loops (  )  const [inline]
Returns:
Whether or not the movie should be looped indefinitely.

References _loop.

Referenced by advanceMovie().

void gnash::Gui::notify_key_event ( gnash::key::code  k,
int  modifier,
bool  pressed 
)
void gnash::Gui::notifyMouseClick ( bool  mouse_pressed  ) 

Mouse notification callback to be called when the mouse is clicked.

Parameters:
mouse_pressed Determines whether the mouse button is being pressed (true) or being released (false)

References gnash::key::m, and gnash::movie_root::mouseClick().

Referenced by gnash::TouchDevice::check(), gnash::MouseDevice::check(), gnash::FltkGui::handle(), gnash::qwidget::mousePressEvent(), gnash::qwidget::mouseReleaseEvent(), gnash::SDLGui::run(), and gnash::AOS4Gui::run().

void gnash::Gui::notifyMouseMove ( int  x,
int  y 
)

Mouse notification callback to be called when the mouse is moved.

Parameters:
x The mouse coordinate X component in user/window coordinate space (pixels).
y The mouse coordinate Y component in user/window coordinate space (pixels).

References _, gnash::DisplayObject::allowHandCursor(), gnash::CURSOR_HAND, gnash::CURSOR_INPUT, gnash::CURSOR_NORMAL, gnash::movie_root::getActiveEntityUnderPointer(), gnash::DisplayObject::isSelectableTextField(), gnash::key::m, gnash::movie_root::mouseMoved(), setCursor(), gnash::key::x, and gnash::key::y.

Referenced by gnash::TouchDevice::check(), gnash::MouseDevice::check(), gnash::FltkGui::handle(), gnash::qwidget::mouseMoveEvent(), notify_key_event(), gnash::SDLGui::run(), and gnash::AOS4Gui::run().

void gnash::Gui::notifyMouseWheel ( int  delta  ) 

Send a mouse wheel event to the stage.

Parameters:
delta A number expressing the extent of the wheel scroll.

References gnash::key::m, and gnash::movie_root::mouseWheel().

void gnash::Gui::pause (  ) 
void gnash::Gui::play (  ) 
virtual void gnash::Gui::playHook (  )  [inline, protected, virtual]

Called by Gui::play().

Referenced by play().

void gnash::Gui::quit (  ) 

Always called on exit.

Handles any common functions, then calls virtual quitUI().

References __PRETTY_FUNCTION__, and quitUI().

Referenced by advanceMovie(), gnash::qwidget::menuitem_quit_callback(), notify_key_event(), gnash::Kde4Gui::setTimeout(), and gnash::KdeGui::setTimeout().

virtual void gnash::Gui::quitUI (  )  [inline, protected, virtual]

End main rendering loop calling GUI-specific exit functions.

Do not call this directly. Call quit() instead. The default implementation calls exit(EXIT_SUCCESS), which isn't nice. Please implement the proper main loop quitter in the subclasses.

Reimplemented in gnash::DumpGui, gnash::GtkGui, gnash::Kde4Gui, gnash::KdeGui, and gnash::NullGui.

References EXIT_SUCCESS.

Referenced by quit().

void gnash::Gui::refreshView (  ) 
virtual void gnash::Gui::renderBuffer (  )  [pure virtual]

Render the current buffer. For OpenGL, this means that the front and back buffers are swapped.

Implemented in gnash::AOS4Gui, gnash::AquaGui, gnash::DumpGui, gnash::FBGui, gnash::FltkGui, gnash::GtkGui, gnash::HaikuGui, gnash::Kde4Gui, gnash::KdeGui, gnash::NullGui, gnash::RiscosGui, and gnash::SDLGui.

void gnash::Gui::requestScreenShots ( const ScreenShotter::FrameList l,
bool  last,
const std::string &  filename 
)

Request a list of screenshots.

Parameters:
l A list of frames to render to an image file
last Whether to render the last frame before exist
filename The filename pattern to save images as.

References _renderer.

void gnash::Gui::resize_view ( int  width,
int  height 
)
void gnash::Gui::resizeWindow ( int  width,
int  height 
) [virtual]

Reimplemented in gnash::GtkGui, and gnash::Kde4Gui.

References _.

void gnash::Gui::restart (  ) 

Instruct the core to restart the movie and set state to play(). This does not change pause state.

References gnash::movie_root::reset(), and start().

Referenced by gnash::qwidget::menuitem_restart_callback(), notify_key_event(), and gnash::AOS4Gui::run().

virtual bool gnash::Gui::run (  )  [pure virtual]
void gnash::Gui::setCursor ( gnash_cursor_type  newcursor  )  [virtual]

Sets the current mouse cursor for the Gui window.

Reimplemented in gnash::AquaGui, gnash::DumpGui, gnash::FltkGui, gnash::GtkGui, gnash::Kde4Gui, and gnash::KdeGui.

Referenced by notifyMouseMove().

void gnash::Gui::setFDCallback ( int  fd,
boost::function< void()>  callback 
)

Instructs the Gui to monitor a file descriptor.

Parameters:
fd The file descriptor to monitor
callback The callback to fire

References watchFD().

void gnash::Gui::setFullscreen (  )  [virtual]

Attempt to run in a fullscreen window both for plugin and standalone player. Use isFullscreen() to see if gnash thinks it's running in fullscreen or not. The switch to fullscreen may fail if, for instance, the window manager refuses to allow it, but the flag will be set anyway.

Reimplemented in gnash::AOS4Gui, gnash::DumpGui, gnash::FBGui, gnash::GtkGui, gnash::HaikuGui, and gnash::Kde4Gui.

References _.

virtual void gnash::Gui::setInterval ( unsigned int  interval  )  [inline, virtual]
void gnash::Gui::setInvalidatedRegion ( const SWFRect bounds  )  [virtual]

Gives the GUI a *hint* which region of the stage should be redrawn.

There is *no* restriction what the GUI might do with these coordinates. Normally the GUI forwards the information to the renderer so that it avoids rendering regions that did not change anyway. The GUI can also alter the bounds before passing them to the renderer and it's absolutely legal for the GUI to simply ignore the call.

Coordinates are in TWIPS!

Note this information is given to the GUI and not directly to the renderer because both of them need to support this feature for correct results. It is up to the GUI to forward this information to the renderer.

Reimplemented in gnash::DumpGui, and gnash::RiscosGui.

Referenced by setInvalidatedRegions().

void gnash::Gui::setInvalidatedRegions ( const InvalidatedRanges ranges  )  [virtual]
void gnash::Gui::setMaxAdvances ( unsigned long  ul  )  [inline]

Set the maximum number of frame advances before Gnash exits.

References _maxAdvances.

void gnash::Gui::setMovieDefinition ( movie_definition md  ) 

Set the definition of top-level movie.

void gnash::Gui::setQuality ( Quality  q  ) 

Set rendering quality, if not locked by RC file..

References gnash::movie_root::setQuality().

void gnash::Gui::setStage ( movie_root stage  ) 

Set the stage to advance/display.

virtual void gnash::Gui::setTimeout ( unsigned int  timeout  )  [pure virtual]

Set the time in milliseconds after which the programme should exit.

Implemented in gnash::AOS4Gui, gnash::AquaGui, gnash::DumpGui, gnash::FBGui, gnash::FltkGui, gnash::GtkGui, gnash::HaikuGui, gnash::Kde4Gui, gnash::KdeGui, gnash::NullGui, gnash::RiscosGui, and gnash::SDLGui.

void gnash::Gui::showMenu ( bool  show  )  [virtual]

Sets whether the menus should be shown (for fscommand).

Parameters:
show true if the menu bar should be shown.

Reimplemented in gnash::FBGui, and gnash::GtkGui.

References _, and LOG_ONCE.

bool gnash::Gui::showMouse ( bool  show  )  [virtual]

Sets whether the gui should show the system mouse pointer.

Parameters:
show true if the mouse should be shown.
Returns:
true if the state changed.

Reimplemented in gnash::AOS4Gui, gnash::FBGui, gnash::GtkGui, and gnash::Kde4Gui.

References _, and LOG_ONCE.

void gnash::Gui::showUpdatedRegions ( bool  x  )  [inline]
bool gnash::Gui::showUpdatedRegions (  )  const [inline]
void gnash::Gui::start (  ) 

Start the movie.

This function will create an instance of the registered top-level movie definition, set variables into it and place it to the stage.

References _height, _width, s2x::f, gnash::movie_root::init(), resize_view(), gnash::InterruptableVirtualClock::resume(), gnash::movie_root::runResources(), s, gnash::movie_root::set_background_alpha(), gnash::RunResources::soundHandler(), and gnash::sound::sound_handler::unpause().

Referenced by advanceMovie(), play(), and restart().

void gnash::Gui::stop (  ) 
virtual void gnash::Gui::stopHook (  )  [inline, protected, virtual]

Called by Gui::stop(). This can be used by GUIs to implement pause widgets (so that resuming a stopped animation is more user-friendly)

Referenced by pause(), and stop().

void gnash::Gui::takeScreenShot (  ) 

Take a screenshot now!

References _renderer, _runResources, gnash::RunResources::baseURL(), filename, name, gnash::key::p, and url.

Referenced by notify_key_event().

void gnash::Gui::toggleFullscreen (  ) 
void gnash::Gui::toggleSound (  ) 

Toggle sound state between muted and unmuted. If there is no active sound handler this does nothing.

References gnash::sound::sound_handler::is_muted(), gnash::sound::sound_handler::mute(), gnash::movie_root::runResources(), s, gnash::RunResources::soundHandler(), and gnash::sound::sound_handler::unmute().

void gnash::Gui::unsetFullscreen (  )  [virtual]

Return from fullscreen to normal mode.

Reimplemented in gnash::AOS4Gui, gnash::DumpGui, gnash::FBGui, gnash::GtkGui, gnash::HaikuGui, and gnash::Kde4Gui.

References _.

Referenced by stop().

void gnash::Gui::updateStageMatrix (  ) 
virtual bool gnash::Gui::want_multiple_regions (  )  [inline, virtual]
bool gnash::Gui::want_redraw (  )  [virtual]

Asks the GUI handler if the next frame should be redrawn completely.

For example, when the contents of the player window have been destroyed, then want_redraw() should return true so that setInvalidatedRegion() is called with the coordinates of the complete screen.

Reimplemented in gnash::DumpGui.

virtual bool gnash::Gui::watchFD ( int   )  [inline, protected, virtual]

Watch a file descriptor.

An implementing Gui should monitor the file descriptor in its main loop. When the file descriptor is triggered, the implementation should call callCallback().

Parameters:
fd The file descriptor to be watched

Reimplemented in gnash::GtkGui, and gnash::Kde4Gui.

Referenced by setFDCallback().

bool gnash::Gui::yesno ( const std::string &  question  )  [virtual]

Prompt user with a question she can answer with yes/no.

Parameters:
question The question to ask user
Returns:
true for YES, false for NO

The default implementation always returns true.

Reimplemented in gnash::HaikuGui.


Member Data Documentation

unsigned long gnash::Gui::_advances [protected]

Counter to keep track of frame advances.

Referenced by advanceMovie().

bool gnash::Gui::_fullscreen [protected]
int gnash::Gui::_height [protected]
unsigned int gnash::Gui::_interval [protected]
bool gnash::Gui::_loop [protected]

Determines if playback should restart after the movie ends.

Referenced by loops().

unsigned long gnash::Gui::_maxAdvances [protected]

Referenced by advanceMovie(), and setMaxAdvances().

bool gnash::Gui::_mouseShown [protected]
bool gnash::Gui::_redraw_flag [protected]

Signals that the next frame must be re-rendered completely because the window size did change.

Referenced by refreshView(), and updateStageMatrix().

boost::shared_ptr<Renderer> gnash::Gui::_renderer [protected]
int gnash::Gui::_width [protected]
unsigned long gnash::Gui::_xid [protected]

The documentation for this class was generated from the following files: