bool InitUILabel(UILabel *&label, int left, int top, int width, int height, const char *viewId, const char *text, const char *fontName, int fontSize)
{
// 检查标签指针是否为空
- if (label == nullptr)
- {
- label = new UILabel();
- }
+ label = new UILabel();
if (label == nullptr)
{
return false; // 内存分配失败,返回false
label->SetFont(fontName, fontSize);
// 设置标签的文本和其他属性
label->SetText(text);
- // label->SetLineBreakMode(UILabel::LINE_BREAK_ELLIPSIS);
+ label->SetLineBreakMode(UILabel::LINE_BREAK_ELLIPSIS);
label->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);
- // label->SetRollSpeed(0);
- // 设置标签可见
- label->SetVisible(true);
- // WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "InitLabelExt is succeed");
+
return true;
}
/***
bool InitLabel(UILabelExt *&label, int left, int top, int width, int height, const char *viewId, const char *text, const char *fontName, int fontSize)
{
// 检查标签指针是否为空
+
+ label = new UILabelExt();
if (label == nullptr)
{
- label = new UILabelExt();
- }
- if (label == nullptr)
- {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "InitLabel is error");
return false; // 内存分配失败,返回false
}
// 设置标签的位置和大小
label->SetLineBreakMode(UILabel::LINE_BREAK_ELLIPSIS);
label->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);
label->SetRollSpeed(0);
- // 设置标签可见
- label->SetVisible(true);
- // WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "InitLabelExt is succeed");
+
return true;
}
bool InitLabelAdapt(UILabelExt *&label, int left, int top, int width, int height, const char *viewId, const char *text, const char *fontName, int fontSize)
{
// 检查标签指针是否为空
+ label = new UILabelExt();
if (label == nullptr)
{
- label = new UILabelExt();
- }
- if (label == nullptr)
- {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "InitLabelAdapt is error");
return false; // 内存分配失败,返回false
}
// 设置标签的位置和大小
label->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT);
label->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);
label->SetRollSpeed(0);
- // 设置标签可见
- label->SetVisible(true);
- // WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "InitLabelExt is succeed");
return true;
}
#ifdef FD230
bool InitLabelExt(UILabelExt *&label, int left, int top, int width, int height, const char *viewId, UIResourceTextId id, const char *fontName, int fontSize)
{
// 检查标签指针是否为空
+ label = new UILabelExt();
if (label == nullptr)
{
- label = new UILabelExt();
- }
- if (label == nullptr)
- {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "InitLabelExt is error");
return false; // 内存分配失败,返回false
}
// 设置标签的位置和大小
label->SetFont(fontName, fontSize);
// 设置标签的文本和其他属性
label->SetTextId(id);
- // label->SetFontId();
label->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);
label->SetLineBreakMode(UILabel::LINE_BREAK_ELLIPSIS);
- label->SetRollSpeed(100);
- // 设置标签可见
- label->SetVisible(true);
- // WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "InitLabelExt is succeed");
return true;
}
button = new UILabelButtonExt();
if (button == nullptr)
{
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "InitButtonExt is error");
return false; // 内存分配失败,返回false
}
button->SetPosition(left, top);
bool InitButton(UIButton *&button, int left, int top, int width, int height, const char *viewId)
{
// 创建新按钮(如果当前按钮为空)
+ button = new UIButton();
if (button == nullptr)
{
- button = new UIButton();
- }
- if (button == nullptr)
- {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "new UIButton fail");
return false; // 内存分配失败,返回false
}
button->SetPosition(left, top);
button->SetStyle(STYLE_BACKGROUND_COLOR, DEFAULT_BACKGROUND_COLOR);
button->SetStyleForState(STYLE_BACKGROUND_COLOR, DEFAULT_BACKGROUND_COLOR, UIButton::PRESSED);
button->SetStyleForState(STYLE_BORDER_COLOR, PRESSED_BORDER_COLOR, UIButton::PRESSED);
- button->SetVisible(true);
- // WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "InitButton is succeed");
return true;
}
*/
bool InitImageView(UIImageView *&imageView, int left, int top, int width, int height, const char *viewId, const char *imagePath)
{
+ imageView = new UIImageView();
if (imageView == nullptr)
{
- imageView = new UIImageView();
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "imagePath %s fail", imagePath);
+ return false;
}
- if (imageView == nullptr)
+ if (imagePath == nullptr)
{
- return false; // 内存分配失败,返回false
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "imagePath %s fail", imagePath);
+ return false;
}
imageView->SetPosition(left, top);
imageView->SetAutoEnable(true);
- // imageView->Resize(width, height);
imageView->SetViewId(viewId);
imageView->SetSrc(imagePath);
- // imageView->SetVisible(true);
- // WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "InitImageView is succeed");
return true;
}
/*带默认参数的初始化label*/