1
#-------------------------------------------------------------------------------
3
# Copyright (c) 2005, Enthought, Inc.
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
11
# Thanks for using Enthought open source!
13
# Author: David C. Morrill
16
#-------------------------------------------------------------------------------
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.
23
#-------------------------------------------------------------------------------
25
#-------------------------------------------------------------------------------
29
#-------------------------------------------------------------------------------
31
#-------------------------------------------------------------------------------
33
class IDockable ( object ):
35
#---------------------------------------------------------------------------
36
# Should the current DockControl be closed before creating the new one:
37
#---------------------------------------------------------------------------
39
def dockable_should_close ( self ):
40
""" Should the current DockControl be closed before creating the new
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
#---------------------------------------------------------------------------
50
def dockable_close ( self, dock_control, force ):
51
""" Returns whether or not it is OK to close the control.
55
#---------------------------------------------------------------------------
56
# Gets a control that can be docked into a DockWindow:
57
#---------------------------------------------------------------------------
59
def dockable_get_control ( self, parent ):
60
""" Gets a control that can be docked into a DockWindow.
62
print "The 'IDockable.dockable_get_control' method must be overridden"
63
panel = wx.Panel( parent, -1 )
64
panel.SetBackgroundColour( wx.RED )
67
#---------------------------------------------------------------------------
68
# Allows the object to override the default DockControl settings:
69
#---------------------------------------------------------------------------
71
def dockable_init_dockcontrol ( self, dock_control ):
72
""" Allows the object to override the default DockControl settings.
76
#---------------------------------------------------------------------------
77
# Returns the right-click popup menu for a DockControl (if any):
78
#---------------------------------------------------------------------------
80
def dockable_menu ( self, dock_control, event ):
81
""" Returns the right-click popup menu for a DockControl (if any).
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
#---------------------------------------------------------------------------
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.
98
#---------------------------------------------------------------------------
99
# Handles a notebook tab being activated or deactivated:
100
#---------------------------------------------------------------------------
102
def dockable_tab_activated ( self, dock_control, activated ):
103
""" Handles a notebook tab being activated or deactivated.
105
'dock_control' is the control being activated or deactivated.
107
If 'activated' is True, the control is being activated; otherwise
108
the control is being deactivated.
112
#---------------------------------------------------------------------------
113
# Handles the IDockable being bound to a specified DockControl:
114
#---------------------------------------------------------------------------
116
def dockable_bind ( self, dock_control ):
117
""" Handles the dockable being bound to a specified DockControl.