2025-02-12 23:12:24 +01:00
|
|
|
/*
|
2025-02-12 23:13:02 +01:00
|
|
|
Crafter.CppDOM
|
|
|
|
|
Copyright (C) 2025 Catcrafts
|
2025-02-12 23:12:24 +01:00
|
|
|
Catcrafts.net
|
|
|
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or
|
|
|
|
|
modify it under the terms of the GNU Lesser General Public
|
|
|
|
|
License as published by the Free Software Foundation; either
|
|
|
|
|
version 3.0 of the License, or (at your option) any later version.
|
|
|
|
|
|
|
|
|
|
This library is distributed in the hope that it will be useful,
|
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
|
Lesser General Public License for more details.
|
|
|
|
|
|
|
|
|
|
You should have received a copy of the GNU Lesser General Public
|
|
|
|
|
License along with this library; if not, write to the Free Software
|
|
|
|
|
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
|
|
|
*/
|
|
|
|
|
|
2025-02-12 23:06:56 +01:00
|
|
|
export module Crafter.CppDOM:HtmlElement;
|
2025-11-09 20:11:22 +01:00
|
|
|
import std;
|
2025-11-10 20:25:50 +01:00
|
|
|
import :BindingsExport;
|
|
|
|
|
import :BindingsImport;
|
2025-11-10 20:02:11 +01:00
|
|
|
import :EventTypes;
|
2025-02-12 23:06:56 +01:00
|
|
|
|
2025-11-09 22:43:52 +01:00
|
|
|
namespace Crafter {
|
2025-02-12 23:06:56 +01:00
|
|
|
export class HtmlElement {
|
|
|
|
|
public:
|
|
|
|
|
void* const ptr;
|
2025-11-10 20:25:50 +01:00
|
|
|
std::vector<std::int32_t> clickHandlers;
|
|
|
|
|
std::vector<std::int32_t> mouseOverHandlers;
|
|
|
|
|
std::vector<std::int32_t> mouseOutHandlers;
|
|
|
|
|
std::vector<std::int32_t> mouseMoveHandlers;
|
|
|
|
|
std::vector<std::int32_t> mouseDownHandlers;
|
|
|
|
|
std::vector<std::int32_t> mouseUpHandlers;
|
|
|
|
|
std::vector<std::int32_t> focusHandlers;
|
|
|
|
|
std::vector<std::int32_t> blurHandlers;
|
|
|
|
|
std::vector<std::int32_t> keyDownHandlers;
|
|
|
|
|
std::vector<std::int32_t> keyUpHandlers;
|
|
|
|
|
std::vector<std::int32_t> keyPressHandlers;
|
|
|
|
|
std::vector<std::int32_t> changeHandlers;
|
|
|
|
|
std::vector<std::int32_t> submitHandlers;
|
|
|
|
|
std::vector<std::int32_t> inputHandlers;
|
|
|
|
|
std::vector<std::int32_t> resizeHandlers;
|
|
|
|
|
std::vector<std::int32_t> scrollHandlers;
|
|
|
|
|
std::vector<std::int32_t> contextMenuHandlers;
|
|
|
|
|
std::vector<std::int32_t> dragStartHandlers;
|
|
|
|
|
std::vector<std::int32_t> dragEndHandlers;
|
|
|
|
|
std::vector<std::int32_t> dropHandlers;
|
|
|
|
|
std::vector<std::int32_t> dragOverHandlers;
|
|
|
|
|
std::vector<std::int32_t> dragEnterHandlers;
|
|
|
|
|
std::vector<std::int32_t> dragLeaveHandlers;
|
|
|
|
|
std::vector<std::int32_t> wheelHandlers;
|
|
|
|
|
|
2025-11-10 21:52:23 +01:00
|
|
|
HtmlElement(const std::string_view id);
|
|
|
|
|
HtmlElement(const std::string_view id, const std::string_view html);
|
|
|
|
|
void SetInnerHTML(const std::string_view html);
|
2025-11-10 22:06:27 +01:00
|
|
|
void SetStyle(const std::string_view style);
|
|
|
|
|
void SetProperty(const std::string_view property, const std::string_view value);
|
|
|
|
|
void AddClass(const std::string_view className);
|
|
|
|
|
void RemoveClass(const std::string_view className);
|
|
|
|
|
void ToggleClass(const std::string_view className);
|
|
|
|
|
bool HasClass(const std::string_view className);
|
2025-11-09 22:43:52 +01:00
|
|
|
|
2025-11-10 21:52:23 +01:00
|
|
|
std::int32_t AddClickListener(std::function<void(Crafter::MouseEvent)> callback);
|
|
|
|
|
void RemoveClickListener(std::int32_t id);
|
2025-11-10 20:02:11 +01:00
|
|
|
|
2025-11-10 21:52:23 +01:00
|
|
|
std::int32_t AddMouseOverListener(std::function<void(Crafter::MouseEvent)> callback);
|
|
|
|
|
void RemoveMouseOverListener(std::int32_t id);
|
2025-11-10 20:02:11 +01:00
|
|
|
|
2025-11-10 21:52:23 +01:00
|
|
|
std::int32_t AddMouseOutListener(std::function<void(Crafter::MouseEvent)> callback);
|
|
|
|
|
void RemoveMouseOutListener(std::int32_t id);
|
2025-11-10 20:02:11 +01:00
|
|
|
|
2025-11-10 21:52:23 +01:00
|
|
|
std::int32_t AddMouseMoveListener(std::function<void(Crafter::MouseEvent)> callback);
|
|
|
|
|
void RemoveMouseMoveListener(std::int32_t id);
|
2025-11-10 20:02:11 +01:00
|
|
|
|
2025-11-10 21:52:23 +01:00
|
|
|
std::int32_t AddMouseDownListener(std::function<void(Crafter::MouseEvent)> callback);
|
|
|
|
|
void RemoveMouseDownListener(std::int32_t id);
|
2025-11-10 20:02:11 +01:00
|
|
|
|
2025-11-10 21:52:23 +01:00
|
|
|
std::int32_t AddMouseUpListener(std::function<void(Crafter::MouseEvent)> callback);
|
|
|
|
|
void RemoveMouseUpListener(std::int32_t id);
|
2025-11-10 20:02:11 +01:00
|
|
|
|
2025-11-10 21:52:23 +01:00
|
|
|
std::int32_t AddFocusListener(std::function<void(Crafter::FocusEvent)> callback);
|
|
|
|
|
void RemoveFocusListener(std::int32_t id);
|
2025-11-10 20:02:11 +01:00
|
|
|
|
2025-11-10 21:52:23 +01:00
|
|
|
std::int32_t AddBlurListener(std::function<void(Crafter::FocusEvent)> callback);
|
|
|
|
|
void RemoveBlurListener(std::int32_t id);
|
2025-11-10 20:02:11 +01:00
|
|
|
|
2025-11-10 21:52:23 +01:00
|
|
|
std::int32_t AddKeyDownListener(std::function<void(KeyboardEvent)> callback);
|
|
|
|
|
void RemoveKeyDownListener(std::int32_t id);
|
2025-11-09 22:43:52 +01:00
|
|
|
|
2025-11-10 21:52:23 +01:00
|
|
|
std::int32_t AddKeyUpListener(std::function<void(KeyboardEvent)> callback);
|
|
|
|
|
void RemoveKeyUpListener(std::int32_t id);
|
2025-11-09 22:43:52 +01:00
|
|
|
|
2025-11-10 21:52:23 +01:00
|
|
|
std::int32_t AddKeyPressListener(std::function<void(KeyboardEvent)> callback);
|
|
|
|
|
void RemoveKeyPressListener(std::int32_t id);
|
2025-11-09 22:56:29 +01:00
|
|
|
|
2025-11-10 21:52:23 +01:00
|
|
|
std::int32_t AddChangeListener(std::function<void(ChangeEvent)> callback);
|
|
|
|
|
void RemoveChangeListener(std::int32_t id);
|
2025-11-09 22:56:29 +01:00
|
|
|
|
2025-11-10 21:52:23 +01:00
|
|
|
std::int32_t AddSubmitListener(std::function<void(void)> callback);
|
|
|
|
|
void RemoveSubmitListener(std::int32_t id);
|
2025-11-09 22:56:29 +01:00
|
|
|
|
2025-11-10 21:52:23 +01:00
|
|
|
std::int32_t AddInputListener(std::function<void(InputEvent)> callback);
|
|
|
|
|
void RemoveInputListener(std::int32_t id);
|
2025-11-09 22:56:29 +01:00
|
|
|
|
2025-11-10 21:52:23 +01:00
|
|
|
std::int32_t AddResizeListener(std::function<void(ResizeEvent)> callback);
|
|
|
|
|
void RemoveResizeListener(std::int32_t id);
|
2025-11-09 22:56:29 +01:00
|
|
|
|
2025-11-10 21:52:23 +01:00
|
|
|
std::int32_t AddScrollListener(std::function<void(ScrollEvent)> callback);
|
|
|
|
|
void RemoveScrollListener(std::int32_t id);
|
2025-11-09 22:56:29 +01:00
|
|
|
|
2025-11-10 21:52:23 +01:00
|
|
|
std::int32_t AddContextMenuListener(std::function<void(MouseEvent)> callback);
|
|
|
|
|
void RemoveContextMenuListener(std::int32_t id);
|
2025-11-09 22:56:29 +01:00
|
|
|
|
2025-11-10 21:52:23 +01:00
|
|
|
std::int32_t AddDragStartListener(std::function<void(MouseEvent)> callback);
|
|
|
|
|
void RemoveDragStartListener(std::int32_t id);
|
2025-11-09 22:56:29 +01:00
|
|
|
|
2025-11-10 21:52:23 +01:00
|
|
|
std::int32_t AddDragEndListener(std::function<void(MouseEvent)> callback);
|
|
|
|
|
void RemoveDragEndListener(std::int32_t id);
|
2025-11-09 22:56:29 +01:00
|
|
|
|
2025-11-10 21:52:23 +01:00
|
|
|
std::int32_t AddDropListener(std::function<void(MouseEvent)> callback);
|
|
|
|
|
void RemoveDropListener(std::int32_t id);
|
2025-11-09 22:56:29 +01:00
|
|
|
|
2025-11-10 21:52:23 +01:00
|
|
|
std::int32_t AddDragOverListener(std::function<void(MouseEvent)> callback);
|
|
|
|
|
void RemoveDragOverListener(std::int32_t id);
|
2025-11-09 22:56:29 +01:00
|
|
|
|
2025-11-10 21:52:23 +01:00
|
|
|
std::int32_t AddDragEnterListener(std::function<void(MouseEvent)> callback);
|
|
|
|
|
void RemoveDragEnterListener(std::int32_t id);
|
2025-11-09 22:56:29 +01:00
|
|
|
|
2025-11-10 21:52:23 +01:00
|
|
|
std::int32_t AddDragLeaveListener(std::function<void(MouseEvent)> callback);
|
|
|
|
|
void RemoveDragLeaveListener(std::int32_t id);
|
2025-11-09 22:56:29 +01:00
|
|
|
|
2025-11-10 21:52:23 +01:00
|
|
|
std::int32_t AddWheelListener(std::function<void(WheelEvent)> callback);
|
|
|
|
|
void RemoveWheelListener(std::int32_t id);
|
2025-11-09 22:56:29 +01:00
|
|
|
|
2025-11-10 21:52:23 +01:00
|
|
|
~HtmlElement();
|
2025-02-12 23:06:56 +01:00
|
|
|
};
|
|
|
|
|
}
|