def get_item_at_pos (self, position):
        """L.get_item_at_pos (...) -> ListItem

        Gets the item at the passed position coordinates.
        """
        eventarea = self.rect_to_client ()
        if not eventarea.collidepoint (position):
            return None
        position = position[0] - eventarea.left, position[1] - eventarea.top
        
        border = base.GlobalStyle.get_border_size \
                 (self.__class__, self.style,
                  StyleInformation.get ("ACTIVE_BORDER")) * 2

        posy = self.vadjustment
        items = self.scrolledlist.items
        width = eventarea.width
        bottom = eventarea.bottom
        images = self.images
        spacing = self.scrolledlist.spacing

        for item in items:
            rect = Rect (images [item][1])
            rect.y = posy
            rect.width = width + border
            if rect.bottom > bottom:
                rect.height = bottom - rect.bottom + border
            if rect.collidepoint (position):
                return item
            posy += images[item][1].height + spacing + border
        return None
    def __init__ (self, width, scroll):
        ScrollBar.__init__ (self)
        # Minimum size for the two scrolling buttons next to each other
        border = base.GlobalStyle.get_border_size \
                 (self.__class__, self.style,
                  StyleInformation.get ("SCROLLBAR_BORDER")) * 2
        height = StyleInformation.get ("HSCROLLBAR_BUTTON_SIZE")[1] + border
        if width < 2 * height:
            width = 2 * height

        self.lock ()
        self.minsize = (width, height) # Default size.
        self.maximum = scroll
        self.unlock ()
Beispiel #3
0
    def __init__(self, width, scroll):
        ScrollBar.__init__(self)
        # Minimum size for the two scrolling buttons next to each other
        border = base.GlobalStyle.get_border_size \
                 (self.__class__, self.style,
                  StyleInformation.get ("SCROLLBAR_BORDER")) * 2
        height = StyleInformation.get("HSCROLLBAR_BUTTON_SIZE")[1] + border
        if width < 2 * height:
            width = 2 * height

        self.lock()
        self.minsize = (width, height)  # Default size.
        self.maximum = scroll
        self.unlock()
Beispiel #4
0
    def _get_slider_size(self):
        """H._get_slider_size () -> int

        Calculates the size of the slider knob.
        """
        border = base.GlobalStyle.get_border_size \
                 (self.__class__, self.style,
                  StyleInformation.get ("SCROLLBAR_BORDER"))

        # Minimum slider size, if the scrollbar is big enough.
        minsize = 10
        fullsize = self.size[0] - 2 * self.size[1]
        if fullsize == 0:
            # If only the both scrolling buttons can be displayed, we will
            # completely skip the slider.
            return 0

        # Full size.
        fullsize += 2 * border
        slider_width = fullsize
        if self.maximum != 0:
            slider_width = fullsize / (float (self.maximum) + fullsize) * \
                           fullsize
            if slider_width < minsize:
                slider_width = minsize
        return int(slider_width)
Beispiel #5
0
    def dispose_widget(self):
        """W.dispose_widget (...) -> int, int

        Moves the child of the Window to its correct position.
        """
        cls = self.__class__
        style = base.GlobalStyle
        st = self.style or style.get_style(cls)
        border = style.get_border_size(cls, st,
                                       StyleInformation.get("WINDOW_BORDER"))
        dropshadow = style.get_style_entry(cls, st, "shadow")

        width = self.image.get_rect().width
        height = self.image.get_rect().height

        posx = (width - dropshadow - self.child.width) / 2
        posy = self._captionrect.height + \
               (height - self._captionrect.height - self.child.height - \
                dropshadow) / 2
        if self.align & ALIGN_LEFT:
            posx = border + self.padding
        elif self.align & ALIGN_RIGHT:
            posx = width - self.child.width - border - self.padding - \
                   dropshadow
        if self.align & ALIGN_TOP:
            posy = self._captionrect.height + self.padding
        elif self.align & ALIGN_BOTTOM:
            posy = height - self.child.height - border - self.padding - \
                   dropshadow
        return posx, posy
Beispiel #6
0
    def invalidate(self, rect):
        """I.invalidate (...) -> None

        Invalidates a rectangular portion of the ImageMap its picture.

        Invalidates a rectangular portion of the shown image of the
        ImageMap and causes the rendering mechanisms to update that
        region.

        The set IMAGEMAP_BORDER of the StyleInformation settings will be
        taken into account automatically and added to the rect offsets.

        Raises a TypeError, if the passed argument is not a pygame.Rect.
        """
        if type(rect) != Rect:
            raise TypeError("rect must be a pygame.Rect")

        self._lock += 1
        border = base.GlobalStyle.get_border_size \
                 (self.__class__, self.style,
                  StyleInformation.get ("IMAGEMAP_BORDER"))

        x, y = rect.x + border, rect.y + border
        self._image.blit(self.picture, (x, y), rect)
        self._image.set_alpha(self.opacity)
        if self.parent:
            rect.x = x + self.x
            rect.y = y + self.y
            self.parent.update(children={self: rect}, resize=False)
        self._lock -= 1
Beispiel #7
0
    def _get_value_from_coords(self, area, coords):
        """V._get_value_from_coords (...) -> float

        Calculates the slider coordinates for the VScrollBar.
        """
        border = base.GlobalStyle.get_border_size \
                 (self.__class__, self.style,
                  StyleInformation.get ("SCROLLBAR_BORDER"))

        val = 0
        if self.maximum > 0:
            slider = self._get_slider_size()

            # Start offset for scrolling - this is the width
            # (button + 2 * border) - border plus the half of the
            # slider.
            sl_y = self.minsize[0] - border + float(slider) / 2

            # Valid sliding range.
            slide = self.minsize[1] - 2 * sl_y

            n = coords[1] - area.top - sl_y
            step = self.maximum / float(slide)
            val = n * step
            if val > self.maximum:
                val = self.maximum
            elif val < 0:
                val = 0
        return val
