def MeasureTabstops(self, stringsData, margin=None, minwidth=32): if margin is None: margin = 6 tabstops = [] tabCount = 0 for stringData in stringsData: if len(stringData) == 5: tabSeperatedColumns, fontsize, letterSpace, shift, uppercase = stringData else: tabSeperatedColumns, fontsize, letterSpace, shift = stringData uppercase = 0 tabSeperatedColumns = GetAsUnicode(tabSeperatedColumns) columnTexts = tabSeperatedColumns.split('<t>') columnTextsCount = len(columnTexts) if columnTextsCount > tabCount: tabstops.extend([minwidth] * (columnTextsCount - tabCount)) tabCount = columnTextsCount i = 0 for columnText in columnTexts: width = max(0, shift - margin) + margin + self.GetTextWidth( columnText, fontsize, letterSpace, uppercase) + margin + 2 if width > tabstops[i]: tabstops[i] = width i += 1 shift = 0 i = 1 while i < tabCount: tabstops[i] += tabstops[i - 1] i += 1 return tabstops
def IsLink(text): textAsUnicode = GetAsUnicode(text) if textAsUnicode.find('<url') != -1: return True if textAsUnicode.find('<a href') != -1: return True return False
def MeasureTabstops(self, stringsData, margin = None, minwidth = 32): if margin is None: margin = 6 tabstops = [] tabCount = 0 for stringData in stringsData: if len(stringData) == 5: tabSeperatedColumns, fontsize, letterSpace, shift, uppercase = stringData else: tabSeperatedColumns, fontsize, letterSpace, shift = stringData uppercase = 0 tabSeperatedColumns = GetAsUnicode(tabSeperatedColumns) columnTexts = tabSeperatedColumns.split('<t>') columnTextsCount = len(columnTexts) if columnTextsCount > tabCount: tabstops.extend([minwidth] * (columnTextsCount - tabCount)) tabCount = columnTextsCount i = 0 for columnText in columnTexts: width = max(0, shift - margin) + margin + self.GetTextWidth(columnText, fontsize, letterSpace, uppercase) + margin + 2 if width > tabstops[i]: tabstops[i] = width i += 1 shift = 0 i = 1 while i < tabCount: tabstops[i] += tabstops[i - 1] i += 1 return tabstops
def GetTextHeight(self, strng, width=0, font=None, fontsize=None, lineSpacing=0.0, letterspace=0, shadow=[(1, -1, -1090519040)], uppercase=0, specialIndent=0, getTextObj=0, tabs=[], fontPath=None, fontStyle=None, fontFamily=None, linespace=None, maxLines=None, **kwds): if strng is None or strng == '': return 0 fontsize = fontsize or fontConst.DEFAULT_FONTSIZE letterspace = letterspace or fontConst.DEFAULT_LETTERSPACE uppercase = uppercase or fontConst.DEFAULT_UPPERCASE if maxLines == 1: width = 0 strng = u'\xd3gd' else: strng = GetAsUnicode(strng) cacheKey = (strng, width, font, fontsize, lineSpacing, letterspace, maxLines, uppercase, specialIndent, getTextObj, uicore.fontSizeFactor) cache = self.GetCache(cacheKey) if cache: return cache if self.defaultLabelClass is None: from carbonui.control.label import LabelCore self.defaultLabelClass = LabelCore t = self.defaultLabelClass(text=strng, parent=None, align=uiconst.TOPLEFT, width=width, tabs=tabs, fontsize=fontsize, lineSpacing=lineSpacing, letterspace=letterspace, maxLines=maxLines, uppercase=uppercase, specialIndent=specialIndent, fontPath=fontPath, fontStyle=fontStyle, fontFamily=fontFamily, shadow=shadow, measuringText=not getTextObj) if getTextObj: retval = t else: retval = t.textheight self.SetCache(cacheKey, retval) return retval
def ScrollEntryNode(**kw): data = Bunch(**kw) decoClass = data.get('decoClass', SE_GenericCore) data.decoClass = decoClass data.GetHeightFunction = getattr(decoClass, 'GetHeight', None) data.GetColumnWidthFunction = getattr(decoClass, 'GetColumnWidth', None) data.PreLoadFunction = getattr(decoClass, 'PreLoad', None) data.allowDynamicResize = getattr(decoClass, 'allowDynamicResize', False) if data.GetHeightFunction: data.GetHeightFunction = data.GetHeightFunction.im_func if data.PreLoadFunction: data.PreLoadFunction = data.PreLoadFunction.im_func if data.GetColumnWidthFunction: data.GetColumnWidthFunction = data.GetColumnWidthFunction.im_func if not data.charIndex and data.label: data.charIndex = GetAsUnicode(data.label).split('<t>')[0] if data.charIndex: data.charIndex = data.charIndex.lower() return data