Changes from Version 1 of documentation/C++Manual/Plugins

Show
Ignore:
Author:
lloydw (IP: 192.168.0.1)
Timestamp:
11/19/07 19:34:08 (10 years ago)
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • documentation/C++Manual/Plugins

    v0 v1  
     1[[PageOutline(1-5, Contents)]] 
     2= Plugins = 
     3 
     4Rocket has a simple, straightforward system for writing plugins. Plugins receive notification when contexts and elements are created and destroyed. 
     5 
     6== Creating a plugin == 
     7 
     8All plugins derive from the Rocket::Core::Plugin class. The virtual functions that can be overridden are: 
     9 
     10{{{ 
     11// Called when Rocket is initialised. 
     12virtual void OnInitialise(); 
     13 
     14// Called when Rocket shuts down. 
     15virtual void OnShutdown(); 
     16 
     17// Called when a new context is created. 
     18virtual void OnContextCreate(Rocket::Core::Context* context); 
     19 
     20// Called when a context is destroyed. 
     21virtual void OnContextDestroy(Rocket::Core::Context* context); 
     22 
     23// Called when a new element is created. 
     24virtual void OnElementCreate(Rocket::Core::Element* element); 
     25 
     26// Called when an element is destroyed. 
     27virtual void OnElementDestroy(Rocket::Core::Element* element); 
     28}}} 
     29 
     30=== Rocket engine events === 
     31 
     32The OnInitialise() function will be called on all registered plugins when Rocket is successfully initialised. If Rocket is already initialised when a plugin is registered, OnInitialise() will be immediately called on the plugin. 
     33 
     34OnShutdown() is called on all registered plugins when Rocket is shut down, immediately after all the contexts and elements are destroyed. Plugins must release any resources they have allocated, including themselves, during this call. 
     35 
     36=== Context events === 
     37 
     38OnContextCreate() and OnContextDestroy() are called on every registered plugin when a context is successfully created or destroyed. 
     39 
     40=== Element events === 
     41 
     42OnElementCreate() and OnElementDestroy() are called on every registered plugin when an element is successfully created or destroyed. 
     43 
     44== Registering a plugin == 
     45 
     46To register a plugin, call the RegisterPlugin() function in Rocket::Core. 
     47 
     48{{{ 
     49Rocket::Core::Plugin* plugin = new CustomPlugin(); 
     50Rocket::Core::RegisterPlugin(plugin); 
     51}}}