ButtonBox.h 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. /*
  2. * Copyright (c) 2020, Andreas Kling <kling@serenityos.org>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #pragma once
  7. #include <LibWeb/HTML/HTMLInputElement.h>
  8. #include <LibWeb/Layout/LabelableNode.h>
  9. namespace Web::Layout {
  10. class ButtonBox : public LabelableNode {
  11. public:
  12. ButtonBox(DOM::Document&, HTML::HTMLInputElement&, NonnullRefPtr<CSS::StyleProperties>);
  13. virtual ~ButtonBox() override;
  14. virtual void prepare_for_replaced_layout() override;
  15. virtual void paint(PaintContext&, PaintPhase) override;
  16. const HTML::HTMLInputElement& dom_node() const { return static_cast<const HTML::HTMLInputElement&>(LabelableNode::dom_node()); }
  17. HTML::HTMLInputElement& dom_node() { return static_cast<HTML::HTMLInputElement&>(LabelableNode::dom_node()); }
  18. private:
  19. virtual bool wants_mouse_events() const override { return true; }
  20. virtual void handle_mousedown(Badge<EventHandler>, const Gfx::IntPoint&, unsigned button, unsigned modifiers) override;
  21. virtual void handle_mouseup(Badge<EventHandler>, const Gfx::IntPoint&, unsigned button, unsigned modifiers) override;
  22. virtual void handle_mousemove(Badge<EventHandler>, const Gfx::IntPoint&, unsigned buttons, unsigned modifiers) override;
  23. virtual void handle_associated_label_mousedown(Badge<Label>) override;
  24. virtual void handle_associated_label_mouseup(Badge<Label>) override;
  25. virtual void handle_associated_label_mousemove(Badge<Label>, bool is_inside_node_or_label) override;
  26. bool m_being_pressed { false };
  27. bool m_tracking_mouse { false };
  28. };
  29. }