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 /** 17 * @addtogroup ArkUI_NativeModule 18 * @{ 19 * 20 * @brief Provides ArkUI UI capabilities on the Native side, such as UI component creation and destruction, 21 * tree node operation, property setting, event monitoring, and so on. 22 * 23 * @since 12 24 */ 25 26 /** 27 * @file styled_string.h 28 * 29 * @brief Provides ArkUI with property string capabilities on the Native side. 30 * 31 * @library libace_ndk.z.so 32 * @syscap SystemCapability.ArkUI.ArkUI.Full 33 * @kit ArkUI 34 * @since 12 35 */ 36 37 #ifndef ARKUI_NATIVE_STYLED_STRING_H 38 #define ARKUI_NATIVE_STYLED_STRING_H 39 40 #include "native_drawing/drawing_text_declaration.h" 41 #include "native_drawing/drawing_text_typography.h" 42 43 #ifdef __cplusplus 44 extern "C" { 45 #endif 46 47 /** 48 * @brief Defines formatted string data objects supported by the text component. 49 * 50 * @since 12 51 */ 52 typedef struct ArkUI_StyledString ArkUI_StyledString; 53 54 /** 55 * @brief Creates a pointer to the ArkUI_StyledString object. 56 * 57 * @param style A pointer to OH_Drawing_TypographyStyle, obtained by {@link OH_Drawing_CreateTypographyStyle}. 58 * @param collection A pointer to OH_Drawing_FontCollection, obtained by {@link OH_Drawing_CreateFontCollection}. 59 * @return Creates a pointer to the ArkUI_StyledString object. If the object returns a null pointer, 60 * the creation failed, either because the address space was full, 61 * or because the style, collection parameter was an exception such as a null pointer. 62 * @since 12 63 */ 64 ArkUI_StyledString* OH_ArkUI_StyledString_Create( 65 OH_Drawing_TypographyStyle* style, OH_Drawing_FontCollection* collection); 66 67 /** 68 * @brief Free the memory occupied by the ArkUI_StyledString object. 69 * 70 * @param handle A pointer to the ArkUI_StyledString object. 71 * @since 12 72 */ 73 void OH_ArkUI_StyledString_Destroy(ArkUI_StyledString* handle); 74 75 /** 76 * @brief Sets the new layout style to the top of the current format string style stack. 77 * 78 * @param handle A pointer to the ArkUI_StyledString object. 79 * @param style A pointer to the OH_Drawing_TextStyle object. 80 * @since 12 81 */ 82 void OH_ArkUI_StyledString_PushTextStyle(ArkUI_StyledString* handle, OH_Drawing_TextStyle* style); 83 84 /** 85 * @brief Sets the corresponding text content based on the current format string style. 86 * 87 * @param handle A pointer to the ArkUI_StyledString object. 88 * @param content A pointer to the text content. 89 * @since 12 90 */ 91 void OH_ArkUI_StyledString_AddText(ArkUI_StyledString* handle, const char* content); 92 93 /** 94 * @brief Removes the top style from the stack in the current format string object. 95 * 96 * @param handle A pointer to the ArkUI_StyledString object. 97 * @since 12 98 */ 99 void OH_ArkUI_StyledString_PopTextStyle(ArkUI_StyledString* handle); 100 101 /** 102 * @brief Creates a pointer to an OH_Drawing_Typography object based on a format string object 103 * for advanced text estimation and typography. 104 * 105 * @param handle A pointer to the ArkUI_StyledString object. 106 * @return A pointer to the OH_Drawing_Typography object. If the object returns a null pointer, 107 * the creation fails because the handle parameter is abnormal, such as a null pointer. 108 * @since 12 109 */ 110 OH_Drawing_Typography* OH_ArkUI_StyledString_CreateTypography(ArkUI_StyledString* handle); 111 112 /** 113 * @brief Set the placeholder. 114 * 115 * @param handle A pointer to the ArkUI_StyledString object. 116 * @param placeholder A pointer to the OH_Drawing_PlaceholderSpan object. 117 * @since 12 118 */ 119 void OH_ArkUI_StyledString_AddPlaceholder(ArkUI_StyledString* handle, OH_Drawing_PlaceholderSpan* placeholder); 120 121 #ifdef __cplusplus 122 }; 123 #endif 124 125 #endif // ARKUI_NATIVE_STYLED_STRING_H 126 /** @} */ 127