1# ------------------------------------------------------------------------------
2# Copyright (c) 2008, Riverbank Computing Limited
3# All rights reserved.
4#
5# This software is provided without warranty under the terms of the BSD license.
6# However, when used with the GPL version of PyQt the additional terms
7# described in the PyQt GPL exception also apply
8
9#
10# Author: Riverbank Computing Limited
11# ------------------------------------------------------------------------------
12
13
14
15from pyface.qt import QtCore
16
17from .editor import Editor
18
19from pyface.heading_text import HeadingText
20
21# FIXME: ToolkitEditorFactory is a proxy class defined here just for backward
22# compatibility. The class has been moved to the
23# traitsui.editors.title_editor file.
24from ..editors.title_editor import TitleEditor
25
26
27class SimpleEditor(Editor):
28    def init(self, parent):
29        """ Finishes initializing the editor by creating the underlying toolkit
30            widget.
31        """
32        self._control = HeadingText(None)
33        self.control = self._control.control
34        if self.factory.allow_selection:
35            flags = (
36                self.control.textInteractionFlags()
37                | QtCore.Qt.TextSelectableByMouse
38            )
39            self.control.setTextInteractionFlags(flags)
40        self.set_tooltip()
41
42    def update_editor(self):
43        """ Updates the editor when the object trait changes external to the
44            editor.
45        """
46        self._control.text = self.str_value
47
48
49CustomEditor = SimpleEditor
50ReadonlyEditor = SimpleEditor
51TextEditor = SimpleEditor
52