Exemple #1
0
    def render(self, context, cr, layout):
        if not self.visible:
            return

        x, y, width, height = self.allocation

        context.save()
        context.add_class("cellrenderer-button")

        if self.has_focus:
            context.set_state(self.state | Gtk.StateFlags.FOCUSED)
        else:
            context.set_state(self.state)

        # render background and focal frame if has-focus
        context.save()
        context.add_class(Gtk.STYLE_CLASS_BUTTON)
        Gtk.render_background(context, cr, x, y, width, height)
        context.restore()

        if self.has_focus:
            Gtk.render_focus(context, cr, x + 3, y + 3, width - 6, height - 6)

        # position and render layout markup
        context.save()
        context.add_class(Gtk.STYLE_CLASS_BUTTON)
        layout.set_markup(self.markup_variants[self.current_variant], -1)
        layout_width = layout.get_pixel_extents()[1].width
        x = x + (width - layout_width) / 2
        y += self.ypad
        Gtk.render_layout(context, cr, x, y, layout)
        context.restore()

        context.restore()
Exemple #2
0
    def do_draw(self, cr):
        cr.save()
        A = self.get_allocation()
        if self._pressed:
            cr.translate(1, 1)

        if self.has_focus():
            Gtk.render_focus(self.get_style_context(), cr, 3, 3, A.width - 6,
                             A.height - 6)

        for child in self:
            self.propagate_draw(child, cr)

        if self.is_installed:
            # paint installed tick overlay
            if self.get_direction() != Gtk.TextDirection.RTL:
                x = y = 36
            else:
                x = A.width - 56
                y = 36

            Gdk.cairo_set_source_pixbuf(cr, self._overlay, x, y)
            cr.paint()

        cr.restore()
Exemple #3
0
    def do_draw(self, cr):
        cr.save()
        A = self.get_allocation()
        if self._pressed:
            cr.translate(1, 1)

        if self.has_focus():
            Gtk.render_focus(self.get_style_context(),
                             cr,
                             3, 3,
                             A.width-6, A.height-6)

        for child in self: self.propagate_draw(child, cr)

        if self.is_installed:
            # paint installed tick overlay
            if self.get_direction() != Gtk.TextDirection.RTL:
                x = y = 36
            else:
                x = A.width - 56
                y = 36

            Gdk.cairo_set_source_pixbuf(cr, self._overlay, x, y)
            cr.paint()

        cr.restore()
        return
    def render(self, context, cr, layout):
        if not self.visible:
            return

        x, y, width, height = self.allocation

        context.save()
        context.add_class("cellrenderer-button")

        if self.has_focus:
            context.set_state(self.state | Gtk.StateFlags.FOCUSED)
        else:
            context.set_state(self.state)

        # render background and focal frame if has-focus
        context.save()
        context.add_class(Gtk.STYLE_CLASS_BUTTON)
        Gtk.render_background(context, cr, x, y, width, height)
        context.restore()

        if self.has_focus:
            Gtk.render_focus(context, cr, x+3, y+3, width-6, height-6)

        # position and render layout markup
        context.save()
        context.add_class(Gtk.STYLE_CLASS_BUTTON)
        layout.set_markup(self.markup_variants[self.current_variant], -1)
        layout_width = layout.get_pixel_extents()[1].width
        x = x + (width - layout_width)/2
        y += self.ypad
        Gtk.render_layout(context, cr, x, y, layout)
        context.restore()

        context.restore()
        return
Exemple #5
0
    def paint(self, cr, a, context, xo, yo):
        if self.is_nopaint:
            return

        cr.save()

        x, y = 0, 0
        w, h = a.width, a.height
        arrow_width = 12  # theme['arrow-width']

        if isinstance(self, PathPart):
            _a = self.get_allocation()
            self.shape.layout(cr,
                              _a.x - xo + 1, _a.y - yo,
                              w, h, 3, arrow_width)
            cr.clip()
        else:
            Gtk.render_background(context, cr,
                                  a.x - xo - 10, a.y - yo,
                                  a.width + 10, a.height)

        cr.translate(a.x - xo, a.y - yo)

        if self.shape.name.find('Arrow') != -1:
            # draw arrow head
            cr.move_to(w - arrow_width / 2, 2)
            cr.line_to(w + 5, h / 2)
            cr.line_to(w - arrow_width / 2, h - 2)
            # fetch the line color and stroke
            rgba = context.get_border_color(Gtk.StateFlags.NORMAL)
            cr.set_source_rgb(rgba.red, rgba.green, rgba.blue)
            cr.set_line_width(1)
            cr.stroke()

        # render the layout
        e = self.layout.get_pixel_extents()[1]
        lw, lh = e.width, e.height
        pw, ph = a.width, a.height

        x = min(self.xpadding, (pw - lw) / 2)
        y = (ph - lh) / 2

        # layout area
        Gtk.render_layout(context,
                          cr,
                          int(x),
                          int(y),
                          self.layout)

        # paint the focus frame if need be
        if isinstance(self, PathPart) and self.has_focus():
            # layout area
            x, w, h = x - 2, lw + 4, lh + 1
            Gtk.render_focus(context, cr, x, y, w, h)

        cr.restore()
    def paint(self, cr, a, context, xo, yo):
        if self.is_nopaint: return

        cr.save()

        x, y = 0, 0
        w, h = a.width, a.height
        arrow_width = 12#theme['arrow-width']

        if isinstance(self, PathPart):
            _a = self.get_allocation()
            self.shape.layout(cr,
                              _a.x-xo+1, _a.y-yo,
                              w, h, 3, arrow_width)
            cr.clip()
        else:
            Gtk.render_background(context, cr,
                                  a.x-xo-10, a.y-yo,
                                  a.width+10, a.height)

        cr.translate(a.x-xo, a.y-yo)

        if self.shape.name.find('Arrow') != -1:
            # draw arrow head
            cr.move_to(w-arrow_width/2, 2)
            cr.line_to(w+5, h/2)
            cr.line_to(w-arrow_width/2, h-2)
            # fetch the line color and stroke
            rgba = context.get_border_color(Gtk.StateFlags.NORMAL)
            cr.set_source_rgb(rgba.red, rgba.green, rgba.blue)
            cr.set_line_width(1)
            cr.stroke()

        # render the layout
        e = self.layout.get_pixel_extents()[1]
        lw, lh = e.width, e.height
        pw, ph = a.width, a.height
 
        x = min(self.xpadding, (pw-lw)/2)
        y = (ph-lh)/2

        # layout area
        Gtk.render_layout(context,
                          cr, 
                          int(x),
                          int(y),
                          self.layout)

        # paint the focus frame if need be
        if isinstance(self, PathPart) and self.has_focus():
            # layout area
            x, w, h = x-2, lw+4, lh+1
            Gtk.render_focus(context, cr, x, y, w, h)

        cr.restore()
        return
