1# (C) Copyright 2005-2020 Enthought, Inc., Austin, TX
2# All rights reserved.
3#
4# This software is provided without warranty under the terms of the BSD
5# license included in LICENSE.txt and may be redistributed only under
6# the conditions described in the aforementioned license. The license
7# is also available online at http://www.enthought.com/licenses/BSD.txt
8#
9# Thanks for using Enthought open source!
10
11
12""" Enthought pyface package component
13"""
14
15
16from traits.api import Bool
17from pyface.workbench.i_view import MView
18
19
20class View(MView):
21    """ The toolkit specific implementation of a View.
22
23    See the IView interface for the API documentation.
24
25    """
26
27    # Trait to indicate if the dock window containing the view should be
28    # closeable. See FIXME comment in the _wx_create_view_dock_control method
29    # in workbench_window_layout.py.
30    closeable = Bool(False)
31
32    # ------------------------------------------------------------------------
33    # 'IWorkbenchPart' interface.
34    # ------------------------------------------------------------------------
35
36    def create_control(self, parent):
37        """ Create the toolkit-specific control that represents the part. """
38
39        import wx
40
41        # By default we create a red panel!
42        control = wx.Panel(parent, -1)
43        control.SetBackgroundColour("red")
44        control.SetSize((100, 200))
45
46        return control
47
48    def destroy_control(self):
49        """ Destroy the toolkit-specific control that represents the part. """
50
51        if self.control is not None:
52            self.control.Destroy()
53            self.control = None
54
55    def set_focus(self):
56        """ Set the focus to the appropriate control in the part. """
57
58        if self.control is not None:
59            self.control.SetFocus()
60
61        return
62