25#ifndef INCLUDED_IGUIOBJECT
26#define INCLUDED_IGUIOBJECT
50#define GUI_OBJECT(obj) \
52 static IGUIObject* ConstructObject(CGUI& pGUI) \
53 { return new obj(pGUI); }
166 void PlaySound(
const CStrW& soundPath)
const;
249 template<
typename... Args>
254 if (isRestricted && (this->*isRestricted)())
257 (this->*callbackFunction)(args...);
261 obj->RecurseObject(isRestricted, callbackFunction, args...);
409 void ScriptEvent(
const CStr& eventName,
const JS::HandleValueArray& paramData);
483 static void Trace(JSTracer* trc,
void* data)
EGUIMessageType
Message types.
Definition: SGUIMessage.h:28
Definition: Canvas2D.h:36
Manages a hotkey setting for a GUI object.
Definition: CGUIHotkey.h:32
void Set(T value, bool sendMessage)
'Uglified' operator=, so that SendMessage is explicit.
Definition: CGUISetting.h:115
This class represents a rectangle relative to a parent rectangle The value can be initialized from a ...
Definition: CGUISize.h:30
The main object that represents a whole GUI page.
Definition: CGUI.h:61
Rectangle class used for screen rectangles.
Definition: Rect.h:31
GUI object such as a button or an input-box.
Definition: IGUIObject.h:60
CGUISimpleSetting< bool > m_Ghost
Definition: IGUIObject.h:535
CGUIHotkey m_Hotkey
Definition: IGUIObject.h:532
void UnsetScriptHandler(const CStr &eventName)
Deletes an event handler assigned to the given name, if such a handler exists.
Definition: IGUIObject.cpp:321
bool ApplyStyle(const CStr &StyleName)
Applies the given style to the object.
Definition: IGUIObject.cpp:240
virtual void Tick()
Called on every GUI tick unless the object or one of its parent is hidden/ghost.
Definition: IGUIObject.h:234
bool SetSettingFromString(const CStr &Setting, const CStrW &Value, const bool SendMessage)
Set a setting by string, regardless of what type it is.
Definition: IGUIObject.cpp:107
IGUIObject * GetParent() const
NOTE! This will not just return m_pParent, when that is need use it! There is one exception to it,...
Definition: IGUIObject.cpp:187
virtual float GetBufferedZ() const
Returns not the Z value, but the actual buffered Z value, i.e.
Definition: IGUIObject.cpp:262
void ScriptEvent(const CStr &eventName)
Execute the script for a particular action.
Definition: IGUIObject.cpp:387
bool IsRootObject() const
Returns whether this object is a child of the base object.
Definition: IGUIObject.cpp:491
virtual void AdditionalChildrenHandled()
Allow the GUI object to process after all child items were handled.
Definition: IGUIObject.h:373
CGUISimpleSetting< CStr > m_Style
Definition: IGUIObject.h:531
const CStr & GetName() const
Get object name, name is unique.
Definition: IGUIObject.h:103
CGUISimpleSetting< bool > m_Enabled
Definition: IGUIObject.h:528
bool IsBaseObject() const
Returns whether this is the object all other objects are descendants of.
Definition: IGUIObject.cpp:486
virtual InReaction PreemptEvent(const SDL_Event_ *ev)
Some objects need to be able to pre-emptively process SDL_Event_.
Definition: IGUIObject.h:278
virtual void HandleMessage(SGUIMessage &Message)
This function is called with different messages for instance when the mouse enters the object.
Definition: IGUIObject.h:242
void SetFocus()
Take focus!
Definition: IGUIObject.cpp:471
virtual void ResetStates()
Reset internal state of this object.
Definition: IGUIObject.cpp:197
CGUI & GetGUI()
Definition: IGUIObject.h:326
CGUISimpleSetting< float > m_Z
Definition: IGUIObject.h:533
CRect m_CachedActualSize
Cached size, real size m_Size is actually dependent on resolution and can have different real outcome...
Definition: IGUIObject.h:380
void UnregisterChild(IGUIObject *child)
Remove an object from the hierarchy.
Definition: IGUIObject.cpp:76
static void Trace(JSTracer *trc, void *data)
Definition: IGUIObject.h:483
std::map< CStr, IGUISetting * > m_Settings
Settings pool, all an object's settings are located here.
Definition: IGUIObject.h:517
virtual bool HandleAdditionalChildren(const XMBData &file, const XMBElement &child)
Handle additional children to the <object>-tag.
Definition: IGUIObject.h:364
std::vector< IGUIObject * > m_Children
Definition: IGUIObject.h:500
void TraceMember(JSTracer *trc)
Definition: IGUIObject.cpp:496
bool IsEnabled() const
Returns whether this object is set to be hidden or ghost.
Definition: IGUIObject.cpp:437
static const CStr EventNameMouseMove
Definition: IGUIObject.h:493
void ReleaseFocus()
Release focus.
Definition: IGUIObject.cpp:476
void SettingChanged(const CStr &Setting, const bool SendMessage)
Updates some internal data depending on the setting changed.
Definition: IGUIObject.cpp:118
std::map< CStr, JS::Heap< JSObject * > > m_ScriptHandlers
Definition: IGUIObject.h:523
InReaction SendMouseEvent(EGUIMessageType type, const CStr &eventName)
Same as SendEvent, but passes mouse coordinates and button state as an argument.
Definition: IGUIObject.cpp:358
static const CStr EventNameMouseLeave
Definition: IGUIObject.h:494
void SetScriptHandler(const CStr &eventName, JS::HandleObject Function)
Assigns a JS function to the event name.
Definition: IGUIObject.cpp:310
IGUIObject(CGUI &pGUI)
Definition: IGUIObject.cpp:43
void UpdateMouseOver(IGUIObject *const &pMouseOver)
Inputes the object that is currently hovered, this function updates this object accordingly (i....
Definition: IGUIObject.cpp:146
bool SettingExists(const CStr &Setting) const
Returns whether there is a setting with the given name registered.
Definition: IGUIObject.cpp:102
virtual const CStr & GetTooltipStyle() const
Definition: IGUIObject.h:195
virtual bool IsMouseHovering() const
This function returns true if the mouse is hovering over this GUI object and if this GUI object is th...
Definition: IGUIObject.h:95
void SetHidden(bool hidden)
Definition: IGUIObject.h:156
bool IsFocused() const
Check if object is focused.
Definition: IGUIObject.cpp:481
virtual void Draw(CCanvas2D &canvas)=0
Draws the object.
CGUISimpleSetting< CStrW > m_Tooltip
Definition: IGUIObject.h:537
CStr GetPresentableName() const
Definition: IGUIObject.cpp:458
virtual const CStrW & GetTooltipText() const
Definition: IGUIObject.h:194
void SetParent(IGUIObject *pParent)
Set parent of this object.
Definition: IGUIObject.h:322
virtual InReaction ManuallyHandleKeys(const SDL_Event_ *ev)
Some objects need to handle the text-related SDL_Event_ manually.
Definition: IGUIObject.h:290
static const CStr EventNameMouseEnter
Definition: IGUIObject.h:492
void RecurseObject(bool(IGUIObject::*isRestricted)() const, void(IGUIObject::*callbackFunction)(Args... args), Args &&... args)
Calls an IGUIObject member function recursively on this object and its children.
Definition: IGUIObject.h:250
void PlaySound(const CStrW &soundPath) const
Retrieves the configured sound filename from the given setting name and plays that once.
Definition: IGUIObject.cpp:452
CGUISimpleSetting< CGUISize > m_Size
Definition: IGUIObject.h:530
JSObject * GetJSObject()
Retrieves the JSObject representing this GUI object.
Definition: IGUIObject.cpp:427
virtual void UpdateCachedSize()
All sizes are relative to resolution, and the calculation is not wanted in real time,...
Definition: IGUIObject.cpp:203
CRect GetComputedSize()
Updates and returns the size of the object.
Definition: IGUIObject.cpp:233
double m_LastClickTime[6]
Definition: IGUIObject.h:506
void RegisterSetting(const CStr &Name, IGUISetting *setting)
Registers the given setting with the GUI object.
Definition: IGUIObject.cpp:86
CGUISimpleSetting< bool > m_Hidden
Definition: IGUIObject.h:529
InReaction SendEvent(EGUIMessageType type, const CStr &eventName)
Send event to this GUI object (HandleMessage and ScriptEvent)
Definition: IGUIObject.cpp:344
CGUISimpleSetting< bool > m_Absolute
Definition: IGUIObject.h:534
virtual void CreateJSObject()
Creates the JS object representing this page upon first use.
std::unique_ptr< IGUIProxyObject > m_JSObject
Definition: IGUIObject.h:526
void SetName(const CStr &Name)
Get object name.
Definition: IGUIObject.h:106
const CGUI & GetGUI() const
Definition: IGUIObject.h:327
void RegisterChild(IGUIObject *child)
Add an object to the hierarchy.
Definition: IGUIObject.cpp:70
bool IsHiddenOrGhost() const
Returns whether this object is set to be hidden or ghost.
Definition: IGUIObject.cpp:447
CGUI & m_pGUI
Definition: IGUIObject.h:520
bool ScriptEventWithReturn(const CStr &eventName)
Execute the script for a particular action.
Definition: IGUIObject.cpp:392
void RegisterScriptHandler(const CStr &eventName, const CStr &Code, CGUI &pGUI)
Set the script handler for a particular object-specific action.
Definition: IGUIObject.cpp:276
IGUIObject * m_pParent
Definition: IGUIObject.h:503
void ChooseMouseOverAndClosest(IGUIObject *&pObject)
Inputs a reference pointer, checks if the new inputted object if hovered, if so, then check if this's...
Definition: IGUIObject.cpp:167
CGUISimpleSetting< CStr > m_TooltipStyle
Definition: IGUIObject.h:538
virtual bool IsMouseOver() const
This function checks if the mouse is hovering the rectangle that the base setting "size" makes.
Definition: IGUIObject.cpp:141
CStr m_Name
Definition: IGUIObject.h:497
void ReregisterSetting(const CStr &Name, IGUISetting *setting)
Definition: IGUIObject.cpp:94
bool m_MouseHovering
This variable is true if the mouse is hovering this object and this object is the topmost object show...
Definition: IGUIObject.h:512
const std::vector< IGUIObject * > & GetChildren() const
Return all child objects of the current object.
Definition: IGUIObject.h:115
virtual ~IGUIObject()
Definition: IGUIObject.cpp:62
bool IsHidden() const
Returns whether this is object is set to be hidden.
Definition: IGUIObject.cpp:442
CGUISimpleSetting< float > m_AspectRatio
Definition: IGUIObject.h:536
JS GUI proxies need to store some private data.
Definition: JSInterface_GUIProxy.h:47
This setting interface allows GUI objects to call setting function functions without having to know t...
Definition: CGUISetting.h:33
Handles the js interface with C++ GUI objects.
Definition: JSInterface_GUIProxy.h:121
Definition: XMBData.h:136
#define UNUSED(param)
mark a function parameter as unused and avoid the corresponding compiler warning.
Definition: code_annotation.h:40
Message send to IGUIObject::HandleMessage() in order to give life to Objects manually with a derived ...
Definition: SGUIMessage.h:68