• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2023 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 #include "core/interfaces/native/node/node_checkbox_modifier.h"
16 
17 #include "core/components_ng/base/view_abstract.h"
18 #include "core/components_ng/pattern/checkbox/checkbox_model_ng.h"
19 #include "core/pipeline_ng/pipeline_context.h"
20 #include "frameworks/core/components/checkable/checkable_theme.h"
21 
22 namespace OHOS::Ace::NG {
23 constexpr float CHECK_BOX_MARK_SIZE_INVALID_VALUE = -1.0f;
24 const uint32_t ERROR_UINT_CODE = -1;
25 const float ERROR_FLOAT_CODE = -1.0f;
26 const int32_t ERROR_INT_CODE = -1;
27 static std::string nameValue;
28 
SetSelect(ArkUINodeHandle node,ArkUI_Bool isSelected)29 void SetSelect(ArkUINodeHandle node, ArkUI_Bool isSelected)
30 {
31     auto *frameNode = reinterpret_cast<FrameNode *>(node);
32     CHECK_NULL_VOID(frameNode);
33     CheckBoxModelNG::SetSelect(frameNode, static_cast<bool>(isSelected));
34 }
35 
SetSelectedColor(ArkUINodeHandle node,ArkUI_Uint32 color)36 void SetSelectedColor(ArkUINodeHandle node, ArkUI_Uint32 color)
37 {
38     auto* frameNode = reinterpret_cast<FrameNode*>(node);
39     CHECK_NULL_VOID(frameNode);
40     CheckBoxModelNG::SetSelectedColor(frameNode, Color(color));
41 }
42 
SetSelectedColorPtr(ArkUINodeHandle node,ArkUI_Uint32 color,void * colorRawPtr)43 void SetSelectedColorPtr(ArkUINodeHandle node, ArkUI_Uint32 color, void* colorRawPtr)
44 {
45     CHECK_NULL_VOID(node);
46     SetSelectedColor(node, color);
47     if (SystemProperties::ConfigChangePerform()) {
48         auto* frameNode = reinterpret_cast<FrameNode*>(node);
49         CHECK_NULL_VOID(frameNode);
50         auto* color = reinterpret_cast<ResourceObject*>(colorRawPtr);
51         auto colorResObj = AceType::Claim(color);
52         CheckBoxModelNG::CreateWithResourceObj(frameNode, CheckBoxColorType::SELECTED_COLOR, colorResObj);
53     }
54 }
55 
SetUnSelectedColor(ArkUINodeHandle node,ArkUI_Uint32 color)56 void SetUnSelectedColor(ArkUINodeHandle node, ArkUI_Uint32 color)
57 {
58     auto* frameNode = reinterpret_cast<FrameNode*>(node);
59     CHECK_NULL_VOID(frameNode);
60     CheckBoxModelNG::SetUnSelectedColor(frameNode, Color(color));
61 }
62 
SetUnSelectedColorPtr(ArkUINodeHandle node,ArkUI_Uint32 color,void * colorRawPtr)63 void SetUnSelectedColorPtr(ArkUINodeHandle node, ArkUI_Uint32 color, void* colorRawPtr)
64 {
65     CHECK_NULL_VOID(node);
66     SetUnSelectedColor(node, color);
67     if (SystemProperties::ConfigChangePerform()) {
68         auto* frameNode = reinterpret_cast<FrameNode*>(node);
69         CHECK_NULL_VOID(frameNode);
70         auto* color = reinterpret_cast<ResourceObject*>(colorRawPtr);
71         auto colorResObj = AceType::Claim(color);
72         CheckBoxModelNG::CreateWithResourceObj(frameNode, CheckBoxColorType::UN_SELECTED_COLOR, colorResObj);
73     }
74 }
75 
SetCheckboxWidth(ArkUINodeHandle node,float value,int unit)76 void SetCheckboxWidth(ArkUINodeHandle node, float value, int unit)
77 {
78     auto *frameNode = reinterpret_cast<FrameNode *>(node);
79     CHECK_NULL_VOID(frameNode);
80     Dimension width =
81         Dimension(static_cast<double>(value), static_cast<OHOS::Ace::DimensionUnit>(unit));
82     CheckBoxModelNG::SetWidth(frameNode, width);
83 }
84 
SetCheckboxHeight(ArkUINodeHandle node,float value,int unit)85 void SetCheckboxHeight(ArkUINodeHandle node, float value, int unit)
86 {
87     auto *frameNode = reinterpret_cast<FrameNode *>(node);
88     CHECK_NULL_VOID(frameNode);
89     Dimension height =
90         Dimension(static_cast<double>(value), static_cast<OHOS::Ace::DimensionUnit>(unit));
91     CheckBoxModelNG::SetHeight(frameNode, height);
92 }
93 
SetMark(ArkUINodeHandle node,uint32_t color,float sizeValue,int sizeUnit,float widthValue,int widthUnit)94 void SetMark(ArkUINodeHandle node, uint32_t color, float sizeValue, int sizeUnit, float widthValue, int widthUnit)
95 {
96     auto *frameNode = reinterpret_cast<FrameNode *>(node);
97     CHECK_NULL_VOID(frameNode);
98     CheckBoxModelNG::SetCheckMarkColor(frameNode, Color(color));
99 
100     Dimension size = Dimension(static_cast<double>(sizeValue), static_cast<OHOS::Ace::DimensionUnit>(sizeUnit));
101     CheckBoxModelNG::SetCheckMarkSize(frameNode, size);
102 
103     Dimension width = Dimension(static_cast<double>(widthValue), static_cast<OHOS::Ace::DimensionUnit>(widthUnit));
104     CheckBoxModelNG::SetCheckMarkWidth(frameNode, width);
105 }
106 
SetCheckboxPadding(ArkUINodeHandle node,const ArkUI_Float32 * values,const int * units,uint32_t length)107 void SetCheckboxPadding(ArkUINodeHandle node, const ArkUI_Float32* values, const int* units, uint32_t length)
108 {
109     auto* frameNode = reinterpret_cast<FrameNode*>(node);
110     CHECK_NULL_VOID(frameNode);
111     if (length != 4) { // 4 : data length
112         return;
113     }
114     CalcLength topDim;
115     CalcLength rightDim;
116     CalcLength bottomDim;
117     CalcLength leftDim;
118     topDim = CalcLength(values[0], static_cast<DimensionUnit>(units[0])); // 0: top Dimension
119     rightDim = CalcLength(values[1], static_cast<DimensionUnit>(units[1])); // 1: right Dimension
120     bottomDim = CalcLength(values[2], static_cast<DimensionUnit>(units[2])); // 2: bottom Dimension
121     leftDim = CalcLength(values[3], static_cast<DimensionUnit>(units[3])); // 3: left Dimension
122     NG::PaddingProperty padding;
123     padding.top = std::optional<CalcLength>(topDim);
124     padding.bottom = std::optional<CalcLength>(bottomDim);
125     padding.left = std::optional<CalcLength>(leftDim);
126     padding.right = std::optional<CalcLength>(rightDim);
127 
128     CheckBoxModelNG::SetPadding(frameNode, padding);
129 }
130 
SetCheckboxResponseRegion(ArkUINodeHandle node,const ArkUI_Float32 * values,const int32_t * units,uint32_t length)131 void SetCheckboxResponseRegion(ArkUINodeHandle node, const ArkUI_Float32* values, const int32_t* units, uint32_t length)
132 {
133     auto* frameNode = reinterpret_cast<FrameNode*>(node);
134     CHECK_NULL_VOID(frameNode);
135     std::vector<DimensionRect> region;
136     uint32_t ARRAY_LENGTH = 4; // 4: dimension length
137     for (uint32_t i = 0; i < length / 4; i++) {
138         CalcDimension xDimen =
139             CalcDimension(values[i * ARRAY_LENGTH], static_cast<DimensionUnit>(units[i * ARRAY_LENGTH]));
140         CalcDimension yDimen =
141             CalcDimension(values[i * ARRAY_LENGTH + 1], static_cast<DimensionUnit>(units[i * ARRAY_LENGTH + 1]));
142         CalcDimension widthDimen = CalcDimension(
143             values[i * ARRAY_LENGTH + 2], static_cast<DimensionUnit>(units[i * ARRAY_LENGTH + 2])); // 2: width value
144         CalcDimension heightDimen = CalcDimension(
145             values[i * ARRAY_LENGTH + 3], static_cast<DimensionUnit>(units[i * ARRAY_LENGTH + 3])); // 3: height value
146         DimensionOffset offsetDimen(xDimen, yDimen);
147         DimensionRect dimenRect(widthDimen, heightDimen, offsetDimen);
148         region.emplace_back(dimenRect);
149     }
150     CheckBoxModelNG::SetResponseRegion(frameNode, region);
151 }
152 
SetCheckboxOnChange(ArkUINodeHandle node,void * callback)153 void SetCheckboxOnChange(ArkUINodeHandle node, void* callback)
154 {
155     auto* frameNode = reinterpret_cast<FrameNode*>(node);
156     CHECK_NULL_VOID(frameNode);
157     if (callback) {
158         auto onChange = reinterpret_cast<std::function<void(bool)>*>(callback);
159         CheckBoxModelNG::SetOnChange(frameNode, std::move(*onChange));
160     } else {
161         CheckBoxModelNG::SetOnChange(frameNode, nullptr);
162     }
163 }
164 
ResetCheckboxPadding(ArkUINodeHandle node)165 void ResetCheckboxPadding(ArkUINodeHandle node)
166 {
167     auto* frameNode = reinterpret_cast<FrameNode*>(node);
168     CHECK_NULL_VOID(frameNode);
169     NG::PaddingProperty padding;
170     padding.top = std::optional<CalcLength>(CalcLength(0.0, DimensionUnit::VP));
171     padding.bottom = std::optional<CalcLength>(CalcLength(0.0, DimensionUnit::VP));
172     padding.left = std::optional<CalcLength>(CalcLength(0.0, DimensionUnit::VP));
173     padding.right = std::optional<CalcLength>(CalcLength(0.0, DimensionUnit::VP));
174 
175     CheckBoxModelNG::SetPadding(frameNode, padding);
176 }
177 
ResetCheckboxResponseRegion(ArkUINodeHandle node)178 void ResetCheckboxResponseRegion(ArkUINodeHandle node) {}
179 
ResetCheckboxOnChange(ArkUINodeHandle node)180 void ResetCheckboxOnChange(ArkUINodeHandle node)
181 {
182     auto *frameNode = reinterpret_cast<FrameNode *>(node);
183     CHECK_NULL_VOID(frameNode);
184     CheckBoxModelNG::SetOnChange(frameNode, nullptr);
185 }
186 
ResetSelect(ArkUINodeHandle node)187 void ResetSelect(ArkUINodeHandle node)
188 {
189     auto *frameNode = reinterpret_cast<FrameNode *>(node);
190     CHECK_NULL_VOID(frameNode);
191     CheckBoxModelNG::SetSelect(frameNode, false);
192 }
193 
ResetSelectedColor(ArkUINodeHandle node)194 void ResetSelectedColor(ArkUINodeHandle node)
195 {
196     auto *frameNode = reinterpret_cast<FrameNode *>(node);
197     CHECK_NULL_VOID(frameNode);
198     CheckBoxModelNG::ResetSelectedColor(frameNode);
199     if (SystemProperties::ConfigChangePerform()) {
200         CheckBoxModelNG::CreateWithResourceObj(frameNode, CheckBoxColorType::SELECTED_COLOR, nullptr);
201     }
202 }
203 
ResetUnSelectedColor(ArkUINodeHandle node)204 void ResetUnSelectedColor(ArkUINodeHandle node)
205 {
206     auto *frameNode = reinterpret_cast<FrameNode *>(node);
207     CHECK_NULL_VOID(frameNode);
208     CheckBoxModelNG::ResetUnSelectedColor(frameNode);
209     if (SystemProperties::ConfigChangePerform()) {
210         CheckBoxModelNG::CreateWithResourceObj(frameNode, CheckBoxColorType::UN_SELECTED_COLOR, nullptr);
211     }
212 }
213 
ResetCheckboxWidth(ArkUINodeHandle node)214 void ResetCheckboxWidth(ArkUINodeHandle node)
215 {
216     auto *frameNode = reinterpret_cast<FrameNode *>(node);
217     CHECK_NULL_VOID(frameNode);
218     auto pipelineContext = frameNode->GetContext();
219     CHECK_NULL_VOID(pipelineContext);
220     auto checkBoxTheme = pipelineContext->GetTheme<CheckboxTheme>();
221     CHECK_NULL_VOID(checkBoxTheme);
222     auto defaultWidth = checkBoxTheme->GetDefaultWidth();
223     auto horizontalPadding = checkBoxTheme->GetHotZoneHorizontalPadding();
224     auto width = defaultWidth - horizontalPadding * 2;
225     CheckBoxModelNG::SetWidth(frameNode, width);
226 }
227 
ResetCheckboxHeight(ArkUINodeHandle node)228 void ResetCheckboxHeight(ArkUINodeHandle node)
229 {
230     auto *frameNode = reinterpret_cast<FrameNode *>(node);
231     CHECK_NULL_VOID(frameNode);
232     auto pipelineContext = frameNode->GetContext();
233     CHECK_NULL_VOID(pipelineContext);
234     auto checkBoxTheme = pipelineContext->GetTheme<CheckboxTheme>();
235     CHECK_NULL_VOID(checkBoxTheme);
236     auto defaultHeight = checkBoxTheme->GetDefaultHeight();
237     auto verticalPadding = checkBoxTheme->GetHotZoneVerticalPadding();
238     auto height = defaultHeight - verticalPadding * 2;
239 
240     CheckBoxModelNG::SetHeight(frameNode, height);
241 }
242 
ResetMark(ArkUINodeHandle node)243 void ResetMark(ArkUINodeHandle node)
244 {
245     auto *frameNode = reinterpret_cast<FrameNode *>(node);
246     CHECK_NULL_VOID(frameNode);
247     auto pipelineContext = frameNode->GetContext();
248     CHECK_NULL_VOID(pipelineContext);
249     auto checkBoxTheme = pipelineContext->GetTheme<CheckboxTheme>();
250 
251     CheckBoxModelNG::ResetCheckMarkColor(frameNode);
252     CheckBoxModelNG::SetCheckMarkSize(
253         frameNode, Dimension(CHECK_BOX_MARK_SIZE_INVALID_VALUE));
254     CheckBoxModelNG::SetCheckMarkWidth(frameNode, checkBoxTheme->GetCheckStroke());
255 }
256 
SetCheckboxShape(ArkUINodeHandle node,ArkUI_Int32 value)257 void SetCheckboxShape(ArkUINodeHandle node, ArkUI_Int32 value)
258 {
259     auto *frameNode = reinterpret_cast<FrameNode *>(node);
260     CHECK_NULL_VOID(frameNode);
261     CheckBoxModelNG::SetCheckboxStyle(frameNode, static_cast<CheckBoxStyle>(value));
262 }
263 
ResetCheckboxShape(ArkUINodeHandle node)264 void ResetCheckboxShape(ArkUINodeHandle node)
265 {
266     auto *frameNode = reinterpret_cast<FrameNode *>(node);
267     CHECK_NULL_VOID(frameNode);
268     CheckBoxModelNG::SetCheckboxStyle(frameNode, CheckBoxStyle::CIRCULAR_STYLE);
269 }
270 
SetIsUserSetMargin(ArkUINodeHandle node)271 void SetIsUserSetMargin(ArkUINodeHandle node)
272 {
273     auto* frameNode = reinterpret_cast<FrameNode*>(node);
274     CHECK_NULL_VOID(frameNode);
275     CheckBoxModelNG::SetIsUserSetMargin(frameNode, true);
276 }
277 
GetSelect(ArkUINodeHandle node)278 ArkUI_Bool GetSelect(ArkUINodeHandle node)
279 {
280     auto *frameNode = reinterpret_cast<FrameNode *>(node);
281     CHECK_NULL_RETURN(frameNode, ERROR_INT_CODE);
282     return static_cast<ArkUI_Bool>(CheckBoxModelNG::GetSelect(frameNode));
283 }
284 
GetSelectedColor(ArkUINodeHandle node)285 ArkUI_Uint32 GetSelectedColor(ArkUINodeHandle node)
286 {
287     auto *frameNode = reinterpret_cast<FrameNode *>(node);
288     CHECK_NULL_RETURN(frameNode, ERROR_UINT_CODE);
289     return CheckBoxModelNG::GetSelectedColor(frameNode).GetValue();
290 }
291 
GetUnSelectedColor(ArkUINodeHandle node)292 ArkUI_Uint32 GetUnSelectedColor(ArkUINodeHandle node)
293 {
294     auto *frameNode = reinterpret_cast<FrameNode *>(node);
295     CHECK_NULL_RETURN(frameNode, ERROR_UINT_CODE);
296     return CheckBoxModelNG::GetUnSelectedColor(frameNode).GetValue();
297 }
298 
GetCheckMarkColor(ArkUINodeHandle node)299 ArkUI_Uint32 GetCheckMarkColor(ArkUINodeHandle node)
300 {
301     auto *frameNode = reinterpret_cast<FrameNode *>(node);
302     CHECK_NULL_RETURN(frameNode, ERROR_UINT_CODE);
303     return CheckBoxModelNG::GetCheckMarkColor(frameNode).GetValue();
304 }
305 
GetCheckMarkSize(ArkUINodeHandle node)306 ArkUI_Float64 GetCheckMarkSize(ArkUINodeHandle node)
307 {
308     auto *frameNode = reinterpret_cast<FrameNode *>(node);
309     CHECK_NULL_RETURN(frameNode, ERROR_FLOAT_CODE);
310     return CheckBoxModelNG::GetCheckMarkSize(frameNode).Value();
311 }
312 
GetCheckMarkWidth(ArkUINodeHandle node)313 ArkUI_Float64 GetCheckMarkWidth(ArkUINodeHandle node)
314 {
315     auto *frameNode = reinterpret_cast<FrameNode *>(node);
316     CHECK_NULL_RETURN(frameNode, ERROR_FLOAT_CODE);
317     return CheckBoxModelNG::GetCheckMarkWidth(frameNode).Value();
318 }
319 
GetCheckboxShape(ArkUINodeHandle node)320 ArkUI_Int32 GetCheckboxShape(ArkUINodeHandle node)
321 {
322     auto *frameNode = reinterpret_cast<FrameNode *>(node);
323     CHECK_NULL_RETURN(frameNode, ERROR_INT_CODE);
324     return static_cast<ArkUI_Int32>(CheckBoxModelNG::GetCheckboxStyle(frameNode));
325 }
326 
SetCheckboxName(ArkUINodeHandle node,ArkUI_CharPtr name)327 void SetCheckboxName(ArkUINodeHandle node, ArkUI_CharPtr name)
328 {
329     CHECK_NULL_VOID(name);
330     auto* frameNode = reinterpret_cast<FrameNode*>(node);
331     CHECK_NULL_VOID(frameNode);
332     CheckBoxModelNG::SetCheckboxName(frameNode, std::string(name));
333 }
334 
SetCheckboxGroup(ArkUINodeHandle node,ArkUI_CharPtr group)335 void SetCheckboxGroup(ArkUINodeHandle node, ArkUI_CharPtr group)
336 {
337     CHECK_NULL_VOID(group);
338     auto* frameNode = reinterpret_cast<FrameNode*>(node);
339     CHECK_NULL_VOID(frameNode);
340     CheckBoxModelNG::SetCheckboxGroup(frameNode, std::string(group));
341 }
342 
GetCheckboxName(ArkUINodeHandle node)343 ArkUI_CharPtr GetCheckboxName(ArkUINodeHandle node)
344 {
345     auto *frameNode = reinterpret_cast<FrameNode *>(node);
346     CHECK_NULL_RETURN(frameNode, "");
347     nameValue = CheckBoxModelNG::GetCheckboxName(frameNode);
348     return nameValue.c_str();
349 }
350 
GetCheckboxGroup(ArkUINodeHandle node)351 ArkUI_CharPtr GetCheckboxGroup(ArkUINodeHandle node)
352 {
353     auto *frameNode = reinterpret_cast<FrameNode *>(node);
354     CHECK_NULL_RETURN(frameNode, "");
355     nameValue = CheckBoxModelNG::GetCheckboxGroup(frameNode);
356     return nameValue.c_str();
357 }
358 
359 namespace NodeModifier {
GetCheckboxModifier()360 const ArkUICheckboxModifier *GetCheckboxModifier()
361 {
362     CHECK_INITIALIZED_FIELDS_BEGIN(); // don't move this line
363     static const ArkUICheckboxModifier modifier = {
364         .setSelect = SetSelect,
365         .setSelectedColor = SetSelectedColor,
366         .setUnSelectedColor = SetUnSelectedColor,
367         .setCheckboxWidth = SetCheckboxWidth,
368         .setCheckboxHeight = SetCheckboxHeight,
369         .setMark = SetMark,
370         .setCheckboxPadding = SetCheckboxPadding,
371         .setCheckboxResponseRegion = SetCheckboxResponseRegion,
372         .setCheckboxOnChange = SetCheckboxOnChange,
373         .resetSelect = ResetSelect,
374         .resetSelectedColor = ResetSelectedColor,
375         .resetUnSelectedColor = ResetUnSelectedColor,
376         .resetCheckboxWidth = ResetCheckboxWidth,
377         .resetCheckboxHeight = ResetCheckboxHeight,
378         .resetMark = ResetMark,
379         .setCheckboxShape = SetCheckboxShape,
380         .resetCheckboxShape = ResetCheckboxShape,
381         .resetCheckboxPadding = ResetCheckboxPadding,
382         .resetCheckboxResponseRegion = ResetCheckboxResponseRegion,
383         .resetCheckboxOnChange = ResetCheckboxOnChange,
384         .setIsUserSetMargin = SetIsUserSetMargin,
385         .getSelect = GetSelect,
386         .getSelectedColor = GetSelectedColor,
387         .getUnSelectedColor = GetUnSelectedColor,
388         .getCheckMarkColor = GetCheckMarkColor,
389         .getCheckMarkSize = GetCheckMarkSize,
390         .getCheckMarkWidth = GetCheckMarkWidth,
391         .getCheckboxShape = GetCheckboxShape,
392         .setCheckboxName = SetCheckboxName,
393         .setCheckboxGroup = SetCheckboxGroup,
394         .getCheckboxName = GetCheckboxName,
395         .getCheckboxGroup = GetCheckboxGroup,
396         .setSelectedColorPtr = SetSelectedColorPtr,
397         .setUnSelectedColorPtr = SetUnSelectedColorPtr,
398     };
399     CHECK_INITIALIZED_FIELDS_END(modifier, 0, 0, 0); // don't move this line
400     return &modifier;
401 }
402 
GetCJUICheckboxModifier()403 const CJUICheckboxModifier* GetCJUICheckboxModifier()
404 {
405     CHECK_INITIALIZED_FIELDS_BEGIN(); // don't move this line
406     static const CJUICheckboxModifier modifier = {
407         .setSelect = SetSelect,
408         .setSelectedColor = SetSelectedColor,
409         .setUnSelectedColor = SetUnSelectedColor,
410         .setCheckboxWidth = SetCheckboxWidth,
411         .setCheckboxHeight = SetCheckboxHeight,
412         .setMark = SetMark,
413         .setCheckboxPadding = SetCheckboxPadding,
414         .setCheckboxResponseRegion = SetCheckboxResponseRegion,
415         .resetSelect = ResetSelect,
416         .resetSelectedColor = ResetSelectedColor,
417         .resetUnSelectedColor = ResetUnSelectedColor,
418         .resetCheckboxWidth = ResetCheckboxWidth,
419         .resetCheckboxHeight = ResetCheckboxHeight,
420         .resetMark = ResetMark,
421         .setCheckboxShape = SetCheckboxShape,
422         .resetCheckboxShape = ResetCheckboxShape,
423         .resetCheckboxPadding = ResetCheckboxPadding,
424         .resetCheckboxResponseRegion = ResetCheckboxResponseRegion,
425         .getSelect = GetSelect,
426         .getSelectedColor = GetSelectedColor,
427         .getUnSelectedColor = GetUnSelectedColor,
428         .getCheckMarkColor = GetCheckMarkColor,
429         .getCheckMarkSize = GetCheckMarkSize,
430         .getCheckMarkWidth = GetCheckMarkWidth,
431         .getCheckboxShape = GetCheckboxShape,
432         .setCheckboxName = SetCheckboxName,
433         .setCheckboxGroup = SetCheckboxGroup,
434         .getCheckboxName = GetCheckboxName,
435         .getCheckboxGroup = GetCheckboxGroup,
436     };
437     CHECK_INITIALIZED_FIELDS_END(modifier, 0, 0, 0); // don't move this line
438     return &modifier;
439 }
440 
SetCheckboxChange(ArkUINodeHandle node,void * extraParam)441 void SetCheckboxChange(ArkUINodeHandle node, void* extraParam)
442 {
443     auto* frameNode = reinterpret_cast<FrameNode*>(node);
444     CHECK_NULL_VOID(frameNode);
445     auto onEvent = [node, extraParam](const bool value) {
446         ArkUINodeEvent event;
447         event.kind = COMPONENT_ASYNC_EVENT;
448         event.extraParam = reinterpret_cast<intptr_t>(extraParam);
449         event.componentAsyncEvent.subKind = ON_CHECKBOX_CHANGE;
450         event.componentAsyncEvent.data[0].i32 = static_cast<int>(value);
451         SendArkUISyncEvent(&event);
452     };
453     CheckBoxModelNG::SetOnChange(frameNode, std::move(onEvent));
454 }
455 
456 } // namespace NodeModifier
457 } // namespace OHOS::Ace::NG
458