Pyrogenesis  trunk
Public Member Functions | Protected Member Functions | Protected Attributes | Private Attributes | Static Private Attributes | List of all members
CList Class Reference

Create a list of elements, where one can be selected by the user. More...

#include <CList.h>

Inheritance diagram for CList:
Inheritance graph
[legend]
Collaboration diagram for CList:
Collaboration graph
[legend]

Public Member Functions

 CList (CGUI &pGUI)
 
virtual ~CList ()
 
virtual void ResetStates ()
 
virtual void UpdateCachedSize ()
 
virtual void AddItem (const CGUIString &str, const CGUIString &data)
 Adds an item last to the list. More...
 
void AddItem (const CGUIString &strAndData)
 Add an item where both parameters are identical. More...
 
- Public Member Functions inherited from IGUIObject
 NONCOPYABLE (IGUIObject)
 
 IGUIObject (CGUI &pGUI)
 
virtual ~IGUIObject ()
 
virtual bool IsMouseOver () const
 This function checks if the mouse is hovering the rectangle that the base setting "size" makes. More...
 
virtual bool IsMouseHovering () const
 This function returns true if the mouse is hovering over this GUI object and if this GUI object is the topmost object in that screen location. More...
 
const CStr & GetName () const
 Get object name, name is unique. More...
 
void SetName (const CStr &Name)
 Get object name. More...
 
CStr GetPresentableName () const
 
const std::vector< IGUIObject * > & GetChildren () const
 Return all child objects of the current object. More...
 
void RegisterSetting (const CStr &Name, IGUISetting *setting)
 Registers the given setting with the GUI object. More...
 
void ReregisterSetting (const CStr &Name, IGUISetting *setting)
 
bool SettingExists (const CStr &Setting) const
 Returns whether there is a setting with the given name registered. More...
 
bool SetSettingFromString (const CStr &Setting, const CStrW &Value, const bool SendMessage)
 Set a setting by string, regardless of what type it is. More...
 
bool IsEnabled () const
 Returns whether this object is set to be hidden or ghost. More...
 
bool IsHidden () const
 Returns whether this is object is set to be hidden. More...
 
void SetHidden (bool hidden)
 
bool IsHiddenOrGhost () const
 Returns whether this object is set to be hidden or ghost. More...
 
void PlaySound (const CStrW &soundPath) const
 Retrieves the configured sound filename from the given setting name and plays that once. More...
 
InReaction SendEvent (EGUIMessageType type, const CStr &eventName)
 Send event to this GUI object (HandleMessage and ScriptEvent) More...
 
InReaction SendMouseEvent (EGUIMessageType type, const CStr &eventName)
 Same as SendEvent, but passes mouse coordinates and button state as an argument. More...
 
CRect GetComputedSize ()
 Updates and returns the size of the object. More...
 
virtual const CStrW & GetTooltipText () const
 
virtual const CStr & GetTooltipStyle () const
 
