Gnash  0.8.10
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:
gnash::AOS4Gui gnash::AquaGui gnash::DumpGui gnash::FltkGui gnash::GtkGui gnash::gui::FBGui gnash::HaikuGui gnash::KdeGui gnash::NullGui gnash::Qt4Gui gnash::SDLGui

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.
virtual 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 setScreenShotter (std::auto_ptr< ScreenShotter > ss)
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 void setClipboard (const std::string &copy)
virtual double getPixelAspectRatio () const
virtual std::pair< int, int > screenResolution () const
virtual double getScreenDPI () const
virtual std::string getScreenColor () const
 Get the screen color type.
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 (bool doDisplay=true)
 Give movie an heart-beat.
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 setMovieDefinition (movie_definition *md)
 Set the definition of top-level movie.
void setStage (movie_root *stage)
 Set the stage to advance/display.
void setAudioDump (const std::string &fname)
 Set the name of a file to dump audio to.
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 () const
 Width of a window pixel, in stage pseudopixel units.
float getYScale () const
 Height of a window pixel, in stage pseudopixel units.
float getFPS () const
 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().
virtual bool visible ()
 Determines whether the Gui is visible (not obscured).

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
 Per-run resources.
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.
std::string _audioDump
 Name of a file to dump audio to.

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:
xidThe X11 Window ID to attach to. If this is argument is zero, a new window is created.
scaleThe scale used to resize the window size, which has been established by extracting information from the SWF file.
loopDefines whether or not the movie should be played once or looped indefinitely.
depthColour 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.

static bool gnash::Gui::advance_movie ( Gui gui) [inline, static]

Convenience static wrapper around advanceMovie for callbacks happiness.

NOTE: this function always return TRUE, for historical reasons. TODO: bring code up-to-date to drop this legacy return code..

Referenced by gnash::AOS4Gui::run(), gnash::gui::FBGui::run(), gnash::FltkGui::handle(), gnash::GtkGui::run(), gnash::HaikuGui::GnashPulse(), gnash::qwidget::timerEvent(), and gnash::DrawingWidget::timerEvent().

bool gnash::Gui::advanceMovie ( bool  doDisplay = true)

Give movie an heart-beat.

This is to take place after the interval specified in the call to setInterval().

Wheter or not this beat advanced the movie to the next frame depends on elapsed time since last advancement.

Returns:
true if this beat resulted in actual frame advancement.

Quit if we've reached the frame advance limit.

References isStopped(), start(), gnash::movie_root::advance(), gnash::movie_root::getRootMovie(), gnash::MovieClip::get_current_frame(), gnash::MovieClip::get_frame_count(), gnash::Movie::ensureFrameLoaded(), gnash::MovieClip::setPlayState(), gnash::MovieClip::PLAYSTATE_PLAY, visible(), loops(), quit(), _renderer, _advances, and _maxAdvances.

Referenced by gnash::DumpGui::run(), gnash::NullGui::run(), and gnash::SDLGui::run().

void gnash::Gui::allowScale ( bool  allow) [virtual]

Sets whether scaling should be allowed (for fscommand)

Parameters:
allowtrue if stage scaling should be allowed

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

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

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

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:
titleThe window title.
widthThe desired window width in pixels.
heightThe desired window height in pixels.
xPositionThe desired window X position from the top left corner.
yPositionThe desired window Y position from the top left corner.

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

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

Handle error message from the core.

Parameters:
msgThe error message recieved

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

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

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.

Reimplemented in gnash::DumpGui.

Referenced by gnash::gui::FBGui::run().

float gnash::Gui::getFPS ( ) const [inline]

Height of a window pixel, in stage pseudopixel units.

Referenced by gnash::gui::FBGui::run().

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

Reimplemented in gnash::GtkGui.

Quality gnash::Gui::getQuality ( ) const

Get current rendering quality.

References _, gnash::QUALITY_HIGH, and gnash::movie_root::getQuality().

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

Get the screen color type.

The choice is between "color" and something designating monochrome (not sure what). If this isn't implemented in the gui we return "color".

virtual double gnash::Gui::getScreenDPI ( ) const [inline, virtual]

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

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

Width of a window pixel, in stage pseudopixel units.

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

Height of a window pixel, in stage pseudopixel units.

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

Hide the menu bar when using standalone player

Reimplemented in gnash::GtkGui.

References LOG_ONCE, and _.

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

/ Initialise the gui and the associated renderer.

Parameters:
argcThe commandline argument count.
argvThe commandline arguments.
Returns:
True on success; false on failure.

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

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]
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_pressedDetermines whether the mouse button is being pressed (true) or being released (false)

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

Referenced by gnash::AOS4Gui::run(), gnash::gui::FBGui::checkForData(), gnash::FltkGui::handle(), gnash::qwidget::mousePressEvent(), gnash::qwidget::mouseReleaseEvent(), gnash::DrawingWidget::mousePressEvent(), gnash::DrawingWidget::mouseReleaseEvent(), and gnash::SDLGui::run().

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

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

