CheckBox.h 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  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(DeprecatedString);
  25. explicit CheckBox(String = {});
  26. private:
  27. void size_to_fit();
  28. // These don't make sense for a check box, so hide them.
  29. using AbstractButton::auto_repeat_interval;
  30. using AbstractButton::set_auto_repeat_interval;
  31. virtual void paint_event(PaintEvent&) override;
  32. bool m_autosize { false };
  33. CheckBoxPosition m_checkbox_position { CheckBoxPosition::Left };
  34. };
  35. }