def styleFromDefault(): styles = dict() tokens = getDefault("PyDETokenColors", fallbackStyleDict) for key, value in tokens.items(): token = string_to_tokentype(key) if value and not value.startswith("#"): value = "#%s" % value styles[token] = value style = type('DrawBotStyle', (Style,), dict(styles=styles)) style.background_color = _NSColorToHexString(getColorDefault("PyDEBackgroundColor", fallbackBackgroundColor)) style.highlight_color = _NSColorToHexString(getColorDefault("PyDEHightLightColor", fallbackHightLightColor)) return style
def styleFromDefault(): styles = dict() tokens = getDefault("PyDETokenColors", fallbackStyleDict) for key, value in tokens.items(): token = string_to_tokentype(key) if value and not value.startswith("#"): value = "#%s" % value styles[token] = value style = type('DrawBotStyle', (Style, ), dict(styles=styles)) style.background_color = _NSColorToHexString( getColorDefault("PyDEBackgroundColor", fallbackBackgroundColor)) style.highlight_color = _NSColorToHexString( getColorDefault("PyDEHightLightColor", fallbackHightLightColor)) return style
def getFromDefaults(self): self._initializing = True self._setFont(getFontDefault("PyDEFont", fallbackFont)) styles = styleFromDefault() items = [] for token, value in fallbackStyles: data = dict(token=str(token)) style = styles.style_for_token(token) data.update(style) item = ColorItem(data) items.append(item) self.tokenList.set(items) self.backgroundColor.set(getColorDefault("PyDEBackgroundColor", fallbackBackgroundColor)) self.hightLightColor.set(getColorDefault("PyDEHightLightColor", fallbackHightLightColor)) self._initializing = False
def drawWithFrame_inView_(self, frame, view): frame.origin.x -= 1 frame.size.width += 2 frame.origin.y -= 2 frame.size.height += 2 textFrame = NSInsetRect(frame, 2, 2) text = self.objectValue() color = getColorDefault("PyDEBackgroundColor", fallbackBackgroundColor) color.set() NSBezierPath.bezierPathWithRect_(frame).fill() if self.isHighlighted(): frame.origin.y += 1 frame.size.height -= 1 color = getColorDefault("PyDEHightLightColor", fallbackHightLightColor) color.set() NSBezierPath.bezierPathWithRect_(frame).fill() text.drawInRect_(textFrame)