Beispiel #8
0
    def get_item_at_pos(self, position):
        """L.get_item_at_pos (...) -> ListItem

        Gets the item at the passed position coordinates.
        """
        eventarea = self.rect_to_client()
        if not eventarea.collidepoint(position):
            return None
        position = position[0] - eventarea.left, position[1] - eventarea.top

        border = base.GlobalStyle.get_border_size \
                 (self.__class__, self.style,
                  StyleInformation.get ("ACTIVE_BORDER")) * 2

        posy = self.vadjustment
        items = self.scrolledlist.items
        width = eventarea.width
        bottom = eventarea.bottom
        images = self.images
        spacing = self.scrolledlist.spacing

        for item in items:
            rect = Rect(images[item][1])
            rect.y = posy
            rect.width = width + border
            if rect.bottom > bottom:
                rect.height = bottom - rect.bottom + border
            if rect.collidepoint(position):
                return item
            posy += images[item][1].height + spacing + border
        return None
    def _get_slider_size (self):
        """H._get_slider_size () -> int

        Calculates the size of the slider knob.
        """
        border = base.GlobalStyle.get_border_size \
                 (self.__class__, self.style,
                  StyleInformation.get ("SCROLLBAR_BORDER"))
        
        # Minimum slider size, if the scrollbar is big enough.
        minsize = 10
        fullsize = self.size[0] - 2 * self.size[1]
        if fullsize == 0:
            # If only the both scrolling buttons can be displayed, we will
            # completely skip the slider.
            return 0

        # Full size.
        fullsize += 2 * border
        slider_width = fullsize
        if self.maximum != 0:
            slider_width = fullsize / (float (self.maximum) + fullsize) * \
                           fullsize
            if slider_width < minsize:
                slider_width = minsize
        return int (slider_width)
Beispiel #10
0
    def invalidate (self, rect):
        """I.invalidate (...) -> None

        Invalidates a rectangular portion of the ImageMap its picture.

        Invalidates a rectangular portion of the shown image of the
        ImageMap and causes the rendering mechanisms to update that
        region.

        The set IMAGEMAP_BORDER of the StyleInformation settings will be
        taken into account automatically and added to the rect offsets.

        Raises a TypeError, if the passed argument is not a pygame.Rect.
        """
        if type (rect) != Rect:
            raise TypeError ("rect must be a pygame.Rect")

        self._lock += 1
        border = base.GlobalStyle.get_border_size \
                 (self.__class__, self.style,
                  StyleInformation.get ("IMAGEMAP_BORDER"))

        x, y = rect.x + border, rect.y + border
        self._image.blit (self.picture, (x, y), rect)
        self._image.set_alpha (self.opacity)
        if self.parent:
            rect.x = x + self.x
            rect.y = y + self.y
            self.parent.update (children={ self : rect }, resize=False)
        self._lock -= 1
Beispiel #11
0
    def _get_value_from_coords (self, area, coords):
        """V._get_value_from_coords (...) -> float

        Calculates the float value of the VScale.

        Calculates the float value of the VScale from the passed
        absolute coordinates tuple relative to the area.
        """
        # We need this for a proper calculation.
        slider = StyleInformation.get ("VSCALE_SLIDER_SIZE")
        
        # The slide range, in which the slider can move.
        slide = self.height - slider[1]

        # Calculate the absolute current position
        n = coords[1] - area.top - slider[1] / 2.0

        # Step range in dependance of the width and value range of the
        # Scale.
        step = (self.maximum - self.minimum) / float (slide)

        # Calculate it.
        val = self.minimum + step * n
        if val > self.maximum:
            val = self.maximum
        elif val < self.minimum:
            val = self.minimum
        return val
Beispiel #12
0
    def dispose_widget (self):
        """W.dispose_widget (...) -> int, int

        Moves the child of the Window to its correct position.
        """
        cls = self.__class__
        style = base.GlobalStyle
        st = self.style or style.get_style (cls)
        border = style.get_border_size (cls, st,
                                        StyleInformation.get ("WINDOW_BORDER"))
        dropshadow = style.get_style_entry (cls, st, "shadow")
        
        width = self.image.get_rect ().width
        height = self.image.get_rect ().height
        
        posx = (width - dropshadow - self.child.width) / 2
        posy = self._captionrect.height + \
               (height - self._captionrect.height - self.child.height - \
                dropshadow) / 2
        if self.align & ALIGN_LEFT:
            posx = border + self.padding
        elif self.align & ALIGN_RIGHT:
            posx = width - self.child.width - border - self.padding - \
                   dropshadow
        if self.align & ALIGN_TOP:
            posy = self._captionrect.height + self.padding
        elif self.align & ALIGN_BOTTOM:
            posy = height - self.child.height - border - self.padding - \
                   dropshadow
        return posx, posy
Beispiel #13
0
    def draw (self):
        """I.draw () -> None

        Draws the ImageButton surface and places its picture and Label on it.
        """
        ButtonBase.draw (self)

        spacing = StyleInformation.get ("IMAGEBUTTON_SPACING")
        rect_img = None
        rect_child = None
        rect = self.image.get_rect ()
        
        if self.picture:
            rect_img = self.picture.get_rect ()
            rect_img.center = rect.center
            if self.child:
                rect_img.right -= (self.child.width / 2 + spacing)
            rect_img.centery = rect.centery
            self.image.blit (self.picture, rect_img)
        
        if self.child:
            self.child.center = rect.center
            if self.picture:
                self.child.left = rect_img.right + spacing
            rect_child = self.child.rect
            self.image.blit (self.child.image, rect_child)
Beispiel #14
0
    def rect_to_client(self, rect=None):
        """V.rect_to_client () -> pygame.Rect

        Returns the absolute coordinates a rect is located at.

        If a rect argument is passed, its size and position are modified
        to match the criteria of the scrolling adjustments of the
        ViewPort. Besides that it exactly behaves like the original
        rect_to_client() method.
        """
        if rect:
            border = base.GlobalStyle.get_border_size \
                     (self.__class__, self.style,
                      StyleInformation.get ("VIEWPORT_BORDER"))
            rect.x = self.x + rect.x
            rect.y = self.y + rect.y
            if rect.right > self.right - border:
                rect.width = self.right - border - rect.left
            if rect.bottom > self.bottom - border:
                rect.height = self.bottom - border - rect.top

            if (self.parent != None) and isinstance(self.parent, BaseWidget):
                return self.parent.rect_to_client(rect)
            return rect
        return Bin.rect_to_client(self)
Beispiel #15
0
    def calculate_size(self):
        """S.calculate_size () -> int, int.

        Calculates the size needed by the children.

        Calculates the size needed by the children and returns the
        resulting width and height.
        """
        border = base.GlobalStyle.get_border_size \
                 (self.__class__, self.style,
                  StyleInformation.get ("STATUSBAR_BORDER"))
        width = 2 * (border + self.padding)
        height = 0
        spacing = self.spacing

        for widget in self.children:
            width += widget.width + spacing
            if widget.height > height:
                height = widget.height
        height += 2 * (border + self.padding)

        # Add width for the tips and date.
        if self.tips:
            width += self.tip_width
            if self.date:
                width += self.spacing
        if self.date:
            width += self.date_width
        if not self.tips and not self.date:
            width -= self.spacing

        return width, height
