AeonGUI
A portable video game graphic user interface library.
Loading...
Searching...
No Matches
Element.hpp
1/*
2Copyright (C) 2019,2020,2023-2026 Rodrigo Jose Hernandez Cordoba
3
4Licensed under the Apache License, Version 2.0 (the "License");
5you may not use this file except in compliance with the License.
6You may obtain a copy of the License at
7
8http://www.apache.org/licenses/LICENSE-2.0
9
10Unless required by applicable law or agreed to in writing, software
11distributed under the License is distributed on an "AS IS" BASIS,
12WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13See the License for the specific language governing permissions and
14limitations under the License.
15*/
16#ifndef AEONGUI_ELEMENT_H
17#define AEONGUI_ELEMENT_H
18#include <cstdint>
19#include <vector>
20#include <memory>
21#include <string>
22#include <variant>
23#include "aeongui/Platform.hpp"
24#include "aeongui/AttributeMap.hpp"
25#include "aeongui/StyleSheet.hpp"
26#include "aeongui/dom/DOMString.hpp"
27#include "Node.hpp"
28
29extern "C"
30{
31 typedef struct lwc_string_s lwc_string;
32}
33namespace AeonGUI
34{
35 class Canvas;
36 namespace DOM
37 {
38 class Document;
45 class Element : public Node
46 {
47 public:
53 DLL Element ( const DOMString& aTagName, AttributeMap&& aAttributes, Node* aParent );
55 DLL virtual ~Element();
59 NodeType nodeType() const final;
63 const DOMString& tagName() const;
67 const DOMString& id() const;
71 const std::vector<lwc_string*>& classes() const;
75 const AttributeMap& attributes() const;
77 private:
78 DOMString mTagName{};
79 DOMString mId{};
80 std::vector<lwc_string*> mClasses{};
81 DLL void OnAncestorChanged() override;
82 protected:
83 AttributeMap mAttributes{};
84 StyleSheetPtr mInlineStyleSheet{};
85 SelectResultsPtr mComputedStyles{};
88 css_select_results* GetParentComputedStyles() const;
91 css_select_results* GetComputedStyles() const;
92 };
93 }
94}
95#endif
Platform-specific DLL import/export macros and compiler helpers.
Abstract 2D rendering surface.
Definition Canvas.hpp:39
Represents a DOM Document.
Definition Document.hpp:38
const std::vector< lwc_string * > & classes() const
Get the element's CSS class list.
Definition Element.cpp:323
NodeType nodeType() const final
Get the node type (always ELEMENT_NODE).
Definition Element.cpp:311
AttributeMap mAttributes
The element's attribute map.
Definition Element.hpp:83
StyleSheetPtr mInlineStyleSheet
Inline style parsed from the style attribute.
Definition Element.hpp:84
virtual ~Element()
Virtual destructor.
Definition Element.cpp:251
const AttributeMap & attributes() const
Get the element's attribute map.
Definition Element.cpp:327
const DOMString & id() const
Get the element's ID attribute value.
Definition Element.cpp:319
css_select_results * GetParentComputedStyles() const
Get computed styles from the parent element.
Definition Element.cpp:259
css_select_results * GetComputedStyles() const
Get this element's computed styles.
Definition Element.cpp:274
Element(const DOMString &aTagName, AttributeMap &&aAttributes, Node *aParent)
Construct an element.
Definition Element.cpp:163
const DOMString & tagName() const
Get the tag name.
Definition Element.cpp:315
SelectResultsPtr mComputedStyles
Computed CSS styles for this element.
Definition Element.hpp:85
NodeType
DOM node type constants.
Definition Node.hpp:44
Node(Node *aParent=nullptr)
Construct a node with an optional parent.
Definition Node.cpp:25