2020-01-18 09:38:21 +01:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
|
2022-02-26 10:50:04 -07:00
|
|
|
* Copyright (c) 2022, the SerenityOS developers.
|
2020-01-18 09:38:21 +01:00
|
|
|
*
|
2021-04-22 01:24:48 -07:00
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
2020-01-18 09:38:21 +01:00
|
|
|
*/
|
|
|
|
|
2019-01-20 04:49:48 +01:00
|
|
|
#pragma once
|
|
|
|
|
2020-02-06 20:33:02 +01:00
|
|
|
#include <LibGUI/AbstractButton.h>
|
2019-01-20 04:49:48 +01:00
|
|
|
|
2020-02-02 15:07:41 +01:00
|
|
|
namespace GUI {
|
|
|
|
|
|
|
|
class CheckBox : public AbstractButton {
|
2020-12-28 13:18:10 +01:00
|
|
|
C_OBJECT(CheckBox);
|
|
|
|
|
2019-01-20 04:49:48 +01:00
|
|
|
public:
|
2022-02-26 10:50:04 -07:00
|
|
|
virtual ~CheckBox() override = default;
|
2019-01-20 04:49:48 +01:00
|
|
|
|
2020-05-12 20:30:33 +02:00
|
|
|
virtual void click(unsigned modifiers = 0) override;
|
2019-03-06 12:52:41 +01:00
|
|
|
|
2021-04-04 11:12:17 -04:00
|
|
|
bool is_autosize() const { return m_autosize; }
|
|
|
|
void set_autosize(bool);
|
|
|
|
|
2022-05-09 19:20:35 +01:00
|
|
|
enum class CheckBoxPosition {
|
|
|
|
Left,
|
|
|
|
Right,
|
|
|
|
};
|
|
|
|
CheckBoxPosition checkbox_position() const { return m_checkbox_position; }
|
|
|
|
void set_checkbox_position(CheckBoxPosition value) { m_checkbox_position = value; }
|
|
|
|
|
2022-07-23 13:49:41 +02:00
|
|
|
protected:
|
2022-12-04 18:02:33 +00:00
|
|
|
explicit CheckBox(DeprecatedString = {});
|
2019-09-21 18:58:48 +02:00
|
|
|
|
2022-07-23 13:49:41 +02:00
|
|
|
private:
|
2021-04-04 11:12:17 -04:00
|
|
|
void size_to_fit();
|
|
|
|
|
2019-07-13 10:27:19 +02:00
|
|
|
// These don't make sense for a check box, so hide them.
|
2020-02-02 15:07:41 +01:00
|
|
|
using AbstractButton::auto_repeat_interval;
|
|
|
|
using AbstractButton::set_auto_repeat_interval;
|
2019-07-13 10:27:19 +02:00
|
|
|
|
2020-02-02 15:07:41 +01:00
|
|
|
virtual void paint_event(PaintEvent&) override;
|
2021-04-04 11:12:17 -04:00
|
|
|
|
|
|
|
bool m_autosize { false };
|
2022-05-09 19:20:35 +01:00
|
|
|
CheckBoxPosition m_checkbox_position { CheckBoxPosition::Left };
|
2019-01-20 04:49:48 +01:00
|
|
|
};
|
2020-02-02 15:07:41 +01:00
|
|
|
|
|
|
|
}
|