Beispiel #16
0
    def _get_value_from_coords(self, area, coords):
        """V._get_value_from_coords (...) -> float

        Calculates the float value of the VScale.

        Calculates the float value of the VScale from the passed
        absolute coordinates tuple relative to the area.
        """
        # We need this for a proper calculation.
        slider = StyleInformation.get("VSCALE_SLIDER_SIZE")

        # The slide range, in which the slider can move.
        slide = self.height - slider[1]

        # Calculate the absolute current position
        n = coords[1] - area.top - slider[1] / 2.0

        # Step range in dependance of the width and value range of the
        # Scale.
        step = (self.maximum - self.minimum) / float(slide)

        # Calculate it.
        val = self.minimum + step * n
        if val > self.maximum:
            val = self.maximum
        elif val < self.minimum:
            val = self.minimum
        return val
    def calculate_size (self):
        """S.calculate_size () -> int, int.

        Calculates the size needed by the children.

        Calculates the size needed by the children and returns the
        resulting width and height.
        """
        border = base.GlobalStyle.get_border_size \
                 (self.__class__, self.style,
                  StyleInformation.get ("STATUSBAR_BORDER"))
        width = 2 * (border + self.padding)
        height = 0
        spacing = self.spacing
        
        for widget in self.children:
            width += widget.width + spacing
            if widget.height > height:
                height = widget.height
        height += 2 * (border + self.padding)

        # Add width for the tips and date.
        if self.tips:
            width += self.tip_width
            if self.date:
                width += self.spacing
        if self.date:
            width += self.date_width
        if not self.tips and not self.date:
            width -= self.spacing

        return width, height
    def _get_value_from_coords (self, area, coords):
        """V._get_value_from_coords (...) -> float

        Calculates the slider coordinates for the VScrollBar.
        """
        border = base.GlobalStyle.get_border_size \
                 (self.__class__, self.style,
                  StyleInformation.get ("SCROLLBAR_BORDER"))

        val = 0
        if self.maximum > 0:
            slider = self._get_slider_size ()

            # Start offset for scrolling - this is the width
            # (button + 2 * border) - border plus the half of the
            # slider.
            sl_y = self.minsize[0] - border + float (slider) / 2

            # Valid sliding range.
            slide = self.minsize[1] - 2 * sl_y
            
            n = coords[1] - area.top - sl_y
            step = self.maximum / float (slide)
            val = n * step
            if val > self.maximum:
                val = self.maximum
            elif val < 0:
                val = 0
        return val
Beispiel #19
0
    def rect_to_client (self, rect=None):
        """V.rect_to_client () -> pygame.Rect

        Returns the absolute coordinates a rect is located at.

        If a rect argument is passed, its size and position are modified
        to match the criteria of the scrolling adjustments of the
        ViewPort. Besides that it exactly behaves like the original
        rect_to_client() method.
        """
        if rect:
            border = base.GlobalStyle.get_border_size \
                     (self.__class__, self.style,
                      StyleInformation.get ("VIEWPORT_BORDER"))
            rect.x = self.x + rect.x
            rect.y = self.y + rect.y
            if rect.right > self.right - border:
                rect.width = self.right - border - rect.left
            if rect.bottom > self.bottom - border:
                rect.height = self.bottom - border - rect.top

            if (self.parent != None) and isinstance (self.parent, BaseWidget):
                return self.parent.rect_to_client (rect)
            return rect
        return Bin.rect_to_client (self)
Beispiel #20
0
    def draw(self):
        """C.draw () -> None

        Draws the RadioButton surface.

        Creates the visible surface of the RadioButton and places a
        radio check and its Label on it.
        """
        border_active = base.GlobalStyle.get_border_size \
                        (self.__class__, self.style,
                         StyleInformation.get ("ACTIVE_BORDER"))
        ButtonBase.draw(self)
        if self.child:
            self.child.centery = self.image.get_rect().centery
            self.child.x = self.padding + border_active + \
                           StyleInformation.get ("RADIO_SPACING") + \
                           StyleInformation.get ("RADIO_SIZE")
            self.image.blit(self.child.image, self.child.rect)
    def draw (self):
        """C.draw () -> None

        Draws the RadioButton surface.

        Creates the visible surface of the RadioButton and places a
        radio check and its Label on it.
        """
        border_active = base.GlobalStyle.get_border_size \
                        (self.__class__, self.style,
                         StyleInformation.get ("ACTIVE_BORDER"))
        ButtonBase.draw (self)
        if self.child:
            self.child.centery = self.image.get_rect ().centery
            self.child.x = self.padding + border_active + \
                           StyleInformation.get ("RADIO_SPACING") + \
                           StyleInformation.get ("RADIO_SIZE")
            self.image.blit (self.child.image, self.child.rect)
    def get_item_position (self, item):
        """L.get_item_position (...) -> int, int

        Gets the relative position coordinates of an item.
        """
        y = 0
        items = self.scrolledlist.items
        active = base.GlobalStyle.get_border_size \
                 (self.__class__, self.style,
                  StyleInformation.get ("ACTIVE_BORDER")) * 2
        spacing = self.scrolledlist.spacing
        border = base.GlobalStyle.get_border_size \
                 (self.__class__, self.style,
                  StyleInformation.get ("VIEWPORT_BORDER"))

        for it in items:
            if it == item:
                break
            y += self._images[item][1].height + spacing + active
        return self.left + border, self.top + y + border
Beispiel #23
0
    def get_item_position(self, item):
        """L.get_item_position (...) -> int, int

        Gets the relative position coordinates of an item.
        """
        y = 0
        items = self.scrolledlist.items
        active = base.GlobalStyle.get_border_size \
                 (self.__class__, self.style,
                  StyleInformation.get ("ACTIVE_BORDER")) * 2
        spacing = self.scrolledlist.spacing
        border = base.GlobalStyle.get_border_size \
                 (self.__class__, self.style,
                  StyleInformation.get ("VIEWPORT_BORDER"))

        for it in items:
            if it == item:
                break
            y += self._images[item][1].height + spacing + active
        return self.left + border, self.top + y + border
