-/***
- * @Date: 2024-08-29 19:24:30
- * @LastEditors: Caisking 3449750381@qq.com
- * @LastEditTime: 2024-08-30 18:57:46
- * @FilePath: /FD230/code/sdk/application/wearable/CustomUIComponentTool/uicomponents/UIComponents.cpp
- */
-/***
- * @Date: 2024-05-10 10:27:30
- * @LastEditors: Caisking 3449750381@qq.com
- * @LastEditTime: 2024-05-10 11:03:56
- * @FilePath: /sdk/application/wearable/CustomUIComponentTool/uicomponents/UIComponents.cpp
- */
-
#include "uicomponents/UIComponents.h"
#include <vector>
+
namespace OHOS
{
- // 定义按键颜色宏
+// 定义按键颜色宏
#define DEFAULT_BACKGROUND_COLOR 0xff191919
#define PRESSED_BACKGROUND_COLOR 0xff249115
#define PRESSED_BORDER_COLOR 0xff0b1928
{
InitLabel(label, x, y, width, height, viewId, text, fontName, fontSize);
}
- /* -------------------------------------------------------------------------- */
+ void InitImageAnimatorSource(UIImageAnimatorView *&imageAnimator, ImageAnimatorInfo *&imageAnimatorInfo, const char **imagePaths, int numFrames, int left, int top, int width, int height, const char *viewId, int time)
+ {
+ if (imageAnimator == nullptr)
+ {
+ imageAnimator = new UIImageAnimatorView();
+ }
+ imageAnimator->SetPosition(left, top);
+ imageAnimator->Resize(width, height);
+ imageAnimator->SetViewId(viewId);
+ // imageAnimator->SetStyle(STYLE_BACKGROUND_COLOR, 0xffffffff);
+ imageAnimator->SetStyle(STYLE_BACKGROUND_OPA, 0xff);
+
+ imageAnimatorInfo = new ImageAnimatorInfo[numFrames];
+ for (int i = 0; i < numFrames; i++)
+ {
+ imageAnimatorInfo[i].imagePath = imagePaths[i];
+ imageAnimatorInfo[i].pos.x = left;
+ imageAnimatorInfo[i].pos.y = top;
+ imageAnimatorInfo[i].width = width;
+ imageAnimatorInfo[i].height = height;
+ imageAnimatorInfo[i].imageType = IMG_SRC_FILE_PATH;
+ }
+
+ imageAnimator->SetImageAnimatorSrc(imageAnimatorInfo, numFrames, time); // 200 is the default delay time
+ imageAnimator->SetTimeOfPause(time);
+ imageAnimator->SetRepeat(true);
+ }
+ void ReleaseImageAnimatorSource(ImageAnimatorInfo *&imageAnimatorInfo, int numFrames)
+ {
+ if (imageAnimatorInfo)
+ {
+ for (int i = 0; i < numFrames; i++)
+ {
+ delete[] imageAnimatorInfo[i].imagePath; // 释放每个 imagePath 的内存
+ }
+ delete[] imageAnimatorInfo; // 释放 ImageAnimatorInfo 数组的内存
+ imageAnimatorInfo = nullptr; // 避免悬挂指针
+ }
+ }
+ /* -------------------------------------------------------------------------- */
+ // UILabel 初始化
+ bool InitUILabel(UILabel *&label, const GeneralConfig &config, const LabelConfig &labelConfig)
+ {
+ // 检查标签指针是否为空
+ if (label == nullptr)
+ {
+ label = new UILabel();
+ if (label == nullptr)
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "InitUILabel is error");
+ return false; // 内存分配失败,返回false
+ }
+ }
+ else
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "InitUILabel is not nullptr");
+ return false; // 标签已存在,返回false
+ }
+
+ // 设置标签的位置和大小
+ label->SetPosition(config.x, config.y);
+ label->Resize(config.width, config.height);
+ // 设置标签的视图 ID
+ label->SetViewId(config.viewId);
+ // 设置标签的样式
+ label->SetStyle(STYLE_TEXT_FONT, labelConfig.fontSize);
+ label->SetFont(labelConfig.fontName, labelConfig.fontSize);
+ // 设置标签的文本和其他属性
+ label->SetText(labelConfig.text);
+ label->SetLineBreakMode(UILabel::LINE_BREAK_ELLIPSIS);
+ label->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);
+
+ return true;
+ }
+
+ // UILabelExt 初始化
+ bool InitLabel(UILabelExt *&label, const GeneralConfig &config, const LabelConfig &labelConfig)
+ {
+ // 检查标签指针是否为空
+ if (label == nullptr)
+ {
+ label = new UILabelExt();
+ if (label == nullptr)
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "InitLabel is error");
+ return false; // 内存分配失败,返回false
+ }
+ }
+ else
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "InitLabel is not nullptr");
+ return false; // 标签已存在,返回false
+ }
+
+ // 设置标签的位置和大小
+ label->SetPosition(config.x, config.y);
+ label->Resize(config.width, config.height);
+ // 设置标签的视图 ID
+ label->SetViewId(config.viewId);
+ // 设置标签的样式
+ label->SetStyle(STYLE_TEXT_FONT, labelConfig.fontSize);
+ label->SetFont(labelConfig.fontName, labelConfig.fontSize);
+ // 设置标签的文本和其他属性
+ label->SetText(labelConfig.text);
+ label->SetLineBreakMode(UILabel::LINE_BREAK_ELLIPSIS);
+ label->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);
+
+ return true;
+ }
+
+ // 自适应 UILabel 初始化
+ bool InitLabelAdapt(UILabelExt *&label, const GeneralConfig &config, const LabelConfig &labelConfig)
+ {
+ // 检查标签指针是否为空
+ if (label == nullptr)
+ {
+ label = new UILabelExt();
+ if (label == nullptr)
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "InitLabelAdapt is error");
+ return false; // 内存分配失败,返回false
+ }
+ }
+ else
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "InitLabelAdapt is not nullptr");
+ return false; // 标签已存在,返回false
+ }
+
+ // 设置标签的位置和大小
+ label->SetPosition(config.x, config.y);
+ label->Resize(config.width, config.height);
+ // 设置标签的视图 ID
+ label->SetViewId(config.viewId);
+ // 设置标签的样式
+ label->SetStyle(STYLE_TEXT_FONT, labelConfig.fontSize);
+ label->SetFont(labelConfig.fontName, labelConfig.fontSize);
+ // 设置标签的文本和其他属性
+ label->SetText(labelConfig.text);
+ label->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); // 可以使用剪裁模式
+ label->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);
+
+ return true;
+ }
+ // UIButton 初始化
+ bool InitButton(UIButton *&button, const GeneralConfig &config)
+ {
+ // 检查按钮指针是否为空
+ if (button == nullptr)
+ {
+ button = new UIButton();
+ if (button == nullptr)
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "InitButton is error");
+ return false; // 内存分配失败,返回false
+ }
+ }
+ else
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "InitButton is not nullptr");
+ return false; // 按钮已存在,返回false
+ }
+
+ // 设置按钮的位置和大小
+ button->SetPosition(config.x, config.y);
+ button->Resize(config.width, config.height);
+ // 设置按钮的视图 ID
+ button->SetViewId(config.viewId);
+
+ return true;
+ }
+
+ // UILabelButton 初始化
+ bool InitLabelButton(UILabelButton *&button, const GeneralConfig &config, const LabelConfig &labelConfig)
+ {
+ // 检查标签按钮指针是否为空
+ if (button == nullptr)
+ {
+ button = new UILabelButton();
+ if (button == nullptr)
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "InitLabelButton is error");
+ return false; // 内存分配失败,返回false
+ }
+ }
+ else
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "InitLabelButton is not nullptr");
+ return false; // 标签按钮已存在,返回false
+ }
+
+ // 设置标签按钮的位置和大小
+ button->SetPosition(config.x, config.y);
+ button->Resize(config.width, config.height);
+ // 设置标签按钮的视图 ID
+ button->SetViewId(config.viewId);
+ // 设置标签按钮的样式
+ button->SetStyle(STYLE_TEXT_FONT, labelConfig.fontSize);
+ button->SetFont(labelConfig.fontName, labelConfig.fontSize);
+ // 设置标签按钮的文本
+ button->SetText(labelConfig.text);
+
+ return true;
+ }
+
+ // UIImageView 初始化
+ bool InitImageView(UIImageView *&imageView, const GeneralConfig &config, const char *imagePath)
+ {
+ // 检查图片视图指针是否为空
+ if (imageView == nullptr)
+ {
+ imageView = new UIImageView();
+ if (imageView == nullptr)
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "InitImageView is error");
+ return false; // 内存分配失败,返回false
+ }
+ }
+ else
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "InitImageView is not nullptr");
+ return false; // 图片视图已存在,返回false
+ }
+
+ // 设置图片视图的位置和大小
+ imageView->SetPosition(config.x, config.y);
+ imageView->Resize(config.width, config.height);
+ // 设置图片视图的视图 ID
+ imageView->SetViewId(config.viewId);
+ // 设置图片的路径
+ imageView->SetSrc(imagePath);
+
+ return true;
+ }
+ /* -------------------------------------------------------------------------- */
/**
* 创建包含图片文件路径的数组
* @param basePath 包含图片文件的基本路径 PullUp_%d.bin
* @param numImages 图片文件的数量
* @return 返回包含图片文件info的数组
*/
- const ImageInfo**CreateImageInfoArray(const char *basePath, int numImages, const char *fileExtension)
+ const ImageInfo **CreateImageInfoArray(const char *basePath, int numImages, const char *fileExtension)
{
const ImageInfo **imageinfo_array = static_cast<const ImageInfo **>(UIMalloc(numImages * sizeof(const ImageInfo *)));
- if(imageinfo_array==nullptr)
+ if (imageinfo_array == nullptr)
{
- return nullptr; // 检查内存分配是否成功
+ return nullptr; // 检查内存分配是否成功
}
- for(int i = 0; i < numImages; i++)
+ for (int i = 0; i < numImages; i++)
{
- char buffer[256]={0};
+ char buffer[256] = {0};
snprintf(buffer, sizeof(buffer), "%s%d.%s", basePath, i + 1, fileExtension);
- imageinfo_array[i]=ImageCacheManager::GetInstance().LoadSingleRes(buffer);
- if( imageinfo_array[i]==nullptr)
+ imageinfo_array[i] = ImageCacheManager::GetInstance().LoadSingleRes(buffer);
+ if (imageinfo_array[i] == nullptr)
{
UIFree(imageinfo_array);
return nullptr; // 检查内存分配是否成功
return imageinfo_array;
}
- void FreeImageInfoArray( const ImageInfo** array,const char *basePath, int numImages, const char *fileExtension)
+ void FreeImageInfoArray(const ImageInfo **array, const char *basePath, int numImages, const char *fileExtension)
{
- for(int i = 0; i < numImages; i++)
+ for (int i = 0; i < numImages; i++)
{
- char buffer[256]={0};
+ char buffer[256] = {0};
snprintf(buffer, sizeof(buffer), "%s%d.%s", basePath, i + 1, fileExtension);
ImageCacheManager::GetInstance().UnloadSingleRes(buffer);
}
UIFree(array);
- return ;
+ return;
}
/* -------------------------------------------------------------------------- */
/**
}
return imageArray;
}
- /**
- * @brief 初始化UIImageAnimatorView,并设置为GIF动画。
- *
- * 该函数用于使用提供的GIF图像和属性初始化UIImageAnimatorView。
- *
- * @param imageAnimator 要初始化的UIImageAnimatorView对象的引用。
- * @param paths GIF图像文件路径的数组。
- * @param numFrames GIF中的帧数。
- * @param left 视图的左侧位置。
- * @param top 视图的顶部位置。
- * @param width 视图的宽度。
- * @param height 视图的高度。
- * @param viewId 视图的ID。
- * @param time 视图的帧速
- * @return 如果初始化成功则返回true,否则返回false。
- */
- void InitImageAnimatorSource(UIImageAnimatorView *&imageAnimator, const char **imagePaths, int numFrames, int left, int top, int width, int height, const char *viewId, int time)
- {
- if (imageAnimator == nullptr)
- {
- imageAnimator = new UIImageAnimatorView();
- }
- imageAnimator->SetPosition(left, top);
- imageAnimator->Resize(width, height);
- imageAnimator->SetViewId(viewId);
- // imageAnimator->SetStyle(STYLE_BACKGROUND_COLOR, 0xffffffff);
- imageAnimator->SetStyle(STYLE_BACKGROUND_OPA, 0xff);
-
- ImageAnimatorInfo *imageAnimatorInfo = new ImageAnimatorInfo[numFrames];
- for (int i = 0; i < numFrames; i++)
- {
- imageAnimatorInfo[i].imagePath = imagePaths[i];
- imageAnimatorInfo[i].pos.x = left;
- imageAnimatorInfo[i].pos.y = top;
- imageAnimatorInfo[i].width = width;
- imageAnimatorInfo[i].height = height;
- imageAnimatorInfo[i].imageType = IMG_SRC_FILE_PATH;
- }
-
- imageAnimator->SetImageAnimatorSrc(imageAnimatorInfo, numFrames, time); // 200 is the default delay time
- imageAnimator->SetTimeOfPause(time);
- imageAnimator->SetRepeat(true);
- // imageAnimator->SetReverse(true);
- // imageAnimator->SetVisible(true);
- }
}
-
-
#ifndef UICOMPONENTS_H
#define UICOMPONENTS_H
namespace OHOS
{
-
+ /* -------------------------------------------------------------------------- */
// 初始化和创建 UI 组件
// =======================
/* 初始化 UILabel */
// 默认参数的 UILabel 初始化
void InitLabelDefault(UILabelExt *&label, int x, int y, int width, int height, const char *viewId, const char *text, int fontSize = 30, const char *fontName = DEFAULT_VECTOR_FONT_FILENAME);
- /*生成动画资源数组*/
+ bool InitLabelExt(UILabelExt *&label, int left, int top, int width, int height, const char *viewId, UIResourceTextId id, const char *fontName, int fontSize);
+ bool InitButtonExt(UILabelButtonExt *&button, int left, int top, int width, int height, const char *viewId, UIResourceTextId id, int fontSize);
+
+ void InitImageAnimatorSource(UIImageAnimatorView *&imageAnimator, ImageAnimatorInfo *&imageAnimatorInfo, const char **imagePaths, int numFrames, int left, int top, int width, int height, const char *viewId, int time);
+
+ void FreeImageInfoArray(const ImageInfo **array, const char *basePath, int numImages, const char *fileExtension = "bin");
+
+ // 更新 Label 的文本
+ /* -------------------------------------------------------------------------- */
+ /* -------------------------------------------------------------------------- */
+ // 封装位置和尺寸信息的结构体
+ struct GeneralConfig
+ {
+ int x, y, width, height; // 位置和尺寸
+ const char *viewId; // 视图 ID
+
+ // 构造函数,允许初始化默认值
+ GeneralConfig(int x = 0, int y = 0, int width = 100, int height = 100, const char *viewId = "defaultId")
+ : x(x), y(y), width(width), height(height), viewId(viewId) {}
+ };
+
+ // 封装动画相关配置
+ struct ImageAnimatorConfig
+ {
+ const char **imagePaths; // 图像路径数组
+ int numFrames; // 帧数
+ int time; // 动画时间
+
+ // 构造函数,允许初始化默认值
+ ImageAnimatorConfig(const char **paths = nullptr, int frames = 0, int time = 100)
+ : imagePaths(paths), numFrames(frames), time(time) {}
+ };
+
+ // 封装标签相关配置
+ struct LabelConfig
+ {
+ const char *text; // 标签文本
+ const char *fontName; // 字体名称
+ int fontSize; // 字体大小
+
+ // 构造函数,允许初始化默认值
+ LabelConfig(const char *text = "", const char *fontName = DEFAULT_VECTOR_FONT_FILENAME, int fontSize = 30)
+ : text(text), fontName(fontName), fontSize(fontSize) {}
+ };
+
+ // 初始化和创建 UI 组件
+ // =======================
+
+ /**
+ * @brief 初始化 UILabel 对象。
+ *
+ * 此函数检查传入的 UILabel 指针是否为空,若为空则分配内存并设置其相关属性。
+ *
+ * @param label 要初始化的 UILabel 对象的引用。
+ * @param config 带有位置、尺寸和视图 ID 的配置。
+ * @param labelConfig 标签的样式和文本配置。
+ * @return true 初始化成功;false 创建失败。
+ */
+ bool InitUILabel(UILabel *&label, const GeneralConfig &config, const LabelConfig &labelConfig);
+
+ /**
+ * @brief 初始化 UILabelExt 对象。
+ *
+ * 与 InitUILabel 类似,但用于扩展的 UILabel。
+ *
+ * @param label 要初始化的 UILabelExt 对象的引用。
+ * @param config 配置参数。
+ * @param labelConfig 标签的样式和文本配置。
+ * @return true 初始化成功;false 创建失败。
+ */
+ bool InitLabel(UILabelExt *&label, const GeneralConfig &config, const LabelConfig &labelConfig);
+
+ /**
+ * @brief 初始化可自适应的 UILabelExt 对象。
+ *
+ * @param label 要初始化的 UILabelExt 对象的引用。
+ * @param config 配置参数。
+ * @param labelConfig 标签的样式和文本配置。
+ * @return true 初始化成功;false 创建失败。
+ */
+ bool InitLabelAdapt(UILabelExt *&label, const GeneralConfig &config, const LabelConfig &labelConfig);
+
+ /**
+ * @brief 初始化 UIButton 对象。
+ *
+ * 此函数将创建 UIButton,并设置其位置、大小和视图 ID。
+ *
+ * @param button 要初始化的 UIButton 对象的引用。
+ * @param config 配置参数(位置、大小、视图 ID)。
+ * @return true 初始化成功;false 创建失败。
+ */
+ bool InitButton(UIButton *&button, const GeneralConfig &config);
+
+ /**
+ * @brief 初始化 UILabelButton 对象。
+ *
+ * 这个函数将创建 UILabelButton,设置它的文本、位置和样式。
+ *
+ * @param button 要初始化的 UILabelButton 对象的引用。
+ * @param config 配置参数。
+ * @param labelConfig 标签样式和文本配置。
+ * @return true 初始化成功;false 创建失败。
+ */
+ bool InitLabelButton(UILabelButton *&button, const GeneralConfig &config, const LabelConfig &labelConfig);
+
+ /**
+ * @brief 初始化 UIImageView 对象。
+ *
+ * 初始化UIImageView并设置位置、大小和视图 ID,同时加载图像。
+ *
+ * @param imageView 要初始化的 UIImageView 对象的引用。
+ * @param config 配置参数。
+ * @param imagePath 图像路径。
+ * @return true 初始化成功;false 创建失败。
+ */
+ bool InitImageView(UIImageView *&imageView, const GeneralConfig &config, const char *imagePath);
+
+ // 动画资源数组生成
+ // =======================
+
+ /**
+ * @brief 创建动态图像路径数组。
+ *
+ * 根据给定路径、数量和文件扩展名生成图像路径数组。
+ *
+ * @param basePath 基础路径。
+ * @param numImages 图像数量。
+ * @param fileExtension 文件扩展名(默认 "bin")。
+ * @return const char** 动态分配的图像路径数组。
+ */
const char **CreateImagePathsArray(const char *basePath, int numImages, const char *fileExtension = "bin");
- /*生成动画资源结构体*/
- const ImageInfo**CreateImageInfoArray(const char *basePath, int numImages, const char *fileExtension = "bin");
- void FreeImageInfoArray( const ImageInfo** array,const char *basePath, int numImages, const char *fileExtension = "bin");
+ /**
+ * @brief 创建图像信息数组。
+ *
+ * 根据路径和数量生成图像信息数组。
+ *
+ * @param basePath 基础路径。
+ * @param numImages 图像数量。
+ * @param fileExtension 文件扩展名(默认 "bin")。
+ * @return const ImageInfo** 动态分配的图像信息数组。
+ */
+ const ImageInfo **CreateImageInfoArray(const char *basePath, int numImages, const char *fileExtension = "bin");
+
+ /**
+ * @brief 释放图像信息数组。
+ *
+ * 释放由 CreateImageInfoArray 创建的图像信息数组的内存。
+ *
+ * @param array 要释放的图像信息数组。
+ * @param numImages 数组长度。
+ */
+ void FreeImageInfoArray(const ImageInfo **array, int numImages);
- /*释放动画资源数组*/
+ /**
+ * @brief 释放图像路径数组。
+ *
+ * 释放由 CreateImagePathsArray 创建的图像路径数组的内存。
+ *
+ * @param imagePaths 要释放的图像路径数组。
+ * @param numImages 数组长度。
+ */
void FreeImagePathsArray(const char **imagePaths, int numImages);
- /*初始化动画资源*/
- void InitImageAnimatorSource(UIImageAnimatorView *&imageAnimator, const char **imagePaths, int numFrames, int left, int top, int width, int height, const char *viewId, int time);
+ /**
+ * @brief 初始化 UIImageAnimatorView,并设置为 GIF 动画。
+ *
+ * @param imageAnimator 初始化的 UIImageAnimatorView 对象的引用。
+ * @param imageAnimatorInfo 储存 GIF 动画信息的数组指针。
+ * @param config 动画相关的配置(包括路径和帧信息)。
+ * @param generalConfig 视图的基本配置(位置、大小、视图 ID 等)。
+ */
+ void InitImageAnimatorSource(UIImageAnimatorView *&imageAnimator, ImageAnimatorInfo *&imageAnimatorInfo, const ImageAnimatorConfig &config, const GeneralConfig &generalConfig);
+
+ /**
+ * @brief 释放 UIImageAnimatorView 的资源。
+ *
+ * @param imageAnimatorInfo 要释放的动画信息。
+ */
+ void ReleaseImageAnimatorSource(ImageAnimatorInfo *&imageAnimatorInfo, int numFrames);
#ifdef FD230
// 扩展功能
// =======================
- bool InitLabelExt(UILabelExt *&label, int left, int top, int width, int height, const char *viewId, UIResourceTextId id, const char *fontName, int fontSize);
- bool InitButtonExt(UILabelButtonExt *&button, int left, int top, int width, int height, const char *viewId, UIResourceTextId id, int fontSize);
+ /**
+ * @brief 初始化带扩展功能的 UILabelExt 对象。
+ *
+ * @param label 要初始化的 UILabelExt 对象的引用。
+ * @param config 配置参数。
+ * @param id 资源文本 ID。
+ * @param labelConfig 标签样式和文本配置。
+ * @return true 初始化成功;false 创建失败。
+ */
+ bool InitLabelExt(UILabelExt *&label, const GeneralConfig &config, UIResourceTextId id, const LabelConfig &labelConfig);
- // 更新 Label 的文本
+ /**
+ * @brief 初始化带扩展功能的 UILabelButtonExt 对象。
+ *
+ * @param button 要初始化的 UILabelButtonExt 对象的引用。
+ * @param config 配置参数。
+ * @param id 资源文本 ID。
+ * @param fontSize 字体大小。
+ * @return true 初始化成功;false 创建失败。
+ */
+ bool InitButtonExt(UILabelButtonExt *&button, const GeneralConfig &config, UIResourceTextId id, int fontSize);
+
+ /**
+ * @brief 更新 UILabelExt 对象的文本。
+ *
+ * @param label 要更新的 UILabelExt 对象的引用。
+ * @param newText 新的文本。
+ * @param id 资源文本 ID。
+ * @return std::string 更新后的文本。
+ */
std::string UpdateLabelText(UILabelExt *&label, const std::string &newText, UIResourceTextId id);
+
+ /**
+ * @brief 更新 UILabelExt 对象的文本,允许数字。
+ *
+ * @param label 要更新的 UILabelExt 对象的引用。
+ * @param num 需要更新的数字。
+ * @param id 资源文本 ID。
+ * @return std::string 更新后的文本。
+ */
std::string UpdateLabel(UILabelExt *&label, int num, UIResourceTextId id);
+
+ /**
+ * @brief 更新 UILabelExt 对象的文本,允许字符串更新。
+ *
+ * @param label 要更新的 UILabelExt 对象的引用。
+ * @param updatestr 需要更新的字符串。
+ * @param id 资源文本 ID。
+ * @return std::string 更新后的文本。
+ */
std::string UpdateLabel(UILabelExt *&label, const std::string &updatestr, UIResourceTextId id);
- // 设置 Label ID
+ /**
+ * @brief 设置 UILabel 的 ID。
+ *
+ * @param label 要设置 ID 的 UILabel 对象的引用。
+ * @param id 资源文本 ID。
+ */
void SetLabelId(UILabel *&label, UIResourceTextId id);
-#endif // FD230
+#endif
} // namespace OHOS