def do_draw(self, cr):
        # Fall trough to the container expose handler.
        # (Leaving out the window expose handler which redraws everything)
        Gtk.Window.do_draw(self, cr)

        if self._invoker is not None and self._invoker.has_rectangle_gap():
            invoker = self._invoker.get_rect()
            palette = self.get_rect()
            gap = _calculate_gap(palette, invoker)
        else:
            gap = False

        allocation = self.get_allocation()
        context = self.get_style_context()
        context.add_class("palette")
        if gap:
            cr.save()
            cr.set_source_rgb(0, 0, 0)
            cr.rectangle(0, 0, allocation.width, allocation.height)
            cr.set_line_width(4)
            cr.stroke()
            cr.restore()
            Gtk.render_frame_gap(
                context, cr, 0, 0, allocation.width, allocation.height, gap[0], gap[1], gap[1] + gap[2]
            )
        else:
            Gtk.render_frame(context, cr, 0, 0, allocation.width, allocation.height)
        return False
 def __drawing_cb(self, button, cr):
     alloc = self.get_allocation()
     context = self.get_style_context()
     context.add_class("toolitem")
     if not self.is_expanded() or self.props.palette is not None and self.props.palette.is_up():
         ToolButton.do_draw(self, cr)
         _paint_arrow(self, cr, math.pi)
         return False
     Gtk.render_frame_gap(context, cr, 0, 0, alloc.width, alloc.height, Gtk.PositionType.BOTTOM, 0, alloc.width)
     _paint_arrow(self, cr, 0)
     return False
    def draw_rectangle(self, cr, palette):
        allocation = self.parent.get_allocation()

        context = self.parent.get_style_context()
        context.add_class('toolitem')

        gap = _calculate_gap(self.get_rect(), palette.get_rect())
        if gap:
            Gtk.render_frame_gap(context, cr, 0, 0, allocation.width,
                                 allocation.height, gap[0], gap[1],
                                 gap[1] + gap[2])
    def draw_rectangle(self, cr, palette):
        allocation = self.parent.get_allocation()

        context = self.parent.get_style_context()
        context.add_class('toolitem')

        gap = _calculate_gap(self.get_rect(), palette.get_rect())
        if gap:
            Gtk.render_frame_gap(context, cr, 0, 0,
                                 allocation.width,
                                 allocation.height,
                                 gap[0], gap[1], gap[1] + gap[2])
 def __drawing_cb(self, button, cr):
     alloc = self.get_allocation()
     context = self.get_style_context()
     context.add_class('toolitem')
     if not self.is_expanded() or self.props.palette is not None and \
             self.props.palette.is_up():
         ToolButton.do_draw(self, cr)
         _paint_arrow(self, cr, math.pi)
         return False
     Gtk.render_frame_gap(context, cr, 0, 0, alloc.width, alloc.height,
                          Gtk.PositionType.BOTTOM, 0, alloc.width)
     _paint_arrow(self, cr, 0)
     return False
Example #6
0
    def draw_background(self, cr):
        style = self.get_style_context()
        state = style.get_state()
        margin = style.get_margin(state)
        alloc = self.get_allocation()
        dir = self.get_direction()
        gap_position = Gtk.PositionType.LEFT if dir == Gtk.TextDirection.LTR else Gtk.PositionType.RIGHT
        if dir == Gtk.TextDirection.LTR:
            start_x = ARROW_WIDTH + margin.left
            end_x = alloc.width - margin.right
        else:
            start_x = margin.left
            end_x = alloc.width - margin.right - ARROW_WIDTH

        start_y = margin.top
        end_y = alloc.height - margin.bottom
        start_gap = ((end_y - start_y - ARROW_HEIGHT) / 2.)
        end_gap = ((end_y - start_y + ARROW_HEIGHT) / 2.)

        Gtk.render_background(style, cr, start_x, start_y, end_x, end_y)
        Gtk.render_frame_gap(style, cr, start_x, start_y, end_x, end_y,
                             gap_position, start_gap, end_gap)
    def do_draw(self, cr):
        # Fall trough to the container expose handler.
        # (Leaving out the window expose handler which redraws everything)
        Gtk.Window.do_draw(self, cr)

        if self._invoker is not None and self._invoker.has_rectangle_gap():
            invoker = self._invoker.get_rect()
            palette = self.get_rect()
            gap = _calculate_gap(palette, invoker)
        else:
            gap = False

        allocation = self.get_allocation()
        context = self.get_style_context()
        context.add_class('toolitem')
        if gap:
            Gtk.render_frame_gap(context, cr, 0, 0, allocation.width,
                                 allocation.height, gap[0], gap[1],
                                 gap[1] + gap[2])
        else:
            Gtk.render_frame(context, cr, 0, 0, allocation.width,
                             allocation.height)
        return False