Beispiel #24
0
    def _get_button_coords(self, area):
        """H._get_button_coords (...) -> tuple

        Gets a tuple with the coordinates of the in- and decrease buttons.
        """
        border = base.GlobalStyle.get_border_size \
                 (self.__class__, self.style,
                  StyleInformation.get ("SCROLLBAR_BORDER"))
        # Respect the set shadow for the ScrollBar.
        button1 = (area.left + border, area.top + border,
                   area.height - 2 * border, area.height - 2 * border)
        button2 = (area.left + area.width - area.height - border,
                   area.top + border, area.height - 2 * border,
                   area.height - 2 * border)
        return (button1, button2)
    def _get_button_coords (self, area):
        """H._get_button_coords (...) -> tuple

        Gets a tuple with the coordinates of the in- and decrease buttons.
        """
        border = base.GlobalStyle.get_border_size \
                 (self.__class__, self.style,
                  StyleInformation.get ("SCROLLBAR_BORDER"))
        # Respect the set shadow for the ScrollBar.
        button1 = (area.left + border, area.top + border,
                   area.height - 2 * border, area.height - 2 * border)
        button2 = (area.left + area.width - area.height - border,
                   area.top + border, area.height - 2 * border,
                   area.height - 2 * border)
        return (button1, button2)
Beispiel #26
0
    def draw (self):
        """V.draw () -> None

        Draws the ViewPort surface and places its child on it.
        """
        border = base.GlobalStyle.get_border_size \
                 (self.__class__, self.style,
                  StyleInformation.get ("VIEWPORT_BORDER"))
        Bin.draw (self)

        if self.child:
            self.child.topleft = border + self.hadjustment, \
                                 border + self.vadjustment
            self.image.blit (self.child.image, (border, border),
                             (abs (self.hadjustment), abs (self.vadjustment),
                              self.width - 2 * border,
                              self.height - 2 * border))
Beispiel #27
0
    def draw(self):
        """V.draw () -> None

        Draws the ViewPort surface and places its child on it.
        """
        border = base.GlobalStyle.get_border_size \
                 (self.__class__, self.style,
                  StyleInformation.get ("VIEWPORT_BORDER"))
        Bin.draw(self)

        if self.child:
            self.child.topleft = border + self.hadjustment, \
                                 border + self.vadjustment
            self.image.blit(
                self.child.image, (border, border),
                (abs(self.hadjustment), abs(self.vadjustment),
                 self.width - 2 * border, self.height - 2 * border))
Beispiel #28
0
    def _get_coords_from_value(self):
        """V._get_coords_from_value () -> int

        Calculates the slider coordinates for the VScrollBar.
        """
        border = base.GlobalStyle.get_border_size \
                 (self.__class__, self.style,
                  StyleInformation.get ("SCROLLBAR_BORDER"))

        val = 0
        if self.maximum > 0:
            slider = self._get_slider_size()
            sl_y = self.minsize[0] - border + float(slider) / 2
            slide = self.minsize[1] - 2 * sl_y
            step = self.maximum / float(slide)
            val = self.value / step + sl_y
            return val
        return self.size[1] / 2
    def _get_coords_from_value (self):
        """V._get_coords_from_value () -> int

        Calculates the slider coordinates for the VScrollBar.
        """
        border = base.GlobalStyle.get_border_size \
                 (self.__class__, self.style,
                  StyleInformation.get ("SCROLLBAR_BORDER"))
        
        val = 0
        if self.maximum > 0:
            slider = self._get_slider_size ()
            sl_y = self.minsize[0] - border + float (slider) / 2
            slide = self.minsize[1] - 2 * sl_y
            step = self.maximum / float (slide)
            val = self.value / step + sl_y
            return val
        return self.size[1] / 2
Beispiel #30
0
    def _get_relative_position(self):
        """I._get_relative_position () -> int, int

        Gets the last relative position of the mouse on the ImageMap
        (absolute position on it).

        If the last position could not be determined -1, -1 will be
        returned instead.
        """
        if self.last_event:
            border = base.GlobalStyle.get_border_size \
                     (self.__class__, self.style,
                      StyleInformation.get ("IMAGEMAP_BORDER"))
            area = self.rect_to_client()

            return self.last_event.data.pos[0] - border - area.x, \
                   self.last_event.data.pos[1] - border - area.y
        return -1, -1
Beispiel #31
0
    def _get_relative_position (self):
        """I._get_relative_position () -> int, int

        Gets the last relative position of the mouse on the ImageMap
        (absolute position on it).

        If the last position could not be determined -1, -1 will be
        returned instead.
        """
        if self.last_event:
            border = base.GlobalStyle.get_border_size \
                     (self.__class__, self.style,
                      StyleInformation.get ("IMAGEMAP_BORDER"))
            area = self.rect_to_client ()
            
            return self.last_event.data.pos[0] - border - area.x, \
                   self.last_event.data.pos[1] - border - area.y
        return -1, -1
Beispiel #32
0
    def update (self, **kwargs):
        """V.update (...) -> None

        Updates the ViewPort.

        Updates the ViewPort and causes its parent to update itself on
        demand.
        """
        if not self.dirty:
            border = base.GlobalStyle.get_border_size \
                     (self.__class__, self.style,
                      StyleInformation.get ("VIEWPORT_BORDER"))
            resize = kwargs.get ("resize", False)

            children = kwargs.get ("children", {})
            blit = self.image.blit
            items = children.items ()

            # Clean up the dirty areas on the widget.
            vals = []
            for child, rect in items:
                blit (self._bg, rect, rect)

                # r will be the area for the blit.
                r = Rect (abs (self.hadjustment), abs (self.vadjustment),
                          self.width - 2 * border, self.height - 2 * border)
                blit (child.image, (border, border), r)
                vals.append (r)

            # If a parent's available, reassign the child rects, so that
            # they point to the absolute position on the widget and build
            # one matching them all for an update.
            if self.parent:
                rect = Rect (self._oldrect)
                if len (vals) != 0:
                    for r in vals:
                        r.x += self.x
                        r.y += self.y
                    rect.unionall (vals[1:])
                self.parent.update (children={ self : rect }, resize=resize)
            self._lock = max (self._lock - 1, 0)
        else:
            Bin.update (self, **kwargs)
