dtGUI::ScriptModule Class Reference

ScriptModule is the binding from CEGUI::Events to specific application callbacks. More...

#include <scriptmodule.h>

Inheritance diagram for dtGUI::ScriptModule:

dtGUI::BaseScriptModule

List of all members.

Public Types

typedef bool(* STATIC_FUNCTION )(const CEGUI::EventArgs &e)
typedef dtUtil::Functor< bool,
TYPELIST_1(const
CEGUI::EventArgs &)> 
HandlerFunctor
typedef std::map< std::string,
HandlerFunctor
CallbackRegistry

Public Member Functions

 ScriptModule ()
virtual ~ScriptModule ()
bool AddCallback (const std::string &name, STATIC_FUNCTION func)
 Add a static callback handler.
bool AddCallback (const std::string &name, const HandlerFunctor &callback)
 Add a non-static callback handler.
const CallbackRegistryGetRegistry () const
 Returns the StaticRegistry.
virtual void executeScriptFile (const CEGUI::String &filename, const CEGUI::String &resourceGroup="")
virtual int executeScriptGlobal (const CEGUI::String &function_name)
virtual void executeString (const CEGUI::String &str)
virtual bool executeScriptedEventHandler (const CEGUI::String &handler_name, const CEGUI::EventArgs &ea)
 Uses the map of strings to functions to execute a function to handle the EventArgs.


Detailed Description

ScriptModule is the binding from CEGUI::Events to specific application callbacks.

Create an instance of this class, and provide it as a parameter during construction of a CEUIDrawable instance. Add new handlers with the AddCallback function.


Member Typedef Documentation

typedef bool(* dtGUI::ScriptModule::STATIC_FUNCTION)(const CEGUI::EventArgs &e)

typedef dtUtil::Functor<bool,TYPELIST_1(const CEGUI::EventArgs&)> dtGUI::ScriptModule::HandlerFunctor

typedef std::map<std::string,HandlerFunctor> dtGUI::ScriptModule::CallbackRegistry


Constructor & Destructor Documentation

ScriptModule::ScriptModule (  ) 

ScriptModule::~ScriptModule (  )  [virtual]


Member Function Documentation

bool ScriptModule::AddCallback ( const std::string &  name,
STATIC_FUNCTION  func 
)

Add a static callback handler.

Example:

 class MyClass
 {
   ...
   static bool OnClick( const CEGUI::EventArgs &e );
   ...
 }
 
  ...
  mScriptModule->AddCallback("OnDoSomething", &OnClick);
  ...
Parameters:
name is the string representation of the handler function to be executed for the CEGUI::Event.
func is the pointer to the function to be called when the CEGUI::Event is activated.

bool ScriptModule::AddCallback ( const std::string &  name,
const HandlerFunctor callback 
)

Add a non-static callback handler.

Example:

 class App
 {
   ...
  public:
   bool OnClick( const CEGUI::EventArgs &e );
   ...
 }
 
  ...
  App *mApp = new App();

  dtGUI::ScriptModule::HandlerFunctor handler( dtUtil::MakeFunctor( &App::OnClick, mApp ) );
  mScriptModule->AddCallback("OnDoSomething", handler );
 ...
Parameters:
name is the string representation of the handler function to be executed for the CEGUI::Event.
func is an instance of a function object to be called when the CEGUI::Event is activated.
Attention:
An attempt was make an implemenation with the signature template<typename InstT> bool AddCallback(const std::string& name, bool (InstT::*MemFun)(const CEGUI::EventArgs&), InstT* instance) but somehow creating the HandleFunctor intenal to the function caused some problems.

const CallbackRegistry& dtGUI::ScriptModule::GetRegistry (  )  const [inline]

Returns the StaticRegistry.

void ScriptModule::executeScriptFile ( const CEGUI::String &  filename,
const CEGUI::String &  resourceGroup = "" 
) [virtual]

Implements dtGUI::BaseScriptModule.

int ScriptModule::executeScriptGlobal ( const CEGUI::String &  function_name  )  [virtual]

Implements dtGUI::BaseScriptModule.

void ScriptModule::executeString ( const CEGUI::String &  str  )  [virtual]

Implements dtGUI::BaseScriptModule.

bool ScriptModule::executeScriptedEventHandler ( const CEGUI::String &  handler_name,
const CEGUI::EventArgs &  ea 
) [virtual]

Uses the map of strings to functions to execute a function to handle the EventArgs.

This function is called by CEGUI::System when a CEGUI::Window throws an CEGUI::Event

Implements dtGUI::BaseScriptModule.


http://www.delta3d.org
2.0.0 generated 14 Feb 2008