Exemple #7
0
    def do_draw(self, cr):
        cr.save()
        A = self.get_allocation()

        if self.has_focus():
            Gtk.render_focus(self.get_style_context(),
                             cr,
                             3, 3,
                             A.width - 6, A.height - 6)
        cr.restore()
        for child in self:
            self.propagate_draw(child, cr)
Exemple #8
0
    def do_draw(self, cr):
        cr.save()
        A = self.get_allocation()

        if self.has_focus():
            Gtk.render_focus(self.get_style_context(), cr, 3, 3, A.width - 6,
                             A.height - 6)

        for child in self:
            self.propagate_draw(child, cr)

        cr.restore()
Exemple #9
0
    def do_draw(self, cr):

        if self.has_focus():
            layout = self.label.get_layout()
            a = self.get_allocation()
            e = layout.get_pixel_extents()[1]
            xo, yo = self.label.get_layout_offsets()
            Gtk.render_focus(self.get_style_context(), cr, xo - a.x - 3,
                             yo - a.y - 1, e.width + 6, e.height + 2)

        for child in self:
            self.propagate_draw(child, cr)
Exemple #10
0
    def do_draw(self, cr):
        if self.has_focus():
            context = self.get_style_context()
            _a = self.get_allocation()
            a = self.image.get_allocation()
            pb = self.image.get_pixbuf()
            pbw, pbh = pb.get_width(), pb.get_height()
            Gtk.render_focus(context, cr, a.x - _a.x + (a.width - pbw) / 2 - 4,
                             a.y - _a.y + (a.height - pbh) / 2 - 4, pbw + 8,
                             pbh + 8)

        for child in self:
            self.propagate_draw(child, cr)
Exemple #11
0
    def do_draw(self, cr):

        if self.has_focus():
            layout = self.label.get_layout()
            a = self.get_allocation()
            e = layout.get_pixel_extents()[1]
            xo, yo = self.label.get_layout_offsets()
            Gtk.render_focus(self.get_style_context(), cr,
                             xo-a.x-3, yo-a.y-1,
                             e.width+6, e.height+2)

        for child in self: self.propagate_draw(child, cr)
        return
Exemple #12
0
    def do_draw(self, cr):
        if self.has_focus():
            context = self.get_style_context()
            _a = self.get_allocation()
            a = self.image.get_allocation()
            pb = self.image.get_pixbuf()
            pbw, pbh = pb.get_width(), pb.get_height()
            Gtk.render_focus(
                context,
                cr,
                a.x - _a.x + (a.width - pbw) / 2 - 4,
                a.y - _a.y + (a.height - pbh) / 2 - 4,
                pbw + 8, pbh + 8)

        for child in self:
            self.propagate_draw(child, cr)
Exemple #13
0
    def do_render(self, drawable, widget, background_area, cell_area,
                  flags):
        if flags & Gtk.CellRendererState.SELECTED:
            state = Gtk.StateFlags.SELECTED
        else:
            state = Gtk.StateFlags.NORMAL

        context = widget.get_style_context()
        context.set_state(state)

        Gtk.render_background(context, drawable, cell_area.x, cell_area.y,
                              cell_area.width, cell_area.height)
        Gtk.render_focus(context, drawable, cell_area.x, cell_area.y, cell_area.width,
                         cell_area.height)

        Gtk.CellRendererText.do_render(self, drawable, widget, background_area,
                                       cell_area, flags)
Exemple #14
0
    def do_draw(self, cr: cairo.Context) -> None:
        cr.save()
        self._canvas_artist.draw(cr)
        cr.restore()

        cr.save()
        self._floating_artist.draw(cr)
        cr.restore()

        cr.save()
        self._widget_artist.draw(cr)
        cr.restore()

        if self.props.has_focus:
            Gtk.render_focus(
                self.get_style_context(),
                cr,
                x=0,
                y=0,
                width=self.get_allocated_width(),
                height=self.get_allocated_height(),
            )