Beispiel #33
0
    def update(self, **kwargs):
        """V.update (...) -> None

        Updates the ViewPort.

        Updates the ViewPort and causes its parent to update itself on
        demand.
        """
        if not self.dirty:
            border = base.GlobalStyle.get_border_size \
                     (self.__class__, self.style,
                      StyleInformation.get ("VIEWPORT_BORDER"))
            resize = kwargs.get("resize", False)

            children = kwargs.get("children", {})
            blit = self.image.blit
            items = children.items()

            # Clean up the dirty areas on the widget.
            vals = []
            for child, rect in items:
                blit(self._bg, rect, rect)

                # r will be the area for the blit.
                r = Rect(abs(self.hadjustment), abs(self.vadjustment),
                         self.width - 2 * border, self.height - 2 * border)
                blit(child.image, (border, border), r)
                vals.append(r)

            # If a parent's available, reassign the child rects, so that
            # they point to the absolute position on the widget and build
            # one matching them all for an update.
            if self.parent:
                rect = Rect(self._oldrect)
                if len(vals) != 0:
                    for r in vals:
                        r.x += self.x
                        r.y += self.y
                    rect.unionall(vals[1:])
                self.parent.update(children={self: rect}, resize=resize)
            self._lock = max(self._lock - 1, 0)
        else:
            Bin.update(self, **kwargs)
    def dispose_widgets (self):
        """S.dispose_widgets (...) -> None
        
        Moves the children of the StatusBar to their correct positions.
        """
        
        border = base.GlobalStyle.get_border_size \
                 (self.__class__, self.style,
                  StyleInformation.get ("STATUSBAR_BORDER"))
        padding = self.padding
        spacing = self.spacing
        diff = (self.height - 2 * (border + padding)) / 2

        x = self._xoffset
        addy = border + padding + diff
        
        for widget in self.children:
            y = border + padding + diff - widget.height / 2
            y = addy - widget.height / 2
            widget.topleft = (x, y)
            x += widget.width + spacing
Beispiel #35
0
    def dispose_widgets(self):
        """S.dispose_widgets (...) -> None
        
        Moves the children of the StatusBar to their correct positions.
        """

        border = base.GlobalStyle.get_border_size \
                 (self.__class__, self.style,
                  StyleInformation.get ("STATUSBAR_BORDER"))
        padding = self.padding
        spacing = self.spacing
        diff = (self.height - 2 * (border + padding)) / 2

        x = self._xoffset
        addy = border + padding + diff

        for widget in self.children:
            y = border + padding + diff - widget.height / 2
            y = addy - widget.height / 2
            widget.topleft = (x, y)
            x += widget.width + spacing
    def draw (self):
        """S.draw () -> None

        Draws the StatusBar surface and places its children on it.
        """
        Container.draw (self)

        cls = self.__class__
        style = base.GlobalStyle
        border = style.get_border_size \
                 (cls, self.style, StyleInformation.get ("STATUSBAR_BORDER"))
        blit = self.image.blit
        rect = self.image.get_rect()
        
        self._xoffset = self.padding + border
        # Draw the current tip.
        if self.tips:
            surface_tip = style.engine.draw_string (self.current_tip,
                                                    self.state, cls,
                                                    self.style)
            r = surface_tip.get_rect ()
            r.x = self._xoffset
            r.centery = rect.centery
            blit (surface_tip, r, (0, 0, self.tip_width, r.height))
            self._xoffset += self.tip_width + self.spacing

        # Place the children of the StatusBar and blit them.
        self.dispose_widgets ()
        for widget in self.children:
            blit (widget.image, widget.rect)

        # Draw the date.
        if self.date:
            surface_date = style.engine.draw_string (self.current_date,
                                                     self.state, cls,
                                                     self.style)
            r = surface_date.get_rect ()
            r.right = rect.right - border - self.padding
            r.centery = rect.centery
            blit (surface_date, r, (0, 0, self._datewidth, r.height))
    def _get_value_from_coords (self, area, coords):
        """H._get_value_from_coords (...) -> float

        Calculates the slider coordinates for the HScrollBar.
        """
        border = base.GlobalStyle.get_border_size \
                 (self.__class__, self.style,
                  StyleInformation.get ("SCROLLBAR_BORDER"))

        val = 0
        if self.maximum > 0:
            slider = self._get_slider_size ()
            sl_x = self.minsize[1] - border + float (slider) / 2
            slide = self.minsize[0] - 2 * sl_x
            n = coords[0] - area.left - sl_x
            step = self.maximum / float (slide)
            val = n * step
            if val > self.maximum:
                val = self.maximum
            elif val < 0:
                val = 0
        return val
Beispiel #38
0
    def _get_coords_from_value (self):
        """V.get_coords_from_value () -> float

        Calculates the coordinates from the current value of the VScale.

        Calculates the relative coordinates on the VScale from the
        current value.
        """
        # We need this for a proper calculation.
        slider = StyleInformation.get ("VSCALE_SLIDER_SIZE")
        height = self.height
        
        # The slide range in which the slider can move.
        slide = height - slider[1]

        # Step range in dependance of the width and value range of the
        # Scale.
        step = (self.maximum - self.minimum) / float (slide)

        # Calculate the value
        val  = (self.value - self.minimum) / step + slider[1] / 2.0
        return val
Beispiel #39
0
    def _get_value_from_coords(self, area, coords):
        """H._get_value_from_coords (...) -> float

        Calculates the slider coordinates for the HScrollBar.
        """
        border = base.GlobalStyle.get_border_size \
                 (self.__class__, self.style,
                  StyleInformation.get ("SCROLLBAR_BORDER"))

        val = 0
        if self.maximum > 0:
            slider = self._get_slider_size()
            sl_x = self.minsize[1] - border + float(slider) / 2
            slide = self.minsize[0] - 2 * sl_x
            n = coords[0] - area.left - sl_x
            step = self.maximum / float(slide)
            val = n * step
            if val > self.maximum:
                val = self.maximum
            elif val < 0:
                val = 0
        return val
Beispiel #40
0
    def _get_coords_from_value(self):
        """V.get_coords_from_value () -> float

        Calculates the coordinates from the current value of the VScale.

        Calculates the relative coordinates on the VScale from the
        current value.
        """
        # We need this for a proper calculation.
        slider = StyleInformation.get("VSCALE_SLIDER_SIZE")
        height = self.height

        # The slide range in which the slider can move.
        slide = height - slider[1]

        # Step range in dependance of the width and value range of the
        # Scale.
        step = (self.maximum - self.minimum) / float(slide)

        # Calculate the value
        val = (self.value - self.minimum) / step + slider[1] / 2.0
        return val
