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

Base class for all nodes in the DOM tree. More...

#include <aeongui/dom/Node.hpp>

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

Public Types

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...

Public Member Functions

 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).
virtual NodeType nodeType () const =0
 Get the node type.
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.

Detailed Description

Base class for all nodes in the DOM tree.

Implements the DOM Node interface: parent/child relationships, tree traversal, and draw hooks for rendering.

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

Member Enumeration Documentation

◆ NodeType

DOM node type constants.

Enumerator
ELEMENT_NODE 

An Element node.

ATTRIBUTE_NODE 

An Attribute node (legacy).

TEXT_NODE 

A Text node.

CDATA_SECTION_NODE 

A CDATASection node.

ENTITY_REFERENCE_NODE 

An EntityReference node (legacy).

ENTITY_NODE 

An Entity node (legacy).

PROCESSING_INSTRUCTION_NODE 

A ProcessingInstruction node.

COMMENT_NODE 

A Comment node.

DOCUMENT_NODE 

A Document node.

DOCUMENT_TYPE_NODE 

A DocumentType node.

DOCUMENT_FRAGMENT_NODE 

A DocumentFragment node.

NOTATION_NODE 

A Notation node (legacy).

Constructor & Destructor Documentation

◆ Node()

AeonGUI::DOM::Node::Node ( Node * aParent = nullptr)

Construct a node with an optional parent.

Parameters
aParentThe parent node, or nullptr.

Member Function Documentation

◆ AddNode()

Node * AeonGUI::DOM::Node::AddNode ( std::unique_ptr< Node > aNode)

Add a child node.

Parameters
aNodeThe child to add (ownership transferred).
Returns
Raw pointer to the added node.

◆ childNodes()

const std::vector< std::unique_ptr< Node > > & AeonGUI::DOM::Node::childNodes ( ) const

Get the list of child nodes.

Returns
Const reference to the vector of children.

◆ DrawFinish()

void AeonGUI::DOM::Node::DrawFinish ( Canvas & aCanvas) const
virtual

Finish drawing this node on the canvas.

Parameters
aCanvasThe target canvas.

◆ DrawStart()

void AeonGUI::DOM::Node::DrawStart ( Canvas & aCanvas) const
virtual

◆ IsDrawEnabled()

bool AeonGUI::DOM::Node::IsDrawEnabled ( ) const
virtual

Returns whether this node and all descendants should be skipped in a drawing operation.

Returns
true by default override to disable drawing.

Reimplemented in AeonGUI::DOM::SVGDefsElement.

◆ nodeType()

virtual NodeType AeonGUI::DOM::Node::nodeType ( ) const
pure virtual

Get the node type.

Returns
One of the NodeType constants.

Implemented in AeonGUI::DOM::Document, AeonGUI::DOM::Element, and AeonGUI::DOM::Text.

◆ OnLoad()

void AeonGUI::DOM::Node::OnLoad ( )
virtual

Use OnLoad to implement custom loading behavior in derived classes. This method is called after all nodes are created and all children have been set. Nodes are visited in depth-first pre-order.

◆ OnUnload()

void AeonGUI::DOM::Node::OnUnload ( )
virtual

Use OnUnload to implement custom unloading behavior in derived classes. This method is called while all nodes are still in place but before they are destroyed. Nodes are visited in depth-first post-order.

◆ parentElement()

Node * AeonGUI::DOM::Node::parentElement ( ) const

Get the parent element (same as parentNode for elements).

Returns
Pointer to the parent element, or nullptr.

◆ parentNode()

Node * AeonGUI::DOM::Node::parentNode ( ) const

Get the parent node.

DOM Properties and Methods

Returns
Pointer to the parent, or nullptr if this is the root.

◆ RemoveNode()

std::unique_ptr< Node > AeonGUI::DOM::Node::RemoveNode ( const Node * aNode)

Remove a child node.

Parameters
aNodeRaw pointer to the child to remove.
Returns
Ownership of the removed node.

◆ TraverseDepthFirstPostOrder() [1/2]

void AeonGUI::DOM::Node::TraverseDepthFirstPostOrder ( const std::function< void(const Node &) > & aAction) const

Traverse the tree depth-first in post-order (const).

Parameters
aActionAction invoked for each node.

◆ TraverseDepthFirstPostOrder() [2/2]

void AeonGUI::DOM::Node::TraverseDepthFirstPostOrder ( const std::function< void(Node &) > & aAction)

Traverse the tree depth-first in post-order.

Parameters
aActionAction invoked for each node.

◆ TraverseDepthFirstPreOrder() [1/6]

void AeonGUI::DOM::Node::TraverseDepthFirstPreOrder ( const std::function< void(const Node &) > & aAction) const

Traverse the tree depth-first in pre-order (const).

Parameters
aActionAction invoked for each node.

◆ TraverseDepthFirstPreOrder() [2/6]

void AeonGUI::DOM::Node::TraverseDepthFirstPreOrder ( const std::function< void(const Node &) > & aPreamble,
const std::function< void(const Node &) > & aPostamble ) const

Traverse pre-order with pre/post callbacks (const).

Parameters
aPreambleCalled before visiting children.
aPostambleCalled after visiting children.

◆ TraverseDepthFirstPreOrder() [3/6]

void AeonGUI::DOM::Node::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).

Parameters
aPreambleCalled before visiting children.
aPostambleCalled after visiting children.
aUnaryPredicateOnly descend into children for which this returns true.

◆ TraverseDepthFirstPreOrder() [4/6]

void AeonGUI::DOM::Node::TraverseDepthFirstPreOrder ( const std::function< void(Node &) > & aAction)

Traverse the tree depth-first in pre-order.

Parameters
aActionAction invoked for each node.

◆ TraverseDepthFirstPreOrder() [5/6]

void AeonGUI::DOM::Node::TraverseDepthFirstPreOrder ( const std::function< void(Node &) > & aPreamble,
const std::function< void(Node &) > & aPostamble )

Traverse pre-order with separate pre and post callbacks.

Parameters
aPreambleCalled before visiting children.
aPostambleCalled after visiting children.

◆ TraverseDepthFirstPreOrder() [6/6]

void AeonGUI::DOM::Node::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.

Parameters
aPreambleCalled before visiting children.
aPostambleCalled after visiting children.
aUnaryPredicateOnly descend into children for which this returns true.

The documentation for this class was generated from the following files:
  • include/aeongui/dom/Node.hpp
  • core/dom/Node.cpp