CheckBoxPaintable.cpp 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. /*
  2. * Copyright (c) 2018-2022, Andreas Kling <kling@serenityos.org>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #include <LibGfx/StylePainter.h>
  7. #include <LibWeb/HTML/HTMLImageElement.h>
  8. #include <LibWeb/Layout/CheckBox.h>
  9. #include <LibWeb/Painting/CheckBoxPaintable.h>
  10. namespace Web::Painting {
  11. NonnullRefPtr<CheckBoxPaintable> CheckBoxPaintable::create(Layout::CheckBox const& layout_box)
  12. {
  13. return adopt_ref(*new CheckBoxPaintable(layout_box));
  14. }
  15. CheckBoxPaintable::CheckBoxPaintable(Layout::CheckBox const& layout_box)
  16. : PaintableBox(layout_box)
  17. {
  18. }
  19. Layout::CheckBox const& CheckBoxPaintable::layout_box() const
  20. {
  21. return static_cast<Layout::CheckBox const&>(layout_node());
  22. }
  23. void CheckBoxPaintable::paint(PaintContext& context, PaintPhase phase) const
  24. {
  25. if (!is_visible())
  26. return;
  27. PaintableBox::paint(context, phase);
  28. if (phase == PaintPhase::Foreground)
  29. Gfx::StylePainter::paint_check_box(context.painter(), enclosing_int_rect(absolute_rect()), context.palette(), layout_box().dom_node().enabled(), layout_box().dom_node().checked(), layout_box().being_pressed());
  30. }
  31. }