Beispiel #41
0
    def draw(self):
        """S.draw () -> None

        Draws the StatusBar surface and places its children on it.
        """
        Container.draw(self)

        cls = self.__class__
        style = base.GlobalStyle
        border = style.get_border_size \
                 (cls, self.style, StyleInformation.get ("STATUSBAR_BORDER"))
        blit = self.image.blit
        rect = self.image.get_rect()

        self._xoffset = self.padding + border
        # Draw the current tip.
        if self.tips:
            surface_tip = style.engine.draw_string(self.current_tip,
                                                   self.state, cls, self.style)
            r = surface_tip.get_rect()
            r.x = self._xoffset
            r.centery = rect.centery
            blit(surface_tip, r, (0, 0, self.tip_width, r.height))
            self._xoffset += self.tip_width + self.spacing

        # Place the children of the StatusBar and blit them.
        self.dispose_widgets()
        for widget in self.children:
            blit(widget.image, widget.rect)

        # Draw the date.
        if self.date:
            surface_date = style.engine.draw_string(self.current_date,
                                                    self.state, cls,
                                                    self.style)
            r = surface_date.get_rect()
            r.right = rect.right - border - self.padding
            r.centery = rect.centery
            blit(surface_date, r, (0, 0, self._datewidth, r.height))
    def _get_coords_from_value (self):
        """H._get_coords_from_value () -> int

        Calculates the slider coordinates for the HScrollBar.
        """
        border = base.GlobalStyle.get_border_size \
                 (self.__class__, self.style,
                  StyleInformation.get ("SCROLLBAR_BORDER"))

        val = 0
        if self.maximum > 0:
            slider = self._get_slider_size ()
            # Start offset for scrolling - this is the height
            # (button + 2 * border) - border plus the half of the
            # slider.
            sl_x = self.minsize[1] - border + float (slider) / 2

            # Valid sliding range.
            slide = self.minsize[0] - 2 * sl_x
            step = self.maximum / float (slide)
            val = self.value / step + sl_x
            return val
        return self.size[0] / 2
Beispiel #43
0
    def _get_coords_from_value(self):
        """H._get_coords_from_value () -> int

        Calculates the slider coordinates for the HScrollBar.
        """
        border = base.GlobalStyle.get_border_size \
                 (self.__class__, self.style,
                  StyleInformation.get ("SCROLLBAR_BORDER"))

        val = 0
        if self.maximum > 0:
            slider = self._get_slider_size()
            # Start offset for scrolling - this is the height
            # (button + 2 * border) - border plus the half of the
            # slider.
            sl_x = self.minsize[1] - border + float(slider) / 2

            # Valid sliding range.
            slide = self.minsize[0] - 2 * sl_x
            step = self.maximum / float(slide)
            val = self.value / step + sl_x
            return val
        return self.size[0] / 2
Beispiel #44
0
    def draw (self):
        """V.draw () -> None

        Draws the VScale surface and its slider.
        """
        Scale.draw (self)
        cls = self.__class__
        style = base.GlobalStyle
        border = style.get_border_size (cls, self.style,
                                        StyleInformation.get ("SCALE_BORDER"))
        active = StyleInformation.get ("ACTIVE_BORDER")
        border_active = style.get_border_size (cls, self.style, active)
        slider = StyleInformation.get ("VSCALE_SLIDER_SIZE")

        # Creates the slider surface.
        sf_slider = style.engine.draw_slider (slider[0], slider[1], self.state,
                                              cls, self.style)
        rect_slider = sf_slider.get_rect ()

        # Dashed border.
        if self.focus:
            b = border + border_active
            r = Rect (b, b, rect_slider.width - 2 * b,
                      rect_slider.height - 2 * b)
            style.engine.draw_border \
                            (sf_slider, self.state, cls, self.style, active, r,
                             StyleInformation.get ("ACTIVE_BORDER_SPACE"))

        size = self.width / 3 - 2 * border, self.height - 2 * border

        # Fill the scale line.
        sf_fill = Draw.draw_rect (size[0], size[1],
                                  StyleInformation.get ("SCALE_COLOR"))
        self.image.blit (sf_fill, (self.width / 3 + border, border))

        # Blit slider at the correct position.
        rect_slider.centerx = self.image.get_rect ().centerx
        rect_slider.centery = self._get_coords_from_value ()
        self.image.blit (sf_slider, rect_slider)

        # Fill until the slider start.
        if rect_slider.y > 0:
            sf_fill = Draw.draw_rect (size[0], rect_slider.y - border,
                                      StyleInformation.get ("PROGRESS_COLOR"))
            self.image.blit (sf_fill, (self.width / 3 + border, border))
Beispiel #45
0
    def draw(self):
        """V.draw () -> None

        Draws the VScale surface and its slider.
        """
        Scale.draw(self)
        cls = self.__class__
        style = base.GlobalStyle
        border = style.get_border_size(cls, self.style,
                                       StyleInformation.get("SCALE_BORDER"))
        active = StyleInformation.get("ACTIVE_BORDER")
        border_active = style.get_border_size(cls, self.style, active)
        slider = StyleInformation.get("VSCALE_SLIDER_SIZE")

        # Creates the slider surface.
        sf_slider = style.engine.draw_slider(slider[0], slider[1], self.state,
                                             cls, self.style)
        rect_slider = sf_slider.get_rect()

        # Dashed border.
        if self.focus:
            b = border + border_active
            r = Rect(b, b, rect_slider.width - 2 * b,
                     rect_slider.height - 2 * b)
            style.engine.draw_border \
                            (sf_slider, self.state, cls, self.style, active, r,
                             StyleInformation.get ("ACTIVE_BORDER_SPACE"))

        size = self.width / 3 - 2 * border, self.height - 2 * border

        # Fill the scale line.
        sf_fill = Draw.draw_rect(size[0], size[1],
                                 StyleInformation.get("SCALE_COLOR"))
        self.image.blit(sf_fill, (self.width / 3 + border, border))

        # Blit slider at the correct position.
        rect_slider.centerx = self.image.get_rect().centerx
        rect_slider.centery = self._get_coords_from_value()
        self.image.blit(sf_slider, rect_slider)

        # Fill until the slider start.
        if rect_slider.y > 0:
            sf_fill = Draw.draw_rect(size[0], rect_slider.y - border,
                                     StyleInformation.get("PROGRESS_COLOR"))
            self.image.blit(sf_fill, (self.width / 3 + border, border))
    def update_items (self):
        """L.update_items () -> None

        Updates the attached items of the ScrolledList.
        """
        draw_item = self.draw_item
        spacing = self.scrolledlist.spacing
        width, height = 0, 0
        items = self.scrolledlist.items
        engine = base.GlobalStyle.engine
        border = base.GlobalStyle.get_border_size \
                     (self.__class__, self.style,
                      StyleInformation.get ("ACTIVE_BORDER")) * 2

        for item in items:
            if item.dirty:
                item.dirty = False
                rect = draw_item (item, engine)[1]
            else:
                rect = self._images[item][1]
            if width < rect.width:
                width = rect.width
            height += rect.height + spacing + border

        # The last item does not need any spacing.
        if height > 0:
            height -= spacing

        # Set the step value of the attached scrolledlist.
        step = 1
        if items.length > 0:
            step = height / items.length + spacing / 2
        self.scrolledlist.vscrollbar.step = step

        self._realwidth = width + border
        self._realheight = height
        self.dirty = True