void RegisterScriptHandler (const CStr &eventName, 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...
 
virtual void Tick ()
 Called on every GUI tick unless the object or one of its parent is hidden/ghost. More...
 
template<typename... Args>
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. More...
 
CGUIGetGUI ()
 
const CGUIGetGUI () const
 
void SetFocus ()
 Take focus! More...
 
void ReleaseFocus ()
 Release focus. More...
 
- Public Member Functions inherited from IGUIScrollBarOwner
 IGUIScrollBarOwner (IGUIObject &m_pObject)
 
virtual ~IGUIScrollBarOwner ()
 
virtual const SGUIScrollBarStyleGetScrollBarStyle (const CStr8 &style) const
 Interface for the m_ScrollBar to use. More...
 
virtual void AddScrollBar (std::unique_ptr< IGUIScrollBar > scrollbar)
 Add a scroll-bar. More...
 
virtual IGUIScrollBarGetScrollBar (const int &index)
 Get Scroll Bar reference (it should be transparent it's actually pointers). More...
 
virtual float GetScrollBarPos (const int index) const
 Get the position of the scroll bar at. More...
 
- Public Member Functions inherited from IGUITextOwner
 IGUITextOwner (IGUIObject &pObject)
 
virtual ~IGUITextOwner ()
 
CGUITextAddText ()
 Adds a text object. More...
 
CGUITextAddText (const CGUIString &Text, const CStrW &Font, const float &Width, const float &BufferZone)
 Adds a text generated by the given arguments. More...
 
virtual void DrawText (CCanvas2D &canvas, size_t index, const CGUIColor &color, const CVector2D &pos, const CRect &clipping=CRect())
 Draws the Text. More...
 

Protected Member Functions

virtual void SetupText ()
 Sets up text, should be called every time changes has been made that can change the visual. More...
 
virtual void SetupText (bool append)
 
virtual void HandleMessage (SGUIMessage &Message)
 
virtual InReaction ManuallyHandleKeys (const SDL_Event_ *ev)
 Handle events manually to catch keyboard inputting. More...
 
virtual void Draw (CCanvas2D &canvas)
 Draws the List box. More...
 
virtual void CreateJSObject ()
 Creates the JS object representing this page upon first use. More...
 
virtual void SelectNextElement ()
 Easy select elements functions. More...
 
virtual void SelectPrevElement ()
 
virtual void SelectFirstElement ()
 
virtual void SelectLastElement ()
 
virtual bool HandleAdditionalChildren (const XMBData &xmb, const XMBElement &child)
 Handle the <item> tag. More...
 
void UpdateAutoScroll ()
 
virtual void DrawList (CCanvas2D &canvas, const int &selected, const CGUISpriteInstance &sprite, const CGUISpriteInstance &spriteOverlay, const CGUISpriteInstance &spriteSelectArea, const CGUISpriteInstance &spriteSelectAreaOverlay, const CGUIColor &textColor)
 
virtual CRect GetListRect () const
 
virtual bool GetModified () const
 
virtual int GetHoveredItem ()
 
- Protected Member Functions inherited from IGUIObject
virtual InReaction PreemptEvent (const SDL_Event_ *ev)
 Some objects need to be able to pre-emptively process SDL_Event_. More...
 
bool ApplyStyle (const CStr &StyleName)
 Applies the given style to the object. More...
 
virtual float GetBufferedZ () const
 Returns not the Z value, but the actual buffered Z value, i.e. More...
 
void RegisterChild (IGUIObject *child)
 Add an object to the hierarchy. More...
 
void UnregisterChild (IGUIObject *child)
 Remove an object from the hierarchy. More...
 
void SetParent (IGUIObject *pParent)
 Set parent 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 nullptr, so that the top-node's children are seemingly parentless. More...
 
virtual void AdditionalChildrenHandled ()
 Allow the GUI object to process after all child items were handled. More...
 
void ScriptEvent (const CStr &eventName)
 Execute the script for a particular action. More...
 
bool ScriptEventWithReturn (const CStr &eventName)
 Execute the script for a particular action. More...
 
void ScriptEvent (const CStr &eventName, const JS::HandleValueArray &paramData)
 Execute the script for a particular action. More...
 
bool ScriptEventWithReturn (const CStr &eventName, const JS::HandleValueArray &paramData)
 Execute the script for a particular action. More...
 
void SetScriptHandler (const CStr &eventName, JS::HandleObject Function)
 Assigns a JS function to the event name. More...
 
void UnsetScriptHandler (const CStr &eventName)
 Deletes an event handler assigned to the given name, if such a handler exists. More...
 
void UpdateMouseOver (IGUIObject *const &pMouseOver)
 Inputes the object that is currently hovered, this function updates this object accordingly (i.e. More...
 
- Protected Member Functions inherited from IGUITextOwner
virtual void UpdateText ()
 Regenerate the text in case it is invalid. More...
 
void CalculateTextPosition (CRect &ObjSize, CVector2D &TextPos, CGUIText &Text)
 Calculate the position for the text, based on the alignment. More...
 

Protected Attributes

std::vector< float > m_ItemsYPositions
 List of each element's relative y position. More...
 
CGUISimpleSetting< float > m_BufferZone
 
CGUISimpleSetting< CStrW > m_Font
 
CGUISimpleSetting< bool > m_ScrollBar
 
CGUISimpleSetting< CStr > m_ScrollBarStyle
 
CGUISimpleSetting< bool > m_ScrollBottom
 
CGUISimpleSetting< CStrW > m_SoundDisabled
 
CGUISimpleSetting< CStrW > m_SoundSelected
 
CGUISimpleSetting< CGUISpriteInstancem_Sprite
 
CGUISimpleSetting< CGUISpriteInstancem_SpriteOverlay
 
CGUISimpleSetting< CGUISpriteInstancem_SpriteSelectArea
 
CGUISimpleSetting< CGUISpriteInstancem_SpriteSelectAreaOverlay
 
CGUISimpleSetting< CGUIColorm_TextColor
 
CGUISimpleSetting< CGUIColorm_TextColorSelected
 
CGUISimpleSetting< i32m_Selected
 
CGUISimpleSetting< bool > m_AutoScroll
 
CGUISimpleSetting< i32m_Hovered
 
CGUISimpleSetting< CGUIListm_List
 
CGUISimpleSetting< CGUIListm_ListData
 
- Protected Attributes inherited from IGUIObject
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...
 
CStr m_Name
 
std::vector< IGUIObject * > m_Children
 
IGUIObjectm_pParent
 
double m_LastClickTime [6]
 
bool m_MouseHovering
 This variable is true if the mouse is hovering this object and this object is the topmost object shown in this location. More...
 
std::map< CStr, IGUISetting * > m_Settings
 Settings pool, all an object's settings are located here. More...
 
CGUIm_pGUI
 
std::map< CStr, JS::Heap< JSObject * > > m_ScriptHandlers
 
std::unique_ptr< IGUIProxyObjectm_JSObject
 
CGUISimpleSetting< bool > m_Enabled
 
CGUISimpleSetting< bool > m_Hidden
 
CGUISimpleSetting< CGUISizem_Size
 
CGUISimpleSetting< CStr > m_Style
 
CGUIHotkey m_Hotkey
 
CGUISimpleSetting< float > m_Z
 
CGUISimpleSetting< bool > m_Absolute
 
CGUISimpleSetting< bool > m_Ghost
 
CGUISimpleSetting< float > m_AspectRatio
 
CGUISimpleSetting< CStrW > m_Tooltip
 
CGUISimpleSetting< CStr > m_TooltipStyle
 
- Protected Attributes inherited from IGUIScrollBarOwner
std::vector< std::unique_ptr< IGUIScrollBar > > m_ScrollBars
 Predominately you will only have one, but you can have as many as you like. More...
 
- Protected Attributes inherited from IGUITextOwner
bool m_GeneratedTextsValid
 Whether the cached text is currently valid (if not then SetupText will be called by Draw) More...
 
std::vector< CGUITextm_GeneratedTexts
 Texts that are generated and ready to be rendered. More...
 
CGUISimpleSetting< EAlignm_TextAlign
 
CGUISimpleSetting< EVAlignm_TextVAlign
 

Private Attributes

bool m_Modified
 
int m_PrevSelectedItem
 
double m_LastItemClickTime
 

Static Private Attributes

static const CStr EventNameSelectionChange = "SelectionChange"
 
static const CStr EventNameHoverChange = "HoverChange"
 
static const CStr EventNameMouseLeftClickItem = "MouseLeftClickItem"
 
static const CStr EventNameMouseLeftDoubleClickItem = "MouseLeftDoubleClickItem"
 

Additional Inherited Members

- Static Protected Attributes inherited from IGUIObject
static const CStr EventNameMouseEnter = "MouseEnter"
 
static const CStr EventNameMouseMove = "MouseMove"
 
static const CStr EventNameMouseLeave = "MouseLeave"
 

Detailed Description

Create a list of elements, where one can be selected by the user.

The control will use a pre-processed text-object for each element, which will be managed by the IGUITextOwner structure.

A scroll-bar will appear when needed. This will be achieved with the IGUIScrollBarOwner structure.

Constructor & Destructor Documentation

◆ CList()

CList::CList ( CGUI pGUI)

◆ ~CList()

CList::~CList ( )
virtual

Member Function Documentation

◆ AddItem() [1/2]

void CList::AddItem ( const CGUIString str,
const CGUIString data 
)
virtual

Adds an item last to the list.

◆ AddItem() [2/2]

void CList::AddItem ( const CGUIString strAndData)

Add an item where both parameters are identical.

◆ CreateJSObject()

virtual void CList::CreateJSObject ( )
protectedvirtual

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.

Reimplemented from IGUIObject.

◆ Draw()

void CList::Draw ( CCanvas2D canvas)
protectedvirtual

Draws the List box.

Implements IGUIObject.

Reimplemented in CDropDown.

◆ DrawList()

void CList::DrawList ( CCanvas2D canvas,
const int &  selected,
const CGUISpriteInstance sprite,
const CGUISpriteInstance spriteOverlay,
const CGUISpriteInstance spriteSelectArea,
const CGUISpriteInstance spriteSelectAreaOverlay,
const CGUIColor textColor 
)
protectedvirtual

Reimplemented in COList.

◆ GetHoveredItem()

int CList::GetHoveredItem ( )
protectedvirtual

◆ GetListRect()

virtual CRect CList::GetListRect ( ) const
inlineprotectedvirtual

Reimplemented in CDropDown, and COList.

◆ GetModified()

virtual bool CList::GetModified ( ) const
inlineprotectedvirtual

◆ HandleAdditionalChildren()

bool CList::HandleAdditionalChildren ( const XMBData xmb,
const XMBElement child 
)
protectedvirtual

Handle the <item> tag.

Reimplemented from IGUIObject.

Reimplemented in COList.

◆ HandleMessage()

void CList::HandleMessage ( SGUIMessage Message)
protectedvirtual
See also
IGUIObject::HandleMessage()

Reimplemented from IGUIObject.

Reimplemented in COList, and CDropDown.

◆ ManuallyHandleKeys()

InReaction CList::ManuallyHandleKeys ( const SDL_Event_ ev)
protectedvirtual

Handle events manually to catch keyboard inputting.

Reimplemented from IGUIObject.

Reimplemented in CDropDown.

◆ ResetStates()

void CList::ResetStates ( )
virtual
See also
IGUIObject::ResetStates()

Reimplemented from IGUIObject.

◆ SelectFirstElement()

void CList::SelectFirstElement ( )
protectedvirtual

◆ SelectLastElement()

void CList::SelectLastElement ( )
protectedvirtual

◆ SelectNextElement()

void CList::SelectNextElement ( )
protectedvirtual

Easy select elements functions.

◆ SelectPrevElement()

void CList::SelectPrevElement ( )
protectedvirtual

◆ SetupText() [1/2]

void CList::SetupText ( )
protectedvirtual

Sets up text, should be called every time changes has been made that can change the visual.

Parameters
append- if true, we assume we only need to render the new element at the end of the list.

Implements IGUITextOwner.

Reimplemented in CDropDown, and COList.

◆ SetupText() [2/2]

void CList::SetupText ( bool  append)
protectedvirtual

◆ UpdateAutoScroll()

void CList::UpdateAutoScroll ( )
protected

◆ UpdateCachedSize()

void CList::UpdateCachedSize ( )
virtual
See also
IGUIObject::UpdateCachedSize()

Reimplemented from IGUIObject.

Reimplemented in CDropDown.

Member Data Documentation

◆ EventNameHoverChange

const CStr CList::EventNameHoverChange = "HoverChange"
staticprivate

◆ EventNameMouseLeftClickItem

const CStr CList::EventNameMouseLeftClickItem = "MouseLeftClickItem"
staticprivate

◆ EventNameMouseLeftDoubleClickItem

const CStr CList::EventNameMouseLeftDoubleClickItem = "MouseLeftDoubleClickItem"
staticprivate

◆ EventNameSelectionChange

const CStr CList::EventNameSelectionChange = "SelectionChange"
staticprivate

◆ m_AutoScroll

CGUISimpleSetting<bool> CList::m_AutoScroll
protected

◆ m_BufferZone

CGUISimpleSetting<float> CList::m_BufferZone
protected

◆ m_Font

CGUISimpleSetting<CStrW> CList::m_Font
protected

◆ m_Hovered

CGUISimpleSetting<i32> CList::m_Hovered
protected

◆ m_ItemsYPositions

std::vector<float> CList::m_ItemsYPositions
protected

List of each element's relative y position.

Will be one larger than m_Items, because it will end with the bottom of the last element. First element will always be zero, but still stored for easy handling.

◆ m_LastItemClickTime

double CList::m_LastItemClickTime
private

◆ m_List

CGUISimpleSetting<CGUIList> CList::m_List
protected

◆ m_ListData

CGUISimpleSetting<CGUIList> CList::m_ListData
protected

◆ m_Modified

bool CList::m_Modified
private

◆ m_PrevSelectedItem

int CList::m_PrevSelectedItem
private

◆ m_ScrollBar

CGUISimpleSetting<bool> CList::m_ScrollBar
protected

◆ m_ScrollBarStyle

CGUISimpleSetting<CStr> CList::m_ScrollBarStyle
protected

◆ m_ScrollBottom

CGUISimpleSetting<bool> CList::m_ScrollBottom
protected

◆ m_Selected

CGUISimpleSetting<i32> CList::m_Selected
protected

◆ m_SoundDisabled

CGUISimpleSetting<CStrW> CList::m_SoundDisabled
protected

◆ m_SoundSelected

CGUISimpleSetting<CStrW> CList::m_SoundSelected
protected

◆ m_Sprite

CGUISimpleSetting<CGUISpriteInstance> CList::m_Sprite
protected

◆ m_SpriteOverlay

CGUISimpleSetting<CGUISpriteInstance> CList::m_SpriteOverlay
protected

◆ m_SpriteSelectArea

CGUISimpleSetting<CGUISpriteInstance> CList::m_SpriteSelectArea
protected

◆ m_SpriteSelectAreaOverlay

CGUISimpleSetting<CGUISpriteInstance> CList::m_SpriteSelectAreaOverlay
protected

◆ m_TextColor

CGUISimpleSetting<CGUIColor> CList::m_TextColor
protected

◆ m_TextColorSelected

CGUISimpleSetting<CGUIColor> CList::m_TextColorSelected
protected

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