コード例 #1
0
ファイル: association.py プロジェクト: seryafarma/gaphor
    def draw(self, context):
        """Draw name and multiplicity of the line end.
        """
        if not self.subject:
            return

        cr = context.cairo
        text_color = context.style.get("text-color")
        if text_color:
            cr.set_source_rgba(*text_color)

        text_draw(
            cr,
            self._name,
            self.font,
            lambda w, h: (self._name_bounds.x, self._name_bounds.y),
        )
        text_draw(
            cr,
            self._mult,
            self.font,
            lambda w, h: (self._mult_bounds.x, self._mult_bounds.y),
        )

        for b in (self._name_bounds, self._mult_bounds):
            text_draw_focus_box(context, b.x, b.y, b.width, b.height)
コード例 #2
0
    def draw(self, context, bounding_box):
        cr = context.cairo
        min_w = max(self.style("min-width"), bounding_box.width)
        min_h = max(self.style("min-height"), bounding_box.height)
        text_align = self.style("text-align")
        vertical_align = self.style("vertical-align")
        padding = self.style("padding")

        text_box = Rectangle(
            bounding_box.x + padding[Padding.LEFT],
            bounding_box.y + padding[Padding.TOP],
            bounding_box.width - padding[Padding.RIGHT] -
            padding[Padding.LEFT],
            bounding_box.height - padding[Padding.TOP] -
            padding[Padding.BOTTOM],
        )

        x, y, w, h = text_draw(
            cr,
            self.text(),
            self.font(),
            lambda w, h: text_point_in_box(text_box,
                                           (w, h), text_align, vertical_align),
            width=text_box.width,
            default_size=(min_w, min_h),
        )
        return x, y, w, h
コード例 #3
0
ファイル: shapes.py プロジェクト: seryafarma/gaphor
    def draw(
        self, context: DrawContext, bounding_box: Rectangle
    ) -> Tuple[int, int, int, int]:
        """Draw the text, return the location and size."""
        style = combined_style(context.style, self._inline_style)
        min_w = max(style["min-width"], bounding_box.width)
        min_h = max(style["min-height"], bounding_box.height)
        text_align = style["text-align"]
        text_box = self.text_box(style, bounding_box)

        with cairo_state(context.cairo) as cr:
            text_color = style["text-color"]
            if text_color:
                cr.set_source_rgba(*text_color)

            x, y, w, h = text_draw(
                cr,
                self.text(),
                style,
                lambda w, h: (bounding_box.x, bounding_box.y),
                width=text_box.width,
                default_size=(min_w, min_h),
                text_align=text_align,
            )
        return x, y, w, h
コード例 #4
0
    def draw(self, context):
        """Draw name and multiplicity of the line end.
        """
        if not self.subject:
            return

        cr = context.cairo

        text_draw(
            cr,
            self._name,
            self.font,
            lambda w, h: (self._name_bounds.x, self._name_bounds.y),
        )
        text_draw(
            cr,
            self._mult,
            self.font,
            lambda w, h: (self._mult_bounds.x, self._mult_bounds.y),
        )

        for b in (self._name_bounds, self._mult_bounds):
            text_draw_focus_box(context, b.x, b.y, b.width, b.height)