Pyrogenesis  13997
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Member Functions | Friends | List of all members
IGUIObject Class Referenceabstract

Base settings, all objects possess these settings in their m_BaseSettings Instructions can be found in the documentations. More...

#include <IGUIObject.h>

Inheritance diagram for IGUIObject:
CGUIDummyObject CImage CMiniMap CProgressBar IGUIButtonBehavior IGUIScrollBarOwner IGUITextOwner CButton CCheckBox CInput CList CText CButton CCheckBox CList CText CTooltip

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
vector_pObjects::iterator ChildrenItBegin ()
 
vector_pObjects::iterator ChildrenItEnd ()
 
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
 
JSBool JSI_IGUIObject::getProperty (JSContext *cx, JSObject *obj, jsid id, jsval *vp)
 
JSBool JSI_IGUIObject::setProperty (JSContext *cx, JSObject *obj, jsid id, JSBool strict, jsval *vp)
 
JSBool JSI_IGUIObject::getComputedSize (JSContext *cx, uintN 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...
 
CGUIGetGUI ()
 
const CGUIGetGUI () 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...
 
IGUIObjectGetParent () 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, const CScriptValRooted &Argument)
 Execute the script for a particular action. More...
 
void SetScriptHandler (const CStr &Action, JSObject *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
 
IGUIObjectm_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, SGUISettingm_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...
 
CGUIm_pGUI
 
std::map< CStr, JSObject ** > m_ScriptHandlers
 
JSObject * 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...
 

Detailed Description

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 !

Definition at line 140 of file IGUIObject.h.

Constructor & Destructor Documentation

IGUIObject::IGUIObject ( )

Definition at line 43 of file IGUIObject.cpp.

IGUIObject::~IGUIObject ( )
virtual

Definition at line 70 of file IGUIObject.cpp.

Member Function Documentation

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.

Parameters
pChildChild to add
Exceptions
PSERROR_GUIfrom CGUI::UpdateObjects().

Definition at line 104 of file IGUIObject.cpp.

void IGUIObject::AddSetting ( const EGUISettingType Type,
const CStr &  Name 
)
protected

Add a setting to m_Settings.

Parameters
TypeSetting type
NameSetting reference name

Definition at line 172 of file IGUIObject.cpp.

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.

Parameters
ObjectMapAdds this to the map_pObjects.
Exceptions
PSERROR_GUI_ObjectNeedsNameName is missing
PSERROR_GUI_NameAmbiguityName is already taken

Definition at line 138 of file IGUIObject.cpp.

vector_pObjects::iterator IGUIObject::ChildrenItBegin ( )
inline

Definition at line 225 of file IGUIObject.h.

vector_pObjects::iterator IGUIObject::ChildrenItEnd ( )
inline

Definition at line 226 of file IGUIObject.h.

void IGUIObject::ChooseMouseOverAndClosest ( IGUIObject *&  pObject)
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.

Parameters
pObjectObject pointer, can be either the old one, or the new one.

Definition at line 303 of file IGUIObject.cpp.

void IGUIObject::Destroy ( )
protectedvirtual

Calls Destroy on all children, and deallocates all memory.

MEGA TODO Should it destroy it's children?

Reimplemented in CMiniMap.

Definition at line 161 of file IGUIObject.cpp.

virtual void IGUIObject::Draw ( )
protectedpure virtual

Draws the object.

Exceptions
PSERRORif 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, CList, CText, CDropDown, CCheckBox, CButton, CImage, IGUIScrollBarOwner, CProgressBar, CTooltip, and CMiniMap.

float IGUIObject::GetBufferedZ ( ) const
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.

Returns
Actual Z value on the screen.

Reimplemented in CDropDown.

Definition at line 406 of file IGUIObject.cpp.

CGUI* IGUIObject::GetGUI ( )
inline

Definition at line 388 of file IGUIObject.h.

const CGUI* IGUIObject::GetGUI ( ) const
inline

Definition at line 389 of file IGUIObject.h.

JSObject * IGUIObject::GetJSObject ( )

Retrieves the JSObject representing this GUI object.

Definition at line 522 of file IGUIObject.cpp.

CPos IGUIObject::GetMousePos ( ) const
protected

Get Mouse from CGUI.

Definition at line 207 of file IGUIObject.cpp.

const CStr& IGUIObject::GetName ( ) const
inline

Get object name, name is unique.

Definition at line 181 of file IGUIObject.h.

IGUIObject * IGUIObject::GetParent ( ) const
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.

Returns
Pointer to parent

Definition at line 323 of file IGUIObject.cpp.

CStr IGUIObject::GetPresentableName ( ) const

Definition at line 536 of file IGUIObject.cpp.

PSRETURN IGUIObject::GetSettingType ( const CStr &  Setting,
EGUISettingType Type 
) const

Retrieves the type of a named setting.

Parameters
SettingSetting by name
TypeStores an EGUISettingType
Returns
PSRETURN (PSRETURN_OK if successful)

Definition at line 285 of file IGUIObject.cpp.

virtual bool IGUIObject::HandleAdditionalChildren ( const XMBElement child,
CXeromyces pFile 
)
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).

