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