blob: a6cac1a1dae2519faf3d6a2bfd280eb59b977fab (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
#include "cru/ui/controls/CheckBox.h"
#include "cru/ui/ThemeManager.h"
#include "cru/ui/helper/ClickDetector.h"
#include "cru/ui/render/BorderRenderObject.h"
namespace cru::ui::controls {
CheckBox::CheckBox()
: Control(kControlName), checked_(false), click_detector_(this) {
container_render_object_.SetAttachedControl(this);
container_render_object_.SetBorderEnabled(true);
auto default_checkbox_style =
ThemeManager::GetInstance()->GetResourceStyleRuleSet("checkbox.style");
GetStyleRuleSet()->SetParent(std::move(default_checkbox_style));
click_detector_.ClickEvent()->AddHandler(
[this](const helper::ClickEventArgs&) { Toggle(); });
}
CheckBox::~CheckBox() {}
void CheckBox::SetChecked(bool checked) {
checked_ = checked;
checked_change_event_.Raise(checked);
}
void CheckBox::ApplyBorderStyle(const style::ApplyBorderStyleInfo& style) {
container_render_object_.ApplyBorderStyle(style);
}
} // namespace cru::ui::controls
|