Reimplemented in CList.

Definition at line 426 of file IGUIObject.h.

virtual void IGUIObject::HandleMessage ( SGUIMessage Message)
inlinevirtual

This function is called with different messages for instance when the mouse enters the object.

Parameters
MessageGUI Message

Reimplemented in CList, CInput, CText, CDropDown, CCheckBox, CProgressBar, IGUIScrollBarOwner, IGUITextOwner, CButton, IGUIButtonBehavior, CRadioButton, CTooltip, and CMiniMap.

Definition at line 322 of file IGUIObject.h.

bool IGUIObject::IsFocused ( ) const
protected

Check if object is focused.

Definition at line 554 of file IGUIObject.cpp.

bool IGUIObject::IsRootObject ( ) const
private

Definition at line 559 of file IGUIObject.cpp.

void IGUIObject::LoadStyle ( CGUI GUIinstance,
const CStr &  StyleName 
)
protected

Loads a style.

Parameters
GUIinstanceReference to the GUI
StyleNameStyle by name

Definition at line 375 of file IGUIObject.cpp.

void IGUIObject::LoadStyle ( const SGUIStyle Style)
protected

Loads a style.

Parameters
StyleThe style object.

Definition at line 388 of file IGUIObject.cpp.

PSRETURN IGUIObject::LogInvalidSettings ( const CStr8 &  Setting) const
private

Logs an invalid setting search and returns the correct return result.

Returns
the error result

Definition at line 564 of file IGUIObject.cpp.

virtual InReaction IGUIObject::ManuallyHandleEvent ( const SDL_Event_ ev)
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.

Reimplemented in CList, CInput, and CDropDown.

Definition at line 345 of file IGUIObject.h.

bool IGUIObject::MouseOver ( )
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.

Returns
true if mouse is hovering

Reimplemented in CGUIDummyObject, and CDropDown.

Definition at line 194 of file IGUIObject.cpp.

bool IGUIObject::MouseOverIcon ( )
virtual

Test if mouse position is over an icon.

Reimplemented in IGUITextOwner, and CText.

Definition at line 202 of file IGUIObject.cpp.

void IGUIObject::RegisterScriptHandler ( const CStr &  Action,
const CStr &  Code,
CGUI pGUI 
)

Set the script handler for a particular object-specific action.

Parameters
ActionName of action
CodeJavascript code to execute when the action occurs
pGUIGUI instance to associate the script with

Definition at line 430 of file IGUIObject.cpp.

virtual void IGUIObject::ResetStates ( )
inlineprotectedvirtual

Reset internal state of this object.

Reimplemented in IGUIButtonBehavior, IGUIScrollBarOwner, CInput, CList, CText, CCheckBox, and CButton.

Definition at line 381 of file IGUIObject.h.

void IGUIObject::ScriptEvent ( const CStr &  Action)
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.

Parameters
ActionName of action

Definition at line 480 of file IGUIObject.cpp.

void IGUIObject::ScriptEvent ( const CStr &  Action,
const CScriptValRooted Argument 
)
protected

