AeonGUI
A portable video game graphic user interface library.
Loading...
Searching...
No Matches
AeonGUI::DOM::Element Class Reference

Base class for DOM elements. More...

#include <aeongui/dom/Element.hpp>

Inheritance diagram for AeonGUI::DOM::Element:
[legend]
Collaboration diagram for AeonGUI::DOM::Element:
[legend]

Public Member Functions

 Element (const DOMString &aTagName, AttributeMap &&aAttributes, Node *aParent)
 Construct an element.
virtual ~Element ()
 Virtual destructor.
NodeType nodeType () const final
 Get the node type (always ELEMENT_NODE).
const DOMString & tagName () const
 Get the tag name.
const DOMString & id () const
 Get the element's ID attribute value.
const std::vector< lwc_string * > & classes () const
 Get the element's CSS class list.
const AttributeMap & attributes () const
 Get the element's attribute map.
Public Member Functions inherited from AeonGUI::DOM::Node
 Node (Node *aParent=nullptr)
 Construct a node with an optional parent.
NodeAddNode (std::unique_ptr< Node > aNode)
 Add a child node.
std::unique_ptr< NodeRemoveNode (const Node *aNode)
 Remove a child node.
void TraverseDepthFirstPreOrder (const std::function< void(Node &) > &aAction)
 Traverse the tree depth-first in pre-order.
void TraverseDepthFirstPreOrder (const std::function< void(const Node &) > &aAction) const
 Traverse the tree depth-first in pre-order (const).
void TraverseDepthFirstPostOrder (const std::function< void(Node &) > &aAction)
 Traverse the tree depth-first in post-order.
void TraverseDepthFirstPostOrder (const std::function< void(const Node &) > &aAction) const
 Traverse the tree depth-first in post-order (const).
void TraverseDepthFirstPreOrder (const std::function< void(Node &) > &aPreamble, const std::function< void(Node &) > &aPostamble)
 Traverse pre-order with separate pre and post callbacks.
void TraverseDepthFirstPreOrder (const std::function< void(const Node &) > &aPreamble, const std::function< void(const Node &) > &aPostamble) const
 Traverse pre-order with pre/post callbacks (const).
void TraverseDepthFirstPreOrder (const std::function< void(Node &) > &aPreamble, const std::function< void(Node &) > &aPostamble, const std::function< bool(Node &) > &aUnaryPredicate)
 Traverse pre-order with pre/post callbacks and a predicate filter.
void TraverseDepthFirstPreOrder (const std::function< void(const Node &) > &aPreamble, const std::function< void(const Node &) > &aPostamble, const std::function< bool(const Node &) > &aUnaryPredicate) const
 Traverse pre-order with pre/post callbacks and predicate (const).
virtual void DrawStart (Canvas &aCanvas) const
 Begin drawing this node on the canvas.
virtual void DrawFinish (Canvas &aCanvas) const
 Finish drawing this node on the canvas.
virtual void OnLoad ()
virtual void OnUnload ()
virtual bool IsDrawEnabled () const
NodeparentNode () const
 Get the parent node.
NodeparentElement () const
 Get the parent element (same as parentNode for elements).
const std::vector< std::unique_ptr< Node > > & childNodes () const
 Get the list of child nodes.
Public Member Functions inherited from AeonGUI::DOM::EventTarget
virtual ~EventTarget ()=0
 Virtual destructor.
void addEventListener (const DOMString &type, EventListener *callback, const std::variant< std::monostate, AddEventListenerOptions, bool > &options={})
 Register an event listener.
void removeEventListener (const DOMString &type, EventListener *callback, const std::variant< std::monostate, EventListenerOptions, bool > &options={})
 Unregister an event listener.
virtual bool dispatchEvent (Event &event)
 Dispatch an event to this target.

Protected Member Functions

css_select_results * GetParentComputedStyles () const
 Get computed styles from the parent element.
css_select_results * GetComputedStyles () const
 Get this element's computed styles.

Protected Attributes

AttributeMap mAttributes {}
 The element's attribute map.
StyleSheetPtr mInlineStyleSheet {}
 Inline style parsed from the style attribute.
SelectResultsPtr mComputedStyles {}
 Computed CSS styles for this element.

Additional Inherited Members

Public Types inherited from AeonGUI::DOM::Node
enum  NodeType {
  ELEMENT_NODE = 1 , ATTRIBUTE_NODE = 2 , TEXT_NODE = 3 , CDATA_SECTION_NODE = 4 ,
  ENTITY_REFERENCE_NODE = 5 , ENTITY_NODE = 6 , PROCESSING_INSTRUCTION_NODE = 7 , COMMENT_NODE = 8 ,
  DOCUMENT_NODE = 9 , DOCUMENT_TYPE_NODE = 10 , DOCUMENT_FRAGMENT_NODE = 11 , NOTATION_NODE = 12
}
 DOM node type constants. More...

Detailed Description

Base class for DOM elements.

An Element has a tag name, attributes, CSS classes, and computed styles. It extends Node with the DOM Element interface.

See also
https://dom.spec.whatwg.org/#interface-element

Constructor & Destructor Documentation

◆ Element()

AeonGUI::DOM::Element::Element ( const DOMString & aTagName,
AttributeMap && aAttributes,
Node * aParent )

Construct an element.

Parameters
aTagNameThe tag name (e.g. "rect", "circle").
aAttributesThe element's attribute map.
aParentThe parent node.

Member Function Documentation

◆ attributes()

const AttributeMap & AeonGUI::DOM::Element::attributes ( ) const

Get the element's attribute map.

Returns
Const reference to the AttributeMap.

◆ classes()

const std::vector< lwc_string * > & AeonGUI::DOM::Element::classes ( ) const

Get the element's CSS class list.

Returns
Vector of interned lwc_string class names.

◆ GetComputedStyles()

css_select_results * AeonGUI::DOM::Element::GetComputedStyles ( ) const
protected

Get this element's computed styles.

Returns
Pointer to computed styles, or nullptr.

◆ GetParentComputedStyles()

css_select_results * AeonGUI::DOM::Element::GetParentComputedStyles ( ) const
protected

Get computed styles from the parent element.

Returns
Pointer to parent's computed styles, or nullptr.

◆ id()

const DOMString & AeonGUI::DOM::Element::id ( ) const

Get the element's ID attribute value.

Returns
The ID string.

◆ nodeType()

Node::NodeType AeonGUI::DOM::Element::nodeType ( ) const
finalvirtual

Get the node type (always ELEMENT_NODE).

DOM Properties and Methods

Returns
NodeType::ELEMENT_NODE.

Implements AeonGUI::DOM::Node.

◆ tagName()

const DOMString & AeonGUI::DOM::Element::tagName ( ) const

Get the tag name.

Returns
The element's tag name.

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