2021-04-03 09:07:45 -04:00
|
|
|
/*
|
2022-01-31 13:07:22 -05:00
|
|
|
* Copyright (c) 2021, Tim Flynn <trflynn89@serenityos.org>
|
2021-04-03 09:07:45 -04:00
|
|
|
*
|
2021-04-22 01:24:48 -07:00
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
2021-04-03 09:07:45 -04:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
#include <LibWeb/HTML/HTMLInputElement.h>
|
2021-04-03 21:50:53 -04:00
|
|
|
#include <LibWeb/Layout/LabelableNode.h>
|
2021-04-03 09:07:45 -04:00
|
|
|
|
|
|
|
|
namespace Web::Layout {
|
|
|
|
|
|
2021-04-03 21:50:53 -04:00
|
|
|
class RadioButton : public LabelableNode {
|
2021-04-03 09:07:45 -04:00
|
|
|
public:
|
|
|
|
|
RadioButton(DOM::Document&, HTML::HTMLInputElement&, NonnullRefPtr<CSS::StyleProperties>);
|
|
|
|
|
virtual ~RadioButton() override;
|
|
|
|
|
|
2022-03-10 02:13:28 +01:00
|
|
|
virtual void paint(PaintContext&, Painting::PaintPhase) override;
|
2021-04-03 09:07:45 -04:00
|
|
|
|
2021-04-03 21:50:53 -04:00
|
|
|
const HTML::HTMLInputElement& dom_node() const { return static_cast<const HTML::HTMLInputElement&>(LabelableNode::dom_node()); }
|
|
|
|
|
HTML::HTMLInputElement& dom_node() { return static_cast<HTML::HTMLInputElement&>(LabelableNode::dom_node()); }
|
2021-04-03 09:07:45 -04:00
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
virtual bool wants_mouse_events() const override { return true; }
|
|
|
|
|
virtual void handle_mousedown(Badge<EventHandler>, const Gfx::IntPoint&, unsigned button, unsigned modifiers) override;
|
|
|
|
|
virtual void handle_mouseup(Badge<EventHandler>, const Gfx::IntPoint&, unsigned button, unsigned modifiers) override;
|
|
|
|
|
virtual void handle_mousemove(Badge<EventHandler>, const Gfx::IntPoint&, unsigned buttons, unsigned modifiers) override;
|
|
|
|
|
|
2021-04-03 21:50:53 -04:00
|
|
|
virtual void handle_associated_label_mousedown(Badge<Label>) override;
|
|
|
|
|
virtual void handle_associated_label_mouseup(Badge<Label>) override;
|
|
|
|
|
virtual void handle_associated_label_mousemove(Badge<Label>, bool is_inside_node_or_label) override;
|
|
|
|
|
|
2021-04-03 09:07:45 -04:00
|
|
|
void set_checked_within_group();
|
|
|
|
|
|
|
|
|
|
bool m_being_pressed { false };
|
|
|
|
|
bool m_tracking_mouse { false };
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
}
|