def draw(self): b = DrawBuffer() color = self.getColor(0x0201) b.moveChar(0, ' ', color, self.size.x) b.moveCStr(1, self.text, color) self.writeLine(0, 0, self.size.x, 1, b)
def draw(self): b = DrawBuffer() if self._light: color = self.getColor(0x0402) scOff = 0 else: color = self.getColor(0x0301) scOff = 4 b.moveChar(0, ' ', color, self.size.x) if self._text: b.moveCStr(1, self._text, color) if self.showMarkers: b.putChar(0, SPECIAL_CHARS[scOff]) self.writeLine(0, 0, self.size.x, 1, b)
def draw(self): b = DrawBuffer() if not self.state & sfDragging: color = self.getColor(1) frame = self.dragFrame else: color = self.getColor(2) frame = self.normalFrame b.moveChar(0, frame, color, self.size.x) if self._modified: b.putChar(0, '☼') s = ' {:3d}:{:3d} '.format(self._location.y + 1, self._location.x + 1) b.moveCStr(8 - s.find(':'), s, color) self.writeBuf(0, 0, self.size.x, 1, b)
def __drawSelect(self, selected): b = DrawBuffer() cNormal = self.getColor(0x0301) cSelect = self.getColor(0x0604) cNormDisabled = self.getColor(0x0202) cSelDisabled = self.getColor(0x0505) b.moveChar(0, ' ', cNormal, self.size.x) i = 0 textItems = (item for item in self._items if item.text) for item in textItems: textLen = nameLength(item.text) if i + textLen < self.size.x: if self.commandEnabled(item.command): if item is selected: color = cSelect else: color = cNormal else: if item is selected: color = cSelDisabled else: color = cNormDisabled b.moveChar(i, ' ', color, 1) b.moveCStr(i + 1, item.text, color) b.moveChar(i + textLen + 1, ' ', color, 1) i += textLen + 2 if i < self.size.x - 2: hintBuf = self.hint(self.helpCtx) if hintBuf: b.moveStr(i, self.hintSeparator, cNormal) i += len(self.hintSeparator) if len(hintBuf) + i > self.size.x: hintBuf = hintBuf[:self.size.x - i] b.moveStr(i, hintBuf, cNormal) i += len(hintBuf) self.writeLine(0, 0, self.size.x, 1, b)
def draw(self): """ Draws the framed menu box and associated menu items in the default colors. """ b = DrawBuffer() cSelect = self.getColor(0x0604) cNormDisabled = self.getColor(0x0202) cSelDisabled = self.getColor(0x0505) y = 0 color = self.cNormal self.__frameLine(b, 0, color) self.writeBuf(0, y, self.size.x, 1, b) y += 1 if self.menu: for p in self.menu.items: color = self.cNormal if not p.name: self.__frameLine(b, 15, color) else: if p.disabled: if p is self._current: color = cSelDisabled else: color = cNormDisabled elif p is self._current: color = cSelect self.__frameLine(b, 10, color) b.moveCStr(3, p.name, color) if not p.command: b.putChar(self.size.x - 4, self.subMenuIndicator) elif p.param: b.moveStr(self.size.x - 3 - len(p.param), p.param, color) self.writeBuf(0, y, self.size.x, 1, b) y += 1 color = self.cNormal self.__frameLine(b, 5, color) self.writeBuf(0, y, self.size.x, 1, b)
def drawMultiBox(self, icon, marker): b = DrawBuffer() cNorm = self.getColor(0x0301) cSel = self.getColor(0x0402) cDis = self.getColor(0x0505) for i in range(self.size.y): b.moveChar(0, ' ', cNorm, self.size.x) for j in range((len(self._strings) - 1) // self.size.y + 1): cur = j * self.size.y + i if cur < len(self._strings): col = self.__column(cur) if col < self.size.x: if not self.buttonState(cur): color = cDis elif (cur == self._sel) and (self.state & sfSelected): color = cSel else: color = cNorm b.moveChar(col, ' ', color, self.size.x - col) b.moveCStr(col, icon, color) b.putChar(col + 2, marker[self.multiMark(cur)]) b.moveCStr(col + 5, self._strings[cur], color) if (self.showMarkers and ((self.state & sfSelected) != 0 and cur == self._sel)): b.putChar(col, SPECIAL_CHARS[0]) b.putChar( self.__column(cur + self.size.y) - 1, SPECIAL_CHARS[1]) self.writeBuf(0, i, self.size.x, 1, b) self.setCursor(self.__column(self._sel) + 2, self.__row(self._sel))
def draw(self): """ Draws the menu bar with the default palette. The `MenuItem.name` and `MenuItem.disabled` data members of each `MenuItem` object in the menu linked list are read to give the menu legends in the correct colors. The current (selected) item is highlighted. """ b = DrawBuffer() cNormal = self.getColor(0x0301) b.moveChar(0, ' ', cNormal, self.size.x) if self.menu and self.menu.items: x = 1 items = (item for item in self.menu.items if item.name) for p in items: nameLen = nameLength(p.name) if x + nameLen < self.size.x: color = self._chooseColor(p) b.moveChar(x, ' ', color, 1) b.moveCStr(x + 1, p.name, color) b.moveChar(x + nameLen + 1, ' ', color, 1) x += (nameLen + 2) self.writeBuf(0, 0, self.size.x, 1, b)
def draw(self): b = DrawBuffer() b.moveCStr(0, self.icon, self.getColor(0x0102)) self.writeLine(0, 0, self.size.x, self.size.y, b)
def draw(self): """ Draws the frame with color attributes and icons appropriate to the current state flags: active, inactive, being dragged. Adds zoom, close and resize icons depending on the owner window's flags. Adds the title, if any, from the owning window's title data member. Active windows are drawn with a double-lined frame and any icons; inactive windows are drawn with a single-lined frame and no icons. """ f = 0 drawable = DrawBuffer() if self.state & sfDragging: cFrame = 0x0505 cTitle = 0x0005 elif not (self.state & sfActive): cFrame = 0x0101 cTitle = 0x0002 else: cFrame = 0x0503 cTitle = 0x0004 f = 9 cFrame = self.getColor(cFrame) cTitle = self.getColor(cTitle) width = self.size.x lineLength = width - 10 if self.owner.flags & (wfClose | wfZoom): lineLength -= 6 self.__frameLine(drawable, 0, f, cFrame & 0xFF) if self.owner.number != wnNoNumber and self.owner.number < 10: lineLength -= 4 if self.owner.flags & wfZoom: i = 7 else: i = 3 drawable.putChar(width - i, chr(self.owner.number + ord('0'))) if self.owner: title = self.owner.getTitle(lineLength) if title: lineLength = min(len(title), width - 10) # min(nameLength(title), width - 10) lineLength = max(lineLength, 0) i = (width - lineLength) >> 1 drawable.putChar(i - 1, ' ') drawable.moveBuf(i, title, cTitle, lineLength) drawable.putChar(i + lineLength, ' ') if self.state & sfActive: if self.owner.flags & wfClose: drawable.moveCStr(2, self.closeIcon, cFrame) if self.owner.flags & wfZoom: minSize = Point() maxSize = Point() self.owner.sizeLimits(minSize, maxSize) if self.owner.size == maxSize: drawable.moveCStr(width - 5, self.unZoomIcon, cFrame) else: drawable.moveCStr(width - 5, self.zoomIcon, cFrame) self.writeLine(0, 0, self.size.x, 1, drawable) for i in range(1, self.size.y - 1): self.__frameLine(drawable, i, f + 3, cFrame) self.writeLine(0, i, self.size.x, 1, drawable) self.__frameLine(drawable, self.size.y - 1, f + 6, cFrame) if self.state & sfActive: if self.owner.flags & wfGrow: drawable.moveCStr(width - 2, self.dragIcon, cFrame) self.writeLine(0, self.size.y - 1, self.size.x, 1, drawable)