Overview   Project   Class   Tree   Deprecated   Index 
0 A.D.
FRAMES    NO FRAMES
SUMMARY:  INNER | FIELD | CONSTR | METHOD

gui
Class IGUIObject

   in IGUIObject.h
   in IGUIObject.cpp
Direct Known Subclasses:
CGUIDummyObject, CImage, CMiniMap, CProgressBar

class IGUIObject

GUI object such as a button or an input-box. Abstract data type !


Field Summary
protected 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.
protected vector_pObjects m_Children
          
private JSObject* m_JSObject
          
protected double[ 6 ] m_LastClickTime
          
protected bool m_MouseHovering
          This is an array of true or false, each element is associated with a string representing a setting.
protected CStr m_Name
          
private CGUI* m_pGUI
          
protected IGUIObject* m_pParent
          
private std::map< CStr, JSObject** > m_ScriptHandlers
          
 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().
 
Constructor Summary
IGUIObject()
          
virtual ~IGUIObject()
          
 
Method Summary
 void AddChild( IGUIObject* pChild )
          Notice nothing will be returned or thrown if the child hasn't been inputted into the GUI yet.
protected void AddSetting( const EGUISettingType& Type, const CStr& Name )
          Add a setting to m_Settings
 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.
 void CheckSettingsValidity()
          Should be called every time the settings has been updated will also send a message GUIM_SETTINGS_UPDATED, so that if a derived object wants to add things to be updated, they add it in that message part, this is a better solution than making this virtual, since the updates that the base class does, are the most essential.
 vector_pObjects::iterator ChildrenItBegin()
          
 vector_pObjects::iterator ChildrenItEnd()
          
private 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.
protected virtual void Destroy()
          Calls Destroy on all children, and deallocates all memory.
protected virtual void Draw()= 0
          Draws the object.
protected virtual float GetBufferedZ() const
          Returns not the Z value, but the actual buffered Z value, i.
protected const CGUI* GetGUI() const
          
 JSObject* GetJSObject()
          Retrieves the JSObject representing this GUI object.
protected CPos GetMousePos() const
          Get Mouse from CGUI.
 const CStr& GetName() const
          Get object name
protected 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.
 CStr GetPresentableName() const
          
 PS_RESULT GetSettingType( const CStr& Setting, EGUISettingType& Type ) const
          Retrieves the type of a named setting.
protected virtual bool HandleAdditionalChildren( const XMBElement& UNUSED( child ), CXeromyces* UNUSED( pFile ) )
          Handle additional children to the -tag.
protected virtual void HandleMessage( const SGUIMessage& UNUSED( Message ) )
          This function is called with different messages for instance when the mouse enters the object.
protected bool IsFocused() const
          Check if object is focused.
private bool IsRootObject() const
          
protected void LoadStyle( CGUI& GUIinstance, const CStr& StyleName )
          Loads a style.
protected void LoadStyle( const SGUIStyle& Style )
          Loads a style.
protected virtual InReaction ManuallyHandleEvent( const SDL_Event_* UNUSED( ev ) )
          Some objects need to handle the SDL_Event_ manually.
 virtual bool MouseOver()
          Get object name, name is unique
 void RegisterScriptHandler( const CStr& Action, const CStr& Code, CGUI* pGUI )
          Set the script handler for a particular object-specific action
protected virtual void ResetStates()
          
protected void ScriptEvent( const CStr& Action )
          Execute the script for a particular action.
protected void SetFocus()
          Take focus!
protected void SetGUI( CGUI* const& pGUI )
          
 void SetName( const CStr& Name )
          
protected void SetParent( IGUIObject* pParent )
          
protected void SetScriptHandler( const CStr& Action, JSObject* Function )
          
 PS_RESULT SetSetting( const CStr& Setting, const CStr& Value, const bool& SkipMessage = false )
          Set a setting by string, regardless of what type it is.
 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
 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.
private void UpdateMouseOver( IGUIObject* const& pMouseOver )
          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).
 

Field Detail

m_CachedActualSize

protected 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.

m_Children

protected vector_pObjects m_Children;

m_JSObject

private JSObject* m_JSObject;

m_LastClickTime

protected double m_LastClickTime[ 6 ];

m_MouseHovering

protected bool m_MouseHovering;
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 -XML-files first, so somehow the GUI needs to know which settings were set, and which is meant to

m_Name

protected CStr m_Name;

m_pGUI

private CGUI* m_pGUI;

m_pParent

protected IGUIObject* m_pParent;

m_ScriptHandlers

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

m_Settings

public 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().
See Also:
SetupSettings()


Constructor Detail

IGUIObject

public IGUIObject();

~IGUIObject

public virtual ~IGUIObject();


Method Detail

AddChild

public void 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:
pChild - Child to add
Throws:
PS_RESULT - from CGUI::UpdateObjects().

