CheckBox.h 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. /*
  2. * Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
  3. * Copyright (c) 2022, the SerenityOS developers.
  4. *
  5. * SPDX-License-Identifier: BSD-2-Clause
  6. */
  7. #pragma once
  8. #include <LibGUI/AbstractButton.h>
  9. namespace GUI {
  10. class CheckBox : public AbstractButton {
  11. C_OBJECT(CheckBox);
  12. public:
  13. virtual ~CheckBox() override = default;
  14. virtual void click(unsigned modifiers = 0) override;
  15. bool is_autosize() const { return m_autosize; }
  16. void set_autosize(bool);
  17. enum class CheckBoxPosition {
  18. Left,
  19. Right,
  20. };
  21. CheckBoxPosition checkbox_position() const { return m_checkbox_position; }
  22. void set_checkbox_position(CheckBoxPosition value) { m_checkbox_position = value; }
  23. protected:
  24. explicit CheckBox(String = {});
  25. private:
  26. void size_to_fit();
  27. // These don't make sense for a check box, so hide them.
  28. using AbstractButton::auto_repeat_interval;
  29. using AbstractButton::set_auto_repeat_interval;
  30. virtual void paint_event(PaintEvent&) override;
  31. bool m_autosize { false };
  32. CheckBoxPosition m_checkbox_position { CheckBoxPosition::Left };
  33. };
  34. }