Pyrogenesis
trunk
|
Base settings, all objects possess these settings in their m_BaseSettings Instructions can be found in the documentations. More...
#include <IGUIObject.h>
Public Member Functions | |
IGUIObject () | |
virtual | ~IGUIObject () |
virtual bool | MouseOver () |
Checks if mouse is hovering this object. More... | |
virtual bool | MouseOverIcon () |
Test if mouse position is over an icon. More... | |
Leaf Functions | |
const CStr & | GetName () const |
Get object name, name is unique. More... | |
void | SetName (const CStr &Name) |
Get object name. More... | |
CStr | GetPresentableName () const |
void | AddToPointersMap (map_pObjects &ObjectMap) |
Adds object and its children to the map, it's name being the first part, and the second being itself. More... | |
void | AddChild (IGUIObject *pChild) |
Notice nothing will be returned or thrown if the child hasn't been inputted into the GUI yet. More... | |
Iterate | |
Used to iterate over all children of this object. | |
vector_pObjects::iterator | begin () |
vector_pObjects::iterator | end () |
Settings Management | |
bool | SettingExists (const CStr &Setting) const |
Checks if settings exists, only available for derived classes that has this set up, that's why the base class just returns false. More... | |
virtual void | UpdateCachedSize () |
All sizes are relative to resolution, and the calculation is not wanted in real time, therefore it is cached, update the cached size with this function. More... | |
PSRETURN | SetSetting (const CStr &Setting, const CStrW &Value, const bool &SkipMessage=false) |
Set a setting by string, regardless of what type it is. More... | |
PSRETURN | GetSettingType (const CStr &Setting, EGUISettingType &Type) const |
Retrieves the type of a named setting. More... | |
void | RegisterScriptHandler (const CStr &Action, const CStr &Code, CGUI *pGUI) |
Set the script handler for a particular object-specific action. More... | |
JSObject * | GetJSObject () |
Retrieves the JSObject representing this GUI object. More... | |
Friends | |
class | CGUI |
class | CInternalCGUIAccessorBase |
class | IGUIScrollBar |
class | GUITooltip |
bool | JSI_IGUIObject::getProperty (JSContext *cx, JS::HandleObject obj, JS::HandleId id, JS::MutableHandleValue vp) |
bool | JSI_IGUIObject::setProperty (JSContext *cx, JS::HandleObject obj, JS::HandleId id, bool strict, JS::MutableHandleValue vp) |
bool | JSI_IGUIObject::getComputedSize (JSContext *cx, uint argc, jsval *vp) |
Called by CGUI and friends | |
Methods that the CGUI will call using its friendship, these should not be called by user. These functions' security are a lot what constitutes the GUI's | |
CRect | m_CachedActualSize |
Cached size, real size m_Size is actually dependent on resolution and can have different real outcomes, this is the real outcome cached to avoid slow calculations in real time. More... | |
virtual void | HandleMessage (SGUIMessage &Message) |
This function is called with different messages for instance when the mouse enters the object. More... | |
CGUI * | GetGUI () |
const CGUI * | GetGUI () const |
void | SetFocus () |
Take focus! More... | |
void | AddSetting (const EGUISettingType &Type, const CStr &Name) |
Add a setting to m_Settings. More... | |
virtual void | Destroy () |
Calls Destroy on all children, and deallocates all memory. More... | |
virtual void | Draw ()=0 |
Draws the object. More... | |
virtual InReaction | ManuallyHandleEvent (const SDL_Event_ *ev) |
Some objects need to handle the SDL_Event_ manually. More... | |
void | LoadStyle (CGUI &GUIinstance, const CStr &StyleName) |
Loads a style. More... | |
void | LoadStyle (const SGUIStyle &Style) |
Loads a style. More... | |
virtual float | GetBufferedZ () const |
Returns not the Z value, but the actual buffered Z value, i.e. More... | |
void | SetGUI (CGUI *const &pGUI) |
void | SetParent (IGUIObject *pParent) |
Set parent of this object. More... | |
virtual void | ResetStates () |
Reset internal state of this object. More... | |
bool | IsFocused () const |
Check if object is focused. More... | |
IGUIObject * | GetParent () const |
NOTE! This will not just return m_pParent, when that is need use it! There is one exception to it, when the parent is the top-node (the object that isn't a real object), this will return NULL, so that the top-node's children are seemingly parentless. More... | |
CPos | GetMousePos () const |
Get Mouse from CGUI. More... | |
virtual bool | HandleAdditionalChildren (const XMBElement &child, CXeromyces *pFile) |
Handle additional children to the <object>-tag. More... | |
InReaction | SendEvent (EGUIMessageType type, const CStr &EventName) |
Send event to this GUI object (HandleMessage and ScriptEvent) More... | |
void | ScriptEvent (const CStr &Action) |
Execute the script for a particular action. More... | |
void | ScriptEvent (const CStr &Action, JS::HandleValue Argument) |
Execute the script for a particular action. More... | |
void | SetScriptHandler (const CStr &Action, JS::HandleObject Function) |
void | UpdateMouseOver (IGUIObject *const &pMouseOver) |
Inputes the object that is currently hovered, this function updates this object accordingly (i.e. More... | |
Internal functions | |
CStr | m_Name |
vector_pObjects | m_Children |
IGUIObject * | m_pParent |
double | m_LastClickTime [6] |
bool | m_MouseHovering |
This is an array of true or false, each element is associated with a string representing a setting. More... | |
std::map< CStr, SGUISetting > | m_Settings |
Settings pool, all an object's settings are located here If a derived object has got more settings that the base settings, it's because they have a new version of the function SetupSettings(). More... | |
CGUI * | m_pGUI |
std::map< CStr, JS::Heap< JSObject * > > | m_ScriptHandlers |
JS::PersistentRootedObject | m_JSObject |
void | ChooseMouseOverAndClosest (IGUIObject *&pObject) |
Inputs a reference pointer, checks if the new inputted object if hovered, if so, then check if this's Z value is greater than the inputted object... More... | |
bool | IsRootObject () const |
PSRETURN | LogInvalidSettings (const CStr8 &Setting) const |
Logs an invalid setting search and returns the correct return result. More... | |
void | TraceMember (JSTracer *trc) |
static void | Trace (JSTracer *trc, void *data) |
Base settings, all objects possess these settings in their m_BaseSettings Instructions can be found in the documentations.
GUI object such as a button or an input-box. Abstract data type !
IGUIObject::IGUIObject | ( | ) |
|
virtual |
void IGUIObject::AddChild | ( | IGUIObject * | pChild | ) |
Notice nothing will be returned or thrown if the child hasn't been inputted into the GUI yet.
This is because that's were all is checked. Now we're just linking two objects, but it's when we're inputting them into the GUI we'll check validity! Notice also when adding it to the GUI this function will inevitably have been called by CGUI::AddObject which will catch the throw and return the error code. i.e. The user will never put in the situation wherein a throw must be caught, the GUI's internal error handling will be completely transparent to the interfacially sequential model.
pChild | Child to add |
PSERROR_GUI | from CGUI::UpdateObjects(). |
|
protected |
Add a setting to m_Settings.
Type | Setting type |
Name | Setting reference name |
void IGUIObject::AddToPointersMap | ( | map_pObjects & | ObjectMap | ) |
Adds object and its children to the map, it's name being the first part, and the second being itself.
ObjectMap | Adds this to the map_pObjects. |
PSERROR_GUI_ObjectNeedsName | Name is missing |
PSERROR_GUI_NameAmbiguity | Name is already taken |
|
inline |
|
private |
Inputs a reference pointer, checks if the new inputted object if hovered, if so, then check if this's Z value is greater than the inputted object...
If so then the object is closer and we'll replace the pointer with this. Also Notice input can be NULL, which means the Z value demand is out. NOTICE you can't input NULL as const so you'll have to set an object to NULL.
pObject | Object pointer, can be either the old one, or the new one. |
|
protectedvirtual |
Calls Destroy on all children, and deallocates all memory.
MEGA TODO Should it destroy it's children?
Reimplemented in CMiniMap.
|
protectedpure virtual |
Draws the object.
PSERROR | if any. But this will mostlikely be very rare since if an object is drawn unsuccessfully it'll probably only output in the Error log, and not disrupt the whole GUI drawing. |
Implemented in CGUIDummyObject, CInput, CDropDown, CList, CText, CChart, CCheckBox, CButton, CImage, CTooltip, IGUIScrollBarOwner, CProgressBar, and CMiniMap.
|
inline |
|
protectedvirtual |
Returns not the Z value, but the actual buffered Z value, i.e.
if it's defined relative, then it will check its parent's Z value and add the relativity.
Reimplemented in CDropDown.
|
inline |
|
inline |
JSObject * IGUIObject::GetJSObject | ( | ) |
Retrieves the JSObject representing this GUI object.
|
inline |
Get object name, name is unique.
|
protected |
NOTE! This will not just return m_pParent, when that is need use it! There is one exception to it, when the parent is the top-node (the object that isn't a real object), this will return NULL, so that the top-node's children are seemingly parentless.
CStr IGUIObject::GetPresentableName | ( | ) | const |
PSRETURN IGUIObject::GetSettingType | ( | const CStr & | Setting, |
EGUISettingType & | Type | ||
) | const |
Retrieves the type of a named setting.
Setting | Setting by name |
Type | Stores an EGUISettingType |
|
inlineprotectedvirtual |
Handle additional children to the <object>-tag.
In IGUIObject, this function does nothing. In CList and CDropDown, it handles the <item>, used to build the data.
Returning false means the object doesn't recognize the child. Should be reported. Notice 'false' is default, because an object not using this function, should not have any additional children (and this function should never be called).
|
inlinevirtual |
This function is called with different messages for instance when the mouse enters the object.
Message | GUI Message |
Reimplemented in CDropDown, CInput, CList, IGUITextOwner, IGUIButtonBehavior, CText, COList, CChart, CCheckBox, CProgressBar, IGUIScrollBarOwner, CButton, CTooltip, CMiniMap, and CRadioButton.
|
protected |
Check if object is focused.
|
private |
|
protected |
Loads a style.
GUIinstance | Reference to the GUI |
StyleName | Style by name |
|
protected |
Loads a style.
Style | The style object. |
|
private |
Logs an invalid setting search and returns the correct return result.
|
inlineprotectedvirtual |
Some objects need to handle the SDL_Event_ manually.
For instance the input box.
Only the object with focus will have this function called.
Returns either IN_PASS or IN_HANDLED. If IN_HANDLED, then the key won't be passed on and processed by other handlers. This is used for keys that the GUI uses.
|
virtual |
Checks if mouse is hovering this object.
The mouse position is cached in CGUI.
This function checks if the mouse is hovering the rectangle that the base setting "size" makes. Although it is virtual, so one could derive an object from CButton, which changes only this to checking the circle that "size" makes.
Reimplemented in CGUIDummyObject, CDropDown, and CMiniMap.
|
virtual |
Test if mouse position is over an icon.
Reimplemented in IGUITextOwner, and CText.
void IGUIObject::RegisterScriptHandler | ( | const CStr & | Action, |
const CStr & | Code, | ||
CGUI * | pGUI | ||
) |
Set the script handler for a particular object-specific action.
Action | Name of action |
Code | Javascript code to execute when the action occurs |
pGUI | GUI instance to associate the script with |
|
inlineprotectedvirtual |
Reset internal state of this object.
Reimplemented in IGUIButtonBehavior, IGUIScrollBarOwner, CInput, CList, CCheckBox, CButton, and CText.
|
protected |
Execute the script for a particular action.
Does nothing if no script has been registered for that action. The mouse coordinates will be passed as the first argument.
Action | Name of action |
|
protected |
Execute the script for a particular action.
Does nothing if no script has been registered for that action.
Action | Name of action |
Argument | Argument to pass to action |
|
protected |
void IGUIObject::SetFocus | ( | ) |
Take focus!
|
protected |
|
inline |
Get object name.
|
inlineprotected |
Set parent of this object.
|
protected |
PSRETURN IGUIObject::SetSetting | ( | const CStr & | Setting, |
const CStrW & | Value, | ||
const bool & | SkipMessage = false |
||
) |
Set a setting by string, regardless of what type it is.
example a CRect(10,10,20,20) would be "10 10 20 20"
Setting | Setting by name |
Value | Value to set to |
SkipMessage | Does not send a GUIM_SETTINGS_UPDATED if true |
bool IGUIObject::SettingExists | ( | const CStr & | Setting | ) | const |
Checks if settings exists, only available for derived classes that has this set up, that's why the base class just returns false.
Setting | setting name |
|
inlinestaticprivate |
|
private |
|
virtual |
All sizes are relative to resolution, and the calculation is not wanted in real time, therefore it is cached, update the cached size with this function.
Reimplemented in CInput, and IGUITextOwner.
|
protected |
Inputes the object that is currently hovered, this function updates this object accordingly (i.e.
if it's the object being inputted one thing happens, and not, another).
pMouseOver | Object that is currently hovered, can OF COURSE be NULL too! |
|
friend |
|
friend |
|
friend |
|
friend |
|
friend |
|
friend |
|
friend |
|
protected |
Cached size, real size m_Size is actually dependent on resolution and can have different real outcomes, this is the real outcome cached to avoid slow calculations in real time.
|
protected |
|
private |
|
protected |
|
protected |
This is an array of true or false, each element is associated with a string representing a setting.
Number of elements is equal to number of settings.
A true means the setting has been manually set in the file when read. This is important to know because I don't want to force the user to include its <styles>-XML-files first, so somehow the GUI needs to know which settings were set, and which is meant to.
|
protected |
|
private |
|
protected |
|
private |
std::map<CStr, SGUISetting> IGUIObject::m_Settings |
Settings pool, all an object's settings are located here If a derived object has got more settings that the base settings, it's because they have a new version of the function SetupSettings().