示例#1
0
    def _renderImpl(self, **kwargs):
        a   = self.attrs
        raw = a.getAsKeyword(TagAttributesEnum.NAME + TagAttributesEnum.COLOR, None)
        if raw:
            c = raw.rstrip('+-')
        else:
            c = raw

        if c in ['hgh', 'high', 'highlight']:
            vclass = 'v-S-hgh'
        elif c in ['lnk', 'link']:
            vclass = 'v-S-lnk'
        elif c in ['sft', 'soft']:
            vclass = 'v-S-sft'
        elif c in ['btn', 'button']:
            vclass = 'v-S-fbn'
        elif c in ['fcl', 'focal']:
            vclass = 'v-S-fcl'
        elif c in ['bck', 'back', 'background']:
            vclass = 'v-S-bckfront'
        elif c in ['dod', 'dodge']:
            vclass = 'v-S-dodfront'
        elif c in ['brn', 'burn']:
            vclass = 'v-S-brnfront'
        elif c in ['bor', 'border']:
            vclass = 'v-S-borfront'
        elif c in ['bbtn', 'backbutton', 'buttonback']:
            vclass = 'v-S-bbnfront'
        elif c is not None:
            vclass = None
            if self._setColor(ColorValue(raw)):
                return
        else:
            vclass = None

        if vclass is not None:
            bendCount = ColorValue.getBendCount(raw)
            if bendCount == 0:
                bendSuffix = ''
            else:
                bendSuffix = ('-d' if bendCount < 0 else '-u') + str(abs(bendCount))

            a.classes.add(vclass + bendSuffix, a.styleGroup)
            return

        props = ColorTag._COLOR_PROPS
        for p in props:
            c = a.get(p, None)
            if c is None:
                continue

            try:
                if self._setColor(c, p):
                    return
            except Exception, err:
                self._processor.logger.writeError('ColorTag: %s | %s -> %s' % (p, str(c), str(type(c))), err)
                a.logAttributeError(p, c) #TODO: This no longer works.