Beispiel #1
0
    def _draw_sash(self, gc, view_bounds=None, mode="default"):
        """ Draw the "window sash" at the top of the function box.
            Color, corner_radius, etc. are all taken from a style object.
        """
        gc.save_state()

        # Set up the styles.
        gc.set_fill_color(self._style.sash_fill_color_)
        gc.set_stroke_color(self._style.sash_border_color_)
        gc.set_line_width(self._style.sash_border_width)

        # Draw the sash with rounded top corners and square bottom corners.
        lower, upper = self.y2-self._style.sash_height, self.y2
        left, right = self.x, self.x2

        radius = self._style.corner_radius
        gc.begin_path()
        gc.move_to(left, lower)
        gc.line_to(right, lower)
        gc.arc_to(right, upper, right-radius, upper, radius)
        gc.arc_to(left, upper, left, upper-radius, radius)
        gc.line_to(left, lower)
        gc.draw_path()

        # Now draw the title text.
        gc.set_fill_color(self._style.title_color_)
        gc.set_font(self._style.title_font)

        # Show text at the same scale as graphics context
        scale = get_scale(gc)
        pos = (scale * (self.x + self._style.corner_radius + self._style.title_x_offset),
               scale * (self.y2 - self._style.sash_height + self._style.title_y_offset))
        gc.show_text(self.label, pos)

        gc.restore_state()
Beispiel #2
0
    def _draw_mainlayer(self, gc, view_bounds, mode="default"):

        gc.save_state()

        self.set_font(gc)
        scale = get_scale(gc)
        x = scale * (self.x + self.offset)
        y = scale * self.y
        gc.show_text_at_point(self.text, x, y)

        if self._draw_cursor:
            x += self.metrics.get_text_extent(self.text[:self.index])[2]
            y2 = self.y2 - self.offset
            gc.set_line_width(2)
            gc.set_stroke_color((0,0,0,1.0))
            gc.begin_path()
            gc.move_to(x, y)
            gc.line_to(x, y2)
            gc.stroke_path()

        gc.restore_state()