Ejemplo n.º 1
0
    def draw(self, force=False):
        if self.hidden:
            return False

        if self.updated or force:
            self.updated = False

            if self.background_color is not None:
                render.fillrect(self.surface, (self.background_color), rect=pygame.Rect((0, 0), self.frame.size))

            for child in self.children:
                if not child.hidden:
                    child.draw(True)
                    self.surface.blit(child.surface, child.frame.topleft)
                    if child.border_color and child.border_widths is not None:
                        if (type(child.border_widths) is int and child.border_widths > 0):
                            pygame.draw.rect(self.surface, child.border_color, child.frame, child.border_widths)
            return True

        else:
            drawn = False

            for child in self.children:
                if not child.hidden:
                    if child.draw():
                        drawn = True
                        self.surface.blit(child.surface, child.frame.topleft)
                        if child.border_color and child.border_widths is not None:
                            if (type(child.border_widths) is int and child.border_widths > 0):
                                pygame.draw.rect(self.surface, child.border_color, child.frame, child.border_widths)

            return drawn
Ejemplo n.º 2
0
    def draw(self):
        if not view.View.draw(self):
            return False

        if not self.vscrollbar.hidden and not self.hscrollbar.hidden:
            hole = pygame.Rect(self.vscrollbar.frame.left,
                               self.vscrollbar.frame.bottom,
                               SCROLLBAR_SIZE,
                               SCROLLBAR_SIZE)
            render.fillrect(self.surface, self.hole_color, hole)

        return True
Ejemplo n.º 3
0
    def draw(self):
        """Do not call directly."""

        if self.hidden:
            return False

        if self.background_color is not None:
            render.fillrect(self.surface,
                            self.background_color,
                            rect=pygame.Rect((0, 0), self.frame.size))

        for child in self.children:
            if not child.hidden:
                child.draw()

                topleft = child.frame.topleft

                if child.shadowed:
                    shadow_size = theme.current.shadow_size
                    shadow_topleft = (topleft[0] - shadow_size // 2,
                                      topleft[1] - shadow_size // 2)
                    self.surface.blit(child.shadow_image, shadow_topleft)

                self.surface.blit(child.surface, topleft)

                if child.border_color and child.border_widths is not None:
                    if (type(child.border_widths) is int
                            and child.border_widths > 0):
                        pygame.draw.rect(self.surface, child.border_color,
                                         child.frame, child.border_widths)
                    else:
                        tw, lw, bw, rw = child.get_border_widths()

                        tl = (child.frame.left, child.frame.top)
                        tr = (child.frame.right - 1, child.frame.top)
                        bl = (child.frame.left, child.frame.bottom - 1)
                        br = (child.frame.right - 1, child.frame.bottom - 1)

                        if tw > 0:
                            pygame.draw.line(self.surface, child.border_color,
                                             tl, tr, tw)
                        if lw > 0:
                            pygame.draw.line(self.surface, child.border_color,
                                             tl, bl, lw)
                        if bw > 0:
                            pygame.draw.line(self.surface, child.border_color,
                                             bl, br, bw)
                        if rw > 0:
                            pygame.draw.line(self.surface, child.border_color,
                                             tr, br, rw)
        return True
Ejemplo n.º 4
0
    def draw(self):
        """Do not call directly."""

        if self.hidden:
            return False

        if self.background_color is not None:
            render.fillrect(self.surface, self.background_color,
                            rect=pygame.Rect((0, 0), self.frame.size))

        for child in self.children:
            if not child.hidden:
                child.draw()

                topleft = child.frame.topleft

                if child.shadowed:
                    shadow_size = theme.current.shadow_size
                    shadow_topleft = (topleft[0] - shadow_size // 2,
                                      topleft[1] - shadow_size // 2)
                    self.surface.blit(child.shadow_image, shadow_topleft)

                self.surface.blit(child.surface, topleft)

                if child.border_color and child.border_widths is not None:
                    if (type(child.border_widths) is int and
                        child.border_widths > 0):
                        pygame.draw.rect(self.surface, child.border_color,
                                         child.frame, child.border_widths)
                    else:
                        tw, lw, bw, rw = child.get_border_widths()

                        tl = (child.frame.left, child.frame.top)
                        tr = (child.frame.right - 1, child.frame.top)
                        bl = (child.frame.left, child.frame.bottom - 1)
                        br = (child.frame.right - 1, child.frame.bottom - 1)

                        if tw > 0:
                            pygame.draw.line(self.surface, child.border_color,
                                             tl, tr, tw)
                        if lw > 0:
                            pygame.draw.line(self.surface, child.border_color,
                                             tl, bl, lw)
                        if bw > 0:
                            pygame.draw.line(self.surface, child.border_color,
                                             bl, br, bw)
                        if rw > 0:
                            pygame.draw.line(self.surface, child.border_color,
                                             tr, br, rw)
        return True
Ejemplo n.º 5
0
    def draw(self, force=False):
        if not view.View.draw(self, force):
            return False

        if self.value_percent > 0:
            t, l, b, r = self.get_border_widths()
            if self.direction == VERTICAL:
                w = self.frame.w - r - l
                h = self.value_percent * self.frame.h - b - t
                y = self.frame.h - b - h
            else:
                y = t
                w = self.value_percent * self.frame.w - r - l
                h = self.frame.h - b - t
            rect = pygame.Rect(l, y, w, h)
            render.fillrect(self.surface, self.value_color, rect=rect, vertical=(self.direction == HORIZONTAL))

        return True
Ejemplo n.º 6
0
    def draw(self):
        if not view.View.draw(self):
            return False

        if self.value_percent > 0:
            t, l, b, r = self.get_border_widths()
            if self.direction == VERTICAL:
                w = self.frame.w - r - l
                h = self.value_percent * self.frame.h - b - t
                y = self.frame.h - b - h
            else:
                y = t
                w = self.value_percent * self.frame.w - r - l
                h = self.frame.h - b - t
            rect = pygame.Rect(l, y, w, h)
            render.fillrect(self.surface,
                            self.value_color,
                            rect=rect,
                            vertical=(self.direction == HORIZONTAL))

        return True