Changeset 83403 in vbox for trunk/src/VBox/ValidationKit/testmanager/webui/wuicontentbase.py
- Timestamp:
- Mar 25, 2020 12:09:58 PM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/ValidationKit/testmanager/webui/wuicontentbase.py
r83397 r83403 116 116 sFmt = '<a %shref="%s">%s</a>'; 117 117 return sFmt % (sExtraAttrs, webutils.escapeAttr(self.sUrl), webutils.escapeElem(self.sName)); 118 119 @staticmethod 120 def estimateStringWidth(sString): 121 """ 122 Takes a string and estimate it's width so the caller can pad with 123 U+2002 before tab in a title text. This is very very rough. 124 """ 125 cchWidth = 0; 126 for ch in sString: 127 if ch.isupper() or ch in u'wm\u2007\u2003\u2001\u3000': 128 cchWidth += 2; 129 else: 130 cchWidth += 1; 131 return cchWidth; 132 133 @staticmethod 134 def getStringWidthPaddingEx(cchWidth, cchMaxWidth): 135 """ Works with estiamteStringWidth(). """ 136 if cchWidth + 2 <= cchMaxWidth: 137 return u'\u2002' * ((cchMaxWidth - cchWidth) * 2 // 3) 138 return u''; 139 140 @staticmethod 141 def getStringWidthPadding(sString, cchMaxWidth): 142 """ Works with estiamteStringWidth(). """ 143 return WuiLinkBase.getStringWidthPaddingEx(WuiLinkBase.estimateStringWidth(sString), cchMaxWidth); 144 145 @staticmethod 146 def padStringToWidth(sString, cchMaxWidth): 147 """ Works with estimateStringWidth. """ 148 cchWidth = WuiLinkBase.estimateStringWidth(sString); 149 if cchWidth < cchMaxWidth: 150 return sString + WuiLinkBase.getStringWidthPaddingEx(cchWidth, cchMaxWidth); 151 return sString; 118 152 119 153
Note:
See TracChangeset
for help on using the changeset viewer.