Changeset View
Changeset View
Standalone View
Standalone View
ps/trunk/source/gui/ObjectBases/IGUIObject.h
Show All 30 Lines | |||||
#include "ps/XML/Xeromyces.h" | #include "ps/XML/Xeromyces.h" | ||||
#include "scriptinterface/ScriptTypes.h" | #include "scriptinterface/ScriptTypes.h" | ||||
#include <map> | #include <map> | ||||
#include <vector> | #include <vector> | ||||
class CGUI; | class CGUI; | ||||
class IGUIObject; | class IGUIObject; | ||||
class IGUIProxyObject; | |||||
class IGUISetting; | class IGUISetting; | ||||
template <typename T> | template <typename T> | ||||
class JSI_GUIProxy; | class JSI_GUIProxy; | ||||
#define GUI_OBJECT(obj) \ | #define GUI_OBJECT(obj) \ | ||||
public: \ | public: \ | ||||
static IGUIObject* ConstructObject(CGUI& pGUI) \ | static IGUIObject* ConstructObject(CGUI& pGUI) \ | ||||
▲ Show 20 Lines • Show All 163 Lines • ▼ Show 20 Lines | public: | ||||
/** | /** | ||||
* All sizes are relative to resolution, and the calculation | * All sizes are relative to resolution, and the calculation | ||||
* is not wanted in real time, therefore it is cached, update | * is not wanted in real time, therefore it is cached, update | ||||
* the cached size with this function. | * the cached size with this function. | ||||
*/ | */ | ||||
virtual void UpdateCachedSize(); | virtual void UpdateCachedSize(); | ||||
/** | /** | ||||
* Updates and returns the size of the object. | |||||
*/ | |||||
CRect GetComputedSize(); | |||||
/** | |||||
* Reset internal state of this object. | * Reset internal state of this object. | ||||
*/ | */ | ||||
virtual void ResetStates(); | virtual void ResetStates(); | ||||
/** | /** | ||||
* Set the script handler for a particular object-specific action | * Set the script handler for a particular object-specific action | ||||
* | * | ||||
* @param eventName Name of action | * @param eventName Name of action | ||||
* @param Code Javascript code to execute when the action occurs | * @param Code Javascript code to execute when the action occurs | ||||
* @param pGUI GUI instance to associate the script with | * @param pGUI GUI instance to associate the script with | ||||
*/ | */ | ||||
void RegisterScriptHandler(const CStr& eventName, const CStr& Code, CGUI& pGUI); | void RegisterScriptHandler(const CStr& eventName, const CStr& Code, CGUI& pGUI); | ||||
/** | /** | ||||
* Retrieves the JSObject representing this GUI object. | * Retrieves the JSObject representing this GUI object. | ||||
*/ | */ | ||||
JSObject* GetJSObject(); | JSObject* GetJSObject(); | ||||
/** | |||||
* The following functions are called from JS. | |||||
*/ | |||||
void toString(ScriptInterface& scriptInterface, JS::MutableHandleValue ret); | |||||
void focus(ScriptInterface& scriptInterface, JS::MutableHandleValue ret); | |||||
void blur(ScriptInterface& scriptInterface, JS::MutableHandleValue ret); | |||||
void getComputedSize(ScriptInterface& scriptInterface, JS::MutableHandleValue ret); | |||||
//@} | //@} | ||||
protected: | protected: | ||||
//-------------------------------------------------------- | //-------------------------------------------------------- | ||||
/** @name Called by CGUI and friends | /** @name Called by CGUI and friends | ||||
* | * | ||||
* Methods that the CGUI will call using | * Methods that the CGUI will call using | ||||
* its friendship, these should not | * its friendship, these should not | ||||
* be called by user. | * be called by user. | ||||
▲ Show 20 Lines • Show All 93 Lines • ▼ Show 20 Lines | public: | ||||
CGUI& GetGUI() { return m_pGUI; } | CGUI& GetGUI() { return m_pGUI; } | ||||
const CGUI& GetGUI() const { return m_pGUI; } | const CGUI& GetGUI() const { return m_pGUI; } | ||||
/** | /** | ||||
* Take focus! | * Take focus! | ||||
*/ | */ | ||||
void SetFocus(); | void SetFocus(); | ||||
/** | |||||
* Release focus. | |||||
*/ | |||||
void ReleaseFocus(); | |||||
protected: | protected: | ||||
/** | /** | ||||
* Check if object is focused. | * Check if object is focused. | ||||
*/ | */ | ||||
bool IsFocused() const; | bool IsFocused() const; | ||||
/** | /** | ||||
* <b>NOTE!</b> This will not just return m_pParent, when that is | * <b>NOTE!</b> This will not just return m_pParent, when that is | ||||
▲ Show 20 Lines • Show All 95 Lines • ▼ Show 20 Lines | |||||
private: | private: | ||||
//-------------------------------------------------------- | //-------------------------------------------------------- | ||||
/** @name Internal functions */ | /** @name Internal functions */ | ||||
//-------------------------------------------------------- | //-------------------------------------------------------- | ||||
//@{ | //@{ | ||||
/** | /** | ||||
* Creates the JS object representing this page upon first use. | * Creates the JS object representing this page upon first use. | ||||
* This function (and its derived versions) are defined in the GUIProxy implementation file for convenience. | |||||
*/ | */ | ||||
virtual void CreateJSObject(); | virtual void CreateJSObject(); | ||||
/** | /** | ||||
* Updates some internal data depending on the setting changed. | * Updates some internal data depending on the setting changed. | ||||
*/ | */ | ||||
void PreSettingChange(const CStr& Setting); | void PreSettingChange(const CStr& Setting); | ||||
void SettingChanged(const CStr& Setting, const bool SendMessage); | void SettingChanged(const CStr& Setting, const bool SendMessage); | ||||
▲ Show 20 Lines • Show All 59 Lines • ▼ Show 20 Lines | protected: | ||||
std::map<CStr, IGUISetting*> m_Settings; | std::map<CStr, IGUISetting*> m_Settings; | ||||
// An object can't function stand alone | // An object can't function stand alone | ||||
CGUI& m_pGUI; | CGUI& m_pGUI; | ||||
// Internal storage for registered script handlers. | // Internal storage for registered script handlers. | ||||
std::map<CStr, JS::Heap<JSObject*> > m_ScriptHandlers; | std::map<CStr, JS::Heap<JSObject*> > m_ScriptHandlers; | ||||
// Cached JSObject representing this GUI object | // Cached JSObject representing this GUI object. | ||||
JS::PersistentRootedObject m_JSObject; | std::unique_ptr<IGUIProxyObject> m_JSObject; | ||||
// Cache references to settings for performance | // Cache references to settings for performance | ||||
bool m_Enabled; | bool m_Enabled; | ||||
bool m_Hidden; | bool m_Hidden; | ||||
CGUISize m_Size; | CGUISize m_Size; | ||||
CStr m_Style; | CStr m_Style; | ||||
CStr m_Hotkey; | CStr m_Hotkey; | ||||
float m_Z; | float m_Z; | ||||
bool m_Absolute; | bool m_Absolute; | ||||
bool m_Ghost; | bool m_Ghost; | ||||
float m_AspectRatio; | float m_AspectRatio; | ||||
CStrW m_Tooltip; | CStrW m_Tooltip; | ||||
CStr m_TooltipStyle; | CStr m_TooltipStyle; | ||||
}; | }; | ||||
#endif // INCLUDED_IGUIOBJECT | #endif // INCLUDED_IGUIOBJECT |
Wildfire Games · Phabricator