Пример #1
0
    def draw(self, screen):
        screen.fill(self.borderColour, self._getEdgeRect())
        # Make pretty edges:
        setOuterBorder = lambda x, y: min(x + y, 255)
        outerBorder1 = tuple(
            [setOuterBorder(self.borderColour[i], 70) for i in (0, 1, 2)])
        outerBorder2 = tuple(
            [setOuterBorder(self.borderColour[i], 35) for i in (0, 1, 2)])
        pygame.draw.rect(screen, outerBorder1, self._getEdgeRect(), 1)
        if self.borderWidth > 2:
            oldRect = self._getEdgeRect()
            newRect = pygame.rect.Rect(oldRect.left + 1, oldRect.top + 1,
                                       oldRect.width - 2, oldRect.height - 2)
            pygame.draw.rect(screen, outerBorder2, newRect, 1)

        text = self.font.render(self.app, self.caption, True, self.titleColour,
                                self.borderColour)
        if self.subCaption is None:
            height = int(self.font.getLineSize(self.app) * 0.25)
        else:
            height = int(self.font.getLineSize(self.app) * 0.1)
        screen.blit(text, addPositions(self.pos,
                                       (self.borderWidth + 5, height)))
        if self.subCaption is not None:
            subText = self.smallFont.render(self.app, self.subCaption, True,
                                            self.titleColour)
            height = int(self.font.getLineSize(self.app) * 0.8)
            screen.blit(subText,
                        addPositions(self.pos, (self.borderWidth + 5, height)))
Пример #2
0
 def _getUsableRect(self):
     if self.usableRect is not None:
         return self.usableRect
     pt = self._getPt()
     padding = self.styleGet('padding')
     usablePt = addPositions(pt, padding)
     size = self._getSize()
     usableSize = tuple([size[i] - padding[i] * 2 for i in 0, 1])
     self.usableRect = pygame.Rect(usablePt, usableSize)
     return self.usableRect
Пример #3
0
 def _getSize(self):
     if self.size is None:
         return addPositions(
             self.font.size(self.app, self.timeFunction()), (2, 0))
     else:
         return self.size.getSize(self.app)
Пример #4
0
 def _getInsideTopLeftPt(self):
     return addPositions(self.pos,
                         (self.borderWidth, self._getHeaderHeight()))
Пример #5
0
 def __movedBy(self, difference):
     self._setPos(addPositions(difference, self.pos))