Execute the script for a particular action.

Does nothing if no script has been registered for that action.

Parameters
ActionName of action
ArgumentArgument to pass to action

Definition at line 504 of file IGUIObject.cpp.

InReaction IGUIObject::SendEvent ( EGUIMessageType  type,
const CStr &  EventName 
)
protected

Send event to this GUI object (HandleMessage and ScriptEvent)

Parameters
typeType of GUI message to be handled
EventNameString representation of event name
Returns
IN_HANDLED if event was handled, or IN_PASS if skipped

Definition at line 466 of file IGUIObject.cpp.

void IGUIObject::SetFocus ( )

Take focus!

Definition at line 549 of file IGUIObject.cpp.

void IGUIObject::SetGUI ( CGUI *const &  pGUI)
inlineprotected

Definition at line 371 of file IGUIObject.h.

void IGUIObject::SetName ( const CStr &  Name)
inline

Get object name.

Definition at line 184 of file IGUIObject.h.

void IGUIObject::SetParent ( IGUIObject pParent)
inlineprotected

Set parent of this object.

Definition at line 376 of file IGUIObject.h.

void IGUIObject::SetScriptHandler ( const CStr &  Action,
JSObject *  Function 
)
protected

Definition at line 452 of file IGUIObject.cpp.

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"

Parameters
SettingSetting by name
ValueValue to set to
SkipMessageDoes not send a GUIM_SETTINGS_UPDATED if true
Returns
PSRETURN (PSRETURN_OK if successful)

Definition at line 260 of file IGUIObject.cpp.

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.

Parameters
Settingsetting name
Returns
True if settings exist.

Definition at line 239 of file IGUIObject.cpp.

void IGUIObject::UpdateCachedSize ( )
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.

Definition at line 336 of file IGUIObject.cpp.

void IGUIObject::UpdateMouseOver ( IGUIObject *const &  pMouseOver)
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).

Parameters
pMouseOverObject that is currently hovered, can OF COURSE be NULL too!

Definition at line 212 of file IGUIObject.cpp.

Friends And Related Function Documentation

friend class CGUI
friend

Definition at line 142 of file IGUIObject.h.

friend class CInternalCGUIAccessorBase
friend

Definition at line 143 of file IGUIObject.h.

friend class GUITooltip
friend

Definition at line 145 of file IGUIObject.h.

friend class IGUIScrollBar
friend

Definition at line 144 of file IGUIObject.h.

JSBool JSI_IGUIObject::getComputedSize ( JSContext *  cx,
uintN  argc,
jsval *  vp 
)
friend
JSBool JSI_IGUIObject::getProperty ( JSContext *  cx,
JSObject *  obj,
jsid  id,
jsval *  vp 
)
friend
JSBool JSI_IGUIObject::setProperty ( JSContext *  cx,
JSObject *  obj,
jsid  id,
JSBool  strict,
jsval *  vp 
)
friend

Member Data Documentation

CRect IGUIObject::m_CachedActualSize
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.

Definition at line 434 of file IGUIObject.h.

vector_pObjects IGUIObject::m_Children
protected

Definition at line 516 of file IGUIObject.h.

JSObject* IGUIObject::m_JSObject
private

Definition at line 560 of file IGUIObject.h.

double IGUIObject::m_LastClickTime[6]
protected

Definition at line 522 of file IGUIObject.h.

bool IGUIObject::m_MouseHovering
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

Definition at line 539 of file IGUIObject.h.

CStr IGUIObject::m_Name
protected

Definition at line 512 of file IGUIObject.h.

CGUI* IGUIObject::m_pGUI
private

Definition at line 554 of file IGUIObject.h.

IGUIObject* IGUIObject::m_pParent
protected

Definition at line 519 of file IGUIObject.h.

std::map<CStr, JSObject**> IGUIObject::m_ScriptHandlers
private

Definition at line 557 of file IGUIObject.h.

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().

See Also
SetupSettings()

Definition at line 550 of file IGUIObject.h.


The documentation for this class was generated from the following files: