allow ELLIPSIS mode through dialogxml

This commit is contained in:
2025-05-07 12:39:47 -05:00
parent e9fb80f09a
commit c407ffd248
3 changed files with 8 additions and 1 deletions

View File

@@ -188,6 +188,7 @@
</xs:restriction> </xs:restriction>
</xs:simpleType> </xs:simpleType>
</xs:attribute> </xs:attribute>
<xs:attribute name="ellipsis" type="bool"/>
<xs:attribute ref="def-key"/> <xs:attribute ref="def-key"/>
<xs:attribute name="fromlist" default="none" type="xs:string"/> <xs:attribute name="fromlist" default="none" type="xs:string"/>
<xs:attributeGroup ref="rect-size"/> <xs:attributeGroup ref="rect-size"/>

View File

@@ -63,6 +63,10 @@ bool cTextMsg::parseAttribute(ticpp::Attribute& attr, std::string tagName, std::
else if(val == "left") right_align = false; else if(val == "left") right_align = false;
else throw xBadVal(tagName, attr.Name(), val, attr.Row(), attr.Column(), fname); else throw xBadVal(tagName, attr.Name(), val, attr.Row(), attr.Column(), fname);
return true; return true;
}else if(attr.Name() == "ellipsis"){
std::string val = attr.Value();
if(val == "true") text_mode = eTextMode::ELLIPSIS;
return true;
} }
return cControl::parseAttribute(attr, tagName, fname); return cControl::parseAttribute(attr, tagName, fname);
} }
@@ -118,7 +122,8 @@ void cTextMsg::calculate_layout() {
cControl& ctrl = key ? getDialog()->getControl(*key) : *this; cControl& ctrl = key ? getDialog()->getControl(*key) : *this;
msg.replace(pos, 1, ctrl.getAttachedKeyDescription()); msg.replace(pos, 1, ctrl.getAttachedKeyDescription());
} }
if(to_rect.bottom - to_rect.top < 20 && msg.find("|") == std::string::npos){ if(text_mode == eTextMode::ELLIPSIS){}
else if(to_rect.bottom - to_rect.top < 20 && msg.find("|") == std::string::npos){
style.lineHeight = 12; style.lineHeight = 12;
to_rect.left += 3; to_rect.left += 3;
text_mode = eTextMode::LEFT_BOTTOM; text_mode = eTextMode::LEFT_BOTTOM;

View File

@@ -94,6 +94,7 @@ The `<text>` tag accepts the following attributes:
* `outline` - See **Common Attributes** above. * `outline` - See **Common Attributes** above.
* `underline` - If true, the text will be underlined. * `underline` - If true, the text will be underlined.
* `align` - `right` or `left`. Defaults to `left`. * `align` - `right` or `left`. Defaults to `left`.
* `ellipsis` - If true, instead of wrapping overflow, truncate to one line with '...'
* `fromlist`, `font`, `size`, `color`, `colour`, `def-key` - * `fromlist`, `font`, `size`, `color`, `colour`, `def-key` -
See **Common Attributes** above. See **Common Attributes** above.