RadioButtonPaintable.cpp 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. /*
  2. * Copyright (c) 2018-2022, Andreas Kling <kling@serenityos.org>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #include <LibGUI/Event.h>
  7. #include <LibGfx/StylePainter.h>
  8. #include <LibWeb/DOM/Document.h>
  9. #include <LibWeb/HTML/BrowsingContext.h>
  10. #include <LibWeb/HTML/HTMLInputElement.h>
  11. #include <LibWeb/Layout/Label.h>
  12. #include <LibWeb/Layout/RadioButton.h>
  13. #include <LibWeb/Painting/RadioButtonPaintable.h>
  14. namespace Web::Painting {
  15. JS::NonnullGCPtr<RadioButtonPaintable> RadioButtonPaintable::create(Layout::RadioButton const& layout_box)
  16. {
  17. return layout_box.heap().allocate_without_realm<RadioButtonPaintable>(layout_box);
  18. }
  19. RadioButtonPaintable::RadioButtonPaintable(Layout::RadioButton const& layout_box)
  20. : LabelablePaintable(layout_box)
  21. {
  22. }
  23. void RadioButtonPaintable::paint(PaintContext& context, PaintPhase phase) const
  24. {
  25. if (!is_visible())
  26. return;
  27. PaintableBox::paint(context, phase);
  28. auto const& radio_box = static_cast<HTML::HTMLInputElement const&>(layout_box().dom_node());
  29. if (phase == PaintPhase::Foreground)
  30. Gfx::StylePainter::paint_radio_button(context.painter(), context.enclosing_device_rect(absolute_rect()).to_type<int>(), context.palette(), radio_box.checked(), being_pressed());
  31. }
  32. }