Parameters:
xThe mouse coordinate X component in user/window coordinate space (pixels).
yThe mouse coordinate Y component in user/window coordinate space (pixels).

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

Referenced by gnash::AOS4Gui::run(), gnash::gui::FBGui::checkForData(), gnash::FltkGui::handle(), notify_key_event(), gnash::qwidget::mouseMoveEvent(), gnash::DrawingWidget::mouseMoveEvent(), and gnash::SDLGui::run().

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

Send a mouse wheel event to the stage.

Parameters:
deltaA number expressing the extent of the wheel scroll.

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

Referenced by gnash::DrawingWidget::wheelEvent().

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 ( )
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::Qt4Gui, gnash::KdeGui, gnash::NullGui, gnash::GtkGui, and gnash::DumpGui.

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::gui::FBGui, gnash::KdeGui, gnash::Qt4Gui, gnash::AOS4Gui, gnash::HaikuGui, gnash::AquaGui, gnash::GtkGui, gnash::NullGui, gnash::SDLGui, gnash::FltkGui, and gnash::DumpGui.

void gnash::Gui::resize_view ( int  width,
int  height 
)

Resize the client area view and the window accordingly.

Parameters:
widthThe desired width in pixels.
heightThe desired height in pixels.

Reimplemented in gnash::gui::FBGui, and gnash::HaikuGui.

References GNASH_REPORT_FUNCTION, assert, gnash::movie_root::setDimensions(), _width, width, _height, height, _validbounds, gnash::geometry::Range2d::setTo(), and updateStageMatrix().

Referenced by gnash::AOS4Gui::run(), gnash::AOS4Gui::setFullscreen(), gnash::AOS4Gui::unsetFullscreen(), gnash::FltkGui::layout(), start(), gnash::KdeGui::resize(), and gnash::Qt4Gui::resize().

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

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

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::AOS4Gui::run(), notify_key_event(), gnash::qwidget::menuitem_restart_callback(), and gnash::DrawingWidget::restart().

virtual bool gnash::Gui::run ( ) [pure virtual]
virtual std::pair<int, int> gnash::Gui::screenResolution ( ) const [inline, virtual]

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

void gnash::Gui::setAudioDump ( const std::string &  fname) [inline]

Set the name of a file to dump audio to.

References _audioDump.

void gnash::Gui::setClipboard ( const std::string &  copy) [virtual]

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

References LOG_ONCE, and _.

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

Sets the current mouse cursor for the Gui window.

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

Referenced by notifyMouseMove().

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::gui::FBGui, gnash::Qt4Gui, gnash::AOS4Gui, gnash::GtkGui, gnash::HaikuGui, and gnash::DumpGui.

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::gui::FBGui, and gnash::DumpGui.

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.

References assert.

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

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

References _, and gnash::movie_root::setQuality().

void gnash::Gui::setScreenShotter ( std::auto_ptr< ScreenShotter ss)
void gnash::Gui::setStage ( movie_root stage)

Set the stage to advance/display.

References assert.

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

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

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

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

Sets whether the menus should be shown (for fscommand)

Parameters:
showtrue if the menu bar should be shown.

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

References LOG_ONCE, and _.

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

Sets whether the gui should show the system mouse pointer.

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

Reimplemented in gnash::gui::FBGui, gnash::GtkGui, gnash::Qt4Gui, and gnash::AOS4Gui.

References LOG_ONCE, and _.

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

References x.

bool gnash::Gui::showUpdatedRegions ( ) const [inline]
void gnash::Gui::start ( )
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 stop(), and pause().

void gnash::Gui::takeScreenShot ( )
void gnash::Gui::toggleFullscreen ( )
void gnash::Gui::toggleSound ( )
void gnash::Gui::unsetFullscreen ( ) [virtual]

Return from fullscreen to normal mode.

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

References _.

Referenced by stop().

void gnash::Gui::updateStageMatrix ( )

Update stage SWFMatrix accordingly to window size and flash Stage configuration (scaleMode, alignment) This method should be called from the core lib when Stage configuration change or is called by resize_view.

References _, assert, gnash::movie_root::getStageScaleMode(), gnash::key::f, _width, _height, gnash::movie_root::getStageAlignment(), _renderer, and _redraw_flag.

Referenced by resize_view().

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

Determines whether the Gui is visible (not obscured).

Reimplemented in gnash::GtkGui.

Referenced by advanceMovie().

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:
fdThe file descriptor to be watched
bool gnash::Gui::yesno ( const std::string &  question) [virtual]

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

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

The default implementation always returns true.

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

References _.


Member Data Documentation

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

Counter to keep track of frame advances.

Referenced by advanceMovie().

std::string gnash::Gui::_audioDump [protected]

Name of a file to dump audio to.

Referenced by start(), and setAudioDump().

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 updateStageMatrix(), and refreshView().

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: