Example #1
0
    def on_draw(self, view, ctx):
        window = view.get_window(Gtk.TextWindowType.TEXT)

        if not Gtk.cairo_should_draw_window(ctx, window):
            return False

        # Draw something
        ctx.set_line_width(1.0)

        Gtk.cairo_transform_to_window(ctx, view, window)

        clipped, clip = Gdk.cairo_get_clip_rectangle(ctx)

        if not clipped:
            return False

        for placeholder in self.ordered_placeholders:
            if not self.placeholder_in_area(placeholder, clip):
                continue

            ctx.save()
            self.draw_placeholder(ctx, placeholder)
            ctx.restore()

        return False
Example #2
0
        def on_draw(self, view, ctx):
                window = view.get_window(Gtk.TextWindowType.TEXT)

                if not Gtk.cairo_should_draw_window(ctx, window):
                        return False

                # Draw something
                ctx.set_line_width(1.0)

                Gtk.cairo_transform_to_window(ctx, view, window)

                clipped, clip = Gdk.cairo_get_clip_rectangle(ctx)

                if not clipped:
                        return False

                for placeholder in self.ordered_placeholders:
                        if not self.placeholder_in_area(placeholder, clip):
                                continue

                        ctx.save()
                        self.draw_placeholder(ctx, placeholder)
                        ctx.restore()

                return False
Example #3
0
    def on_view_draw_after(self, view, cr):
        window = view.get_window(Gtk.TextWindowType.TOP)

        if window is None or not Gtk.cairo_should_draw_window(cr, window):
            return False

        if not self._in_mode:
            return False

        layout = view.create_pango_layout(_('Multi Edit Mode'))
        extents = layout.get_pixel_extents()

        w = window.get_width()
        h = window.get_height()

        Gtk.cairo_transform_to_window(cr, view, window)

        cr.save()

        cr.translate(0.5, 0.5)
        cr.set_line_width(1)

        col = self.get_border_color()
        Gdk.cairo_set_source_rgba(cr, col)

        cr.move_to(0, h - 1)
        cr.rel_line_to(w, 0)
        cr.stroke()
        cr.restore()

        ctx = self.view.get_style_context()
        ctx.save()
        ctx.add_class('top')

        cr.save()
        Gtk.render_layout(ctx, cr, w - extents[1].width - 3,
                          (h - extents[1].height) / 2, layout)
        cr.restore()

        if not self._status:
            status = ''
        else:
            status = str(self._status)

        if status:
            layout.set_markup(status, -1)

            cr.save()
            Gtk.render_layout(ctx, cr, 3, (h - extents[1].height) / 2, layout)
            cr.restore()

        ctx.restore()

        return False
    def on_view_draw_after(self, view, cr):
        window = view.get_window(Gtk.TextWindowType.TOP)

        if window is None or not Gtk.cairo_should_draw_window(cr, window):
            return False

        if not self._in_mode:
            return False

        layout = view.create_pango_layout(_('Multi Edit Mode'))
        extents = layout.get_pixel_extents()

        w = window.get_width()
        h = window.get_height()

        Gtk.cairo_transform_to_window(cr, view, window)

        cr.save()

        cr.translate(0.5, 0.5)
        cr.set_line_width(1)

        col = self.get_border_color()
        Gdk.cairo_set_source_rgba(cr, col)

        cr.move_to(0, h - 1)
        cr.rel_line_to(w, 0)
        cr.stroke()
        cr.restore()

        ctx = self.view.get_style_context()
        ctx.save()
        ctx.add_class('top')

        cr.save()
        Gtk.render_layout(ctx, cr, w - extents[1].width - 3, (h - extents[1].height) / 2, layout)
        cr.restore()

        if not self._status:
            status = ''
        else:
            status = str(self._status)

        if status:
            layout.set_markup(status, -1)

            cr.save()
            Gtk.render_layout(ctx, cr, 3, (h - extents[1].height) / 2, layout)
            cr.restore()

        ctx.restore()

        return False
