• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2023-2025 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/search_modifier.h"
16 #include "ui/base/geometry/calc_dimension.h"
17 #include "ui/properties/color.h"
18 
19 #include "base/utils/utf_helper.h"
20 #include "core/components/search/search_theme.h"
21 #include "core/components/text_field/textfield_theme.h"
22 #include "core/components_ng/pattern/search/search_model_ng.h"
23 #include "core/components/common/properties/text_style_parser.h"
24 
25 namespace OHOS::Ace::NG {
26 namespace{
27 
28 constexpr Dimension DEFAULT_FONT_SIZE = 16.0_fp;
29 constexpr FontWeight DEFAULT_FONT_WEIGHT = FontWeight::NORMAL;
30 constexpr Ace::FontStyle DEFAULT_FONT_STYLE = Ace::FontStyle::NORMAL;
31 const bool DEFAULT_SELECTION_MENU_HIDDEN = false;
32 constexpr CancelButtonStyle DEFAULT_CANCEL_BUTTON_STYLE = CancelButtonStyle::INPUT;
33 constexpr Dimension THEME_SEARCH_FONT_SIZE = Dimension(16.0, DimensionUnit::FP);
34 constexpr TextDecoration DEFAULT_TEXT_DECORATION = TextDecoration::NONE;
35 constexpr Color DEFAULT_DECORATION_COLOR = Color(0xff000000);
36 constexpr TextDecorationStyle DEFAULT_DECORATION_STYLE = TextDecorationStyle::SOLID;
37 constexpr int16_t DEFAULT_ALPHA = 255;
38 constexpr double DEFAULT_OPACITY = 0.2;
39 constexpr float DEFAULT_MIN_FONT_SCALE = 0.0f;
40 constexpr float DEFAULT_MAX_FONT_SCALE = static_cast<float>(INT32_MAX);
41 constexpr bool DEFAULT_ENABLE_PREVIEW_TEXT_VALUE = true;
42 constexpr int32_t DEFAULT_CARET_POSITION = 0;
43 constexpr bool DEFAULT_ENABLE_HAPTIC_FEEDBACK_VALUE = true;
44 
SetSearchTextFont(ArkUINodeHandle node,const struct ArkUIFontStruct * value,void * resRawPtr)45 void SetSearchTextFont(ArkUINodeHandle node, const struct ArkUIFontStruct* value, void* resRawPtr)
46 {
47     auto* frameNode = reinterpret_cast<FrameNode*>(node);
48     CHECK_NULL_VOID(frameNode);
49     Font font;
50     font.fontSize = Dimension(value->fontSizeNumber, static_cast<DimensionUnit>(value->fontSizeUnit));
51     font.fontWeight = static_cast<FontWeight>(value->fontWeight);
52     font.fontFamilies.assign(value->fontFamilies, value->fontFamilies + value->familyLength);
53     font.fontStyle = static_cast<OHOS::Ace::FontStyle>(value->fontStyle);
54 
55     SearchModelNG::SetTextFont(frameNode, font);
56     auto pattern = frameNode->GetPattern();
57     CHECK_NULL_VOID(pattern);
58     if (SystemProperties::ConfigChangePerform() && resRawPtr) {
59         auto resObj = AceType::Claim(reinterpret_cast<ResourceObject*>(resRawPtr));
60         pattern->RegisterResource<CalcDimension>("fontSize", resObj,
61         Dimension(value->fontSizeNumber, static_cast<DimensionUnit>(value->fontSizeUnit)));
62     } else {
63         pattern->UnRegisterResource("fontSize");
64     }
65 }
66 
ResetSearchTextFont(ArkUINodeHandle node)67 void ResetSearchTextFont(ArkUINodeHandle node)
68 {
69     auto* frameNode = reinterpret_cast<FrameNode*>(node);
70     CHECK_NULL_VOID(frameNode);
71     Font font;
72     font.fontSize = DEFAULT_FONT_SIZE;
73     font.fontWeight = DEFAULT_FONT_WEIGHT;
74     font.fontStyle = DEFAULT_FONT_STYLE;
75     SearchModelNG::SetTextFont(frameNode, font);
76     if (SystemProperties::ConfigChangePerform()) {
77         auto pattern = frameNode->GetPattern();
78         CHECK_NULL_VOID(pattern);
79         pattern->UnRegisterResource("fontSize");
80     }
81 }
82 
SetSearchPlaceholderColor(ArkUINodeHandle node,ArkUI_Uint32 color,void * resRawPtr)83 void SetSearchPlaceholderColor(ArkUINodeHandle node, ArkUI_Uint32 color, void* resRawPtr)
84 {
85     auto* frameNode = reinterpret_cast<FrameNode*>(node);
86     CHECK_NULL_VOID(frameNode);
87     SearchModelNG::SetPlaceholderColor(frameNode, Color(color));
88     auto pattern = frameNode->GetPattern();
89     CHECK_NULL_VOID(pattern);
90     if (SystemProperties::ConfigChangePerform() && resRawPtr) {
91         auto resObj = AceType::Claim(reinterpret_cast<ResourceObject*>(resRawPtr));
92         pattern->RegisterResource<Color>("placeholderColor", resObj, Color(color));
93     } else {
94         pattern->UnRegisterResource("placeholderColor");
95     }
96 }
97 
ResetSearchPlaceholderColor(ArkUINodeHandle node)98 void ResetSearchPlaceholderColor(ArkUINodeHandle node)
99 {
100     auto* frameNode = reinterpret_cast<FrameNode*>(node);
101     CHECK_NULL_VOID(frameNode);
102     SearchModelNG::ResetPlaceholderColor(frameNode);
103     if (SystemProperties::ConfigChangePerform()) {
104         auto pattern = frameNode->GetPattern();
105         CHECK_NULL_VOID(pattern);
106         pattern->UnRegisterResource("placeholderColor");
107     }
108 }
109 
SetSearchSelectionMenuHidden(ArkUINodeHandle node,ArkUI_Uint32 selectionMenuHidden)110 void SetSearchSelectionMenuHidden(ArkUINodeHandle node, ArkUI_Uint32 selectionMenuHidden)
111 {
112     auto* frameNode = reinterpret_cast<FrameNode*>(node);
113     CHECK_NULL_VOID(frameNode);
114     SearchModelNG::SetSelectionMenuHidden(frameNode, static_cast<bool>(selectionMenuHidden));
115 }
116 
ResetSearchSelectionMenuHidden(ArkUINodeHandle node)117 void ResetSearchSelectionMenuHidden(ArkUINodeHandle node)
118 {
119     auto* frameNode = reinterpret_cast<FrameNode*>(node);
120     CHECK_NULL_VOID(frameNode);
121     SearchModelNG::SetSelectionMenuHidden(frameNode, DEFAULT_SELECTION_MENU_HIDDEN);
122 }
123 
SetSearchCaretStyle(ArkUINodeHandle node,const ArkUI_Float32 number,ArkUI_Int32 unit,ArkUI_Uint32 caretColor,void * widthRawPtr,void * colorRawPtr)124 void SetSearchCaretStyle(ArkUINodeHandle node, const ArkUI_Float32 number, ArkUI_Int32 unit, ArkUI_Uint32 caretColor,
125                          void* widthRawPtr, void* colorRawPtr)
126 {
127     auto* frameNode = reinterpret_cast<FrameNode*>(node);
128     CHECK_NULL_VOID(frameNode);
129     SearchModelNG::SetCaretWidth(frameNode, Dimension(number, static_cast<DimensionUnit>(unit)));
130     SearchModelNG::SetCaretColor(frameNode, Color(caretColor));
131     auto pattern = frameNode->GetPattern();
132     CHECK_NULL_VOID(pattern);
133     if (SystemProperties::ConfigChangePerform() && widthRawPtr) {
134         auto resObj = AceType::Claim(reinterpret_cast<ResourceObject*>(widthRawPtr));
135         pattern->RegisterResource<CalcDimension>("caretWidth", resObj,
136         Dimension(number, static_cast<DimensionUnit>(unit)));
137     } else {
138         pattern->UnRegisterResource("caretWidth");
139     }
140     if (SystemProperties::ConfigChangePerform() && colorRawPtr) {
141         auto resObj = AceType::Claim(reinterpret_cast<ResourceObject*>(colorRawPtr));
142         pattern->RegisterResource<Color>("caretColor", resObj, Color(caretColor));
143     } else {
144         pattern->UnRegisterResource("caretColor");
145     }
146 }
147 
ResetSearchCaretStyle(ArkUINodeHandle node)148 void ResetSearchCaretStyle(ArkUINodeHandle node)
149 {
150     auto* frameNode = reinterpret_cast<FrameNode*>(node);
151     CHECK_NULL_VOID(frameNode);
152     auto textFieldTheme = GetTheme<TextFieldTheme>();
153     CHECK_NULL_VOID(textFieldTheme);
154     CalcDimension caretWidth = textFieldTheme->GetCursorWidth();
155     SearchModelNG::SetCaretWidth(frameNode, Dimension(caretWidth.Value(), caretWidth.Unit()));
156     SearchModelNG::ResetCaretColor(frameNode);
157     if (SystemProperties::ConfigChangePerform()) {
158         auto pattern = frameNode->GetPattern();
159         CHECK_NULL_VOID(pattern);
160         pattern->UnRegisterResource("caretWidth");
161         pattern->UnRegisterResource("caretColor");
162     }
163 }
164 
SetSearchTextAlign(ArkUINodeHandle node,ArkUI_Int32 value)165 void SetSearchTextAlign(ArkUINodeHandle node, ArkUI_Int32 value)
166 {
167     auto* frameNode = reinterpret_cast<FrameNode*>(node);
168     CHECK_NULL_VOID(frameNode);
169     TextAlign value_textAlign = static_cast<TextAlign>(value);
170     SearchModelNG::SetTextAlign(frameNode, value_textAlign);
171 }
172 
ResetSearchTextAlign(ArkUINodeHandle node)173 void ResetSearchTextAlign(ArkUINodeHandle node)
174 {
175     auto* frameNode = reinterpret_cast<FrameNode*>(node);
176     CHECK_NULL_VOID(frameNode);
177     SearchModelNG::SetTextAlign(frameNode, TextAlign::START);
178 }
179 
SetSearchCancelButton(ArkUINodeHandle node,ArkUI_Int32 style,const struct ArkUISizeType * size,ArkUI_Uint32 color,ArkUI_CharPtr src,ArkUIImageIconRes * imageIconRes)180 void SetSearchCancelButton(ArkUINodeHandle node, ArkUI_Int32 style, const struct ArkUISizeType* size,
181                            ArkUI_Uint32 color, ArkUI_CharPtr src, ArkUIImageIconRes* imageIconRes)
182 {
183     auto* frameNode = reinterpret_cast<FrameNode*>(node);
184     CHECK_NULL_VOID(frameNode);
185     SearchModelNG::SetCancelButtonStyle(frameNode, static_cast<CancelButtonStyle>(style));
186     NG::IconOptions cancelIconOptions = NG::IconOptions(
187         Color(color), Dimension(size->value, static_cast<DimensionUnit>(size->unit)), std::string(src), "", "");
188     SearchModelNG::SetCancelImageIcon(frameNode, cancelIconOptions);
189     auto pattern = frameNode->GetPattern();
190     CHECK_NULL_VOID(pattern);
191     if (SystemProperties::ConfigChangePerform() && imageIconRes && imageIconRes->sizeObj) {
192         auto resObj = AceType::Claim(reinterpret_cast<ResourceObject*>(imageIconRes->sizeObj));
193         pattern->RegisterResource<CalcDimension>("cancelButtonIconSize", resObj,
194         Dimension(size->value, static_cast<DimensionUnit>(size->unit)));
195     } else {
196         pattern->UnRegisterResource("cancelButtonIconSize");
197     }
198     if (SystemProperties::ConfigChangePerform() && imageIconRes && imageIconRes->colorObj) {
199         auto resObj = AceType::Claim(reinterpret_cast<ResourceObject*>(imageIconRes->colorObj));
200         pattern->RegisterResource<Color>("cancelButtonIconColor", resObj, Color(color));
201     } else {
202         pattern->UnRegisterResource("cancelButtonIconColor");
203     }
204     if (SystemProperties::ConfigChangePerform() && imageIconRes && imageIconRes->srcObj) {
205         auto resObj = AceType::Claim(reinterpret_cast<ResourceObject*>(imageIconRes->srcObj));
206         pattern->RegisterResource<std::string>("cancelButtonIconSrc", resObj, std::string(src));
207     } else {
208         pattern->UnRegisterResource("cancelButtonIconSrc");
209     }
210 }
211 
ResetSearchCancelButton(ArkUINodeHandle node)212 void ResetSearchCancelButton(ArkUINodeHandle node)
213 {
214     auto* frameNode = reinterpret_cast<FrameNode*>(node);
215     CHECK_NULL_VOID(frameNode);
216     SearchModelNG::SetCancelButtonStyle(frameNode, DEFAULT_CANCEL_BUTTON_STYLE);
217     if (SystemProperties::ConfigChangePerform()) {
218         auto pattern = frameNode->GetPattern();
219         CHECK_NULL_VOID(pattern);
220         pattern->UnRegisterResource("cancelButtonIconSize");
221         pattern->UnRegisterResource("cancelButtonIconColor");
222         pattern->UnRegisterResource("cancelButtonIconSrc");
223     }
224 }
225 
SetSearchEnableKeyboardOnFocus(ArkUINodeHandle node,ArkUI_Uint32 value)226 void SetSearchEnableKeyboardOnFocus(ArkUINodeHandle node, ArkUI_Uint32 value)
227 {
228     auto* frameNode = reinterpret_cast<FrameNode*>(node);
229     CHECK_NULL_VOID(frameNode);
230     SearchModelNG::RequestKeyboardOnFocus(frameNode, static_cast<bool>(value));
231 }
232 
ResetSearchEnableKeyboardOnFocus(ArkUINodeHandle node)233 void ResetSearchEnableKeyboardOnFocus(ArkUINodeHandle node)
234 {
235     auto* frameNode = reinterpret_cast<FrameNode*>(node);
236     CHECK_NULL_VOID(frameNode);
237     SearchModelNG::RequestKeyboardOnFocus(frameNode, true);
238 }
239 
SetSearchPlaceholderFont(ArkUINodeHandle node,const struct ArkUIFontStruct * value,void * resRawPtr)240 void SetSearchPlaceholderFont(ArkUINodeHandle node, const struct ArkUIFontStruct* value, void* resRawPtr)
241 {
242     auto* frameNode = reinterpret_cast<FrameNode*>(node);
243     CHECK_NULL_VOID(frameNode);
244     Font font;
245     font.fontSize = Dimension(value->fontSizeNumber, static_cast<DimensionUnit>(value->fontSizeUnit));
246     font.fontWeight = static_cast<FontWeight>(value->fontWeight);
247     font.fontFamilies.assign(value->fontFamilies, value->fontFamilies + value->familyLength);
248     font.fontStyle = static_cast<OHOS::Ace::FontStyle>(value->fontStyle);
249 
250     SearchModelNG::SetPlaceholderFont(frameNode, font);
251     auto pattern = frameNode->GetPattern();
252     CHECK_NULL_VOID(pattern);
253     if (SystemProperties::ConfigChangePerform() && resRawPtr) {
254         auto resObj = AceType::Claim(reinterpret_cast<ResourceObject*>(resRawPtr));
255         pattern->RegisterResource<CalcDimension>("placeholderFontSize", resObj,
256         Dimension(value->fontSizeNumber, static_cast<DimensionUnit>(value->fontSizeUnit)));
257     } else {
258         pattern->UnRegisterResource("placeholderFontSize");
259     }
260 }
261 
ResetSearchPlaceholderFont(ArkUINodeHandle node)262 void ResetSearchPlaceholderFont(ArkUINodeHandle node)
263 {
264     auto* frameNode = reinterpret_cast<FrameNode*>(node);
265     CHECK_NULL_VOID(frameNode);
266     Font font;
267     font.fontSize = THEME_SEARCH_FONT_SIZE;
268     font.fontWeight = DEFAULT_FONT_WEIGHT;
269     font.fontStyle = DEFAULT_FONT_STYLE;
270     SearchModelNG::SetPlaceholderFont(frameNode, font);
271     if (SystemProperties::ConfigChangePerform()) {
272         auto pattern = frameNode->GetPattern();
273         CHECK_NULL_VOID(pattern);
274         pattern->UnRegisterResource("placeholderFontSize");
275     }
276 }
277 
SetSearchSearchIcon(ArkUINodeHandle node,const struct ArkUIIconOptionsStruct * value,ArkUIImageIconRes * imageIconRes)278 void SetSearchSearchIcon(ArkUINodeHandle node, const struct ArkUIIconOptionsStruct* value,
279     ArkUIImageIconRes* imageIconRes)
280 {
281     auto* frameNode = reinterpret_cast<FrameNode*>(node);
282     CHECK_NULL_VOID(frameNode);
283     Color iconColor;
284     if (value->color != INVALID_COLOR_VALUE) {
285         iconColor = Color(value->color);
286     }
287 
288     NG::IconOptions cancelInconOptions = NG::IconOptions(
289         iconColor, Dimension(value->value, static_cast<DimensionUnit>(value->unit)), std::string(value->src), "", "");
290     SearchModelNG::SetSearchImageIcon(frameNode, cancelInconOptions);
291     auto pattern = frameNode->GetPattern();
292     CHECK_NULL_VOID(pattern);
293     if (SystemProperties::ConfigChangePerform() && imageIconRes && imageIconRes->sizeObj) {
294         auto resObj = AceType::Claim(reinterpret_cast<ResourceObject*>(imageIconRes->sizeObj));
295         pattern->RegisterResource<CalcDimension>("searchIconSize", resObj,
296         Dimension(value->value, static_cast<DimensionUnit>(value->unit)));
297     } else {
298         pattern->UnRegisterResource("searchIconSize");
299     }
300     if (SystemProperties::ConfigChangePerform() && imageIconRes && imageIconRes->colorObj) {
301         auto resObj = AceType::Claim(reinterpret_cast<ResourceObject*>(imageIconRes->colorObj));
302         pattern->RegisterResource<Color>("searchIconColor", resObj, iconColor);
303     } else {
304         pattern->UnRegisterResource("searchIconColor");
305     }
306     if (SystemProperties::ConfigChangePerform() && imageIconRes && imageIconRes->srcObj) {
307         auto resObj = AceType::Claim(reinterpret_cast<ResourceObject*>(imageIconRes->srcObj));
308         pattern->RegisterResource<std::string>("searchIconSrc", resObj, std::string(value->src));
309     } else {
310         pattern->UnRegisterResource("searchIconSrc");
311     }
312 }
313 
ResetSearchSearchIcon(ArkUINodeHandle node)314 void ResetSearchSearchIcon(ArkUINodeHandle node)
315 {
316     auto* frameNode = reinterpret_cast<FrameNode*>(node);
317     CHECK_NULL_VOID(frameNode);
318     SearchModelNG::SetSearchSrcPath(frameNode, "");
319     if (SystemProperties::ConfigChangePerform()) {
320         auto pattern = frameNode->GetPattern();
321         CHECK_NULL_VOID(pattern);
322         pattern->UnRegisterResource("searchIconSize");
323         pattern->UnRegisterResource("searchIconColor");
324         pattern->UnRegisterResource("searchIconSrc");
325     }
326 }
327 
SetSearchSearchButton(ArkUINodeHandle node,const struct ArkUISearchButtonOptionsStruct * value,ArkUIImageIconRes * imageIconRes)328 void SetSearchSearchButton(ArkUINodeHandle node, const struct ArkUISearchButtonOptionsStruct* value,
329                            ArkUIImageIconRes* imageIconRes)
330 {
331     auto* frameNode = reinterpret_cast<FrameNode*>(node);
332     CHECK_NULL_VOID(frameNode);
333     SearchModelNG::SetSearchButton(frameNode, value->value);
334     SearchModelNG::SetSearchButtonFontSize(frameNode, CalcDimension(value->sizeValue,
335         static_cast<DimensionUnit>(value->sizeUnit)));
336     SearchModelNG::SetSearchButtonFontColor(frameNode, Color(value->fontColor));
337     SearchModelNG::SetSearchButtonAutoDisable(frameNode, value->autoDisable);
338     auto pattern = frameNode->GetPattern();
339     CHECK_NULL_VOID(pattern);
340     if (SystemProperties::ConfigChangePerform() && imageIconRes && imageIconRes->sizeObj) {
341         auto resObj = AceType::Claim(reinterpret_cast<ResourceObject*>(imageIconRes->sizeObj));
342         pattern->RegisterResource<CalcDimension>("searchButtonFontSize", resObj,
343         CalcDimension(value->sizeValue, static_cast<DimensionUnit>(value->sizeUnit)));
344     } else {
345         pattern->UnRegisterResource("searchButtonFontSize");
346     }
347     if (SystemProperties::ConfigChangePerform() && imageIconRes && imageIconRes->colorObj) {
348         auto resObj = AceType::Claim(reinterpret_cast<ResourceObject*>(imageIconRes->colorObj));
349         pattern->RegisterResource<Color>("searchButtonFontColor", resObj, Color(value->fontColor));
350     } else {
351         pattern->UnRegisterResource("searchButtonFontColor");
352     }
353     if (SystemProperties::ConfigChangePerform() && imageIconRes && imageIconRes->srcObj) {
354         auto resObj = AceType::Claim(reinterpret_cast<ResourceObject*>(imageIconRes->srcObj));
355         pattern->RegisterResource<std::string>("searchButtonValue", resObj, value->value);
356     } else {
357         pattern->UnRegisterResource("searchButtonValue");
358     }
359 }
360 
ResetSearchSearchButton(ArkUINodeHandle node)361 void ResetSearchSearchButton(ArkUINodeHandle node)
362 {
363     auto* frameNode = reinterpret_cast<FrameNode*>(node);
364     CHECK_NULL_VOID(frameNode);
365     SearchModelNG::SetSearchButton(frameNode, "");
366     if (SystemProperties::ConfigChangePerform()) {
367         auto pattern = frameNode->GetPattern();
368         CHECK_NULL_VOID(pattern);
369         pattern->UnRegisterResource("searchButtonFontSize");
370         pattern->UnRegisterResource("searchButtonFontColor");
371         pattern->UnRegisterResource("searchButtonValue");
372     }
373 }
374 
SetSearchFontColor(ArkUINodeHandle node,ArkUI_Uint32 value,void * resRawPtr)375 void SetSearchFontColor(ArkUINodeHandle node, ArkUI_Uint32 value, void* resRawPtr)
376 {
377     auto* frameNode = reinterpret_cast<FrameNode*>(node);
378     CHECK_NULL_VOID(frameNode);
379     SearchModelNG::SetTextColor(frameNode, Color(value));
380     auto pattern = frameNode->GetPattern();
381     CHECK_NULL_VOID(pattern);
382     if (SystemProperties::ConfigChangePerform() && resRawPtr) {
383         auto resObj = AceType::Claim(reinterpret_cast<ResourceObject*>(resRawPtr));
384         pattern->RegisterResource<Color>("fontColor", resObj, Color(value));
385     } else {
386         pattern->UnRegisterResource("fontColor");
387     }
388 }
389 
ResetSearchFontColor(ArkUINodeHandle node)390 void ResetSearchFontColor(ArkUINodeHandle node)
391 {
392     auto* frameNode = reinterpret_cast<FrameNode*>(node);
393     CHECK_NULL_VOID(frameNode);
394     SearchModelNG::ResetTextColor(frameNode);
395     if (SystemProperties::ConfigChangePerform()) {
396         auto pattern = frameNode->GetPattern();
397         CHECK_NULL_VOID(pattern);
398         pattern->UnRegisterResource("fontColor");
399     }
400 }
401 
SetSearchCopyOption(ArkUINodeHandle node,ArkUI_Uint32 value)402 void SetSearchCopyOption(ArkUINodeHandle node, ArkUI_Uint32 value)
403 {
404     auto* frameNode = reinterpret_cast<FrameNode*>(node);
405     CHECK_NULL_VOID(frameNode);
406     auto copyOptions = CopyOptions::Local;
407     copyOptions = static_cast<CopyOptions>(value);
408     SearchModelNG::SetCopyOption(frameNode, copyOptions);
409 }
410 
ResetSearchCopyOption(ArkUINodeHandle node)411 void ResetSearchCopyOption(ArkUINodeHandle node)
412 {
413     auto* frameNode = reinterpret_cast<FrameNode*>(node);
414     CHECK_NULL_VOID(frameNode);
415     auto copyOptions = CopyOptions::Local;
416     SearchModelNG::SetCopyOption(frameNode, copyOptions);
417 }
418 
SetSearchEnterKeyType(ArkUINodeHandle node,ArkUI_Int32 value)419 void SetSearchEnterKeyType(ArkUINodeHandle node, ArkUI_Int32 value)
420 {
421     auto *frameNode = reinterpret_cast<FrameNode *>(node);
422     CHECK_NULL_VOID(frameNode);
423     SearchModelNG::SetSearchEnterKeyType(frameNode, CastToTextInputAction(value));
424 }
425 
ResetSearchEnterKeyType(ArkUINodeHandle node)426 void ResetSearchEnterKeyType(ArkUINodeHandle node)
427 {
428     auto *frameNode = reinterpret_cast<FrameNode *>(node);
429     CHECK_NULL_VOID(frameNode);
430     SearchModelNG::SetSearchEnterKeyType(frameNode, TextInputAction::SEARCH);
431 }
432 
SetSearchHeight(ArkUINodeHandle node,ArkUI_Float32 heightValue,ArkUI_Int32 heightUnit)433 void SetSearchHeight(ArkUINodeHandle node, ArkUI_Float32 heightValue, ArkUI_Int32 heightUnit)
434 {
435     auto* frameNode = reinterpret_cast<FrameNode*>(node);
436     CHECK_NULL_VOID(frameNode);
437     SearchModelNG::SetHeight(frameNode, CalcDimension(heightValue, (DimensionUnit)heightUnit));
438 }
439 
ResetSearchHeight(ArkUINodeHandle node)440 void ResetSearchHeight(ArkUINodeHandle node)
441 {
442     auto* frameNode = reinterpret_cast<FrameNode*>(node);
443     CHECK_NULL_VOID(frameNode);
444     ViewAbstract::ClearWidthOrHeight(frameNode, false);
445 }
446 
SetSearchFontFeature(ArkUINodeHandle node,ArkUI_CharPtr value)447 void SetSearchFontFeature(ArkUINodeHandle node, ArkUI_CharPtr value)
448 {
449     auto* frameNode = reinterpret_cast<FrameNode*>(node);
450     CHECK_NULL_VOID(frameNode);
451     std::string strValue = value;
452     SearchModelNG::SetFontFeature(frameNode, ParseFontFeatureSettings(strValue));
453 }
454 
ResetSearchFontFeature(ArkUINodeHandle node)455 void ResetSearchFontFeature(ArkUINodeHandle node)
456 {
457     auto* frameNode = reinterpret_cast<FrameNode*>(node);
458     CHECK_NULL_VOID(frameNode);
459     std::string strValue = "";
460     SearchModelNG::SetFontFeature(frameNode, ParseFontFeatureSettings(strValue));
461 }
462 
SetSearchInspectorId(ArkUINodeHandle node,ArkUI_CharPtr key)463 void SetSearchInspectorId(ArkUINodeHandle node, ArkUI_CharPtr key)
464 {
465     auto* frameNode = reinterpret_cast<FrameNode*>(node);
466     CHECK_NULL_VOID(frameNode);
467     SearchModelNG::SetId(frameNode, key);
468 }
469 
ResetSearchInspectorId(ArkUINodeHandle node)470 void ResetSearchInspectorId(ArkUINodeHandle node)
471 {
472     auto* frameNode = reinterpret_cast<FrameNode*>(node);
473     CHECK_NULL_VOID(frameNode);
474     SearchModelNG::SetId(frameNode, "");
475 }
476 
SetSearchDecoration(ArkUINodeHandle node,ArkUI_Int32 decoration,ArkUI_Uint32 color,ArkUI_Int32 style,void * resRawPtr)477 void SetSearchDecoration(ArkUINodeHandle node, ArkUI_Int32 decoration, ArkUI_Uint32 color,
478     ArkUI_Int32 style, void* resRawPtr)
479 {
480     auto* frameNode = reinterpret_cast<FrameNode*>(node);
481     CHECK_NULL_VOID(frameNode);
482     SearchModelNG::SetTextDecoration(frameNode, static_cast<TextDecoration>(decoration));
483     SearchModelNG::SetTextDecorationColor(frameNode, Color(color));
484     SearchModelNG::SetTextDecorationStyle(frameNode, static_cast<TextDecorationStyle>(style));
485     auto pattern = frameNode->GetPattern();
486     CHECK_NULL_VOID(pattern);
487     if (SystemProperties::ConfigChangePerform() && resRawPtr) {
488         auto resObj = AceType::Claim(reinterpret_cast<ResourceObject*>(resRawPtr));
489         pattern->RegisterResource<Color>("decorationColor", resObj, Color(color));
490     } else {
491         pattern->UnRegisterResource("decorationColor");
492     }
493 }
494 
ResetSearchDecoration(ArkUINodeHandle node)495 void ResetSearchDecoration(ArkUINodeHandle node)
496 {
497     auto* frameNode = reinterpret_cast<FrameNode*>(node);
498     CHECK_NULL_VOID(frameNode);
499     SearchModelNG::SetTextDecoration(frameNode, DEFAULT_TEXT_DECORATION);
500     SearchModelNG::SetTextDecorationColor(frameNode, DEFAULT_DECORATION_COLOR);
501     SearchModelNG::SetTextDecorationStyle(frameNode, DEFAULT_DECORATION_STYLE);
502     if (SystemProperties::ConfigChangePerform()) {
503         auto pattern = frameNode->GetPattern();
504         CHECK_NULL_VOID(pattern);
505         pattern->UnRegisterResource("decorationColor");
506     }
507 }
508 
SetSearchLetterSpacing(ArkUINodeHandle node,ArkUI_Float32 value,ArkUI_Int32 unit,void * resRawPtr)509 void SetSearchLetterSpacing(ArkUINodeHandle node, ArkUI_Float32 value, ArkUI_Int32 unit, void* resRawPtr)
510 {
511     auto* frameNode = reinterpret_cast<FrameNode*>(node);
512     CHECK_NULL_VOID(frameNode);
513     SearchModelNG::SetLetterSpacing(frameNode, CalcDimension(value, (DimensionUnit)unit));
514     auto pattern = frameNode->GetPattern();
515     CHECK_NULL_VOID(pattern);
516     if (SystemProperties::ConfigChangePerform() && resRawPtr) {
517         auto resObj = AceType::Claim(reinterpret_cast<ResourceObject*>(resRawPtr));
518         pattern->RegisterResource<CalcDimension>("letterSpacing", resObj, CalcDimension(value, (DimensionUnit)unit));
519     } else {
520         pattern->UnRegisterResource("letterSpacing");
521     }
522 }
523 
ResetSearchLetterSpacing(ArkUINodeHandle node)524 void ResetSearchLetterSpacing(ArkUINodeHandle node)
525 {
526     auto* frameNode = reinterpret_cast<FrameNode*>(node);
527     CHECK_NULL_VOID(frameNode);
528     CalcDimension value;
529     value.Reset();
530     SearchModelNG::SetLetterSpacing(frameNode, value);
531     if (SystemProperties::ConfigChangePerform()) {
532         auto pattern = frameNode->GetPattern();
533         CHECK_NULL_VOID(pattern);
534         pattern->UnRegisterResource("letterSpacing");
535     }
536 }
SetSearchLineHeight(ArkUINodeHandle node,ArkUI_Float32 value,ArkUI_Int32 unit,void * resRawPtr)537 void SetSearchLineHeight(ArkUINodeHandle node, ArkUI_Float32 value, ArkUI_Int32 unit, void* resRawPtr)
538 {
539     auto* frameNode = reinterpret_cast<FrameNode*>(node);
540     CHECK_NULL_VOID(frameNode);
541     SearchModelNG::SetLineHeight(frameNode, CalcDimension(value, (DimensionUnit)unit));
542     auto pattern = frameNode->GetPattern();
543     CHECK_NULL_VOID(pattern);
544     if (SystemProperties::ConfigChangePerform() && resRawPtr) {
545         auto resObj = AceType::Claim(reinterpret_cast<ResourceObject*>(resRawPtr));
546         pattern->RegisterResource<CalcDimension>("lineHeight", resObj, CalcDimension(value, (DimensionUnit)unit));
547     } else {
548         pattern->UnRegisterResource("lineHeight");
549     }
550 }
ResetSearchLineHeight(ArkUINodeHandle node)551 void ResetSearchLineHeight(ArkUINodeHandle node)
552 {
553     auto* frameNode = reinterpret_cast<FrameNode*>(node);
554     CHECK_NULL_VOID(frameNode);
555     CalcDimension value;
556     value.Reset();
557     SearchModelNG::SetLineHeight(frameNode, value);
558     if (SystemProperties::ConfigChangePerform()) {
559         auto pattern = frameNode->GetPattern();
560         CHECK_NULL_VOID(pattern);
561         pattern->UnRegisterResource("lineHeight");
562     }
563 }
564 
SetSearchHalfLeading(ArkUINodeHandle node,ArkUI_Uint32 halfLeading)565 void SetSearchHalfLeading(ArkUINodeHandle node, ArkUI_Uint32 halfLeading)
566 {
567     auto* frameNode = reinterpret_cast<FrameNode*>(node);
568     CHECK_NULL_VOID(frameNode);
569     SearchModelNG::SetHalfLeading(frameNode, static_cast<bool>(halfLeading));
570 }
571 
ResetSearchHalfLeading(ArkUINodeHandle node)572 void ResetSearchHalfLeading(ArkUINodeHandle node)
573 {
574     auto* frameNode = reinterpret_cast<FrameNode*>(node);
575     CHECK_NULL_VOID(frameNode);
576     bool value = false;
577     SearchModelNG::SetHalfLeading(frameNode, value);
578 }
579 
SetSearchAdaptMinFontSize(ArkUINodeHandle node,ArkUI_Float32 value,ArkUI_Int32 unit,void * resRawPtr)580 void SetSearchAdaptMinFontSize(ArkUINodeHandle node, ArkUI_Float32 value, ArkUI_Int32 unit, void* resRawPtr)
581 {
582     auto* frameNode = reinterpret_cast<FrameNode*>(node);
583     CHECK_NULL_VOID(frameNode);
584     SearchModelNG::SetAdaptMinFontSize(frameNode, CalcDimension(value, (DimensionUnit)unit));
585     auto pattern = frameNode->GetPattern();
586     CHECK_NULL_VOID(pattern);
587     if (SystemProperties::ConfigChangePerform() && resRawPtr) {
588         auto resObj = AceType::Claim(reinterpret_cast<ResourceObject*>(resRawPtr));
589         pattern->RegisterResource<CalcDimension>("minFontSize", resObj, CalcDimension(value, (DimensionUnit)unit));
590     } else {
591         pattern->UnRegisterResource("minFontSize");
592     }
593 }
594 
ResetSearchAdaptMinFontSize(ArkUINodeHandle node)595 void ResetSearchAdaptMinFontSize(ArkUINodeHandle node)
596 {
597     auto* frameNode = reinterpret_cast<FrameNode*>(node);
598     CHECK_NULL_VOID(frameNode);
599     auto pipelineContext = PipelineBase::GetCurrentContext();
600     CHECK_NULL_VOID(pipelineContext);
601     auto theme = pipelineContext->GetTheme<SearchTheme>();
602     CHECK_NULL_VOID(theme);
603     CalcDimension minFontSize = theme->GetTextStyle().GetAdaptMinFontSize();
604     SearchModelNG::SetAdaptMinFontSize(frameNode, minFontSize);
605     if (SystemProperties::ConfigChangePerform()) {
606         auto pattern = frameNode->GetPattern();
607         CHECK_NULL_VOID(pattern);
608         pattern->UnRegisterResource("minFontSize");
609     }
610 }
611 
SetSearchAdaptMaxFontSize(ArkUINodeHandle node,ArkUI_Float32 value,ArkUI_Int32 unit,void * resRawPtr)612 void SetSearchAdaptMaxFontSize(ArkUINodeHandle node, ArkUI_Float32 value, ArkUI_Int32 unit, void* resRawPtr)
613 {
614     auto* frameNode = reinterpret_cast<FrameNode*>(node);
615     CHECK_NULL_VOID(frameNode);
616     SearchModelNG::SetAdaptMaxFontSize(frameNode, CalcDimension(value, (DimensionUnit)unit));
617     auto pattern = frameNode->GetPattern();
618     CHECK_NULL_VOID(pattern);
619     if (SystemProperties::ConfigChangePerform() && resRawPtr) {
620         auto resObj = AceType::Claim(reinterpret_cast<ResourceObject*>(resRawPtr));
621         pattern->RegisterResource<CalcDimension>("maxFontSize", resObj, CalcDimension(value, (DimensionUnit)unit));
622     } else {
623         pattern->UnRegisterResource("maxFontSize");
624     }
625 }
626 
ResetSearchAdaptMaxFontSize(ArkUINodeHandle node)627 void ResetSearchAdaptMaxFontSize(ArkUINodeHandle node)
628 {
629     auto* frameNode = reinterpret_cast<FrameNode*>(node);
630     CHECK_NULL_VOID(frameNode);
631     auto pipelineContext = PipelineBase::GetCurrentContext();
632     CHECK_NULL_VOID(pipelineContext);
633     auto theme = pipelineContext->GetTheme<SearchTheme>();
634     CHECK_NULL_VOID(theme);
635     CalcDimension maxFontSize = theme->GetTextStyle().GetAdaptMaxFontSize();
636     SearchModelNG::SetAdaptMaxFontSize(frameNode, maxFontSize);
637     if (SystemProperties::ConfigChangePerform()) {
638         auto pattern = frameNode->GetPattern();
639         CHECK_NULL_VOID(pattern);
640         pattern->UnRegisterResource("maxFontSize");
641     }
642 }
643 
SetSearchSelectedBackgroundColor(ArkUINodeHandle node,ArkUI_Uint32 color,void * resRawPtr)644 void SetSearchSelectedBackgroundColor(ArkUINodeHandle node, ArkUI_Uint32 color, void* resRawPtr)
645 {
646     auto* frameNode = reinterpret_cast<FrameNode*>(node);
647     CHECK_NULL_VOID(frameNode);
648     Color selectedColor = Color(color);
649     if (selectedColor.GetAlpha() == DEFAULT_ALPHA) {
650         // Default setting of 20% opacity
651         selectedColor = selectedColor.ChangeOpacity(DEFAULT_OPACITY);
652     }
653     SearchModelNG::SetSelectedBackgroundColor(frameNode, selectedColor);
654     auto pattern = frameNode->GetPattern();
655     CHECK_NULL_VOID(pattern);
656     if (SystemProperties::ConfigChangePerform() && resRawPtr) {
657         auto resObj = AceType::Claim(reinterpret_cast<ResourceObject*>(resRawPtr));
658         pattern->RegisterResource<Color>("selectedBackgroundColor", resObj, selectedColor);
659     } else {
660         pattern->UnRegisterResource("selectedBackgroundColor");
661     }
662 }
663 
ResetSearchSelectedBackgroundColor(ArkUINodeHandle node)664 void ResetSearchSelectedBackgroundColor(ArkUINodeHandle node)
665 {
666     auto* frameNode = reinterpret_cast<FrameNode*>(node);
667     CHECK_NULL_VOID(frameNode);
668     SearchModelNG::ResetSelectedBackgroundColor(frameNode);
669     if (SystemProperties::ConfigChangePerform()) {
670         auto pattern = frameNode->GetPattern();
671         CHECK_NULL_VOID(pattern);
672         pattern->UnRegisterResource("selectedBackgroundColor");
673     }
674 }
675 
SetSearchTextIndent(ArkUINodeHandle node,ArkUI_Float32 number,ArkUI_Int32 unit,void * resRawPtr)676 void SetSearchTextIndent(ArkUINodeHandle node, ArkUI_Float32 number, ArkUI_Int32 unit, void* resRawPtr)
677 {
678     auto* frameNode = reinterpret_cast<FrameNode*>(node);
679     CHECK_NULL_VOID(frameNode);
680     SearchModelNG::SetTextIndent(frameNode, Dimension(number, static_cast<DimensionUnit>(unit)));
681     auto pattern = frameNode->GetPattern();
682     CHECK_NULL_VOID(pattern);
683     if (SystemProperties::ConfigChangePerform() && resRawPtr) {
684         auto resObj = AceType::Claim(reinterpret_cast<ResourceObject*>(resRawPtr));
685         pattern->RegisterResource<CalcDimension>("textIndent", resObj,
686         Dimension(number, static_cast<DimensionUnit>(unit)));
687     } else {
688         pattern->UnRegisterResource("textIndent");
689     }
690 }
691 
ResetSearchTextIndent(ArkUINodeHandle node)692 void ResetSearchTextIndent(ArkUINodeHandle node)
693 {
694     auto* frameNode = reinterpret_cast<FrameNode*>(node);
695     CHECK_NULL_VOID(frameNode);
696     SearchModelNG::SetTextIndent(frameNode, CalcDimension(0, DimensionUnit::VP));
697     if (SystemProperties::ConfigChangePerform()) {
698         auto pattern = frameNode->GetPattern();
699         CHECK_NULL_VOID(pattern);
700         pattern->UnRegisterResource("textIndent");
701     }
702 }
703 
SetSearchMaxLength(ArkUINodeHandle node,ArkUI_Int32 value)704 void SetSearchMaxLength(ArkUINodeHandle node, ArkUI_Int32 value)
705 {
706     auto *frameNode = reinterpret_cast<FrameNode *>(node);
707     CHECK_NULL_VOID(frameNode);
708     SearchModelNG::SetMaxLength(frameNode, value);
709 }
710 
ResetSearchMaxLength(ArkUINodeHandle node)711 void ResetSearchMaxLength(ArkUINodeHandle node)
712 {
713     auto *frameNode = reinterpret_cast<FrameNode *>(node);
714     CHECK_NULL_VOID(frameNode);
715     SearchModelNG::ResetMaxLength(frameNode);
716 }
717 
SetSearchType(ArkUINodeHandle node,ArkUI_Int32 value)718 void SetSearchType(ArkUINodeHandle node, ArkUI_Int32 value)
719 {
720     auto *frameNode = reinterpret_cast<FrameNode *>(node);
721     CHECK_NULL_VOID(frameNode);
722     SearchModelNG::SetType(frameNode, CastToTextInputType(value));
723 }
724 
ResetSearchType(ArkUINodeHandle node)725 void ResetSearchType(ArkUINodeHandle node)
726 {
727     auto *frameNode = reinterpret_cast<FrameNode *>(node);
728     CHECK_NULL_VOID(frameNode);
729     SearchModelNG::SetType(frameNode, Ace::TextInputType::TEXT);
730 }
731 
SetSearchOnEditChange(ArkUINodeHandle node,void * callback)732 void SetSearchOnEditChange(ArkUINodeHandle node, void* callback)
733 {
734     auto* frameNode = reinterpret_cast<FrameNode*>(node);
735     CHECK_NULL_VOID(frameNode);
736     if (callback) {
737         auto onEditChange = reinterpret_cast<std::function<void(bool)>*>(callback);
738         SearchModelNG::SetOnEditChange(frameNode, std::move(*onEditChange));
739     } else {
740         SearchModelNG::SetOnEditChange(frameNode, nullptr);
741     }
742 }
743 
ResetSearchOnEditChange(ArkUINodeHandle node)744 void ResetSearchOnEditChange(ArkUINodeHandle node)
745 {
746     auto* frameNode = reinterpret_cast<FrameNode*>(node);
747     CHECK_NULL_VOID(frameNode);
748     SearchModelNG::SetOnEditChange(frameNode, nullptr);
749 }
750 
SetSearchOnSubmitWithEvent(ArkUINodeHandle node,void * callback)751 void SetSearchOnSubmitWithEvent(ArkUINodeHandle node, void* callback)
752 {
753     auto* frameNode = reinterpret_cast<FrameNode*>(node);
754     CHECK_NULL_VOID(frameNode);
755     if (callback) {
756         auto onSubmit =
757             reinterpret_cast<std::function<void(const std::u16string&, NG::TextFieldCommonEvent&)>*>(callback);
758         SearchModelNG::SetOnSubmit(frameNode, std::move(*onSubmit));
759     } else {
760         SearchModelNG::SetOnSubmit(frameNode, nullptr);
761     }
762 }
763 
ResetSearchOnSubmitWithEvent(ArkUINodeHandle node)764 void ResetSearchOnSubmitWithEvent(ArkUINodeHandle node)
765 {
766     auto *frameNode = reinterpret_cast<FrameNode *>(node);
767     CHECK_NULL_VOID(frameNode);
768     SearchModelNG::SetOnSubmit(frameNode, nullptr);
769 }
770 
SetSearchOnCopy(ArkUINodeHandle node,void * callback)771 void SetSearchOnCopy(ArkUINodeHandle node, void* callback)
772 {
773     auto* frameNode = reinterpret_cast<FrameNode*>(node);
774     CHECK_NULL_VOID(frameNode);
775     if (callback) {
776         auto onCopy = reinterpret_cast<std::function<void(const std::u16string&)>*>(callback);
777         SearchModelNG::SetOnCopy(frameNode, std::move(*onCopy));
778     } else {
779         SearchModelNG::SetOnCopy(frameNode, nullptr);
780     }
781 }
782 
ResetSearchOnCopy(ArkUINodeHandle node)783 void ResetSearchOnCopy(ArkUINodeHandle node)
784 {
785     auto *frameNode = reinterpret_cast<FrameNode *>(node);
786     CHECK_NULL_VOID(frameNode);
787     SearchModelNG::SetOnCopy(frameNode, nullptr);
788 }
789 
SetSearchOnCut(ArkUINodeHandle node,void * callback)790 void SetSearchOnCut(ArkUINodeHandle node, void* callback)
791 {
792     auto* frameNode = reinterpret_cast<FrameNode*>(node);
793     CHECK_NULL_VOID(frameNode);
794     if (callback) {
795         auto onCut = reinterpret_cast<std::function<void(const std::u16string&)>*>(callback);
796         SearchModelNG::SetOnCut(frameNode, std::move(*onCut));
797     } else {
798         SearchModelNG::SetOnCut(frameNode, nullptr);
799     }
800 }
801 
ResetSearchOnCut(ArkUINodeHandle node)802 void ResetSearchOnCut(ArkUINodeHandle node)
803 {
804     auto *frameNode = reinterpret_cast<FrameNode *>(node);
805     CHECK_NULL_VOID(frameNode);
806     SearchModelNG::SetOnCut(frameNode, nullptr);
807 }
808 
SetSearchOnPaste(ArkUINodeHandle node,void * callback)809 void SetSearchOnPaste(ArkUINodeHandle node, void* callback)
810 {
811     auto* frameNode = reinterpret_cast<FrameNode*>(node);
812     CHECK_NULL_VOID(frameNode);
813     if (callback) {
814         auto onPasteWithEvent = reinterpret_cast<std::function<void(
815                 const std::u16string&, NG::TextCommonEvent&)>*>(callback);
816         SearchModelNG::SetOnPasteWithEvent(frameNode, std::move(*onPasteWithEvent));
817     } else {
818         SearchModelNG::SetOnPasteWithEvent(frameNode, nullptr);
819     }
820 }
821 
ResetSearchOnPaste(ArkUINodeHandle node)822 void ResetSearchOnPaste(ArkUINodeHandle node)
823 {
824     auto *frameNode = reinterpret_cast<FrameNode *>(node);
825     CHECK_NULL_VOID(frameNode);
826     SearchModelNG::SetOnPasteWithEvent(frameNode, nullptr);
827 }
828 
SetSearchOnChange(ArkUINodeHandle node,void * callback)829 void SetSearchOnChange(ArkUINodeHandle node, void* callback)
830 {
831     auto* frameNode = reinterpret_cast<FrameNode*>(node);
832     CHECK_NULL_VOID(frameNode);
833     if (callback) {
834         auto onSubmit = reinterpret_cast<std::function<void(const ChangeValueInfo&)>*>(callback);
835         SearchModelNG::SetOnChange(frameNode, std::move(*onSubmit));
836     } else {
837         SearchModelNG::SetOnChange(frameNode, nullptr);
838     }
839 }
840 
ResetSearchOnChange(ArkUINodeHandle node)841 void ResetSearchOnChange(ArkUINodeHandle node)
842 {
843     auto *frameNode = reinterpret_cast<FrameNode *>(node);
844     CHECK_NULL_VOID(frameNode);
845     SearchModelNG::SetOnChange(frameNode, nullptr);
846 }
847 
SetSearchOnTextSelectionChange(ArkUINodeHandle node,void * callback)848 void SetSearchOnTextSelectionChange(ArkUINodeHandle node, void* callback)
849 {
850     auto* frameNode = reinterpret_cast<FrameNode*>(node);
851     CHECK_NULL_VOID(frameNode);
852     if (callback) {
853         auto onChange = reinterpret_cast<std::function<void(int32_t, int32_t)>*>(callback);
854         SearchModelNG::SetOnTextSelectionChange(frameNode, std::move(*onChange));
855     } else {
856         SearchModelNG::SetOnTextSelectionChange(frameNode, nullptr);
857     }
858 }
859 
ResetSearchOnTextSelectionChange(ArkUINodeHandle node)860 void ResetSearchOnTextSelectionChange(ArkUINodeHandle node)
861 {
862     auto *frameNode = reinterpret_cast<FrameNode *>(node);
863     CHECK_NULL_VOID(frameNode);
864     SearchModelNG::SetOnTextSelectionChange(frameNode, nullptr);
865 }
866 
SetSearchOnContentScroll(ArkUINodeHandle node,void * callback)867 void SetSearchOnContentScroll(ArkUINodeHandle node, void* callback)
868 {
869     auto* frameNode = reinterpret_cast<FrameNode*>(node);
870     CHECK_NULL_VOID(frameNode);
871     if (callback) {
872         auto onScroll = reinterpret_cast<std::function<void(float, float)>*>(callback);
873         SearchModelNG::SetOnContentScroll(frameNode, std::move(*onScroll));
874     } else {
875         SearchModelNG::SetOnContentScroll(frameNode, nullptr);
876     }
877 }
878 
ResetSearchOnContentScroll(ArkUINodeHandle node)879 void ResetSearchOnContentScroll(ArkUINodeHandle node)
880 {
881     auto *frameNode = reinterpret_cast<FrameNode *>(node);
882     CHECK_NULL_VOID(frameNode);
883     SearchModelNG::SetOnContentScroll(frameNode, nullptr);
884 }
885 
SetSearchShowCounterOptions(ArkUINodeHandle node,ArkUI_Bool open,ArkUI_Int32 thresholdPercentage,ArkUI_Bool highlightBorder)886 void SetSearchShowCounterOptions(
887     ArkUINodeHandle node, ArkUI_Bool open, ArkUI_Int32 thresholdPercentage, ArkUI_Bool highlightBorder)
888 {
889     auto* frameNode = reinterpret_cast<FrameNode*>(node);
890     CHECK_NULL_VOID(frameNode);
891     SearchModelNG::SetShowCounter(frameNode, open);
892     SearchModelNG::SetCounterType(frameNode, thresholdPercentage);
893     SearchModelNG::SetShowCounterBorder(frameNode, highlightBorder);
894 }
895 
ResetSearchShowCounterOptions(ArkUINodeHandle node)896 void ResetSearchShowCounterOptions(ArkUINodeHandle node)
897 {
898     auto *frameNode = reinterpret_cast<FrameNode *>(node);
899     CHECK_NULL_VOID(frameNode);
900     SearchModelNG::SetShowCounter(frameNode, false);
901     SearchModelNG::SetCounterType(frameNode, -1);
902     SearchModelNG::SetShowCounterBorder(frameNode, true);
903 }
904 
GetSearchController(ArkUINodeHandle node)905 ArkUINodeHandle GetSearchController(ArkUINodeHandle node)
906 {
907     auto* frameNode = reinterpret_cast<FrameNode*>(node);
908     CHECK_NULL_RETURN(frameNode, nullptr);
909     auto controller = SearchModelNG::GetSearchController(frameNode);
910     CHECK_NULL_RETURN(controller, nullptr);
911     auto nodecontroller = reinterpret_cast<ArkUINodeHandle>(OHOS::Ace::AceType::RawPtr(controller));
912     return nodecontroller;
913 }
914 
SetSearchValue(ArkUINodeHandle node,ArkUI_CharPtr value)915 void SetSearchValue(ArkUINodeHandle node, ArkUI_CharPtr value)
916 {
917     auto* frameNode = reinterpret_cast<FrameNode*>(node);
918     CHECK_NULL_VOID(frameNode);
919     std::optional<std::string> valueNG = value;
920 
921     SearchModelNG::SetTextValue(frameNode, valueNG);
922 }
923 
ResetSearchValue(ArkUINodeHandle node)924 void ResetSearchValue(ArkUINodeHandle node)
925 {
926     auto* frameNode = reinterpret_cast<FrameNode*>(node);
927     CHECK_NULL_VOID(frameNode);
928     SearchModelNG::SetTextValue(frameNode, "");
929 }
930 
SetSearchPlaceholder(ArkUINodeHandle node,ArkUI_CharPtr placeholder)931 void SetSearchPlaceholder(ArkUINodeHandle node, ArkUI_CharPtr placeholder)
932 {
933     auto* frameNode = reinterpret_cast<FrameNode*>(node);
934     CHECK_NULL_VOID(frameNode);
935     std::optional<std::string> placeholderNG = placeholder;
936 
937     SearchModelNG::SetPlaceholder(frameNode, placeholderNG);
938 }
939 
ResetSearchPlaceholder(ArkUINodeHandle node)940 void ResetSearchPlaceholder(ArkUINodeHandle node)
941 {
942     auto* frameNode = reinterpret_cast<FrameNode*>(node);
943     CHECK_NULL_VOID(frameNode);
944     SearchModelNG::SetPlaceholder(frameNode, "");
945 }
946 
SetSearchIcon(ArkUINodeHandle node,ArkUI_CharPtr icon)947 void SetSearchIcon(ArkUINodeHandle node, ArkUI_CharPtr icon)
948 {
949     auto* frameNode = reinterpret_cast<FrameNode*>(node);
950     CHECK_NULL_VOID(frameNode);
951     std::optional<std::string> iconNG = icon;
952 
953     SearchModelNG::SetIcon(frameNode, iconNG);
954 }
955 
ResetSearchIcon(ArkUINodeHandle node)956 void ResetSearchIcon(ArkUINodeHandle node)
957 {
958     auto* frameNode = reinterpret_cast<FrameNode*>(node);
959     CHECK_NULL_VOID(frameNode);
960     SearchModelNG::SetIcon(frameNode, "");
961 }
962 
SetSearchOnWillChange(ArkUINodeHandle node,ArkUI_Int64 callback)963 void SetSearchOnWillChange(ArkUINodeHandle node, ArkUI_Int64 callback)
964 {
965     auto* frameNode = reinterpret_cast<FrameNode*>(node);
966     CHECK_NULL_VOID(frameNode);
967     if (callback) {
968         auto onWillChange = reinterpret_cast<std::function<bool(const ChangeValueInfo&)>*>(callback);
969         SearchModelNG::SetOnWillChangeEvent(frameNode, std::move(*onWillChange));
970     } else {
971         SearchModelNG::SetOnWillChangeEvent(frameNode, nullptr);
972     }
973 }
974 
ResetSearchOnWillChange(ArkUINodeHandle node)975 void ResetSearchOnWillChange(ArkUINodeHandle node)
976 {
977     auto *frameNode = reinterpret_cast<FrameNode *>(node);
978     CHECK_NULL_VOID(frameNode);
979     SearchModelNG::SetOnWillChangeEvent(frameNode, nullptr);
980 }
981 
SetSearchOnWillInsert(ArkUINodeHandle node,ArkUI_Int64 callback)982 void SetSearchOnWillInsert(ArkUINodeHandle node, ArkUI_Int64 callback)
983 {
984     auto* frameNode = reinterpret_cast<FrameNode*>(node);
985     CHECK_NULL_VOID(frameNode);
986     if (callback) {
987         auto onWillInsert = reinterpret_cast<std::function<bool(const InsertValueInfo&)>*>(callback);
988         SearchModelNG::SetOnWillInsertValueEvent(frameNode, std::move(*onWillInsert));
989     } else {
990         SearchModelNG::SetOnWillInsertValueEvent(frameNode, nullptr);
991     }
992 }
993 
ResetSearchOnWillInsert(ArkUINodeHandle node)994 void ResetSearchOnWillInsert(ArkUINodeHandle node)
995 {
996     auto *frameNode = reinterpret_cast<FrameNode *>(node);
997     CHECK_NULL_VOID(frameNode);
998     SearchModelNG::SetOnWillInsertValueEvent(frameNode, nullptr);
999 }
1000 
SetSearchOnDidInsert(ArkUINodeHandle node,ArkUI_Int64 callback)1001 void SetSearchOnDidInsert(ArkUINodeHandle node, ArkUI_Int64 callback)
1002 {
1003     auto* frameNode = reinterpret_cast<FrameNode*>(node);
1004     CHECK_NULL_VOID(frameNode);
1005     if (callback) {
1006         auto onDidInsert = reinterpret_cast<std::function<void(const InsertValueInfo&)>*>(callback);
1007         SearchModelNG::SetOnDidInsertValueEvent(frameNode, std::move(*onDidInsert));
1008     } else {
1009         SearchModelNG::SetOnDidInsertValueEvent(frameNode, nullptr);
1010     }
1011 }
1012 
ResetSearchOnDidInsert(ArkUINodeHandle node)1013 void ResetSearchOnDidInsert(ArkUINodeHandle node)
1014 {
1015     auto *frameNode = reinterpret_cast<FrameNode *>(node);
1016     CHECK_NULL_VOID(frameNode);
1017     SearchModelNG::SetOnDidInsertValueEvent(frameNode, nullptr);
1018 }
1019 
SetSearchOnWillDelete(ArkUINodeHandle node,ArkUI_Int64 callback)1020 void SetSearchOnWillDelete(ArkUINodeHandle node, ArkUI_Int64 callback)
1021 {
1022     auto* frameNode = reinterpret_cast<FrameNode*>(node);
1023     CHECK_NULL_VOID(frameNode);
1024     if (callback) {
1025         auto onWillDelete = reinterpret_cast<std::function<bool(const DeleteValueInfo&)>*>(callback);
1026         SearchModelNG::SetOnWillDeleteEvent(frameNode, std::move(*onWillDelete));
1027     } else {
1028         SearchModelNG::SetOnWillDeleteEvent(frameNode, nullptr);
1029     }
1030 }
1031 
ResetSearchOnWillDelete(ArkUINodeHandle node)1032 void ResetSearchOnWillDelete(ArkUINodeHandle node)
1033 {
1034     auto *frameNode = reinterpret_cast<FrameNode *>(node);
1035     CHECK_NULL_VOID(frameNode);
1036     SearchModelNG::SetOnWillDeleteEvent(frameNode, nullptr);
1037 }
1038 
SetSearchOnDidDelete(ArkUINodeHandle node,ArkUI_Int64 callback)1039 void SetSearchOnDidDelete(ArkUINodeHandle node, ArkUI_Int64 callback)
1040 {
1041     auto* frameNode = reinterpret_cast<FrameNode*>(node);
1042     CHECK_NULL_VOID(frameNode);
1043     if (callback) {
1044         auto onDidDelete = reinterpret_cast<std::function<void(const DeleteValueInfo&)>*>(callback);
1045         SearchModelNG::SetOnDidDeleteEvent(frameNode, std::move(*onDidDelete));
1046     } else {
1047         SearchModelNG::SetOnDidDeleteEvent(frameNode, nullptr);
1048     }
1049 }
1050 
ResetSearchOnDidDelete(ArkUINodeHandle node)1051 void ResetSearchOnDidDelete(ArkUINodeHandle node)
1052 {
1053     auto *frameNode = reinterpret_cast<FrameNode *>(node);
1054     CHECK_NULL_VOID(frameNode);
1055     SearchModelNG::SetOnDidDeleteEvent(frameNode, nullptr);
1056 }
1057 
SetSearchEnablePreviewText(ArkUINodeHandle node,ArkUI_Uint32 value)1058 void SetSearchEnablePreviewText(ArkUINodeHandle node, ArkUI_Uint32 value)
1059 {
1060     auto *frameNode = reinterpret_cast<FrameNode *>(node);
1061     CHECK_NULL_VOID(frameNode);
1062     SearchModelNG::SetEnablePreviewText(frameNode, static_cast<bool>(value));
1063 }
1064 
ResetSearchEnablePreviewText(ArkUINodeHandle node)1065 void ResetSearchEnablePreviewText(ArkUINodeHandle node)
1066 {
1067     auto *frameNode = reinterpret_cast<FrameNode *>(node);
1068     CHECK_NULL_VOID(frameNode);
1069     SearchModelNG::SetEnablePreviewText(frameNode, DEFAULT_ENABLE_PREVIEW_TEXT_VALUE);
1070 }
1071 
SetSearchCaretPosition(ArkUINodeHandle node,ArkUI_Int32 value)1072 void SetSearchCaretPosition(ArkUINodeHandle node, ArkUI_Int32 value)
1073 {
1074     auto* frameNode = reinterpret_cast<FrameNode*>(node);
1075     CHECK_NULL_VOID(frameNode);
1076 
1077     SearchModelNG::SetCaretPosition(frameNode, value);
1078 }
1079 
ResetSearchCaretPosition(ArkUINodeHandle node)1080 void ResetSearchCaretPosition(ArkUINodeHandle node)
1081 {
1082     auto* frameNode = reinterpret_cast<FrameNode*>(node);
1083     CHECK_NULL_VOID(frameNode);
1084 
1085     SearchModelNG::SetCaretPosition(frameNode, DEFAULT_CARET_POSITION);
1086 }
1087 
SetSearchSelectionMenuOptions(ArkUINodeHandle node,void * onCreateMenuCallback,void * onMenuItemClickCallback,void * onPrepareMenuCallback)1088 void SetSearchSelectionMenuOptions(
1089     ArkUINodeHandle node, void* onCreateMenuCallback, void* onMenuItemClickCallback, void* onPrepareMenuCallback)
1090 {
1091     auto* frameNode = reinterpret_cast<FrameNode*>(node);
1092     CHECK_NULL_VOID(frameNode);
1093     if (onCreateMenuCallback) {
1094         NG::OnCreateMenuCallback onCreateMenu = *(reinterpret_cast<NG::OnCreateMenuCallback*>(onCreateMenuCallback));
1095         SearchModelNG::OnCreateMenuCallbackUpdate(frameNode, std::move(onCreateMenu));
1096     } else {
1097         SearchModelNG::OnCreateMenuCallbackUpdate(frameNode, nullptr);
1098     }
1099     if (onMenuItemClickCallback) {
1100         NG::OnMenuItemClickCallback onMenuItemClick =
1101             *(reinterpret_cast<NG::OnMenuItemClickCallback*>(onMenuItemClickCallback));
1102         SearchModelNG::OnMenuItemClickCallbackUpdate(frameNode, std::move(onMenuItemClick));
1103     } else {
1104         SearchModelNG::OnMenuItemClickCallbackUpdate(frameNode, nullptr);
1105     }
1106     if (onPrepareMenuCallback) {
1107         NG::OnPrepareMenuCallback onPrepareMenu =
1108             *(reinterpret_cast<NG::OnPrepareMenuCallback*>(onPrepareMenuCallback));
1109         SearchModelNG::OnPrepareMenuCallbackUpdate(frameNode, std::move(onPrepareMenu));
1110     } else {
1111         SearchModelNG::OnPrepareMenuCallbackUpdate(frameNode, nullptr);
1112     }
1113 }
1114 
ResetSearchSelectionMenuOptions(ArkUINodeHandle node)1115 void ResetSearchSelectionMenuOptions(ArkUINodeHandle node)
1116 {
1117     auto* frameNode = reinterpret_cast<FrameNode*>(node);
1118     CHECK_NULL_VOID(frameNode);
1119     NG::OnCreateMenuCallback onCreateMenuCallback;
1120     NG::OnMenuItemClickCallback onMenuItemClick;
1121     NG::OnPrepareMenuCallback onPrepareMenuCallback;
1122     SearchModelNG::OnCreateMenuCallbackUpdate(frameNode, std::move(onCreateMenuCallback));
1123     SearchModelNG::OnMenuItemClickCallbackUpdate(frameNode, std::move(onMenuItemClick));
1124     SearchModelNG::OnPrepareMenuCallbackUpdate(frameNode, std::move(onPrepareMenuCallback));
1125 }
1126 
SetSearchMinFontScale(ArkUINodeHandle node,ArkUI_Float32 number,void * resRawPtr)1127 void SetSearchMinFontScale(ArkUINodeHandle node, ArkUI_Float32 number, void* resRawPtr)
1128 {
1129     auto* frameNode = reinterpret_cast<FrameNode*>(node);
1130     CHECK_NULL_VOID(frameNode);
1131     SearchModelNG::SetMinFontScale(frameNode, number);
1132     auto pattern = frameNode->GetPattern();
1133     CHECK_NULL_VOID(pattern);
1134     if (SystemProperties::ConfigChangePerform() && resRawPtr) {
1135         auto resObj = AceType::Claim(reinterpret_cast<ResourceObject*>(resRawPtr));
1136         pattern->RegisterResource<float>("minFontScale", resObj, number);
1137     } else {
1138         pattern->UnRegisterResource("minFontScale");
1139     }
1140 }
1141 
ResetSearchMinFontScale(ArkUINodeHandle node)1142 void ResetSearchMinFontScale(ArkUINodeHandle node)
1143 {
1144     auto* frameNode = reinterpret_cast<FrameNode*>(node);
1145     CHECK_NULL_VOID(frameNode);
1146     SearchModelNG::SetMinFontScale(frameNode, DEFAULT_MIN_FONT_SCALE);
1147     if (SystemProperties::ConfigChangePerform()) {
1148         auto pattern = frameNode->GetPattern();
1149         CHECK_NULL_VOID(pattern);
1150         pattern->UnRegisterResource("minFontScale");
1151     }
1152 }
1153 
SetSearchMaxFontScale(ArkUINodeHandle node,ArkUI_Float32 number,void * resRawPtr)1154 void SetSearchMaxFontScale(ArkUINodeHandle node, ArkUI_Float32 number, void* resRawPtr)
1155 {
1156     auto* frameNode = reinterpret_cast<FrameNode*>(node);
1157     CHECK_NULL_VOID(frameNode);
1158     SearchModelNG::SetMaxFontScale(frameNode, number);
1159     auto pattern = frameNode->GetPattern();
1160     CHECK_NULL_VOID(pattern);
1161     if (SystemProperties::ConfigChangePerform() && resRawPtr) {
1162         auto resObj = AceType::Claim(reinterpret_cast<ResourceObject*>(resRawPtr));
1163         pattern->RegisterResource<float>("maxFontScale", resObj, number);
1164     } else {
1165         pattern->UnRegisterResource("maxFontScale");
1166     }
1167 }
1168 
ResetSearchMaxFontScale(ArkUINodeHandle node)1169 void ResetSearchMaxFontScale(ArkUINodeHandle node)
1170 {
1171     auto* frameNode = reinterpret_cast<FrameNode*>(node);
1172     CHECK_NULL_VOID(frameNode);
1173     SearchModelNG::SetMaxFontScale(frameNode, DEFAULT_MAX_FONT_SCALE);
1174     if (SystemProperties::ConfigChangePerform()) {
1175         auto pattern = frameNode->GetPattern();
1176         CHECK_NULL_VOID(pattern);
1177         pattern->UnRegisterResource("maxFontScale");
1178     }
1179 }
1180 
SetSearchEnableHapticFeedback(ArkUINodeHandle node,ArkUI_Uint32 value)1181 void SetSearchEnableHapticFeedback(ArkUINodeHandle node, ArkUI_Uint32 value)
1182 {
1183     auto* frameNode = reinterpret_cast<FrameNode*>(node);
1184     CHECK_NULL_VOID(frameNode);
1185     SearchModelNG::SetEnableHapticFeedback(frameNode, static_cast<bool>(value));
1186 }
1187 
ResetSearchEnableHapticFeedback(ArkUINodeHandle node)1188 void ResetSearchEnableHapticFeedback(ArkUINodeHandle node)
1189 {
1190     auto* frameNode = reinterpret_cast<FrameNode*>(node);
1191     CHECK_NULL_VOID(frameNode);
1192     SearchModelNG::SetEnableHapticFeedback(frameNode, DEFAULT_ENABLE_HAPTIC_FEEDBACK_VALUE);
1193 }
1194 
SetSearchAutoCapitalizationMode(ArkUINodeHandle node,ArkUI_Int32 value)1195 void SetSearchAutoCapitalizationMode(ArkUINodeHandle node, ArkUI_Int32 value)
1196 {
1197     auto *frameNode = reinterpret_cast<FrameNode *>(node);
1198     CHECK_NULL_VOID(frameNode);
1199     SearchModelNG::SetAutoCapitalizationMode(frameNode, CastToAutoCapitalizationMode(value));
1200 }
1201 
ResetSearchAutoCapitalizationMode(ArkUINodeHandle node)1202 void ResetSearchAutoCapitalizationMode(ArkUINodeHandle node)
1203 {
1204     auto *frameNode = reinterpret_cast<FrameNode *>(node);
1205     CHECK_NULL_VOID(frameNode);
1206     SearchModelNG::SetAutoCapitalizationMode(frameNode, AutoCapitalizationMode::NONE);
1207 }
1208 
SetStopBackPress(ArkUINodeHandle node,ArkUI_Uint32 value)1209 void SetStopBackPress(ArkUINodeHandle node, ArkUI_Uint32 value)
1210 {
1211     auto* frameNode = reinterpret_cast<FrameNode*>(node);
1212     CHECK_NULL_VOID(frameNode);
1213     SearchModelNG::SetStopBackPress(frameNode, static_cast<bool>(value));
1214 }
1215 
ResetStopBackPress(ArkUINodeHandle node)1216 void ResetStopBackPress(ArkUINodeHandle node)
1217 {
1218     auto* frameNode = reinterpret_cast<FrameNode*>(node);
1219     CHECK_NULL_VOID(frameNode);
1220     SearchModelNG::SetStopBackPress(frameNode, true);
1221 }
1222 
1223 
SetSearchStrokeWidth(ArkUINodeHandle node,ArkUI_Float32 number,ArkUI_Int32 unit)1224 void SetSearchStrokeWidth(ArkUINodeHandle node, ArkUI_Float32 number, ArkUI_Int32 unit)
1225 {
1226     auto* frameNode = reinterpret_cast<FrameNode*>(node);
1227     CHECK_NULL_VOID(frameNode);
1228     SearchModelNG::SetStrokeWidth(frameNode, Dimension(number, static_cast<DimensionUnit>(unit)));
1229 }
1230 
ResetSearchStrokeWidth(ArkUINodeHandle node)1231 void ResetSearchStrokeWidth(ArkUINodeHandle node)
1232 {
1233     auto* frameNode = reinterpret_cast<FrameNode*>(node);
1234     CHECK_NULL_VOID(frameNode);
1235     SearchModelNG::SetStrokeWidth(frameNode, 0.0_px);
1236 }
1237 
SetSearchStrokeColor(ArkUINodeHandle node,ArkUI_Uint32 value)1238 void SetSearchStrokeColor(ArkUINodeHandle node, ArkUI_Uint32 value)
1239 {
1240     auto* frameNode = reinterpret_cast<FrameNode*>(node);
1241     CHECK_NULL_VOID(frameNode);
1242     SearchModelNG::SetStrokeColor(frameNode, Color(value));
1243 }
1244 
ResetSearchStrokeColor(ArkUINodeHandle node)1245 void ResetSearchStrokeColor(ArkUINodeHandle node)
1246 {
1247     auto* frameNode = reinterpret_cast<FrameNode*>(node);
1248     CHECK_NULL_VOID(frameNode);
1249     SearchModelNG::ResetStrokeColor(frameNode);
1250 }
1251 
SetEnableAutoSpacing(ArkUINodeHandle node,ArkUI_Bool enableAutoSpacing)1252 void SetEnableAutoSpacing(ArkUINodeHandle node, ArkUI_Bool enableAutoSpacing)
1253 {
1254     auto* frameNode = reinterpret_cast<FrameNode*>(node);
1255     CHECK_NULL_VOID(frameNode);
1256     SearchModelNG::SetEnableAutoSpacing(frameNode, static_cast<bool>(enableAutoSpacing));
1257 }
1258 
ResetEnableAutoSpacing(ArkUINodeHandle node)1259 void ResetEnableAutoSpacing(ArkUINodeHandle node)
1260 {
1261     auto* frameNode = reinterpret_cast<FrameNode*>(node);
1262     CHECK_NULL_VOID(frameNode);
1263     SearchModelNG::SetEnableAutoSpacing(frameNode, false);
1264 }
1265 
SetSearchMargin(ArkUINodeHandle node)1266 void SetSearchMargin(ArkUINodeHandle node)
1267 {
1268     auto* frameNode = reinterpret_cast<FrameNode*>(node);
1269     CHECK_NULL_VOID(frameNode);
1270     SearchModelNG::SetUserMargin(frameNode);
1271 }
1272 
ResetSearchMargin(ArkUINodeHandle node)1273 void ResetSearchMargin(ArkUINodeHandle node)
1274 {
1275     auto* frameNode = reinterpret_cast<FrameNode*>(node);
1276     CHECK_NULL_VOID(frameNode);
1277     SearchModelNG::SetUserMargin(frameNode);
1278 }
1279 
1280 } // namespace
1281 namespace NodeModifier {
GetSearchModifier()1282 const ArkUISearchModifier* GetSearchModifier()
1283 {
1284     CHECK_INITIALIZED_FIELDS_BEGIN(); // don't move this line
1285     static const ArkUISearchModifier modifier = {
1286         .setSearchPlaceholderColor = SetSearchPlaceholderColor,
1287         .resetSearchPlaceholderColor = ResetSearchPlaceholderColor,
1288         .setSearchTextFont = SetSearchTextFont,
1289         .resetSearchTextFont = ResetSearchTextFont,
1290         .setSearchSelectionMenuHidden = SetSearchSelectionMenuHidden,
1291         .resetSearchSelectionMenuHidden = ResetSearchSelectionMenuHidden,
1292         .setSearchCaretStyle = SetSearchCaretStyle,
1293         .resetSearchCaretStyle = ResetSearchCaretStyle,
1294         .setSearchTextAlign = SetSearchTextAlign,
1295         .resetSearchTextAlign = ResetSearchTextAlign,
1296         .setSearchCancelButton = SetSearchCancelButton,
1297         .resetSearchCancelButton = ResetSearchCancelButton,
1298         .setSearchEnableKeyboardOnFocus = SetSearchEnableKeyboardOnFocus,
1299         .resetSearchEnableKeyboardOnFocus = ResetSearchEnableKeyboardOnFocus,
1300         .setSearchPlaceholderFont = SetSearchPlaceholderFont,
1301         .resetSearchPlaceholderFont = ResetSearchPlaceholderFont,
1302         .setSearchSearchIcon = SetSearchSearchIcon,
1303         .resetSearchSearchIcon = ResetSearchSearchIcon,
1304         .setSearchSearchButton = SetSearchSearchButton,
1305         .resetSearchSearchButton = ResetSearchSearchButton,
1306         .setSearchFontColor = SetSearchFontColor,
1307         .resetSearchFontColor = ResetSearchFontColor,
1308         .setSearchCopyOption = SetSearchCopyOption,
1309         .resetSearchCopyOption = ResetSearchCopyOption,
1310         .setSearchEnterKeyType = SetSearchEnterKeyType,
1311         .resetSearchEnterKeyType = ResetSearchEnterKeyType,
1312         .setSearchHeight = SetSearchHeight,
1313         .resetSearchHeight = ResetSearchHeight,
1314         .setSearchInspectorId = SetSearchInspectorId,
1315         .resetSearchInspectorId = ResetSearchInspectorId,
1316         .setSearchDecoration = SetSearchDecoration,
1317         .resetSearchDecoration = ResetSearchDecoration,
1318         .setSearchLetterSpacing = SetSearchLetterSpacing,
1319         .resetSearchLetterSpacing = ResetSearchLetterSpacing,
1320         .setSearchLineHeight = SetSearchLineHeight,
1321         .resetSearchLineHeight = ResetSearchLineHeight,
1322         .setSearchHalfLeading = SetSearchHalfLeading,
1323         .resetSearchHalfLeading = ResetSearchHalfLeading,
1324         .setSearchFontFeature = SetSearchFontFeature,
1325         .resetSearchFontFeature = ResetSearchFontFeature,
1326         .setSearchAdaptMinFontSize = SetSearchAdaptMinFontSize,
1327         .resetSearchAdaptMinFontSize = ResetSearchAdaptMinFontSize,
1328         .setSearchAdaptMaxFontSize = SetSearchAdaptMaxFontSize,
1329         .resetSearchAdaptMaxFontSize = ResetSearchAdaptMaxFontSize,
1330         .setSearchSelectedBackgroundColor = SetSearchSelectedBackgroundColor,
1331         .resetSearchSelectedBackgroundColor = ResetSearchSelectedBackgroundColor,
1332         .setSearchTextIndent = SetSearchTextIndent,
1333         .resetSearchTextIndent = ResetSearchTextIndent,
1334         .setSearchValue = SetSearchValue,
1335         .resetSearchValue = ResetSearchValue,
1336         .setSearchPlaceholder = SetSearchPlaceholder,
1337         .resetSearchPlaceholder = ResetSearchPlaceholder,
1338         .setSearchIcon = SetSearchIcon,
1339         .resetSearchIcon = ResetSearchIcon,
1340         .setSearchCaretPosition = SetSearchCaretPosition,
1341         .resetSearchCaretPosition = ResetSearchCaretPosition,
1342         .setSearchMaxLength = SetSearchMaxLength,
1343         .resetSearchMaxLength = ResetSearchMaxLength,
1344         .setSearchType = SetSearchType,
1345         .resetSearchType = ResetSearchType,
1346         .setSearchOnEditChange = SetSearchOnEditChange,
1347         .resetSearchOnEditChange = ResetSearchOnEditChange,
1348         .setSearchOnSubmitWithEvent = SetSearchOnSubmitWithEvent,
1349         .resetSearchOnSubmitWithEvent = ResetSearchOnSubmitWithEvent,
1350         .setSearchOnCopy = SetSearchOnCopy,
1351         .resetSearchOnCopy = ResetSearchOnCopy,
1352         .setSearchOnCut = SetSearchOnCut,
1353         .resetSearchOnCut = ResetSearchOnCut,
1354         .setSearchOnPaste = SetSearchOnPaste,
1355         .resetSearchOnPaste = ResetSearchOnPaste,
1356         .setSearchOnChange = SetSearchOnChange,
1357         .resetSearchOnChange = ResetSearchOnChange,
1358         .setSearchOnTextSelectionChange = SetSearchOnTextSelectionChange,
1359         .resetSearchOnTextSelectionChange = ResetSearchOnTextSelectionChange,
1360         .setSearchOnContentScroll = SetSearchOnContentScroll,
1361         .resetSearchOnContentScroll = ResetSearchOnContentScroll,
1362         .setSearchShowCounter = SetSearchShowCounterOptions,
1363         .resetSearchShowCounter = ResetSearchShowCounterOptions,
1364         .getSearchController = GetSearchController,
1365         .setSearchOnWillChange = SetSearchOnWillChange,
1366         .resetSearchOnWillChange = ResetSearchOnWillChange,
1367         .setSearchOnWillInsert = SetSearchOnWillInsert,
1368         .resetSearchOnWillInsert = ResetSearchOnWillInsert,
1369         .setSearchOnDidInsert = SetSearchOnDidInsert,
1370         .resetSearchOnDidInsert = ResetSearchOnDidInsert,
1371         .setSearchOnWillDelete = SetSearchOnWillDelete,
1372         .resetSearchOnWillDelete = ResetSearchOnWillDelete,
1373         .setSearchOnDidDelete = SetSearchOnDidDelete,
1374         .resetSearchOnDidDelete = ResetSearchOnDidDelete,
1375         .setSearchEnablePreviewText = SetSearchEnablePreviewText,
1376         .resetSearchEnablePreviewText = ResetSearchEnablePreviewText,
1377         .setSearchSelectionMenuOptions = SetSearchSelectionMenuOptions,
1378         .resetSearchSelectionMenuOptions = ResetSearchSelectionMenuOptions,
1379         .setSearchEnableHapticFeedback = SetSearchEnableHapticFeedback,
1380         .resetSearchEnableHapticFeedback = ResetSearchEnableHapticFeedback,
1381         .setSearchAutoCapitalizationMode = SetSearchAutoCapitalizationMode,
1382         .resetSearchAutoCapitalizationMode = ResetSearchAutoCapitalizationMode,
1383         .setSearchMinFontScale = SetSearchMinFontScale,
1384         .resetSearchMinFontScale = ResetSearchMinFontScale,
1385         .setSearchMaxFontScale = SetSearchMaxFontScale,
1386         .resetSearchMaxFontScale = ResetSearchMaxFontScale,
1387         .setStopBackPress = SetStopBackPress,
1388         .resetStopBackPress = ResetStopBackPress,
1389         .setSearchKeyboardAppearance = SetSearchKeyboardAppearance,
1390         .resetSearchKeyboardAppearance = ResetSearchKeyboardAppearance,
1391         .setSearchStrokeWidth = SetSearchStrokeWidth,
1392         .resetSearchStrokeWidth = ResetSearchStrokeWidth,
1393         .setSearchStrokeColor = SetSearchStrokeColor,
1394         .resetSearchStrokeColor = ResetSearchStrokeColor,
1395         .setEnableAutoSpacing = SetEnableAutoSpacing,
1396         .resetEnableAutoSpacing = ResetEnableAutoSpacing,
1397         .setSearchMargin = SetSearchMargin,
1398         .resetSearchMargin = ResetSearchMargin,
1399     };
1400     CHECK_INITIALIZED_FIELDS_END(modifier, 0, 0, 0); // don't move this line
1401     return &modifier;
1402 }
1403 
GetCJUISearchModifier()1404 const CJUISearchModifier* GetCJUISearchModifier()
1405 {
1406     CHECK_INITIALIZED_FIELDS_BEGIN(); // don't move this line
1407     static const CJUISearchModifier modifier = {
1408         .setSearchPlaceholderColor = SetSearchPlaceholderColor,
1409         .resetSearchPlaceholderColor = ResetSearchPlaceholderColor,
1410         .setSearchTextFont = SetSearchTextFont,
1411         .resetSearchTextFont = ResetSearchTextFont,
1412         .setSearchSelectionMenuHidden = SetSearchSelectionMenuHidden,
1413         .resetSearchSelectionMenuHidden = ResetSearchSelectionMenuHidden,
1414         .setSearchCaretStyle = SetSearchCaretStyle,
1415         .resetSearchCaretStyle = ResetSearchCaretStyle,
1416         .setSearchTextAlign = SetSearchTextAlign,
1417         .resetSearchTextAlign = ResetSearchTextAlign,
1418         .setSearchCancelButton = SetSearchCancelButton,
1419         .resetSearchCancelButton = ResetSearchCancelButton,
1420         .setSearchEnableKeyboardOnFocus = SetSearchEnableKeyboardOnFocus,
1421         .resetSearchEnableKeyboardOnFocus = ResetSearchEnableKeyboardOnFocus,
1422         .setSearchPlaceholderFont = SetSearchPlaceholderFont,
1423         .resetSearchPlaceholderFont = ResetSearchPlaceholderFont,
1424         .setSearchSearchIcon = SetSearchSearchIcon,
1425         .resetSearchSearchIcon = ResetSearchSearchIcon,
1426         .setSearchSearchButton = SetSearchSearchButton,
1427         .resetSearchSearchButton = ResetSearchSearchButton,
1428         .setSearchFontColor = SetSearchFontColor,
1429         .resetSearchFontColor = ResetSearchFontColor,
1430         .setSearchCopyOption = SetSearchCopyOption,
1431         .resetSearchCopyOption = ResetSearchCopyOption,
1432         .setSearchEnterKeyType = SetSearchEnterKeyType,
1433         .resetSearchEnterKeyType = ResetSearchEnterKeyType,
1434         .setSearchHeight = SetSearchHeight,
1435         .resetSearchHeight = ResetSearchHeight,
1436         .setSearchFontFeature = SetSearchFontFeature,
1437         .resetSearchFontFeature = ResetSearchFontFeature,
1438         .setSearchDecoration = SetSearchDecoration,
1439         .resetSearchDecoration = ResetSearchDecoration,
1440         .setSearchLetterSpacing = SetSearchLetterSpacing,
1441         .resetSearchLetterSpacing = ResetSearchLetterSpacing,
1442         .setSearchLineHeight = SetSearchLineHeight,
1443         .resetSearchLineHeight = ResetSearchLineHeight,
1444         .setSearchAdaptMinFontSize = SetSearchAdaptMinFontSize,
1445         .resetSearchAdaptMinFontSize = ResetSearchAdaptMinFontSize,
1446         .setSearchAdaptMaxFontSize = SetSearchAdaptMaxFontSize,
1447         .resetSearchAdaptMaxFontSize = ResetSearchAdaptMaxFontSize,
1448         .setSearchSelectedBackgroundColor = SetSearchSelectedBackgroundColor,
1449         .resetSearchSelectedBackgroundColor = ResetSearchSelectedBackgroundColor,
1450         .setSearchTextIndent = SetSearchTextIndent,
1451         .resetSearchTextIndent = ResetSearchTextIndent,
1452         .setSearchMaxLength = SetSearchMaxLength,
1453         .resetSearchMaxLength = ResetSearchMaxLength,
1454         .setSearchType = SetSearchType,
1455         .resetSearchType = ResetSearchType,
1456         .setSearchOnEditChange = SetSearchOnEditChange,
1457         .resetSearchOnEditChange = ResetSearchOnEditChange,
1458         .setSearchOnSubmitWithEvent = SetSearchOnSubmitWithEvent,
1459         .resetSearchOnSubmitWithEvent = ResetSearchOnSubmitWithEvent,
1460         .setSearchOnCopy = SetSearchOnCopy,
1461         .resetSearchOnCopy = ResetSearchOnCopy,
1462         .setSearchOnCut = SetSearchOnCut,
1463         .resetSearchOnCut = ResetSearchOnCut,
1464         .setSearchOnPaste = SetSearchOnPaste,
1465         .resetSearchOnPaste = ResetSearchOnPaste,
1466         .setSearchOnChange = SetSearchOnChange,
1467         .resetSearchOnChange = ResetSearchOnChange,
1468         .setSearchOnTextSelectionChange = SetSearchOnTextSelectionChange,
1469         .resetSearchOnTextSelectionChange = ResetSearchOnTextSelectionChange,
1470         .setSearchOnContentScroll = SetSearchOnContentScroll,
1471         .resetSearchOnContentScroll = ResetSearchOnContentScroll,
1472         .setSearchShowCounter = SetSearchShowCounterOptions,
1473         .resetSearchShowCounter = ResetSearchShowCounterOptions,
1474         .getSearchController = GetSearchController,
1475         .setSearchValue = SetSearchValue,
1476         .resetSearchValue = ResetSearchValue,
1477         .setSearchPlaceholder = SetSearchPlaceholder,
1478         .resetSearchPlaceholder = ResetSearchPlaceholder,
1479         .setSearchIcon = SetSearchIcon,
1480         .resetSearchIcon = ResetSearchIcon,
1481         .setSearchOnWillInsert = SetSearchOnWillInsert,
1482         .resetSearchOnWillInsert = ResetSearchOnWillInsert,
1483         .setSearchOnDidInsert = SetSearchOnDidInsert,
1484         .resetSearchOnDidInsert = ResetSearchOnDidInsert,
1485         .setSearchOnWillDelete = SetSearchOnWillDelete,
1486         .resetSearchOnWillDelete = ResetSearchOnWillDelete,
1487         .setSearchOnDidDelete = SetSearchOnDidDelete,
1488         .resetSearchOnDidDelete = ResetSearchOnDidDelete,
1489         .setSearchEnablePreviewText = SetSearchEnablePreviewText,
1490         .resetSearchEnablePreviewText = ResetSearchEnablePreviewText,
1491         .setSearchCaretPosition = SetSearchCaretPosition,
1492         .resetSearchCaretPosition = ResetSearchCaretPosition,
1493     };
1494     CHECK_INITIALIZED_FIELDS_END(modifier, 0, 0, 0); // don't move this line
1495     return &modifier;
1496 }
1497 
SetOnSearchSubmit(ArkUINodeHandle node,void * extraParam)1498 void SetOnSearchSubmit(ArkUINodeHandle node, void* extraParam)
1499 {
1500     auto* frameNode = reinterpret_cast<FrameNode*>(node);
1501     CHECK_NULL_VOID(frameNode);
1502     auto onEvent = [extraParam](const std::u16string& text, NG::TextFieldCommonEvent& commonEvent) {
1503         ArkUINodeEvent event;
1504         std::string utf8Text = UtfUtils::Str16DebugToStr8(text);
1505         event.kind = TEXT_INPUT;
1506         event.extraParam = reinterpret_cast<intptr_t>(extraParam);
1507         event.textInputEvent.subKind = ON_SEARCH_SUBMIT;
1508         event.textInputEvent.nativeStringPtr = reinterpret_cast<intptr_t>(utf8Text.c_str());
1509         SendArkUISyncEvent(&event);
1510     };
1511     SearchModelNG::SetOnSubmit(frameNode, std::move(onEvent));
1512 }
1513 
SetOnSearchChange(ArkUINodeHandle node,void * extraParam)1514 void SetOnSearchChange(ArkUINodeHandle node, void* extraParam)
1515 {
1516     auto* frameNode = reinterpret_cast<FrameNode*>(node);
1517     CHECK_NULL_VOID(frameNode);
1518     auto onEvent = [extraParam](const ChangeValueInfo& info) {
1519         ArkUINodeEvent event;
1520         std::string utf8Text = UtfUtils::Str16DebugToStr8(info.value);
1521         event.kind = TEXT_INPUT;
1522         event.extraParam = reinterpret_cast<intptr_t>(extraParam);
1523         event.textInputEvent.subKind = ON_SEARCH_CHANGE;
1524         event.textInputEvent.nativeStringPtr = reinterpret_cast<intptr_t>(utf8Text.c_str());
1525         SendArkUISyncEvent(&event);
1526     };
1527     SearchModelNG::SetOnChange(frameNode, std::move(onEvent));
1528 }
1529 
SetOnSearchCopy(ArkUINodeHandle node,void * extraParam)1530 void SetOnSearchCopy(ArkUINodeHandle node, void* extraParam)
1531 {
1532     auto* frameNode = reinterpret_cast<FrameNode*>(node);
1533     CHECK_NULL_VOID(frameNode);
1534     auto onEvent = [extraParam](const std::u16string& text) {
1535         ArkUINodeEvent event;
1536         std::string utf8Text = UtfUtils::Str16DebugToStr8(text);
1537         event.kind = TEXT_INPUT;
1538         event.extraParam = reinterpret_cast<intptr_t>(extraParam);
1539         event.textInputEvent.subKind = ON_SEARCH_COPY;
1540         event.textInputEvent.nativeStringPtr = reinterpret_cast<intptr_t>(utf8Text.c_str());
1541         SendArkUISyncEvent(&event);
1542     };
1543     SearchModelNG::SetOnCopy(frameNode, std::move(onEvent));
1544 }
1545 
SetOnSearchCut(ArkUINodeHandle node,void * extraParam)1546 void SetOnSearchCut(ArkUINodeHandle node, void* extraParam)
1547 {
1548     auto* frameNode = reinterpret_cast<FrameNode*>(node);
1549     CHECK_NULL_VOID(frameNode);
1550     auto onEvent = [extraParam](const std::u16string& text) {
1551         ArkUINodeEvent event;
1552         std::string utf8Text = UtfUtils::Str16DebugToStr8(text);
1553         event.kind = TEXT_INPUT;
1554         event.extraParam = reinterpret_cast<intptr_t>(extraParam);
1555         event.textInputEvent.subKind = ON_SEARCH_CUT;
1556         event.textInputEvent.nativeStringPtr = reinterpret_cast<intptr_t>(utf8Text.c_str());
1557         SendArkUISyncEvent(&event);
1558     };
1559     SearchModelNG::SetOnCut(frameNode, std::move(onEvent));
1560 }
1561 
SetOnSearchPaste(ArkUINodeHandle node,void * extraParam)1562 void SetOnSearchPaste(ArkUINodeHandle node, void* extraParam)
1563 {
1564     auto* frameNode = reinterpret_cast<FrameNode*>(node);
1565     CHECK_NULL_VOID(frameNode);
1566     auto onEvent = [extraParam](const std::u16string& text, NG::TextCommonEvent& textEvent) {
1567         ArkUINodeEvent event;
1568         std::string utf8Text = UtfUtils::Str16DebugToStr8(text);
1569         event.kind = TEXT_INPUT;
1570         event.extraParam = reinterpret_cast<intptr_t>(extraParam);
1571         event.textInputEvent.subKind = ON_SEARCH_PASTE;
1572         event.textInputEvent.nativeStringPtr = reinterpret_cast<intptr_t>(utf8Text.c_str());
1573         SendArkUISyncEvent(&event);
1574     };
1575     SearchModelNG::SetOnPasteWithEvent(frameNode, std::move(onEvent));
1576 }
1577 
SetSearchKeyboardAppearance(ArkUINodeHandle node,ArkUI_Uint32 keyboardAppearance)1578 void SetSearchKeyboardAppearance(ArkUINodeHandle node, ArkUI_Uint32 keyboardAppearance)
1579 {
1580     auto* frameNode = reinterpret_cast<FrameNode*>(node);
1581     CHECK_NULL_VOID(frameNode);
1582     auto value = static_cast<KeyboardAppearance>(keyboardAppearance);
1583     SearchModelNG::SetKeyboardAppearance(frameNode, value);
1584 }
1585 
ResetSearchKeyboardAppearance(ArkUINodeHandle node)1586 void ResetSearchKeyboardAppearance(ArkUINodeHandle node)
1587 {
1588     auto* frameNode = reinterpret_cast<FrameNode*>(node);
1589     CHECK_NULL_VOID(frameNode);
1590     auto value = KeyboardAppearance::NONE_IMMERSIVE;
1591     SearchModelNG::SetKeyboardAppearance(frameNode, value);
1592 }
1593 }
1594 } // namespace OHOS::Ace::NG
1595