~ubuntu-branches/ubuntu/trusty/python-pyface/trusty

« back to all changes in this revision

Viewing changes to pyface/dock/idockable.py

  • Committer: Bazaar Package Importer
  • Author(s): Varun Hiremath
  • Date: 2011-07-09 10:57:54 UTC
  • Revision ID: james.westby@ubuntu.com-20110709105754-k4fw9am00s9vj5yf
Tags: upstream-4.0.0
ImportĀ upstreamĀ versionĀ 4.0.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#-------------------------------------------------------------------------------
 
2
#
 
3
#  Copyright (c) 2005, Enthought, Inc.
 
4
#  All rights reserved.
 
5
#
 
6
#  This software is provided without warranty under the terms of the BSD
 
7
#  license included in enthought/LICENSE.txt and may be redistributed only
 
8
#  under the conditions described in the aforementioned license.  The license
 
9
#  is also available online at http://www.enthought.com/licenses/BSD.txt
 
10
#
 
11
#  Thanks for using Enthought open source!
 
12
#
 
13
#  Author: David C. Morrill
 
14
#  Date:   12/14/2005
 
15
#
 
16
#-------------------------------------------------------------------------------
 
17
 
 
18
""" Defines the IDockable interface which objects contained in a DockWindow
 
19
    DockControl can implement in order to allow themselves to be dragged into
 
20
    a different DockWindow.
 
21
"""
 
22
 
 
23
#-------------------------------------------------------------------------------
 
24
#  Imports:
 
25
#-------------------------------------------------------------------------------
 
26
 
 
27
import wx
 
28
 
 
29
#-------------------------------------------------------------------------------
 
30
#  'IDockable' class:
 
31
#-------------------------------------------------------------------------------
 
32
 
 
33
class IDockable ( object ):
 
34
 
 
35
    #---------------------------------------------------------------------------
 
36
    #  Should the current DockControl be closed before creating the new one:
 
37
    #---------------------------------------------------------------------------
 
38
 
 
39
    def dockable_should_close ( self ):
 
40
        """ Should the current DockControl be closed before creating the new
 
41
            one.
 
42
        """
 
43
        return True
 
44
 
 
45
    #---------------------------------------------------------------------------
 
46
    #  Returns whether or not it is OK to close the control, and if it is OK,
 
47
    #  then it closes the DockControl itself:
 
48
    #---------------------------------------------------------------------------
 
49
 
 
50
    def dockable_close ( self, dock_control, force ):
 
51
        """ Returns whether or not it is OK to close the control.
 
52
        """
 
53
        return False
 
54
 
 
55
    #---------------------------------------------------------------------------
 
56
    #  Gets a control that can be docked into a DockWindow:
 
57
    #---------------------------------------------------------------------------
 
58
 
 
59
    def dockable_get_control ( self, parent ):
 
60
        """ Gets a control that can be docked into a DockWindow.
 
61
        """
 
62
        print "The 'IDockable.dockable_get_control' method must be overridden"
 
63
        panel = wx.Panel( parent, -1 )
 
64
        panel.SetBackgroundColour( wx.RED )
 
65
        return panel
 
66
 
 
67
    #---------------------------------------------------------------------------
 
68
    #  Allows the object to override the default DockControl settings:
 
69
    #---------------------------------------------------------------------------
 
70
 
 
71
    def dockable_init_dockcontrol ( self, dock_control ):
 
72
        """ Allows the object to override the default DockControl settings.
 
73
        """
 
74
        pass
 
75
 
 
76
    #---------------------------------------------------------------------------
 
77
    #  Returns the right-click popup menu for a DockControl (if any):
 
78
    #---------------------------------------------------------------------------
 
79
 
 
80
    def dockable_menu ( self, dock_control, event ):
 
81
        """ Returns the right-click popup menu for a DockControl (if any).
 
82
        """
 
83
        return None
 
84
 
 
85
    #---------------------------------------------------------------------------
 
86
    #  Handles the user double-clicking on the DockControl:
 
87
    #  A result of False indicates the event was not handled; all other results
 
88
    #  indicate that the event was handled successfully.
 
89
    #---------------------------------------------------------------------------
 
90
 
 
91
    def dockable_dclick ( self, dock_control, event ):
 
92
        """ Handles the user double-clicking on the DockControl.
 
93
            A result of False indicates the event was not handled; all other
 
94
            results indicate that the event was handled successfully.
 
95
        """
 
96
        return False
 
97
 
 
98
    #---------------------------------------------------------------------------
 
99
    #  Handles a notebook tab being activated or deactivated:
 
100
    #---------------------------------------------------------------------------
 
101
 
 
102
    def dockable_tab_activated ( self, dock_control, activated ):
 
103
        """ Handles a notebook tab being activated or deactivated.
 
104
 
 
105
            'dock_control' is the control being activated or deactivated.
 
106
 
 
107
            If 'activated' is True, the control is being activated; otherwise
 
108
            the control is being deactivated.
 
109
        """
 
110
        pass
 
111
 
 
112
    #---------------------------------------------------------------------------
 
113
    #  Handles the IDockable being bound to a specified DockControl:
 
114
    #---------------------------------------------------------------------------
 
115
 
 
116
    def dockable_bind ( self, dock_control ):
 
117
        """ Handles the dockable being bound to a specified DockControl.
 
118
        """
 
119
        pass
 
120