Rocket::Core::Context Class Reference
#include <Context.h>
|
Public Member Functions |
| | Context (const String &name) |
|
virtual | ~Context () |
| | Destroys a context.
|
| const String & | GetName () const |
| void | SetDimensions (const Vector2i &dimensions) |
| const Vector2i & | GetDimensions () const |
|
bool | Update () |
| | Updates all elements in the context's documents.
|
|
bool | Render () |
| | Renders all visible elements in the context's documents.
|
| ElementDocument * | CreateDocument (const String &tag="body") |
| ElementDocument * | LoadDocument (const String &document_path) |
| ElementDocument * | LoadDocument (Stream *document_stream) |
| ElementDocument * | LoadDocumentFromMemory (const String &string) |
| void | UnloadDocument (ElementDocument *document) |
|
void | UnloadAllDocuments () |
| | Unloads all loaded documents.
|
| void | AddMouseCursor (ElementDocument *cursor_document) |
| ElementDocument * | LoadMouseCursor (const String &cursor_document_path) |
| void | UnloadMouseCursor (const String &cursor_name) |
|
void | UnloadAllMouseCursors () |
| | Unloads all currently loaded cursors.
|
| bool | SetMouseCursor (const String &cursor_name) |
| void | ShowMouseCursor (bool show) |
| ElementDocument * | GetDocument (const String &id) |
| ElementDocument * | GetDocument (int index) |
| int | GetNumDocuments () const |
| Element * | GetHoverElement () |
| Element * | GetFocusElement () |
| Element * | GetRootElement () |
| void | PullDocumentToFront (ElementDocument *document) |
| void | PushDocumentToBack (ElementDocument *document) |
| void | AddEventListener (const String &event, EventListener *listener, bool in_capture_phase=false) |
| void | RemoveEventListener (const String &event, EventListener *listener, bool in_capture_phase=false) |
| bool | ProcessKeyDown (Input::KeyIdentifier key_identifier, int key_modifier_state) |
| bool | ProcessKeyUp (Input::KeyIdentifier key_identifier, int key_modifier_state) |
| bool | ProcessTextInput (word character) |
| bool | ProcessTextInput (const String &string) |
| void | ProcessMouseMove (int x, int y, int key_modifier_state) |
| void | ProcessMouseButtonDown (int button_index, int key_modifier_state) |
| void | ProcessMouseButtonUp (int button_index, int key_modifier_state) |
| bool | ProcessMouseWheel (int wheel_delta, int key_modifier_state) |
| RenderInterface * | GetRenderInterface () const |
| void | SetInstancer (ContextInstancer *instancer) |
Protected Member Functions |
|
virtual void | OnReferenceDeactivate () |
| | A hook method called when the reference count drops to 0.
|
Friends |
|
class | Element |
| ROCKETCORE_API Context * | CreateContext (const String &, const Vector2i &, RenderInterface *) |
Detailed Description
A context for storing, rendering and processing RML documents. Multiple contexts can exist simultaneously.
- Author:
- Peter Curry
Constructor & Destructor Documentation
| Rocket::Core::Context::Context |
( |
const String & |
name |
) |
|
Constructs a new, uninitialised context. This should not be called directly, use Core::CreateContext() instead.
- Parameters:
-
| [in] | name | The name of the context. |
Member Function Documentation
| const String & Rocket::Core::Context::GetName |
( |
|
) |
const |
Returns the name of the context.
- Returns:
- The context's name.
| void Rocket::Core::Context::SetDimensions |
( |
const Vector2i & |
dimensions |
) |
|
Changes the dimensions of the context.
- Parameters:
-
| [in] | dimensions | The new dimensions of the context. |
| const Vector2i & Rocket::Core::Context::GetDimensions |
( |
|
) |
const |
Returns the dimensions of the context.
- Returns:
- The current dimensions of the context.
Creates a new, empty document and places it into this context.
- Parameters:
-
| [in] | tag | The document type to create. |
- Returns:
- The new document, or NULL if no document could be created. The document is returned with a reference owned by the caller.
Load a document into the context.
- Parameters:
-
| [in] | document_path | The path to the document to load. |
- Returns:
- The loaded document, or NULL if no document was loaded. The document is returned with a reference owned by the caller.
Load a document into the context.
- Parameters:
-
| [in] | document_stream | The opened stream, ready to read. |
- Returns:
- The loaded document, or NULL if no document was loaded. The document is returned with a reference owned by the caller.
Load a document into the context.
- Parameters:
-
| [in] | string | The string containing the document RML. |
- Returns:
- The loaded document, or NULL if no document was loaded. The document is returned with a reference owned by the caller.
Unload the given document.
- Parameters:
-
| [in] | document | The document to unload. |
| void Rocket::Core::Context::AddMouseCursor |
( |
ElementDocument * |
cursor_document |
) |
|
Adds a previously-loaded cursor document as a mouse cursor within this context. This allows you to share cursors between contexts.
- Parameters:
-
| [in] | cursor_document | The document to add as a cursor into this context. |
Loads a document as a mouse cursor within this context.
- Parameters:
-
| [in] | cursor_document_path | The path to the document to load as a cursor. |
- Returns:
- The loaded cursor document, or NULL if no document was loaded. The document is returned with a reference owned by the caller.
| void Rocket::Core::Context::UnloadMouseCursor |
( |
const String & |
cursor_name |
) |
|
Unload the given cursor.
- Parameters:
-
| [in] | cursor_name | The name of cursor to unload. |
| bool Rocket::Core::Context::SetMouseCursor |
( |
const String & |
cursor_name |
) |
|
Sets a cursor as the active cursor.
- Parameters:
-
| [in] | cursor_name | The name of the cursor to activate. |
- Returns:
- True if a cursor exists with the given name, false if not.
| void Rocket::Core::Context::ShowMouseCursor |
( |
bool |
show |
) |
|
Shows or hides the cursor.
- Parameters:
-
| [in] | show | True to show the cursor, false to hide it. |
Returns the first document in the context with the given id.
- Parameters:
-
| [in] | id | The id of the desired document. |
- Returns:
- The document (if it was found), or NULL if no document exists with the ID. The document is returned with a borrowed reference.
Returns a document in the context by index.
- Parameters:
-
| [in] | index | The index of the desired document. |
- Returns:
- The document (if one exists with this index), or NULL if the index was invalid. The document is returned with a borrowed reference.
| int Rocket::Core::Context::GetNumDocuments |
( |
|
) |
const |
Returns the number of documents in the context.
- Returns:
- The number of documents in the context.
| Element * Rocket::Core::Context::GetHoverElement |
( |
|
) |
|
Returns the hover element.
- Returns:
- The element the mouse cursor is hovering over. The element is returned with a borrowed reference.
| Element * Rocket::Core::Context::GetFocusElement |
( |
|
) |
|
Returns the focus element.
- Returns:
- The element with input focus. The element is returned with a borrowed reference.
| Element * Rocket::Core::Context::GetRootElement |
( |
|
) |
|
Returns the root element that holds all the documents
- Returns:
- The root element. The element is returned with a borrowed reference.
| void Rocket::Core::Context::PullDocumentToFront |
( |
ElementDocument * |
document |
) |
|
Brings the document to the front of the document stack.
- Parameters:
-
| [in] | document | The document to pull to the front of the stack. |
| void Rocket::Core::Context::PushDocumentToBack |
( |
ElementDocument * |
document |
) |
|
Sends the document to the back of the document stack.
- Parameters:
-
| [in] | document | The document to push to the bottom of the stack. |
| void Rocket::Core::Context::AddEventListener |
( |
const String & |
event, |
|
|
EventListener * |
listener, |
|
|
bool |
in_capture_phase = false | |
|
) |
| | |
Adds an event listener to the context's root element.
- Parameters:
-
| [in] | event | The name of the event to attach to. |
| [in] | listener | Listener object to be attached. |
| [in] | in_capture_phase | True if the listener is to be attached to the capture phase, false for the bubble phase. |
| void Rocket::Core::Context::RemoveEventListener |
( |
const String & |
event, |
|
|
EventListener * |
listener, |
|
|
bool |
in_capture_phase = false | |
|
) |
| | |
Removes an event listener from the context's root element.
- Parameters:
-
| [in] | event | The name of the event to detach from. |
| [in] | listener | Listener object to be detached. |
| [in] | in_capture_phase | True to detach from the capture phase, false from the bubble phase. |
| bool Rocket::Core::Context::ProcessKeyDown |
( |
Input::KeyIdentifier |
key_identifier, |
|
|
int |
key_modifier_state | |
|
) |
| | |
Sends a key down event into this context.
- Parameters:
-
| [in] | key_identifier | The key pressed. |
| [in] | key_modifier_state | The state of key modifiers (shift, control, caps-lock, etc) keys; this should be generated by ORing together members of the Input::KeyModifier enumeration. |
- Returns:
- True if the event was not consumed (ie, was prevented from propagating by an element), false if it was.
| bool Rocket::Core::Context::ProcessKeyUp |
( |
Input::KeyIdentifier |
key_identifier, |
|
|
int |
key_modifier_state | |
|
) |
| | |
Sends a key up event into this context.
- Parameters:
-
| [in] | key_identifier | The key released. |
| [in] | key_modifier_state | The state of key modifiers (shift, control, caps-lock, etc) keys; this should be generated by ORing together members of the Input::KeyModifier enumeration. |
- Returns:
- True if the event was not consumed (ie, was prevented from propagating by an element), false if it was.
| bool Rocket::Core::Context::ProcessTextInput |
( |
word |
character |
) |
|
Sends a single character of text as text input into this context.
- Parameters:
-
| [in] | character | The UCS-2 character to send into this context. |
- Returns:
- True if the event was not consumed (ie, was prevented from propagating by an element), false if it was.
| bool Rocket::Core::Context::ProcessTextInput |
( |
const String & |
string |
) |
|
Sends a string of text as text input into this context.
- Parameters:
-
| [in] | string | The UCS-2 string to send into this context. |
- Returns:
- True if the event was not consumed (ie, was prevented from propagating by an element), false if it was.
| void Rocket::Core::Context::ProcessMouseMove |
( |
int |
x, |
|
|
int |
y, |
|
|
int |
key_modifier_state | |
|
) |
| | |
Sends a mouse movement event into this context.
- Parameters:
-
| [in] | x | The x-coordinate of the mouse cursor, in window-coordinates (ie, 0 should be the left of the client area). |
| [in] | y | The y-coordinate of the mouse cursor, in window-coordinates (ie, 0 should be the top of the client area). |
| [in] | key_modifier_state | The state of key modifiers (shift, control, caps-lock, etc) keys; this should be generated by ORing together members of the Input::KeyModifier enumeration. |
| void Rocket::Core::Context::ProcessMouseButtonDown |
( |
int |
button_index, |
|
|
int |
key_modifier_state | |
|
) |
| | |
Sends a mouse-button down event into this context.
- Parameters:
-
| [in] | button_index | The index of the button that was pressed; 0 for the left button, 1 for right, and any others from 2 onwards. |
| [in] | key_modifier_state | The state of key modifiers (shift, control, caps-lock, etc) keys; this should be generated by ORing together members of the Input::KeyModifier enumeration. |
| void Rocket::Core::Context::ProcessMouseButtonUp |
( |
int |
button_index, |
|
|
int |
key_modifier_state | |
|
) |
| | |
Sends a mouse-button up event into this context.
- Parameters:
-
| [in] | button_index | The index of the button that was release; 0 for the left button, 1 for right, and any others from 2 onwards. |
| [in] | key_modifier_state | The state of key modifiers (shift, control, caps-lock, etc) keys; this should be generated by ORing together members of the Input::KeyModifier enumeration. |
| bool Rocket::Core::Context::ProcessMouseWheel |
( |
int |
wheel_delta, |
|
|
int |
key_modifier_state | |
|
) |
| | |
Sends a mouse-wheel movement event into this context.
- Parameters:
-
| [in] | wheel_delta | The mouse-wheel movement this frame. Rocket treats a negative delta as up movement (away from the user), positive as down. |
| [in] | key_modifier_state | The state of key modifiers (shift, control, caps-lock, etc) keys; this should be generated by ORing together members of the Input::KeyModifier enumeration. |
- Returns:
- True if the event was not consumed (ie, was prevented from propagating by an element), false if it was.
Gets the context's render interface.
- Returns:
- The render interface the context renders through.
Sets the instancer to use for releasing this object.
- Parameters:
-
| [in] | instancer | The context's instancer. |
Friends And Related Function Documentation
Creates a new element context.
- Parameters:
-
| [in] | name | The new name of the context. This must be unique. |
| [in] | dimensions | The initial dimensions of the new context. |
| [in] | render_interface | The custom render interface to use, or NULL to use the default. |
- Returns:
- The new context, or NULL if the context could not be created.
The documentation for this class was generated from the following files:
- Include/Rocket/Core/Context.h
- Source/Core/Context.cpp