Esempio n. 1
0
    def draw(self, context: DrawContext, bounding_box: Rectangle):
        """Draw the editable text."""
        super().draw(context, bounding_box)
        style = combined_style(context.style, self._inline_style)

        text_box = self.text_box(style, bounding_box)
        text_align = style.get("text-align", TextAlign.CENTER)
        focus_box = self.focus_box
        x, y = focus_box_pos(text_box, (focus_box.width, focus_box.height), text_align)
        focus_box.x = x
        focus_box.y = y

        text_draw_focus_box(context, *focus_box)
Esempio n. 2
0
 def draw(
     self, context: DrawContext, bounding_box: Rectangle
 ) -> Tuple[int, int, int, int]:
     """Draw the editable text."""
     style = combined_style(context.style, self._inline_style)
     x, y, w, h = super().draw(context, bounding_box)
     text_box = self.text_box(style, bounding_box)
     text_align = style["text-align"]
     vertical_align = style["vertical-align"]
     x, y = focus_box_pos(text_box, self.text_size, text_align, vertical_align)
     text_draw_focus_box(context, x, y, w, h)
     self.bounding_box = Rectangle(x, y, width=w, height=h)
     return x, y, w, h