Beispiel #47
0
    def update_items(self):
        """L.update_items () -> None

        Updates the attached items of the ScrolledList.
        """
        draw_item = self.draw_item
        spacing = self.scrolledlist.spacing
        width, height = 0, 0
        items = self.scrolledlist.items
        engine = base.GlobalStyle.engine
        border = base.GlobalStyle.get_border_size \
                     (self.__class__, self.style,
                      StyleInformation.get ("ACTIVE_BORDER")) * 2

        for item in items:
            if item.dirty:
                item.dirty = False
                rect = draw_item(item, engine)[1]
            else:
                rect = self._images[item][1]
            if width < rect.width:
                width = rect.width
            height += rect.height + spacing + border

        # The last item does not need any spacing.
        if height > 0:
            height -= spacing

        # Set the step value of the attached scrolledlist.
        step = 1
        if items.length > 0:
            step = height / items.length + spacing / 2
        self.scrolledlist.vscrollbar.step = step

        self._realwidth = width + border
        self._realheight = height
        self.dirty = True
Beispiel #48
0
    def _scroll_to_cursor(self):
        """S._scroll_to_cursor () -> None

        Scrolls the list to the cursor.
        """
        if not self.cursor or not self.child.images.has_key(self.cursor):
            return

        border = base.GlobalStyle.get_border_size \
                     (self.child.__class__, self.child.style,
                      StyleInformation.get ("ACTIVE_BORDER")) * 2

        x, y = self.child.get_item_position(self.cursor)
        w, h = self.child.width, self.child.height
        height = self.child.images[self.cursor][1].height + border + \
                 self.spacing
        # Bottom edge of the item.
        py = y + height

        if (self.vscrollbar.value - y > 0):  # Scrolling up.
            self.vscrollbar.value = max(0, y - border)
        elif (py > self.vscrollbar.value + h):
            self.vscrollbar.value = min(abs(py - h + border),
                                        self.vscrollbar.maximum)
    def _scroll_to_cursor (self):
        """S._scroll_to_cursor () -> None

        Scrolls the list to the cursor.
        """
        if not self.cursor or not self.child.images.has_key (self.cursor):
            return

        border = base.GlobalStyle.get_border_size \
                     (self.child.__class__, self.child.style,
                      StyleInformation.get ("ACTIVE_BORDER")) * 2

        x, y = self.child.get_item_position (self.cursor)
        w, h = self.child.width, self.child.height
        height = self.child.images[self.cursor][1].height + border + \
                 self.spacing
        # Bottom edge of the item.
        py = y + height

        if (self.vscrollbar.value - y > 0): # Scrolling up.
            self.vscrollbar.value = max (0, y - border)
        elif (py > self.vscrollbar.value + h):
            self.vscrollbar.value = min (abs (py - h + border),
                                         self.vscrollbar.maximum)
Beispiel #50
0
    def draw(self):
        """L.draw () -> None

        Draws the ListViewPort surface and places its items on it.
        """
        Bin.draw(self)
        style = base.GlobalStyle
        cls = self.__class__
        color = StyleInformation.get("SELECTION_COLOR")
        active = StyleInformation.get("ACTIVE_BORDER")
        border_active = style.get_border_size(cls, self.style, active)
        border = style.get_border_size \
                 (cls, self.style, StyleInformation.get ("VIEWPORT_BORDER"))
        active_space = StyleInformation.get("ACTIVE_BORDER_SPACE")
        st = self.style
        state = self.state
        realwidth = self.real_width

        posy = 0
        draw_rect = Draw.draw_rect
        sdraw_rect = style.engine.draw_rect
        sdraw_border = style.engine.draw_border

        spacing = self.scrolledlist.spacing
        width = self.width - 2 * border
        height = self.height - 2 * border
        selheight = 0
        surface = None

        cursor_found = False
        cursor = self.scrolledlist.cursor
        items = self.scrolledlist.items
        focus = self.scrolledlist.focus
        images = self.images

        lower = abs(self.vadjustment) - spacing - 2 * border_active
        upper = abs(self.vadjustment) + height

        # Overall surface
        surface_all = sdraw_rect(max(realwidth, width), self.real_height,
                                 state, cls, st)
        blit = surface_all.blit

        for item in items:
            image, rect = images[item]

            # Draw only those which are visible.
            if (posy + rect.height < lower):
                posy += rect.height + 2 * border_active + spacing
                continue
            elif posy > upper:
                break

            selheight = rect.height + 2 * border_active
            if item.selected:
                # Highlight the selection.
                surface = draw_rect(max(width, realwidth), selheight, color)

                # Show input focus.
                if focus and (item == cursor):
                    sdraw_border(surface,
                                 state,
                                 cls,
                                 st,
                                 active,
                                 space=active_space)
                    cursor_found = True
                surface.blit(image, (border_active, border_active))
                blit(surface, (0, posy))

            elif focus and not cursor_found and (item == cursor):
                # Input focus.
                surface = sdraw_rect(max(width, realwidth), selheight, state,
                                     cls, st)
                sdraw_border(surface,
                             state,
                             cls,
                             st,
                             active,
                             space=active_space)
                surface.blit(image, (border_active, border_active))
                cursor_found = True
                blit(surface, (0, posy))
            else:
                # Regular image, move by the active border, so that
                # all items have the correct offset.
                blit(image, (border_active, posy + border_active))

            posy += selheight + spacing

        self.image.blit(
            surface_all, (border, border),
            (abs(self.hadjustment), abs(self.vadjustment), width, height))
    def draw (self):
        """L.draw () -> None

        Draws the ListViewPort surface and places its items on it.
        """
        Bin.draw (self)
        style = base.GlobalStyle
        cls  = self.__class__
        color = StyleInformation.get ("SELECTION_COLOR")
        active = StyleInformation.get ("ACTIVE_BORDER")
        border_active = style.get_border_size (cls, self.style, active)
        border = style.get_border_size \
                 (cls, self.style, StyleInformation.get ("VIEWPORT_BORDER"))
        active_space = StyleInformation.get ("ACTIVE_BORDER_SPACE")
        st = self.style
        state = self.state
        realwidth = self.real_width

        posy = 0
        draw_rect = Draw.draw_rect
        sdraw_rect = style.engine.draw_rect
        sdraw_border = style.engine.draw_border

        spacing = self.scrolledlist.spacing
        width = self.width - 2 * border
        height = self.height - 2 * border
        selheight = 0
        surface = None

        cursor_found = False
        cursor = self.scrolledlist.cursor
        items = self.scrolledlist.items
        focus = self.scrolledlist.focus
        images = self.images

        lower = abs (self.vadjustment) - spacing - 2 * border_active
        upper = abs (self.vadjustment) + height

        # Overall surface
        surface_all = sdraw_rect (max (realwidth, width), self.real_height,
                                  state, cls, st)
        blit = surface_all.blit

        for item in items:
            image, rect = images[item]

            # Draw only those which are visible.
            if (posy + rect.height < lower):
                posy += rect.height + 2 * border_active + spacing
                continue
            elif posy > upper:
                break
            
            selheight = rect.height + 2 * border_active
            if item.selected:
                # Highlight the selection.
                surface = draw_rect (max (width, realwidth), selheight, color)

                # Show input focus.
                if focus and (item == cursor):
                    sdraw_border (surface, state, cls, st, active,
                                  space=active_space)
                    cursor_found = True
                surface.blit (image, (border_active, border_active))
                blit (surface, (0, posy))

            elif focus and not cursor_found and (item == cursor):
                # Input focus.
                surface = sdraw_rect (max (width, realwidth), selheight, state,
                                      cls, st)
                sdraw_border (surface, state, cls, st, active,
                              space=active_space)
                surface.blit (image, (border_active, border_active))
                cursor_found = True
                blit (surface, (0, posy))
            else:
                # Regular image, move by the active border, so that
                # all items have the correct offset.
                blit (image, (border_active, posy + border_active))

            posy += selheight + spacing
        
        self.image.blit (surface_all, (border, border),
                         (abs (self.hadjustment), abs (self.vadjustment),
                          width, height))