AddSetting

protected void AddSetting( const EGUISettingType& Type, const CStr& Name );
Add a setting to m_Settings
Parameters:
Type - Setting type
Name - Setting reference name

AddToPointersMap

public 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.
Parameters:
ObjectMap - Adds this to the map_pObjects.
Throws:
PS_NEEDS_NAME - Name is missing
PS_NAME_AMBIGUITY - Name is already taken

CheckSettingsValidity

public void CheckSettingsValidity();
Should be called every time the settings has been updated will also send a message GUIM_SETTINGS_UPDATED, so that if a derived object wants to add things to be updated, they add it in that message part, this is a better solution than making this virtual, since the updates that the base class does, are the most essential. This is not private since there should be no harm in checking validity.
Throws:
TODO - not quite settled yet.

ChildrenItBegin

public vector_pObjects::iterator ChildrenItBegin();

ChildrenItEnd

public vector_pObjects::iterator ChildrenItEnd();

ChooseMouseOverAndClosest

private 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... 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:
pObject - Object pointer, can be either the old one, or the new one.

Destroy

protected virtual void Destroy();
Calls Destroy on all children, and deallocates all memory. MEGA TODO Should it destroy it's children?

Draw

protected virtual void Draw()= 0;
Draws the object.
Throws:
PS_RESULT - 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.

GetBufferedZ

protected virtual float GetBufferedZ() const;
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.

GetGUI

protected const CGUI* GetGUI() const;

GetJSObject

public JSObject* GetJSObject();
Retrieves the JSObject representing this GUI object.

GetMousePos

protected CPos GetMousePos() const;
Get Mouse from CGUI.

GetName

public const CStr& GetName() const;
Get object name

GetParent

protected 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.
Returns:
Pointer to parent

GetPresentableName

public CStr GetPresentableName() const;

GetSettingType

public PS_RESULT GetSettingType( const CStr& Setting, EGUISettingType& Type ) const;
Retrieves the type of a named setting.
Parameters:
Setting - Setting by name
Type - Stores an EGUISettingType
Returns:
PS_RESULT (PS_OK if successful)

HandleAdditionalChildren

protected virtual bool HandleAdditionalChildren( const XMBElement& UNUSED( child ), CXeromyces* UNUSED( pFile ) );
Handle additional children to the -tag. In IGUIObject, this function does nothing. In CList and CDropDown, it handles the , 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).

HandleMessage

protected virtual void HandleMessage( const SGUIMessage& UNUSED( Message ) );
This function is called with different messages for instance when the mouse enters the object.
Parameters:
Message - GUI Message

IsFocused

protected bool IsFocused() const;
Check if object is focused.

IsRootObject

private bool IsRootObject() const;

LoadStyle

protected void LoadStyle( CGUI& GUIinstance, const CStr& StyleName );
Loads a style.
Parameters:
GUIinstance - Reference to the GUI
StyleName - Style by name

LoadStyle

protected void LoadStyle( const SGUIStyle& Style );
Loads a style.
Parameters:
Style - The style object.

ManuallyHandleEvent

protected virtual InReaction ManuallyHandleEvent( const SDL_Event_* UNUSED( ev ) );
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.

MouseOver

public virtual bool MouseOver();
Get object name, name is unique

RegisterScriptHandler

public void RegisterScriptHandler( const CStr& Action, const CStr& Code, CGUI* pGUI );
Set the script handler for a particular object-specific action
Parameters:
Action - Name of action
Code - Javascript code to execute when the action occurs
pGUI - GUI instance to associate the script with

ResetStates

protected virtual void ResetStates();

ScriptEvent

protected void ScriptEvent( const CStr& Action );
Execute the script for a particular action. Does nothing if no script has been registered for that action.
Parameters:
Action - Name of action

SetFocus

protected void SetFocus();
Take focus!

SetGUI

protected void SetGUI( CGUI* const& pGUI );

SetName

public void SetName( const CStr& Name );

SetParent

protected void SetParent( IGUIObject* pParent );

SetScriptHandler

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

SetSetting

public PS_RESULT SetSetting( const CStr& Setting, const CStr& 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:
Setting - Setting by name
Value - Value to set to
Returns:
PS_RESULT (PS_OK if successful)

SettingExists

public 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
Parameters:
Setting - setting name
Returns:
True if settings exist.

UpdateCachedSize

public 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.

UpdateMouseOver

private void UpdateMouseOver( IGUIObject* const& pMouseOver );
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:
pMouseOver - Object that is currently hovered, can OF COURSE be NULL too!

 Overview   Project   Class   Tree   Deprecated   Index 
0 A.D.
Generated on September 04, 2007 at 18:13
CppDoc v2.4.0
FRAMES    NO FRAMES
SUMMARY:  INNER | FIELD | CONSTR | METHOD