def get_position(self):
        lines = split(self.text, '\n')
        caret = self.caret + 1
        index = 0
        line_index = 0
        for line in lines:
            line += '\n'
            caret -= len(line)
            if caret <= 0:
                index = len(line) + caret
                break
            line_index += 1
        return (index, line_index)


RegisterCommands(CommonTextEditor)


class SimpleText(CommonText, RectangularPrimitive):

    has_edit_mode = 1
    is_Text = 1
    is_SimpleText = 1
    is_curve = 1
    is_clip = 1
    has_font = 1
    has_fill = 1
    has_line = 0

    commands = CommonText.commands + RectangularPrimitive.commands
Exemplo n.º 2
0
        else:
            text = _("Ellipse axes %(axes)[size], center %(center)[position]")
        return text, dict

    def SaveToFile(self, file):
        Primitive.SaveToFile(self, file)
        file.Ellipse(self.trafo, self.start_angle, self.end_angle,
                     self.arc_type)

    def Editor(self):
        return EllipseEditor(self)

    context_commands = ('EllipseArc', 'EllipseChord', 'EllipsePieSlice')


RegisterCommands(Ellipse)


class EllipseCreator(RectangularCreator):

    creation_text = _("Create Ellipse")

    def compute_trafo(self, state):
        start = self.drag_start
        end = self.drag_cur
        if state & AlternateMask:
            # start is the center of the ellipse
            if state & ConstraintMask:
                # end is a point of the periphery of a *circle* centered
                # at start
                radius = abs(start - end)
Exemplo n.º 3
0
        finally:
            if clipped:
                device.PopClip()
            if mask.has_properties:
                mask.properties = attr

    def permute_objects(self, permutation):
        # make sure the mask stays at index 0
        if permutation[0] != 0:
            permutation = list(permutation)
            permutation.remove(0)
            permutation.insert(0, 0)
        return EditableCompound.permute_objects(self, permutation)

    def Mask(self):
        return self.objects[0]

    def MaskedObjects(self):
        return self.objects[1:]

    def SelectMask(self):
        if self.document is not None:
            self.document.SelectObject(self.objects[0])

    AddCmd(commands, SelectMask, _("Select Mask"), key_stroke='m')

    context_commands = ('SelectMask', )


RegisterCommands(MaskGroup)