feat: add a new awesome feature

This commit is contained in:
2025-11-02 18:04:55 +08:00
parent c4852d080f
commit 4bb0352088
23 changed files with 4712 additions and 1899 deletions
+16 -12
View File
@@ -3,16 +3,18 @@
Label::Label()
:Control(0, 0, 0, 0)
{
this->id = "Label";
this->text = "默认标签";
textColor = RGB(0,0,0);
textStyle.color = RGB(0,0,0);
textBkColor = RGB(255, 255, 255);; //默认白色背景
}
Label::Label(int x, int y, std::string text, COLORREF textcolor, COLORREF bkColor)
:Control(x, y, 0, 0)
{
this->id = "Label";
this->text = text;
textColor = textcolor;
textStyle.color = textcolor;
textBkColor = bkColor; //默认白色背景
}
@@ -28,14 +30,21 @@ void Label::draw()
setbkmode(OPAQUE); //设置背景不透明
setbkcolor(textBkColor); //设置背景颜色
}
settextcolor(textColor);
settextcolor(textStyle.color);
settextstyle(textStyle.nHeight, textStyle.nWidth, textStyle.lpszFace,
textStyle.nEscapement, textStyle.nOrientation, textStyle.nWeight,
textStyle.bItalic, textStyle.bUnderline, textStyle.bStrikeOut); //设置字体样式
this->saveBackground(x, y,textwidth(text.c_str()),textheight(text.c_str()));
this-> restBackground();
if (0 == this->width || 0 == this->height)
{
this->width = textwidth(text.c_str());
this->height = textheight(text.c_str());
}
if ((saveBkX != this->x) || (saveBkY != this->y) || (!hasSnap) || (saveWidth != this->width) || (saveHeight != this->height) || !saveBkImage)
saveBackground(this->x, this->y,this->width,this->height);
// 恢复背景(清除旧内容)
restBackground();
outtextxy(x, y, LPCTSTR(text.c_str()));
this->restoreStyle();
restoreStyle();
dirty = false;
}
}
@@ -52,12 +61,6 @@ void Label::setTextdisap(bool key)
this->dirty = true;
}
void Label::setTextColor(COLORREF color)
{
textColor = color;
this->dirty = true;
}
void Label::setTextBkColor(COLORREF color)
{
textBkColor = color;
@@ -68,4 +71,5 @@ void Label::setText(std::string text)
{
this->text = text;
this->dirty = true;
}