• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2024 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 
16 #include <cstdint>
17 #include "native_styled_string.h"
18 #include "node_extened.h"
19 #include "styled_string.h"
20 
21 #include "base/utils/utils.h"
22 
23 #ifdef __cplusplus
24 extern "C" {
25 #endif
26 
27 constexpr int NUM_0 = 0;
28 constexpr int NUM_1 = 1;
29 constexpr int NUM_2 = 2;
30 constexpr int NUM_3 = 3;
31 constexpr int NUM_4 = 4;
32 constexpr int NUM_5 = 5;
33 constexpr int32_t MAX_DISPLAY_COUNT_MIN = 6;
34 constexpr int32_t MAX_DISPLAY_COUNT_MAX = 9;
35 constexpr float DEFAULT_SIZE_18 = 18.0f;
36 constexpr float DEFAULT_SIZE_24 = 24.0f;
37 constexpr float DEFAULT_SIZE_32 = 32.0f;
38 constexpr float ARROW_SIZE_COEFFICIENT = 0.75f;
39 constexpr int EXPECTED_UPDATE_INTERVAL_VALUE = 1000;
40 constexpr float DEFAULT_VISIBLE_RATIO_MIN = 0.0f;
41 constexpr float DEFAULT_VISIBLE_RATIO_MAX = 1.0f;
42 
OH_ArkUI_LayoutConstraint_Create()43 ArkUI_LayoutConstraint* OH_ArkUI_LayoutConstraint_Create()
44 {
45     ArkUI_LayoutConstraint* layoutConstraint = new ArkUI_LayoutConstraint { 0, 0, 0, 0, 0, 0 };
46     return layoutConstraint;
47 }
48 
OH_ArkUI_LayoutConstraint_Copy(const ArkUI_LayoutConstraint * constraint)49 ArkUI_LayoutConstraint* OH_ArkUI_LayoutConstraint_Copy(const ArkUI_LayoutConstraint* constraint)
50 {
51     CHECK_NULL_RETURN(constraint, nullptr);
52     ArkUI_LayoutConstraint* layoutConstraint = new ArkUI_LayoutConstraint { 0, 0, 0, 0, 0, 0 };
53     layoutConstraint->minWidth = constraint->minWidth;
54     layoutConstraint->maxWidth = constraint->maxWidth;
55     layoutConstraint->minHeight = constraint->minHeight;
56     layoutConstraint->maxHeight = constraint->maxHeight;
57     layoutConstraint->percentReferWidth = constraint->percentReferWidth;
58     layoutConstraint->percentReferHeight = constraint->percentReferHeight;
59     return layoutConstraint;
60 }
61 
OH_ArkUI_LayoutConstraint_Dispose(ArkUI_LayoutConstraint * constraint)62 void* OH_ArkUI_LayoutConstraint_Dispose(ArkUI_LayoutConstraint* constraint)
63 {
64     delete constraint;
65     return nullptr;
66 }
67 
OH_ArkUI_NodeCustomEvent_GetLayoutConstraintInMeasure(ArkUI_NodeCustomEvent * event)68 ArkUI_LayoutConstraint* OH_ArkUI_NodeCustomEvent_GetLayoutConstraintInMeasure(ArkUI_NodeCustomEvent* event)
69 {
70     CHECK_NULL_RETURN(event, nullptr);
71     ArkUI_LayoutConstraint* layoutConstraint = new ArkUI_LayoutConstraint;
72     layoutConstraint->minWidth = event->event->data[NUM_0];
73     layoutConstraint->minHeight = event->event->data[NUM_1];
74     layoutConstraint->maxWidth = event->event->data[NUM_2];
75     layoutConstraint->maxHeight = event->event->data[NUM_3];
76     layoutConstraint->percentReferWidth = event->event->data[NUM_4];
77     layoutConstraint->percentReferHeight = event->event->data[NUM_5];
78     return layoutConstraint;
79 }
80 
OH_ArkUI_NodeCustomEvent_GetPositionInLayout(ArkUI_NodeCustomEvent * event)81 ArkUI_IntOffset OH_ArkUI_NodeCustomEvent_GetPositionInLayout(ArkUI_NodeCustomEvent* event)
82 {
83     ArkUI_IntOffset intOffset;
84     CHECK_NULL_RETURN(event, intOffset);
85     intOffset.x = event->event->data[NUM_0];
86     intOffset.y = event->event->data[NUM_1];
87     return intOffset;
88 }
89 
OH_ArkUI_NodeCustomEvent_GetDrawContextInDraw(ArkUI_NodeCustomEvent * event)90 ArkUI_DrawContext* OH_ArkUI_NodeCustomEvent_GetDrawContextInDraw(ArkUI_NodeCustomEvent* event)
91 {
92     CHECK_NULL_RETURN(event, nullptr);
93     ArkUI_DrawContext* drawContext = new ArkUI_DrawContext();
94     drawContext->width = event->event->data[NUM_2];
95     drawContext->height = event->event->data[NUM_3];
96     drawContext->canvas = reinterpret_cast<void*>(event->event->canvas);
97     return drawContext;
98 }
99 
OH_ArkUI_NodeCustomEvent_GetEventTargetId(ArkUI_NodeCustomEvent * event)100 int32_t OH_ArkUI_NodeCustomEvent_GetEventTargetId(ArkUI_NodeCustomEvent* event)
101 {
102     CHECK_NULL_RETURN(event, -1);
103     return event->targetId;
104 }
105 
OH_ArkUI_NodeCustomEvent_GetUserData(ArkUI_NodeCustomEvent * event)106 void* OH_ArkUI_NodeCustomEvent_GetUserData(ArkUI_NodeCustomEvent* event)
107 {
108     CHECK_NULL_RETURN(event, nullptr);
109     return event->userData;
110 }
111 
OH_ArkUI_NodeCustomEvent_GetNodeHandle(ArkUI_NodeCustomEvent * event)112 ArkUI_NodeHandle OH_ArkUI_NodeCustomEvent_GetNodeHandle(ArkUI_NodeCustomEvent* event)
113 {
114     CHECK_NULL_RETURN(event, nullptr);
115     return event->node;
116 }
117 
OH_ArkUI_NodeCustomEvent_GetEventType(ArkUI_NodeCustomEvent * event)118 ArkUI_NodeCustomEventType OH_ArkUI_NodeCustomEvent_GetEventType(ArkUI_NodeCustomEvent* event)
119 {
120     CHECK_NULL_RETURN(event, static_cast<ArkUI_NodeCustomEventType>(-1));
121     return static_cast<ArkUI_NodeCustomEventType>(event->event->kind);
122 }
123 
OH_ArkUI_NodeCustomEvent_GetCustomSpanMeasureInfo(ArkUI_NodeCustomEvent * event,ArkUI_CustomSpanMeasureInfo * info)124 int32_t OH_ArkUI_NodeCustomEvent_GetCustomSpanMeasureInfo(
125     ArkUI_NodeCustomEvent* event, ArkUI_CustomSpanMeasureInfo* info)
126 {
127     if (!event || !info || !event->event) {
128         return ARKUI_ERROR_CODE_PARAM_INVALID;
129     }
130     info->fontSize = event->event->numberData[0].f32;
131     return ARKUI_ERROR_CODE_NO_ERROR;
132 }
133 
OH_ArkUI_NodeCustomEvent_SetCustomSpanMetrics(ArkUI_NodeCustomEvent * event,ArkUI_CustomSpanMetrics * metrics)134 int32_t OH_ArkUI_NodeCustomEvent_SetCustomSpanMetrics(
135     ArkUI_NodeCustomEvent* event, ArkUI_CustomSpanMetrics* metrics)
136 {
137     if (!event || !metrics || !event->event) {
138         return ARKUI_ERROR_CODE_PARAM_INVALID;
139     }
140     event->event->numberReturnData[0].f32 = metrics->width;
141     event->event->numberReturnData[1].f32 = metrics->height;
142     return ARKUI_ERROR_CODE_NO_ERROR;
143 }
144 
OH_ArkUI_NodeCustomEvent_GetCustomSpanDrawInfo(ArkUI_NodeCustomEvent * event,ArkUI_CustomSpanDrawInfo * info)145 int32_t OH_ArkUI_NodeCustomEvent_GetCustomSpanDrawInfo(
146     ArkUI_NodeCustomEvent* event, ArkUI_CustomSpanDrawInfo* info)
147 {
148     if (!event || !info || !event->event) {
149         return ARKUI_ERROR_CODE_PARAM_INVALID;
150     }
151     info->optionsX = event->event->numberData[0].f32;
152     info->optionsLineTop = event->event->numberData[1].f32;
153     info->optionsLineBottom = event->event->numberData[2].f32;
154     info->optionsBaseLine = event->event->numberData[3].f32;
155     return ARKUI_ERROR_CODE_NO_ERROR;
156 }
157 
OH_ArkUI_CustomSpanMeasureInfo_Create(void)158 ArkUI_CustomSpanMeasureInfo* OH_ArkUI_CustomSpanMeasureInfo_Create(void)
159 {
160     ArkUI_CustomSpanMeasureInfo* info = new ArkUI_CustomSpanMeasureInfo { 0 };
161     return info;
162 }
163 
OH_ArkUI_CustomSpanMeasureInfo_Dispose(ArkUI_CustomSpanMeasureInfo * info)164 void OH_ArkUI_CustomSpanMeasureInfo_Dispose(ArkUI_CustomSpanMeasureInfo* info)
165 {
166     if (!info) {
167         return;
168     }
169     delete info;
170     info = nullptr;
171 }
172 
OH_ArkUI_CustomSpanMeasureInfo_GetFontSize(ArkUI_CustomSpanMeasureInfo * info)173 float OH_ArkUI_CustomSpanMeasureInfo_GetFontSize(ArkUI_CustomSpanMeasureInfo* info)
174 {
175     if (!info) {
176         return 0.0f;
177     }
178     return info->fontSize;
179 }
180 
OH_ArkUI_CustomSpanMetrics_Create(void)181 ArkUI_CustomSpanMetrics* OH_ArkUI_CustomSpanMetrics_Create(void)
182 {
183     ArkUI_CustomSpanMetrics* metrics = new ArkUI_CustomSpanMetrics { 0, 0 };
184     return metrics;
185 }
186 
OH_ArkUI_CustomSpanMetrics_Dispose(ArkUI_CustomSpanMetrics * metrics)187 void OH_ArkUI_CustomSpanMetrics_Dispose(ArkUI_CustomSpanMetrics* metrics)
188 {
189     if (!metrics) {
190         return;
191     }
192     delete metrics;
193     metrics = nullptr;
194 }
195 
OH_ArkUI_CustomSpanMetrics_SetWidth(ArkUI_CustomSpanMetrics * metrics,float width)196 int32_t OH_ArkUI_CustomSpanMetrics_SetWidth(ArkUI_CustomSpanMetrics* metrics, float width)
197 {
198     if (!metrics) {
199         return ARKUI_ERROR_CODE_PARAM_INVALID;
200     }
201     metrics->width = width;
202     return ARKUI_ERROR_CODE_NO_ERROR;
203 }
204 
OH_ArkUI_CustomSpanMetrics_SetHeight(ArkUI_CustomSpanMetrics * metrics,float height)205 int32_t OH_ArkUI_CustomSpanMetrics_SetHeight(ArkUI_CustomSpanMetrics* metrics, float height)
206 {
207     if (!metrics) {
208         return ARKUI_ERROR_CODE_PARAM_INVALID;
209     }
210     metrics->height = height;
211     return ARKUI_ERROR_CODE_NO_ERROR;
212 }
213 
OH_ArkUI_CustomSpanDrawInfo_Create(void)214 ArkUI_CustomSpanDrawInfo* OH_ArkUI_CustomSpanDrawInfo_Create(void)
215 {
216     ArkUI_CustomSpanDrawInfo* info = new ArkUI_CustomSpanDrawInfo { 0, 0, 0, 0 };
217     return info;
218 }
219 
OH_ArkUI_CustomSpanDrawInfo_Dispose(ArkUI_CustomSpanDrawInfo * info)220 void OH_ArkUI_CustomSpanDrawInfo_Dispose(ArkUI_CustomSpanDrawInfo* info)
221 {
222     if (!info) {
223         return;
224     }
225     delete info;
226     info = nullptr;
227 }
228 
OH_ArkUI_CustomSpanDrawInfo_GetXOffset(ArkUI_CustomSpanDrawInfo * info)229 float OH_ArkUI_CustomSpanDrawInfo_GetXOffset(ArkUI_CustomSpanDrawInfo* info)
230 {
231     if (!info) {
232         return 0.0f;
233     }
234     return info->optionsX;
235 }
236 
OH_ArkUI_CustomSpanDrawInfo_GetLineTop(ArkUI_CustomSpanDrawInfo * info)237 float OH_ArkUI_CustomSpanDrawInfo_GetLineTop(ArkUI_CustomSpanDrawInfo* info)
238 {
239     if (!info) {
240         return 0.0f;
241     }
242     return info->optionsLineTop;
243 }
244 
OH_ArkUI_CustomSpanDrawInfo_GetLineBottom(ArkUI_CustomSpanDrawInfo * info)245 float OH_ArkUI_CustomSpanDrawInfo_GetLineBottom(ArkUI_CustomSpanDrawInfo* info)
246 {
247     if (!info) {
248         return 0.0f;
249     }
250     return info->optionsLineBottom;
251 }
252 
OH_ArkUI_CustomSpanDrawInfo_GetBaseline(ArkUI_CustomSpanDrawInfo * info)253 float OH_ArkUI_CustomSpanDrawInfo_GetBaseline(ArkUI_CustomSpanDrawInfo* info)
254 {
255     if (!info) {
256         return 0.0f;
257     }
258     return info->optionsBaseLine;
259 }
260 
OH_ArkUI_LayoutConstraint_GetMaxWidth(const ArkUI_LayoutConstraint * constraint)261 int32_t OH_ArkUI_LayoutConstraint_GetMaxWidth(const ArkUI_LayoutConstraint* constraint)
262 {
263     CHECK_NULL_RETURN(constraint, -1);
264     return constraint->maxWidth;
265 }
OH_ArkUI_LayoutConstraint_GetMinWidth(const ArkUI_LayoutConstraint * constraint)266 int32_t OH_ArkUI_LayoutConstraint_GetMinWidth(const ArkUI_LayoutConstraint* constraint)
267 {
268     CHECK_NULL_RETURN(constraint, -1);
269     return constraint->minWidth;
270 }
OH_ArkUI_LayoutConstraint_GetMaxHeight(const ArkUI_LayoutConstraint * constraint)271 int32_t OH_ArkUI_LayoutConstraint_GetMaxHeight(const ArkUI_LayoutConstraint* constraint)
272 {
273     CHECK_NULL_RETURN(constraint, -1);
274     return constraint->maxHeight;
275 }
OH_ArkUI_LayoutConstraint_GetMinHeight(const ArkUI_LayoutConstraint * constraint)276 int32_t OH_ArkUI_LayoutConstraint_GetMinHeight(const ArkUI_LayoutConstraint* constraint)
277 {
278     CHECK_NULL_RETURN(constraint, -1);
279     return constraint->minHeight;
280 }
OH_ArkUI_LayoutConstraint_GetPercentReferenceWidth(const ArkUI_LayoutConstraint * constraint)281 int32_t OH_ArkUI_LayoutConstraint_GetPercentReferenceWidth(const ArkUI_LayoutConstraint* constraint)
282 {
283     CHECK_NULL_RETURN(constraint, -1);
284     return constraint->percentReferWidth;
285 }
OH_ArkUI_LayoutConstraint_GetPercentReferenceHeight(const ArkUI_LayoutConstraint * constraint)286 int32_t OH_ArkUI_LayoutConstraint_GetPercentReferenceHeight(const ArkUI_LayoutConstraint* constraint)
287 {
288     CHECK_NULL_RETURN(constraint, -1);
289     return constraint->percentReferHeight;
290 }
291 
OH_ArkUI_LayoutConstraint_SetMinWidth(ArkUI_LayoutConstraint * constraint,int32_t value)292 void OH_ArkUI_LayoutConstraint_SetMinWidth(ArkUI_LayoutConstraint* constraint, int32_t value)
293 {
294     CHECK_NULL_VOID(constraint);
295     constraint->minWidth = value;
296 }
OH_ArkUI_LayoutConstraint_SetMaxWidth(ArkUI_LayoutConstraint * constraint,int32_t value)297 void OH_ArkUI_LayoutConstraint_SetMaxWidth(ArkUI_LayoutConstraint* constraint, int32_t value)
298 {
299     CHECK_NULL_VOID(constraint);
300     constraint->maxWidth = value;
301 }
302 
OH_ArkUI_LayoutConstraint_SetMaxHeight(ArkUI_LayoutConstraint * constraint,int32_t value)303 void OH_ArkUI_LayoutConstraint_SetMaxHeight(ArkUI_LayoutConstraint* constraint, int32_t value)
304 {
305     CHECK_NULL_VOID(constraint);
306     constraint->maxHeight = value;
307 }
OH_ArkUI_LayoutConstraint_SetMinHeight(ArkUI_LayoutConstraint * constraint,int32_t value)308 void OH_ArkUI_LayoutConstraint_SetMinHeight(ArkUI_LayoutConstraint* constraint, int32_t value)
309 {
310     CHECK_NULL_VOID(constraint);
311     constraint->minHeight = value;
312 }
OH_ArkUI_LayoutConstraint_SetPercentReferenceWidth(ArkUI_LayoutConstraint * constraint,int32_t value)313 void OH_ArkUI_LayoutConstraint_SetPercentReferenceWidth(ArkUI_LayoutConstraint* constraint, int32_t value)
314 {
315     CHECK_NULL_VOID(constraint);
316     constraint->percentReferWidth = value;
317 }
OH_ArkUI_LayoutConstraint_SetPercentReferenceHeight(ArkUI_LayoutConstraint * constraint,int32_t value)318 void OH_ArkUI_LayoutConstraint_SetPercentReferenceHeight(ArkUI_LayoutConstraint* constraint, int32_t value)
319 {
320     CHECK_NULL_VOID(constraint);
321     constraint->percentReferHeight = value;
322 }
323 
OH_ArkUI_DrawContext_GetCanvas(ArkUI_DrawContext * context)324 void* OH_ArkUI_DrawContext_GetCanvas(ArkUI_DrawContext* context)
325 {
326     return context ? context->canvas : nullptr;
327 }
OH_ArkUI_DrawContext_GetSize(ArkUI_DrawContext * context)328 ArkUI_IntSize OH_ArkUI_DrawContext_GetSize(ArkUI_DrawContext* context)
329 {
330     ArkUI_IntSize intSize;
331     if (context == nullptr) {
332         return intSize;
333     }
334     intSize.width = context->width;
335     intSize.height = context->height;
336     return intSize;
337 }
338 
OH_ArkUI_SwiperIndicator_Create(ArkUI_SwiperIndicatorType indicatorType)339 ArkUI_SwiperIndicator* OH_ArkUI_SwiperIndicator_Create(ArkUI_SwiperIndicatorType indicatorType)
340 {
341     if (indicatorType != ARKUI_SWIPER_INDICATOR_TYPE_DOT) {
342         return nullptr;
343     }
344     ArkUI_SwiperIndicator* indicator = new ArkUI_SwiperIndicator;
345     indicator->type = indicatorType;
346     indicator->dimLeft = ArkUI_OptionalFloat { 0, 0.0f };
347     indicator->dimRight = ArkUI_OptionalFloat { 0, 0.0f };
348     indicator->dimTop = ArkUI_OptionalFloat { 0, 0.0f };
349     indicator->dimBottom = ArkUI_OptionalFloat { 0, 0.0f };
350     indicator->ignoreSizeValue = ArkUI_OptionalInt { 0, 0 };
351     if (indicatorType == ARKUI_SWIPER_INDICATOR_TYPE_DOT) {
352         indicator->itemWidth = ArkUI_OptionalFloat { 0, 0.0f };
353         indicator->itemHeight = ArkUI_OptionalFloat { 0, 0.0f };
354         indicator->selectedItemWidth = ArkUI_OptionalFloat { 0, 0.0f };
355         indicator->selectedItemHeight = ArkUI_OptionalFloat { 0, 0.0f };
356         indicator->maskValue = ArkUI_OptionalInt { 0, 0 };
357         indicator->colorValue = ArkUI_OptionalUint { 0, 0xFF000000 };
358         indicator->selectedColorValue = ArkUI_OptionalUint { 0, 0xFF000000 };
359         indicator->maxDisplayCount = ArkUI_OptionalInt { 0, 0 };
360         indicator->dimSpace = ArkUI_OptionalFloat { 0, 8.0f };
361     } else {
362         return nullptr;
363     }
364     return indicator;
365 }
366 
OH_ArkUI_SwiperIndicator_Dispose(ArkUI_SwiperIndicator * indicator)367 void OH_ArkUI_SwiperIndicator_Dispose(ArkUI_SwiperIndicator* indicator)
368 {
369     delete indicator;
370 }
371 
OH_ArkUI_SwiperIndicator_SetStartPosition(ArkUI_SwiperIndicator * indicator,float value)372 void OH_ArkUI_SwiperIndicator_SetStartPosition(ArkUI_SwiperIndicator* indicator, float value)
373 {
374     CHECK_NULL_VOID(indicator);
375     indicator->dimLeft.isSet = 1;
376     indicator->dimLeft.value = value;
377 }
378 
OH_ArkUI_SwiperIndicator_GetStartPosition(ArkUI_SwiperIndicator * indicator)379 float OH_ArkUI_SwiperIndicator_GetStartPosition(ArkUI_SwiperIndicator* indicator)
380 {
381     CHECK_NULL_RETURN(indicator, 0.0f);
382     return indicator->dimLeft.value;
383 }
384 
OH_ArkUI_SwiperIndicator_SetTopPosition(ArkUI_SwiperIndicator * indicator,float value)385 void OH_ArkUI_SwiperIndicator_SetTopPosition(ArkUI_SwiperIndicator* indicator, float value)
386 {
387     CHECK_NULL_VOID(indicator);
388     indicator->dimTop.isSet = 1;
389     indicator->dimTop.value = value;
390 }
391 
OH_ArkUI_SwiperIndicator_GetTopPosition(ArkUI_SwiperIndicator * indicator)392 float OH_ArkUI_SwiperIndicator_GetTopPosition(ArkUI_SwiperIndicator* indicator)
393 {
394     CHECK_NULL_RETURN(indicator, 0.0f);
395     return indicator->dimTop.value;
396 }
397 
OH_ArkUI_SwiperIndicator_SetEndPosition(ArkUI_SwiperIndicator * indicator,float value)398 void OH_ArkUI_SwiperIndicator_SetEndPosition(ArkUI_SwiperIndicator* indicator, float value)
399 {
400     CHECK_NULL_VOID(indicator);
401     indicator->dimRight.isSet = 1;
402     indicator->dimRight.value = value;
403 }
404 
OH_ArkUI_SwiperIndicator_GetEndPosition(ArkUI_SwiperIndicator * indicator)405 float OH_ArkUI_SwiperIndicator_GetEndPosition(ArkUI_SwiperIndicator* indicator)
406 {
407     CHECK_NULL_RETURN(indicator, 0.0f);
408     return indicator->dimRight.value;
409 }
410 
OH_ArkUI_SwiperIndicator_SetBottomPosition(ArkUI_SwiperIndicator * indicator,float value)411 void OH_ArkUI_SwiperIndicator_SetBottomPosition(ArkUI_SwiperIndicator* indicator, float value)
412 {
413     CHECK_NULL_VOID(indicator);
414     indicator->dimBottom.isSet = 1;
415     indicator->dimBottom.value = value;
416 }
417 
OH_ArkUI_SwiperIndicator_GetBottomPosition(ArkUI_SwiperIndicator * indicator)418 float OH_ArkUI_SwiperIndicator_GetBottomPosition(ArkUI_SwiperIndicator* indicator)
419 {
420     CHECK_NULL_RETURN(indicator, 0.0f);
421     return indicator->dimBottom.value;
422 }
423 
OH_ArkUI_SwiperIndicator_SetItemWidth(ArkUI_SwiperIndicator * indicator,float value)424 void OH_ArkUI_SwiperIndicator_SetItemWidth(ArkUI_SwiperIndicator* indicator, float value)
425 {
426     CHECK_NULL_VOID(indicator);
427     indicator->itemWidth.isSet = 1;
428     indicator->itemWidth.value = value;
429 }
430 
OH_ArkUI_SwiperIndicator_GetItemWidth(ArkUI_SwiperIndicator * indicator)431 float OH_ArkUI_SwiperIndicator_GetItemWidth(ArkUI_SwiperIndicator* indicator)
432 {
433     CHECK_NULL_RETURN(indicator, 0.0f);
434     return indicator->itemWidth.value;
435 }
436 
OH_ArkUI_SwiperIndicator_SetItemHeight(ArkUI_SwiperIndicator * indicator,float value)437 void OH_ArkUI_SwiperIndicator_SetItemHeight(ArkUI_SwiperIndicator* indicator, float value)
438 {
439     CHECK_NULL_VOID(indicator);
440     indicator->itemHeight.isSet = 1;
441     indicator->itemHeight.value = value;
442 }
443 
OH_ArkUI_SwiperIndicator_GetItemHeight(ArkUI_SwiperIndicator * indicator)444 float OH_ArkUI_SwiperIndicator_GetItemHeight(ArkUI_SwiperIndicator* indicator)
445 {
446     CHECK_NULL_RETURN(indicator, 0.0f);
447     return indicator->itemHeight.value;
448 }
449 
OH_ArkUI_SwiperIndicator_SetSelectedItemWidth(ArkUI_SwiperIndicator * indicator,float value)450 void OH_ArkUI_SwiperIndicator_SetSelectedItemWidth(ArkUI_SwiperIndicator* indicator, float value)
451 {
452     CHECK_NULL_VOID(indicator);
453     indicator->selectedItemWidth.isSet = 1;
454     indicator->selectedItemWidth.value = value;
455 }
456 
OH_ArkUI_SwiperIndicator_GetSelectedItemWidth(ArkUI_SwiperIndicator * indicator)457 float OH_ArkUI_SwiperIndicator_GetSelectedItemWidth(ArkUI_SwiperIndicator* indicator)
458 {
459     CHECK_NULL_RETURN(indicator, 0.0f);
460     return indicator->selectedItemWidth.value;
461 }
462 
OH_ArkUI_SwiperIndicator_SetSelectedItemHeight(ArkUI_SwiperIndicator * indicator,float value)463 void OH_ArkUI_SwiperIndicator_SetSelectedItemHeight(ArkUI_SwiperIndicator* indicator, float value)
464 {
465     CHECK_NULL_VOID(indicator);
466     indicator->selectedItemHeight.isSet = 1;
467     indicator->selectedItemHeight.value = value;
468 }
469 
OH_ArkUI_SwiperIndicator_GetSelectedItemHeight(ArkUI_SwiperIndicator * indicator)470 float OH_ArkUI_SwiperIndicator_GetSelectedItemHeight(ArkUI_SwiperIndicator* indicator)
471 {
472     CHECK_NULL_RETURN(indicator, 0.0f);
473     return indicator->selectedItemHeight.value;
474 }
475 
OH_ArkUI_SwiperIndicator_SetMask(ArkUI_SwiperIndicator * indicator,int32_t mask)476 void OH_ArkUI_SwiperIndicator_SetMask(ArkUI_SwiperIndicator* indicator, int32_t mask)
477 {
478     CHECK_NULL_VOID(indicator);
479     indicator->maskValue.isSet = 1;
480     indicator->maskValue.value = mask;
481 }
482 
OH_ArkUI_SwiperIndicator_GetMask(ArkUI_SwiperIndicator * indicator)483 int32_t OH_ArkUI_SwiperIndicator_GetMask(ArkUI_SwiperIndicator* indicator)
484 {
485     CHECK_NULL_RETURN(indicator, 0);
486     return indicator->maskValue.value;
487 }
488 
OH_ArkUI_SwiperIndicator_SetColor(ArkUI_SwiperIndicator * indicator,uint32_t color)489 void OH_ArkUI_SwiperIndicator_SetColor(ArkUI_SwiperIndicator* indicator, uint32_t color)
490 {
491     CHECK_NULL_VOID(indicator);
492     indicator->colorValue.isSet = 1;
493     indicator->colorValue.value = color;
494 }
495 
OH_ArkUI_SwiperIndicator_GetColor(ArkUI_SwiperIndicator * indicator)496 uint32_t OH_ArkUI_SwiperIndicator_GetColor(ArkUI_SwiperIndicator* indicator)
497 {
498     CHECK_NULL_RETURN(indicator, 0);
499     return indicator->colorValue.value;
500 }
501 
OH_ArkUI_SwiperIndicator_SetSelectedColor(ArkUI_SwiperIndicator * indicator,uint32_t selectedColor)502 void OH_ArkUI_SwiperIndicator_SetSelectedColor(ArkUI_SwiperIndicator* indicator, uint32_t selectedColor)
503 {
504     CHECK_NULL_VOID(indicator);
505     indicator->selectedColorValue.isSet = 1;
506     indicator->selectedColorValue.value = selectedColor;
507 }
508 
OH_ArkUI_SwiperIndicator_GetSelectedColor(ArkUI_SwiperIndicator * indicator)509 uint32_t OH_ArkUI_SwiperIndicator_GetSelectedColor(ArkUI_SwiperIndicator* indicator)
510 {
511     CHECK_NULL_RETURN(indicator, 0);
512     return indicator->selectedColorValue.value;
513 }
514 
515 
OH_ArkUI_SwiperIndicator_SetMaxDisplayCount(ArkUI_SwiperIndicator * indicator,int32_t maxDisplayCount)516 int32_t OH_ArkUI_SwiperIndicator_SetMaxDisplayCount(ArkUI_SwiperIndicator* indicator, int32_t maxDisplayCount)
517 {
518     CHECK_NULL_RETURN(indicator, ARKUI_ERROR_CODE_PARAM_INVALID);
519     if (maxDisplayCount < MAX_DISPLAY_COUNT_MIN || maxDisplayCount > MAX_DISPLAY_COUNT_MAX) {
520         return ARKUI_ERROR_CODE_PARAM_INVALID;
521     }
522     indicator->maxDisplayCount.isSet = 1;
523     indicator->maxDisplayCount.value = maxDisplayCount;
524     return ARKUI_ERROR_CODE_NO_ERROR;
525 }
526 
OH_ArkUI_SwiperIndicator_GetMaxDisplayCount(ArkUI_SwiperIndicator * indicator)527 int32_t OH_ArkUI_SwiperIndicator_GetMaxDisplayCount(ArkUI_SwiperIndicator* indicator)
528 {
529     CHECK_NULL_RETURN(indicator, 0);
530     return indicator->maxDisplayCount.value;
531 }
532 
OH_ArkUI_SwiperIndicator_SetIgnoreSizeOfBottom(ArkUI_SwiperIndicator * indicator,int32_t ignoreSize)533 void OH_ArkUI_SwiperIndicator_SetIgnoreSizeOfBottom(ArkUI_SwiperIndicator* indicator, int32_t ignoreSize)
534 {
535     CHECK_NULL_VOID(indicator);
536     indicator->ignoreSizeValue.isSet = 1;
537     indicator->ignoreSizeValue.value = ignoreSize;
538 }
539 
OH_ArkUI_SwiperIndicator_GetIgnoreSizeOfBottom(ArkUI_SwiperIndicator * indicator)540 int32_t OH_ArkUI_SwiperIndicator_GetIgnoreSizeOfBottom(ArkUI_SwiperIndicator* indicator)
541 {
542     CHECK_NULL_RETURN(indicator, 0.0f);
543     return indicator->ignoreSizeValue.value;
544 }
545 
OH_ArkUI_SwiperIndicator_SetSpace(ArkUI_SwiperIndicator * indicator,float space)546 void OH_ArkUI_SwiperIndicator_SetSpace(ArkUI_SwiperIndicator* indicator, float space)
547 {
548     CHECK_NULL_VOID(indicator);
549     indicator->dimSpace.isSet = 1;
550     indicator->dimSpace.value = space;
551 }
552 
OH_ArkUI_SwiperIndicator_GetSpace(ArkUI_SwiperIndicator * indicator)553 float OH_ArkUI_SwiperIndicator_GetSpace(ArkUI_SwiperIndicator* indicator)
554 {
555     CHECK_NULL_RETURN(indicator, 8.0f);
556     return indicator->dimSpace.value;
557 }
558 
OH_ArkUI_SwiperDigitIndicator_Create()559 ArkUI_SwiperDigitIndicator* OH_ArkUI_SwiperDigitIndicator_Create()
560 {
561     ArkUI_SwiperDigitIndicator* indicator = new ArkUI_SwiperDigitIndicator;
562     indicator->type = ARKUI_SWIPER_INDICATOR_TYPE_DIGIT;
563     indicator->dimLeft = ArkUI_OptionalFloat { 0, 0.0f };
564     indicator->dimRight = ArkUI_OptionalFloat { 0, 0.0f };
565     indicator->dimTop = ArkUI_OptionalFloat { 0, 0.0f };
566     indicator->dimBottom = ArkUI_OptionalFloat { 0, 0.0f };
567     indicator->fontColor = ArkUI_OptionalUint { 0, 0xFF000000 };
568     indicator->selectedFontColor = ArkUI_OptionalUint { 0, 0xFF000000 };
569     indicator->fontSize = ArkUI_OptionalFloat { 0, 14.0f };
570     indicator->selectedFontSize = ArkUI_OptionalFloat { 0, 14.0f };
571     indicator->fontWeight = ArkUI_OptionalUint { 0, ARKUI_FONT_WEIGHT_NORMAL };
572     indicator->selectedFontWeight = ArkUI_OptionalUint { 0, ARKUI_FONT_WEIGHT_NORMAL };
573     indicator->ignoreSizeValue = ArkUI_OptionalInt {0, 0};
574     return indicator;
575 }
576 
OH_ArkUI_SwiperDigitIndicator_Destroy(ArkUI_SwiperDigitIndicator * indicator)577 void OH_ArkUI_SwiperDigitIndicator_Destroy(ArkUI_SwiperDigitIndicator* indicator)
578 {
579     delete indicator;
580 }
581 
OH_ArkUI_SwiperDigitIndicator_SetStartPosition(ArkUI_SwiperDigitIndicator * indicator,float value)582 void OH_ArkUI_SwiperDigitIndicator_SetStartPosition(ArkUI_SwiperDigitIndicator* indicator, float value)
583 {
584     CHECK_NULL_VOID(indicator);
585     indicator->dimLeft.isSet = 1;
586     indicator->dimLeft.value = value;
587 }
588 
OH_ArkUI_SwiperDigitIndicator_GetStartPosition(ArkUI_SwiperDigitIndicator * indicator)589 float OH_ArkUI_SwiperDigitIndicator_GetStartPosition(ArkUI_SwiperDigitIndicator* indicator)
590 {
591     CHECK_NULL_RETURN(indicator, 0.0f);
592     return indicator->dimLeft.value;
593 }
594 
OH_ArkUI_SwiperDigitIndicator_SetTopPosition(ArkUI_SwiperDigitIndicator * indicator,float value)595 void OH_ArkUI_SwiperDigitIndicator_SetTopPosition(ArkUI_SwiperDigitIndicator* indicator, float value)
596 {
597     CHECK_NULL_VOID(indicator);
598     indicator->dimTop.isSet = 1;
599     indicator->dimTop.value = value;
600 }
601 
OH_ArkUI_SwiperDigitIndicator_GetTopPosition(ArkUI_SwiperDigitIndicator * indicator)602 float OH_ArkUI_SwiperDigitIndicator_GetTopPosition(ArkUI_SwiperDigitIndicator* indicator)
603 {
604     CHECK_NULL_RETURN(indicator, 0.0f);
605     return indicator->dimTop.value;
606 }
607 
OH_ArkUI_SwiperDigitIndicator_SetEndPosition(ArkUI_SwiperDigitIndicator * indicator,float value)608 void OH_ArkUI_SwiperDigitIndicator_SetEndPosition(ArkUI_SwiperDigitIndicator* indicator, float value)
609 {
610     CHECK_NULL_VOID(indicator);
611     indicator->dimRight.isSet = 1;
612     indicator->dimRight.value = value;
613 }
614 
OH_ArkUI_SwiperDigitIndicator_GetEndPosition(ArkUI_SwiperDigitIndicator * indicator)615 float OH_ArkUI_SwiperDigitIndicator_GetEndPosition(ArkUI_SwiperDigitIndicator* indicator)
616 {
617     CHECK_NULL_RETURN(indicator, 0.0f);
618     return indicator->dimRight.value;
619 }
620 
OH_ArkUI_SwiperDigitIndicator_SetBottomPosition(ArkUI_SwiperDigitIndicator * indicator,float value)621 void OH_ArkUI_SwiperDigitIndicator_SetBottomPosition(ArkUI_SwiperDigitIndicator* indicator, float value)
622 {
623     CHECK_NULL_VOID(indicator);
624     indicator->dimBottom.isSet = 1;
625     indicator->dimBottom.value = value;
626 }
627 
OH_ArkUI_SwiperDigitIndicator_GetBottomPosition(ArkUI_SwiperDigitIndicator * indicator)628 float OH_ArkUI_SwiperDigitIndicator_GetBottomPosition(ArkUI_SwiperDigitIndicator* indicator)
629 {
630     CHECK_NULL_RETURN(indicator, 0.0f);
631     return indicator->dimBottom.value;
632 }
633 
OH_ArkUI_SwiperDigitIndicator_SetFontColor(ArkUI_SwiperDigitIndicator * indicator,uint32_t color)634 void OH_ArkUI_SwiperDigitIndicator_SetFontColor(ArkUI_SwiperDigitIndicator* indicator, uint32_t color)
635 {
636     CHECK_NULL_VOID(indicator);
637     indicator->fontColor.isSet = 1;
638     indicator->fontColor.value = color;
639 }
640 
OH_ArkUI_SwiperDigitIndicator_GetFontColor(ArkUI_SwiperDigitIndicator * indicator)641 uint32_t OH_ArkUI_SwiperDigitIndicator_GetFontColor(ArkUI_SwiperDigitIndicator* indicator)
642 {
643     CHECK_NULL_RETURN(indicator, 0);
644     return indicator->fontColor.value;
645 }
646 
OH_ArkUI_SwiperDigitIndicator_SetSelectedFontColor(ArkUI_SwiperDigitIndicator * indicator,uint32_t selectedColor)647 void OH_ArkUI_SwiperDigitIndicator_SetSelectedFontColor(ArkUI_SwiperDigitIndicator* indicator, uint32_t selectedColor)
648 {
649     CHECK_NULL_VOID(indicator);
650     indicator->selectedFontColor.isSet = 1;
651     indicator->selectedFontColor.value = selectedColor;
652 }
653 
OH_ArkUI_SwiperDigitIndicator_GetSelectedFontColor(ArkUI_SwiperDigitIndicator * indicator)654 uint32_t OH_ArkUI_SwiperDigitIndicator_GetSelectedFontColor(ArkUI_SwiperDigitIndicator* indicator)
655 {
656     CHECK_NULL_RETURN(indicator, 0);
657     return indicator->selectedFontColor.value;
658 }
659 
OH_ArkUI_SwiperDigitIndicator_SetFontSize(ArkUI_SwiperDigitIndicator * indicator,float size)660 void OH_ArkUI_SwiperDigitIndicator_SetFontSize(ArkUI_SwiperDigitIndicator* indicator, float size)
661 {
662     CHECK_NULL_VOID(indicator);
663     indicator->fontSize.isSet = 1;
664     indicator->fontSize.value = size;
665 }
666 
OH_ArkUI_SwiperDigitIndicator_GetFontSize(ArkUI_SwiperDigitIndicator * indicator)667 float OH_ArkUI_SwiperDigitIndicator_GetFontSize(ArkUI_SwiperDigitIndicator* indicator)
668 {
669     CHECK_NULL_RETURN(indicator, 0.0f);
670     return indicator->fontSize.value;
671 }
672 
OH_ArkUI_SwiperDigitIndicator_SetSelectedFontSize(ArkUI_SwiperDigitIndicator * indicator,float size)673 void OH_ArkUI_SwiperDigitIndicator_SetSelectedFontSize(ArkUI_SwiperDigitIndicator* indicator, float size)
674 {
675     CHECK_NULL_VOID(indicator);
676     indicator->selectedFontSize.isSet = 1;
677     indicator->selectedFontSize.value = size;
678 }
679 
OH_ArkUI_SwiperDigitIndicator_GetSelectedFontSize(ArkUI_SwiperDigitIndicator * indicator)680 float OH_ArkUI_SwiperDigitIndicator_GetSelectedFontSize(ArkUI_SwiperDigitIndicator* indicator)
681 {
682     CHECK_NULL_RETURN(indicator, 0.0f);
683     return indicator->selectedFontSize.value;
684 }
685 
OH_ArkUI_SwiperDigitIndicator_SetFontWeight(ArkUI_SwiperDigitIndicator * indicator,ArkUI_FontWeight fontWeight)686 void OH_ArkUI_SwiperDigitIndicator_SetFontWeight(ArkUI_SwiperDigitIndicator* indicator, ArkUI_FontWeight fontWeight)
687 {
688     CHECK_NULL_VOID(indicator);
689     indicator->fontWeight.isSet = 1;
690     indicator->fontWeight.value = static_cast<uint32_t>(fontWeight);
691 }
692 
OH_ArkUI_SwiperDigitIndicator_GetFontWeight(ArkUI_SwiperDigitIndicator * indicator)693 ArkUI_FontWeight OH_ArkUI_SwiperDigitIndicator_GetFontWeight(ArkUI_SwiperDigitIndicator* indicator)
694 {
695     CHECK_NULL_RETURN(indicator, static_cast<ArkUI_FontWeight>(0));
696     return static_cast<ArkUI_FontWeight>(indicator->fontWeight.value);
697 }
698 
OH_ArkUI_SwiperDigitIndicator_SetSelectedFontWeight(ArkUI_SwiperDigitIndicator * indicator,ArkUI_FontWeight selectedFontWeight)699 void OH_ArkUI_SwiperDigitIndicator_SetSelectedFontWeight(
700     ArkUI_SwiperDigitIndicator* indicator, ArkUI_FontWeight selectedFontWeight)
701 {
702     CHECK_NULL_VOID(indicator);
703     indicator->selectedFontWeight.isSet = 1;
704     indicator->selectedFontWeight.value = static_cast<uint32_t>(selectedFontWeight);
705 }
706 
OH_ArkUI_SwiperDigitIndicator_GetSelectedFontWeight(ArkUI_SwiperDigitIndicator * indicator)707 ArkUI_FontWeight OH_ArkUI_SwiperDigitIndicator_GetSelectedFontWeight(ArkUI_SwiperDigitIndicator* indicator)
708 {
709     CHECK_NULL_RETURN(indicator, static_cast<ArkUI_FontWeight>(0));
710     return static_cast<ArkUI_FontWeight>(indicator->selectedFontWeight.value);
711 }
712 
OH_ArkUI_SwiperDigitIndicator_SetIgnoreSizeOfBottom(ArkUI_SwiperDigitIndicator * indicator,int32_t ignoreSize)713 void OH_ArkUI_SwiperDigitIndicator_SetIgnoreSizeOfBottom(ArkUI_SwiperDigitIndicator* indicator, int32_t ignoreSize)
714 {
715     CHECK_NULL_VOID(indicator);
716     indicator->ignoreSizeValue.isSet = 1;
717     indicator->ignoreSizeValue.value = ignoreSize;
718 }
719 
OH_ArkUI_SwiperDigitIndicator_GetIgnoreSizeOfBottom(ArkUI_SwiperDigitIndicator * indicator)720 int32_t OH_ArkUI_SwiperDigitIndicator_GetIgnoreSizeOfBottom(ArkUI_SwiperDigitIndicator* indicator)
721 {
722     CHECK_NULL_RETURN(indicator, 0);
723     return indicator->ignoreSizeValue.value;
724 }
725 
OH_ArkUI_SwiperArrowStyle_Create()726 ArkUI_SwiperArrowStyle* OH_ArkUI_SwiperArrowStyle_Create()
727 {
728     ArkUI_SwiperArrowStyle* arrowStyle = new ArkUI_SwiperArrowStyle;
729     arrowStyle->showBackground = ArkUI_OptionalInt { 0, 0 };
730     arrowStyle->showSidebarMiddle = ArkUI_OptionalInt { 0, 0 };
731     arrowStyle->backgroundSize = ArkUI_OptionalFloat { 0, DEFAULT_SIZE_24 };
732     arrowStyle->backgroundColor = ArkUI_OptionalUint { 0, 0x00000000 };
733     arrowStyle->arrowSize = ArkUI_OptionalFloat { 0, DEFAULT_SIZE_18 };
734     arrowStyle->arrowColor = ArkUI_OptionalUint { 0, 0x00182431 };
735     return arrowStyle;
736 }
737 
OH_ArkUI_SwiperArrowStyle_Destroy(ArkUI_SwiperArrowStyle * arrowStyle)738 void OH_ArkUI_SwiperArrowStyle_Destroy(ArkUI_SwiperArrowStyle* arrowStyle)
739 {
740     delete arrowStyle;
741 }
742 
OH_ArkUI_SwiperArrowStyle_SetShowBackground(ArkUI_SwiperArrowStyle * arrowStyle,int32_t showBackground)743 void OH_ArkUI_SwiperArrowStyle_SetShowBackground(ArkUI_SwiperArrowStyle* arrowStyle, int32_t showBackground)
744 {
745     CHECK_NULL_VOID(arrowStyle);
746     if (showBackground != 0 && showBackground != 1) {
747         return;
748     }
749     arrowStyle->showBackground.isSet = 1;
750     arrowStyle->showBackground.value = showBackground;
751 }
752 
OH_ArkUI_SwiperArrowStyle_GetShowBackground(ArkUI_SwiperArrowStyle * arrowStyle)753 int32_t OH_ArkUI_SwiperArrowStyle_GetShowBackground(ArkUI_SwiperArrowStyle* arrowStyle)
754 {
755     CHECK_NULL_RETURN(arrowStyle, 0);
756     return arrowStyle->showBackground.value;
757 }
758 
OH_ArkUI_SwiperArrowStyle_SetShowSidebarMiddle(ArkUI_SwiperArrowStyle * arrowStyle,int32_t showSidebarMiddle)759 void OH_ArkUI_SwiperArrowStyle_SetShowSidebarMiddle(ArkUI_SwiperArrowStyle* arrowStyle, int32_t showSidebarMiddle)
760 {
761     CHECK_NULL_VOID(arrowStyle);
762     if (showSidebarMiddle != 0 && showSidebarMiddle != 1) {
763         return;
764     }
765     arrowStyle->showSidebarMiddle.isSet = 1;
766     arrowStyle->showSidebarMiddle.value = showSidebarMiddle;
767     if (showSidebarMiddle == 1) {
768         if (!arrowStyle->backgroundSize.isSet) {
769             arrowStyle->backgroundSize.value = DEFAULT_SIZE_32;
770         }
771         if (!arrowStyle->backgroundColor.isSet) {
772             arrowStyle->backgroundColor.value = 0x19182431;
773         }
774         if (!arrowStyle->arrowSize.isSet) {
775             arrowStyle->arrowSize.value = DEFAULT_SIZE_24;
776         }
777     }
778 }
779 
OH_ArkUI_SwiperArrowStyle_GetShowSidebarMiddle(ArkUI_SwiperArrowStyle * arrowStyle)780 int32_t OH_ArkUI_SwiperArrowStyle_GetShowSidebarMiddle(ArkUI_SwiperArrowStyle* arrowStyle)
781 {
782     CHECK_NULL_RETURN(arrowStyle, 0);
783     return arrowStyle->showSidebarMiddle.value;
784 }
785 
OH_ArkUI_SwiperArrowStyle_SetBackgroundSize(ArkUI_SwiperArrowStyle * arrowStyle,float backgroundSize)786 void OH_ArkUI_SwiperArrowStyle_SetBackgroundSize(ArkUI_SwiperArrowStyle* arrowStyle, float backgroundSize)
787 {
788     CHECK_NULL_VOID(arrowStyle);
789     arrowStyle->backgroundSize.isSet = 1;
790     arrowStyle->backgroundSize.value = backgroundSize;
791 }
792 
OH_ArkUI_SwiperArrowStyle_GetBackgroundSize(ArkUI_SwiperArrowStyle * arrowStyle)793 float OH_ArkUI_SwiperArrowStyle_GetBackgroundSize(ArkUI_SwiperArrowStyle* arrowStyle)
794 {
795     CHECK_NULL_RETURN(arrowStyle, DEFAULT_SIZE_24);
796     if (arrowStyle->showSidebarMiddle.value == 1) {
797         if (!arrowStyle->backgroundSize.isSet) {
798             return DEFAULT_SIZE_32;
799         }
800     }
801     if (!arrowStyle->backgroundSize.isSet) {
802         return DEFAULT_SIZE_24;
803     }
804     return arrowStyle->backgroundSize.value;
805 }
806 
OH_ArkUI_SwiperArrowStyle_SetBackgroundColor(ArkUI_SwiperArrowStyle * arrowStyle,uint32_t backgroundColor)807 void OH_ArkUI_SwiperArrowStyle_SetBackgroundColor(ArkUI_SwiperArrowStyle* arrowStyle, uint32_t backgroundColor)
808 {
809     CHECK_NULL_VOID(arrowStyle);
810     arrowStyle->backgroundColor.isSet = 1;
811     arrowStyle->backgroundColor.value = backgroundColor;
812 }
813 
OH_ArkUI_SwiperArrowStyle_GetBackgroundColor(ArkUI_SwiperArrowStyle * arrowStyle)814 uint32_t OH_ArkUI_SwiperArrowStyle_GetBackgroundColor(ArkUI_SwiperArrowStyle* arrowStyle)
815 {
816     CHECK_NULL_RETURN(arrowStyle, 0x00000000);
817     if (arrowStyle->showSidebarMiddle.value == 1) {
818         if (!arrowStyle->backgroundColor.isSet) {
819             return 0x19182431;
820         }
821     }
822     if (!arrowStyle->backgroundColor.isSet) {
823         return 0x00000000;
824     }
825     return arrowStyle->backgroundColor.value;
826 }
827 
OH_ArkUI_SwiperArrowStyle_SetArrowSize(ArkUI_SwiperArrowStyle * arrowStyle,float arrowSize)828 void OH_ArkUI_SwiperArrowStyle_SetArrowSize(ArkUI_SwiperArrowStyle* arrowStyle, float arrowSize)
829 {
830     CHECK_NULL_VOID(arrowStyle);
831     if (arrowStyle->showBackground.value == 1) {
832         arrowSize = arrowStyle->backgroundSize.value * ARROW_SIZE_COEFFICIENT;
833     }
834     arrowStyle->arrowSize.isSet = 1;
835     arrowStyle->arrowSize.value = arrowSize;
836 }
837 
OH_ArkUI_SwiperArrowStyle_GetArrowSize(ArkUI_SwiperArrowStyle * arrowStyle)838 float OH_ArkUI_SwiperArrowStyle_GetArrowSize(ArkUI_SwiperArrowStyle* arrowStyle)
839 {
840     CHECK_NULL_RETURN(arrowStyle, DEFAULT_SIZE_18);
841     if (arrowStyle->showBackground.value == 1) {
842         return arrowStyle->backgroundSize.value * ARROW_SIZE_COEFFICIENT;
843     }
844     if (arrowStyle->showSidebarMiddle.value == 1) {
845         if (!arrowStyle->arrowSize.isSet) {
846             return DEFAULT_SIZE_24;
847         }
848     }
849     if (!arrowStyle->arrowSize.isSet) {
850         return DEFAULT_SIZE_18;
851     }
852     return arrowStyle->arrowSize.value;
853 }
854 
OH_ArkUI_SwiperArrowStyle_SetArrowColor(ArkUI_SwiperArrowStyle * arrowStyle,uint32_t arrowColor)855 void OH_ArkUI_SwiperArrowStyle_SetArrowColor(ArkUI_SwiperArrowStyle* arrowStyle, uint32_t arrowColor)
856 {
857     CHECK_NULL_VOID(arrowStyle);
858     arrowStyle->arrowColor.isSet = 1;
859     arrowStyle->arrowColor.value = arrowColor;
860 }
861 
OH_ArkUI_SwiperArrowStyle_GetArrowColor(ArkUI_SwiperArrowStyle * arrowStyle)862 uint32_t OH_ArkUI_SwiperArrowStyle_GetArrowColor(ArkUI_SwiperArrowStyle* arrowStyle)
863 {
864     CHECK_NULL_RETURN(arrowStyle, 0x00182431);
865     return arrowStyle->arrowColor.value;
866 }
867 
OH_ArkUI_StyledString_Create(OH_Drawing_TypographyStyle * typoStyle,OH_Drawing_FontCollection * collection)868 ArkUI_StyledString* OH_ArkUI_StyledString_Create(
869     OH_Drawing_TypographyStyle* typoStyle, OH_Drawing_FontCollection* collection)
870 {
871     ArkUI_StyledString* storage = new ArkUI_StyledString;
872     storage->builder = OH_Drawing_CreateTypographyHandler(typoStyle, collection);
873     OH_Drawing_TypographyStyle* typographyStyle = OH_Drawing_CreateTypographyStyle();
874     storage->paragraphStyle = typographyStyle;
875     return storage;
876 }
877 
OH_ArkUI_StyledString_Destroy(ArkUI_StyledString * storage)878 void OH_ArkUI_StyledString_Destroy(ArkUI_StyledString* storage)
879 {
880     OH_Drawing_DestroyTypographyHandler(reinterpret_cast<OH_Drawing_TypographyCreate*>(storage->builder));
881     for (auto item : storage->items) {
882         if (item->placeholder) {
883             delete reinterpret_cast<OH_Drawing_PlaceholderSpan*>(item->placeholder);
884             item->placeholder = nullptr;
885         }
886         delete item;
887     }
888     while (!storage->styles.empty()) {
889         auto style = reinterpret_cast<OH_Drawing_TextStyle*>(storage->styles.top());
890         OH_Drawing_DestroyTextStyle(style);
891         storage->styles.pop();
892     }
893     storage->styles = std::stack<void*>();
894     storage->items.clear();
895     OH_Drawing_TypographyStyle* paragraphStyle =
896         reinterpret_cast<OH_Drawing_TypographyStyle*>(storage->paragraphStyle);
897     OH_Drawing_DestroyTypographyStyle(paragraphStyle);
898     delete storage;
899 }
900 
OH_ArkUI_StyledString_PushTextStyle(ArkUI_StyledString * storage,OH_Drawing_TextStyle * style)901 void OH_ArkUI_StyledString_PushTextStyle(ArkUI_StyledString* storage, OH_Drawing_TextStyle* style)
902 {
903     OH_Drawing_TypographyHandlerPushTextStyle(reinterpret_cast<OH_Drawing_TypographyCreate*>(storage->builder), style);
904     OH_Drawing_TextStyle* textStyle = OH_Drawing_CreateTextStyle();
905     // copy text style
906     if (style) {
907         OH_Drawing_SetTextStyleColor(textStyle, OH_Drawing_TextStyleGetColor(style));
908         OH_Drawing_SetTextStyleFontSize(textStyle, OH_Drawing_TextStyleGetFontSize(style));
909         OH_Drawing_SetTextStyleFontWeight(textStyle, OH_Drawing_TextStyleGetFontWeight(style));
910         OH_Drawing_SetTextStyleBaseLine(textStyle, OH_Drawing_TextStyleGetBaseline(style));
911         OH_Drawing_SetTextStyleFontHeight(textStyle, OH_Drawing_TextStyleGetFontHeight(style));
912         OH_Drawing_SetTextStyleFontStyle(textStyle, OH_Drawing_TextStyleGetFontStyle(style));
913     }
914     storage->styles.push(textStyle);
915 }
916 
OH_ArkUI_StyledString_AddText(ArkUI_StyledString * storage,const char * content)917 void OH_ArkUI_StyledString_AddText(ArkUI_StyledString* storage, const char* content)
918 {
919     OH_Drawing_TypographyHandlerAddText(reinterpret_cast<OH_Drawing_TypographyCreate*>(storage->builder), content);
920 
921     ArkUI_SpanItem* spanItem = new ArkUI_SpanItem;
922     spanItem->content = content;
923     if (storage->styles.empty()) {
924         spanItem->textStyle = nullptr;
925     } else {
926         spanItem->textStyle = storage->styles.top();
927     }
928     storage->items.emplace_back(spanItem);
929 }
930 
OH_ArkUI_StyledString_PopTextStyle(ArkUI_StyledString * storage)931 void OH_ArkUI_StyledString_PopTextStyle(ArkUI_StyledString* storage)
932 {
933     OH_Drawing_TypographyHandlerPopTextStyle(reinterpret_cast<OH_Drawing_TypographyCreate*>(storage->builder));
934     if (storage->styles.empty()) {
935         return;
936     }
937     storage->styles.pop();
938 }
939 
OH_ArkUI_StyledString_CreateTypography(ArkUI_StyledString * storage)940 OH_Drawing_Typography* OH_ArkUI_StyledString_CreateTypography(ArkUI_StyledString* storage)
941 {
942     OH_Drawing_Typography* paragraph =
943         OH_Drawing_CreateTypography(reinterpret_cast<OH_Drawing_TypographyCreate*>(storage->builder));
944     storage->paragraph = paragraph;
945     return reinterpret_cast<OH_Drawing_Typography*>(paragraph);
946 }
947 
OH_ArkUI_StyledString_AddPlaceholder(ArkUI_StyledString * storage,OH_Drawing_PlaceholderSpan * placeholder)948 void OH_ArkUI_StyledString_AddPlaceholder(ArkUI_StyledString* storage, OH_Drawing_PlaceholderSpan* placeholder)
949 {
950     OH_Drawing_TypographyHandlerAddPlaceholder(
951         reinterpret_cast<OH_Drawing_TypographyCreate*>(storage->builder), placeholder);
952     ArkUI_SpanItem* spanItem = new ArkUI_SpanItem;
953     if (placeholder) {
954         spanItem->placeholder = new OH_Drawing_PlaceholderSpan {
955             placeholder->width, placeholder->height,
956             placeholder->alignment, placeholder->baseline,
957             placeholder->baselineOffset };
958     } else {
959         spanItem->placeholder = new OH_Drawing_PlaceholderSpan();
960     }
961     storage->items.emplace_back(spanItem);
962 }
963 
OH_ArkUI_AccessibilityState_Create()964 ArkUI_AccessibilityState* OH_ArkUI_AccessibilityState_Create()
965 {
966     ArkUI_AccessibilityState* state = new ArkUI_AccessibilityState;
967     state->isDisabled = ArkUI_OptionalInt { 0, 0 };
968     state->isSelected = ArkUI_OptionalInt { 0, 0 };
969     state->checkedType = ArkUI_OptionalInt { 0, 0 };
970     return state;
971 }
972 
OH_ArkUI_AccessibilityState_Dispose(ArkUI_AccessibilityState * state)973 void OH_ArkUI_AccessibilityState_Dispose(ArkUI_AccessibilityState* state)
974 {
975     delete state;
976 }
977 
OH_ArkUI_AccessibilityState_SetDisabled(ArkUI_AccessibilityState * state,int32_t isDisabled)978 void OH_ArkUI_AccessibilityState_SetDisabled(ArkUI_AccessibilityState* state, int32_t isDisabled)
979 {
980     CHECK_NULL_VOID(state);
981     state->isDisabled.isSet = 1;
982     state->isDisabled.value = isDisabled;
983 }
984 
OH_ArkUI_AccessibilityState_IsDisabled(ArkUI_AccessibilityState * state)985 int32_t OH_ArkUI_AccessibilityState_IsDisabled(ArkUI_AccessibilityState* state)
986 {
987     CHECK_NULL_RETURN(state, 0);
988     return state->isDisabled.value;
989 }
990 
OH_ArkUI_AccessibilityState_SetSelected(ArkUI_AccessibilityState * state,int32_t isSelected)991 void OH_ArkUI_AccessibilityState_SetSelected(ArkUI_AccessibilityState* state, int32_t isSelected)
992 {
993     CHECK_NULL_VOID(state);
994     state->isSelected.isSet = 1;
995     state->isSelected.value = isSelected;
996 }
997 
OH_ArkUI_AccessibilityState_IsSelected(ArkUI_AccessibilityState * state)998 int32_t OH_ArkUI_AccessibilityState_IsSelected(ArkUI_AccessibilityState* state)
999 {
1000     CHECK_NULL_RETURN(state, 0);
1001     return state->isSelected.value;
1002 }
1003 
OH_ArkUI_AccessibilityState_SetCheckedState(ArkUI_AccessibilityState * state,int32_t checkedState)1004 void OH_ArkUI_AccessibilityState_SetCheckedState(ArkUI_AccessibilityState* state, int32_t checkedState)
1005 {
1006     CHECK_NULL_VOID(state);
1007     state->checkedType.isSet = 1;
1008     state->checkedType.value = checkedState;
1009 }
1010 
OH_ArkUI_AccessibilityState_GetCheckedState(ArkUI_AccessibilityState * state)1011 int32_t OH_ArkUI_AccessibilityState_GetCheckedState(ArkUI_AccessibilityState* state)
1012 {
1013     CHECK_NULL_RETURN(state, 0);
1014     return state->checkedType.value;
1015 }
1016 
OH_ArkUI_AccessibilityValue_Create()1017 ArkUI_AccessibilityValue* OH_ArkUI_AccessibilityValue_Create()
1018 {
1019     ArkUI_AccessibilityValue* value = new ArkUI_AccessibilityValue;
1020     value->min = ArkUI_OptionalInt { 0, -1 };
1021     value->max = ArkUI_OptionalInt { 0, -1 };
1022     value->current = ArkUI_OptionalInt { 0, -1 };
1023     value->rangeMin = ArkUI_OptionalInt { 0, -1 };
1024     value->rangeMax = ArkUI_OptionalInt { 0, -1 };
1025     value->rangeCurrent = ArkUI_OptionalInt { 0, -1 };
1026     value->text = ArkUI_OptionalCharPtr { 0, "" };
1027     return value;
1028 }
1029 
OH_ArkUI_AccessibilityValue_Dispose(ArkUI_AccessibilityValue * value)1030 void OH_ArkUI_AccessibilityValue_Dispose(ArkUI_AccessibilityValue* value)
1031 {
1032     delete value;
1033 }
1034 
OH_ArkUI_AccessibilityValue_SetMin(ArkUI_AccessibilityValue * value,int32_t min)1035 void OH_ArkUI_AccessibilityValue_SetMin(ArkUI_AccessibilityValue* value, int32_t min)
1036 {
1037     CHECK_NULL_VOID(value);
1038     value->min.isSet = 1;
1039     value->min.value = min;
1040 }
1041 
OH_ArkUI_AccessibilityValue_GetMin(ArkUI_AccessibilityValue * value)1042 int32_t OH_ArkUI_AccessibilityValue_GetMin(ArkUI_AccessibilityValue* value)
1043 {
1044     CHECK_NULL_RETURN(value, -1);
1045     return value->min.value;
1046 }
1047 
OH_ArkUI_AccessibilityValue_SetMax(ArkUI_AccessibilityValue * value,int32_t max)1048 void OH_ArkUI_AccessibilityValue_SetMax(ArkUI_AccessibilityValue* value, int32_t max)
1049 {
1050     CHECK_NULL_VOID(value);
1051     value->max.isSet = 1;
1052     value->max.value = max;
1053 }
1054 
OH_ArkUI_AccessibilityValue_GetMax(ArkUI_AccessibilityValue * value)1055 int32_t OH_ArkUI_AccessibilityValue_GetMax(ArkUI_AccessibilityValue* value)
1056 {
1057     CHECK_NULL_RETURN(value, -1);
1058     return value->max.value;
1059 }
1060 
OH_ArkUI_AccessibilityValue_SetCurrent(ArkUI_AccessibilityValue * value,int32_t current)1061 void OH_ArkUI_AccessibilityValue_SetCurrent(ArkUI_AccessibilityValue* value, int32_t current)
1062 {
1063     CHECK_NULL_VOID(value);
1064     value->current.isSet = 1;
1065     value->current.value = current;
1066 }
1067 
OH_ArkUI_AccessibilityValue_GetCurrent(ArkUI_AccessibilityValue * value)1068 int32_t OH_ArkUI_AccessibilityValue_GetCurrent(ArkUI_AccessibilityValue* value)
1069 {
1070     CHECK_NULL_RETURN(value, -1);
1071     return value->current.value;
1072 }
1073 
OH_ArkUI_AccessibilityValue_SetRangeMin(ArkUI_AccessibilityValue * value,int32_t rangeMin)1074 void OH_ArkUI_AccessibilityValue_SetRangeMin(ArkUI_AccessibilityValue* value, int32_t rangeMin)
1075 {
1076     CHECK_NULL_VOID(value);
1077     value->rangeMin.isSet = 1;
1078     value->rangeMin.value = rangeMin;
1079 }
1080 
OH_ArkUI_AccessibilityValue_GetRangeMin(ArkUI_AccessibilityValue * value)1081 int32_t OH_ArkUI_AccessibilityValue_GetRangeMin(ArkUI_AccessibilityValue* value)
1082 {
1083     CHECK_NULL_RETURN(value, -1);
1084     return value->rangeMin.value;
1085 }
1086 
OH_ArkUI_AccessibilityValue_SetRangeMax(ArkUI_AccessibilityValue * value,int32_t rangeMax)1087 void OH_ArkUI_AccessibilityValue_SetRangeMax(ArkUI_AccessibilityValue* value, int32_t rangeMax)
1088 {
1089     CHECK_NULL_VOID(value);
1090     value->rangeMax.isSet = 1;
1091     value->rangeMax.value = rangeMax;
1092 }
1093 
OH_ArkUI_AccessibilityValue_GetRangeMax(ArkUI_AccessibilityValue * value)1094 int32_t OH_ArkUI_AccessibilityValue_GetRangeMax(ArkUI_AccessibilityValue* value)
1095 {
1096     CHECK_NULL_RETURN(value, -1);
1097     return value->rangeMax.value;
1098 }
1099 
OH_ArkUI_AccessibilityValue_SetRangeCurrent(ArkUI_AccessibilityValue * value,int32_t rangeCurrent)1100 void OH_ArkUI_AccessibilityValue_SetRangeCurrent(ArkUI_AccessibilityValue* value, int32_t rangeCurrent)
1101 {
1102     CHECK_NULL_VOID(value);
1103     value->rangeCurrent.isSet = 1;
1104     value->rangeCurrent.value = rangeCurrent;
1105 }
1106 
OH_ArkUI_AccessibilityValue_GetRangeCurrent(ArkUI_AccessibilityValue * value)1107 int32_t OH_ArkUI_AccessibilityValue_GetRangeCurrent(ArkUI_AccessibilityValue* value)
1108 {
1109     CHECK_NULL_RETURN(value, -1);
1110     return value->rangeCurrent.value;
1111 }
1112 
OH_ArkUI_AccessibilityValue_SetText(ArkUI_AccessibilityValue * value,const char * text)1113 void OH_ArkUI_AccessibilityValue_SetText(ArkUI_AccessibilityValue* value, const char* text)
1114 {
1115     CHECK_NULL_VOID(value);
1116     value->text.isSet = 1;
1117     value->text.value = text;
1118 }
1119 
OH_ArkUI_AccessibilityValue_GetText(ArkUI_AccessibilityValue * value)1120 const char* OH_ArkUI_AccessibilityValue_GetText(ArkUI_AccessibilityValue* value)
1121 {
1122     CHECK_NULL_RETURN(value, "");
1123     return value->text.value;
1124 }
1125 
OH_ArkUI_VisibleAreaEventOptions_Create()1126 ArkUI_VisibleAreaEventOptions* OH_ArkUI_VisibleAreaEventOptions_Create()
1127 {
1128     ArkUI_VisibleAreaEventOptions* options = new ArkUI_VisibleAreaEventOptions;
1129     options->expectedUpdateInterval = 1000;
1130     return options;
1131 }
1132 
OH_ArkUI_VisibleAreaEventOptions_Dispose(ArkUI_VisibleAreaEventOptions * option)1133 void OH_ArkUI_VisibleAreaEventOptions_Dispose(ArkUI_VisibleAreaEventOptions* option)
1134 {
1135     if (!option) {
1136         return;
1137     }
1138     delete option;
1139     option = nullptr;
1140 }
1141 
OH_ArkUI_VisibleAreaEventOptions_SetRatios(ArkUI_VisibleAreaEventOptions * option,float * value,int32_t size)1142 int32_t OH_ArkUI_VisibleAreaEventOptions_SetRatios(ArkUI_VisibleAreaEventOptions* option, float* value, int32_t size)
1143 {
1144     if (!option) {
1145         return ARKUI_ERROR_CODE_PARAM_INVALID;
1146     }
1147     option->ratios.clear();
1148     for (int32_t i = 0; i < size; i++) {
1149         auto ratio = value[i];
1150         ratio = std::clamp(ratio, DEFAULT_VISIBLE_RATIO_MIN, DEFAULT_VISIBLE_RATIO_MAX);
1151         option->ratios.push_back(ratio);
1152     }
1153     return ARKUI_ERROR_CODE_NO_ERROR;
1154 }
1155 
OH_ArkUI_VisibleAreaEventOptions_SetExpectedUpdateInterval(ArkUI_VisibleAreaEventOptions * option,int32_t value)1156 int32_t OH_ArkUI_VisibleAreaEventOptions_SetExpectedUpdateInterval(ArkUI_VisibleAreaEventOptions* option, int32_t value)
1157 {
1158     if (!option) {
1159         return ARKUI_ERROR_CODE_PARAM_INVALID;
1160     }
1161     if (value < 0) {
1162         value = EXPECTED_UPDATE_INTERVAL_VALUE;
1163     }
1164     option->expectedUpdateInterval = value;
1165     return ARKUI_ERROR_CODE_NO_ERROR;
1166 }
1167 
OH_ArkUI_VisibleAreaEventOptions_GetRatios(ArkUI_VisibleAreaEventOptions * option,float * value,int32_t * size)1168 int32_t OH_ArkUI_VisibleAreaEventOptions_GetRatios(ArkUI_VisibleAreaEventOptions* option, float* value, int32_t* size)
1169 {
1170     if (!option || !value || !size) {
1171         return ARKUI_ERROR_CODE_PARAM_INVALID;
1172     }
1173     int32_t ratiosSize = static_cast<int32_t>(option->ratios.size());
1174     if (*size < ratiosSize) {
1175         *size = ratiosSize;
1176         return ARKUI_ERROR_CODE_BUFFER_SIZE_ERROR;
1177     }
1178     int32_t index = 0;
1179     for (const auto& element : option->ratios) {
1180         value[index] = element;
1181         index++;
1182     }
1183     *size = static_cast<int32_t>(option->ratios.size());
1184     return ARKUI_ERROR_CODE_NO_ERROR;
1185 }
1186 
OH_ArkUI_VisibleAreaEventOptions_GetExpectedUpdateInterval(ArkUI_VisibleAreaEventOptions * option)1187 int32_t OH_ArkUI_VisibleAreaEventOptions_GetExpectedUpdateInterval(ArkUI_VisibleAreaEventOptions* option)
1188 {
1189     if (!option) {
1190         return -1;
1191     }
1192     return option->expectedUpdateInterval;
1193 }
1194 #ifdef __cplusplus
1195 };
1196 #endif
1197