Beispiel #52
0
    def draw(self):
        """V.draw () -> None

        Draws the VScrollBar surface and places its Buttons and slider on it.
        """
        ScrollBar.draw(self)
        cls = self.__class__
        style = base.GlobalStyle
        st = self.style or style.get_style(cls)
        rect = self.image.get_rect()
        draw_rect = style.engine.draw_rect
        draw_border = style.engine.draw_border
        draw_arrow = style.engine.draw_arrow

        # Create both buttons.
        border = style.get_border_size \
                 (cls, st, StyleInformation.get ("SCROLLBAR_BORDER"))
        button_type = StyleInformation.get("SCROLLBAR_BUTTON_BORDER")

        width_button = rect.width - 2 * border

        # We use a temporary state here, so that just the buttons will
        # have the typical sunken effect.
        tmp_state = self.state
        if self.state == STATE_ACTIVE:
            tmp_state = STATE_NORMAL

        # First button.
        state_button = tmp_state
        if self.button_dec:
            state_button = STATE_ACTIVE
        button1 = draw_rect(width_button, width_button, state_button, cls, st)
        draw_border(button1, state_button, cls, st, button_type)
        rect_button1 = button1.get_rect()

        # Draw the arrow.
        draw_arrow(button1, ARROW_UP, state_button, cls, st)
        rect_button1.y = border
        rect_button1.centerx = rect.centerx
        self.image.blit(button1, rect_button1)

        # Second button
        state_button = tmp_state
        if self.button_inc:
            state_button = STATE_ACTIVE

        button2 = draw_rect(width_button, width_button, state_button, cls, st)
        draw_border(button2, state_button, cls, st, button_type)
        rect_button2 = button2.get_rect()

        # Draw the arrow.
        draw_arrow(button2, ARROW_DOWN, state_button, cls, st)
        rect_button2.y = rect.height - width_button - border
        rect_button2.centerx = rect.centerx
        self.image.blit(button2, rect_button2)

        # Create the slider.
        slider_size = self._get_slider_size()
        if slider_size > 0:
            sl = style.engine.draw_slider(width_button, slider_size, tmp_state,
                                          cls, st)
            r = sl.get_rect()
            r.centerx = rect.centerx
            r.centery = self._get_coords_from_value()
            self.image.blit(sl, r)
    def draw (self):
        """V.draw () -> None

        Draws the VScrollBar surface and places its Buttons and slider on it.
        """
        ScrollBar.draw (self)
        cls = self.__class__
        style = base.GlobalStyle
        st = self.style or style.get_style (cls)
        rect = self.image.get_rect ()
        draw_rect = style.engine.draw_rect
        draw_border = style.engine.draw_border
        draw_arrow = style.engine.draw_arrow
        
        # Create both buttons.
        border = style.get_border_size \
                 (cls, st, StyleInformation.get ("SCROLLBAR_BORDER"))
        button_type = StyleInformation.get ("SCROLLBAR_BUTTON_BORDER")
        
        width_button = rect.width - 2 * border

        # We use a temporary state here, so that just the buttons will
        # have the typical sunken effect.
        tmp_state = self.state
        if self.state == STATE_ACTIVE:
            tmp_state = STATE_NORMAL

        # First button.
        state_button = tmp_state
        if self.button_dec:
            state_button = STATE_ACTIVE
        button1 = draw_rect (width_button, width_button, state_button, cls, st)
        draw_border (button1, state_button, cls, st, button_type)
        rect_button1 = button1.get_rect ()

        # Draw the arrow.
        draw_arrow (button1, ARROW_UP, state_button, cls, st)
        rect_button1.y = border
        rect_button1.centerx = rect.centerx
        self.image.blit (button1, rect_button1)

        # Second button
        state_button = tmp_state
        if self.button_inc:
            state_button = STATE_ACTIVE
        
        button2 = draw_rect (width_button, width_button, state_button, cls, st)
        draw_border (button2, state_button, cls, st, button_type)
        rect_button2 = button2.get_rect ()

        # Draw the arrow.
        draw_arrow (button2, ARROW_DOWN, state_button, cls, st)
        rect_button2.y = rect.height - width_button - border
        rect_button2.centerx = rect.centerx
        self.image.blit (button2, rect_button2)

        # Create the slider.
        slider_size = self._get_slider_size ()
        if slider_size > 0:
            sl = style.engine.draw_slider (width_button, slider_size,
                                           tmp_state, cls, st)
            r = sl.get_rect ()
            r.centerx = rect.centerx
            r.centery = self._get_coords_from_value ()
            self.image.blit (sl, r)