Exemple #1
0
    def render_label(self):
        key = G.get_mayus_key(self.mayus, self._text, self)
        if key == 'SPACE':
            return

        self.context.set_font_size(self.font_size)
        self.context.select_font_face(*G.FONT)
        x = self.x + (self.width / 2.0) - (self.context.text_extents(key)[3] /
                                           2.0)
        y = self.y + (self.height / 2.0) + (self.context.text_extents(key)[4] /
                                            2.0)
        if self.lower_key == '-':
            x -= self.context.text_extents(key)[3] * 3.0

        elif self.lower_key == '.':
            x -= self.context.text_extents(key)[3] * 1.5
            y += (self.context.text_extents(key)[4] / 4.0)

        elif self.lower_key == ',':
            x -= self.context.text_extents(key)[3] / 1.5

        self.context.set_source_rgba(*self.label_color)
        self.context.move_to(x, y)

        self.context.show_text(key)
Exemple #2
0
    def render_as_intro_key(self):
        self.font_size = self._size[0] / len(G.KEYS1()) * self._increment
        self.width = \
            self._size[0] / float(len(G.KEYS1()) - 1) * self._increment
        self.height = self._size[1] / 5.0 * self._increment
        self.x = self.width * G.KEYS1().index(G.DEL_KEY) + self._pos[0] + 20
        self.y = self.height * 2 + self._center[1] - \
            self._mouse_position[1] * self._increment

        key = G.get_mayus_key(self.mayus, self._text, self)

        if self.selected:
            self.context.set_source_rgba(*self.selected_color)
        else:
            self.context.set_source_rgba(*self.normal_color)

        self.context.rectangle(self.x, self.y, self.width, self.height)
        self.context.fill()

        self.context.set_font_size(self.font_size)
        x = self.x + (self.width / 2.0) - (self.context.text_extents(key)[2] /
                                           2.0)
        y = self.y + (self.height / 2.0) + (self.context.text_extents(key)[3] /
                                            2.0)
        self.context.set_source_rgba(*self.label_color)
        self.context.move_to(x, y)
        self.context.show_text(key)

        self.check_selected()
Exemple #3
0
    def text_changed(self, widget, key):
        text = key.lower_key
        if text != G.DEL_KEY:
            text = G.get_mayus_key(self.area.mayus, self.text, key)
            if text == 'SPACE':
                text = ' '
            elif text == G.INTRO_KEY:
                text = '\n'
            elif text == G.TAB_KEY:
                text = '\t'

            self.buffer.insert_at_cursor(text)

        else:
            if self.buffer.get_selection_bounds():
                start, end = self.buffer.get_bounds()
                _end, _start = self.buffer.get_selection_bounds()
                offset = _end.get_offset()

                text = self.buffer.get_text(
                    start, _end, 0) + self.buffer.get_text(_start, end, 0)
                self.buffer.set_text(text)
                self.buffer.place_cursor(
                    self.buffer.get_iter_at_offset(offset))

            else:
                _end = self.buffer.get_iter_at_mark(
                    self.buffer.get_selection_bound())
                self.buffer.backspace(_end, True, True)