Skip to main content

ferroui_controls/
check_box.rs

1use crate::primitives::{TemplatedControlImpl, ToggleButton, ToggleButtonImpl};
2use crate::{ButtonImpl, ContentControlImpl, ControlImpl};
3use ferroui_base::input::InputElementImpl;
4use ferroui_base::interactivity::InteractiveImpl;
5use ferroui_base::layout::LayoutableImpl;
6use ferroui_base::{
7    ferro_class, ferro_impl_classes, instantiate, FerroObjectImpl, Ref, StyledElementImpl, VisualImpl,
8};
9
10/// A check box control.
11#[repr(C)]
12pub struct CheckBox {
13    base: ToggleButton,
14}
15
16ferro_class!(CheckBox: ToggleButton);
17ferroui_base::ferro_class_info!(CheckBox { new: CheckBox::new });
18ferro_impl_classes!(
19    CheckBox: FerroObjectImpl,
20    StyledElementImpl,
21    VisualImpl,
22    LayoutableImpl,
23    InteractiveImpl,
24    InputElementImpl,
25    ControlImpl,
26    TemplatedControlImpl,
27    ContentControlImpl,
28    ButtonImpl,
29    ToggleButtonImpl
30);
31
32impl CheckBox {
33    fn static_constructor() {
34        crate::automation::AutomationProperties::control_type_override_property()
35            .override_default_value::<CheckBox>(Some(crate::automation::peers::AutomationControlType::CheckBox));
36    }
37
38    /// Creates the class data; see [`ferroui_base::FerroObject::construct`].
39    pub fn construct() -> Self {
40        Self { base: ToggleButton::construct() }
41    }
42
43    /// Creates a check box.
44    pub fn new() -> Ref<Self> {
45        instantiate(Self::construct())
46    }
47}