Example #5
0
    def on_view_draw(self, view, cr):
        window = view.get_window(Gtk.TextWindowType.TEXT)

        if Gtk.cairo_should_draw_window(cr, window):
            return self._draw_column_mode(cr)

        window = view.get_window(Gtk.TextWindowType.TOP)

        if window is None or not Gtk.cairo_should_draw_window(cr, window):
            return False

        if not self._in_mode:
            return False

        layout = view.create_pango_layout(_('Multi Edit Mode'))
        extents = layout.get_pixel_extents()

        w = window.get_width()
        h = window.get_height()

        Gtk.cairo_transform_to_window(cr, view, window)

        cr.translate(0.5, 0.5)
        cr.set_line_width(1)

        col = self.get_border_color()
        Gdk.cairo_set_source_rgba(cr, col)

        cr.move_to(0, h - 1)
        cr.rel_line_to(w, 0)
        cr.stroke()

        context = self._view.get_style_context()
        Gdk.cairo_set_source_rgba(cr, context.get_color(Gtk.StateFlags.NORMAL))
        cr.move_to(w - extents[1].width - 3, (h - extents[1].height) / 2)
        PangoCairo.show_layout(cr, layout)

        if not self._status:
            status = ''
        else:
            status = str(self._status)

        if status:
            layout.set_markup(status, -1)

            cr.move_to(3, (h - extents[1].height) / 2)
            PangoCairo.show_layout(cr, layout)

        return False
    def on_view_draw(self, view, cr):
        window = view.get_window(Gtk.TextWindowType.TEXT)

        if Gtk.cairo_should_draw_window (cr, window):
            return self._draw_column_mode(cr)

        window = view.get_window(Gtk.TextWindowType.TOP)

        if window is None or not Gtk.cairo_should_draw_window (cr, window):
            return False

        if not self._in_mode:
            return False

        layout = view.create_pango_layout(_('Multi Edit Mode'))
        extents = layout.get_pixel_extents()

        w = window.get_width()
        h = window.get_height()

        Gtk.cairo_transform_to_window(cr, view, window)

        cr.translate(0.5, 0.5)
        cr.set_line_width(1)

        col = self.get_border_color()
        Gdk.cairo_set_source_rgba(cr, col)

        cr.move_to(0, h - 1)
        cr.rel_line_to(w, 0)
        cr.stroke()

        context = self._view.get_style_context()
        Gdk.cairo_set_source_rgba(cr, context.get_color(Gtk.StateFlags.NORMAL))
        cr.move_to(w - extents[1].width - 3, (h - extents[1].height) / 2)
        PangoCairo.show_layout(cr, layout)

        if not self._status:
            status = ''
        else:
            status = str(self._status)

        if status:
            layout.set_markup(status, -1)

            cr.move_to(3, (h - extents[1].height) / 2)
            PangoCairo.show_layout(cr, layout)

        return False
Example #7
0
    def on_draw(self, widget, ct):
        win = widget.get_window(Gtk.TextWindowType.BOTTOM)

        if not Gtk.cairo_should_draw_window(ct, win):
            return False

        Gtk.cairo_transform_to_window(ct, widget, win)

        color = self.get_border_color()
        width = win.get_width()

        ct.set_source_rgba(color.red, color.green, color.blue, color.alpha)
        ct.move_to(0, 0)
        ct.line_to(width, 0)
        ct.stroke()

        return False
Example #8
0
    def on_draw(self, widget, ct):
        win = widget.get_window(Gtk.TextWindowType.BOTTOM)

        if not Gtk.cairo_should_draw_window(ct, win):
            return False

        Gtk.cairo_transform_to_window(ct, widget, win)

        color = self.get_border_color()
        width = win.get_width()

        ct.set_source_rgba(color.red, color.green, color.blue, color.alpha)
        ct.move_to(0, 0)
        ct.line_to(width, 0)
        ct.stroke()

        return False