Esempio n. 1
0
 def test_moveBuf(self):
     """
     Test Move Buf
     """
     b = DrawBuffer()
     b.moveBuf(0, 'abcdefghijk', 0, 5)
     data = list(b._data[:10])
     result = [ord(c) for c in 'abcde\0\0\0\0\0']
     assert data == result, ("_data is", data, "vs", result)
Esempio n. 2
0
 def draw(self):
     super().draw()
     b = DrawBuffer()
     b.moveBuf(0, self.curMessage, self.getColor(1), len(self.curMessage))
     self.writeBuf(0, 0, len(self.curMessage), 1, b)
Esempio n. 3
0
    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)