新增tavleView控件,初步可用

This commit is contained in:
睿 安
2026-01-28 15:00:12 +08:00
parent bcbf890ebd
commit abcfc78596
494 changed files with 3202 additions and 484 deletions

View File

@@ -45,7 +45,7 @@ namespace ezui {
m_timer->Stop();
}
void TextBox::SetPadding(int px, int py) {
// 兼容旧接口:水平=px 垂直=py
// 兼容旧接口:水平=px 垂直=py
SetPadding4(px, py, px, py);
}
void TextBox::SetPadding4(int left, int top, int right, int bottom) {
@@ -649,6 +649,35 @@ namespace ezui {
{
this->m_passwordChar = passwordChar.unicode();
}
void TextBox::SetFocusAndCaret(int caretPos)
{
// 设置焦点状态
m_focus = true;
m_bCareShow = true;
m_timer->Start();
// 设置光标位置
if (caretPos < 0) {
m_textPos = (int)m_text.size(); // -1 表示末尾
} else {
m_textPos = caretPos;
}
// 确保 m_textPos 在有效范围内
if (m_textPos < 0) m_textPos = 0;
if (m_textPos > (int)m_text.size()) m_textPos = (int)m_text.size();
// 清除选中状态
m_selectRects.clear();
m_pointA = Point();
m_pointB = Point();
m_A_TextPos = m_textPos;
m_B_TextPos = m_textPos;
// 需要重绘以确保 m_font 和 m_textLayout 被初始化
// 之后 OnForePaint 中会调用 BuildCare
Invalidate();
}
Rect TextBox::GetCareRect()
{
Rect rect(m_careRect);
@@ -744,6 +773,10 @@ namespace ezui {
m_font = new Font(fontFamily, fontSize);
Analysis();
}
// 如果有焦点但光标未初始化,重新构建光标
if (m_focus && m_careRect.IsEmptyArea() && m_textLayout) {
BuildCare();
}
Color fontColor = GetForeColor();
e.Graphics.SetFont(fontFamily, fontSize);
if (m_text.empty()) {