Package muntjac :: Package event :: Module layout_events
[hide private]
[frames] | no frames]

Source Code for Module muntjac.event.layout_events

  1  # Copyright (C) 2012 Vaadin Ltd.  
  2  # Copyright (C) 2012 Richard Lincoln 
  3  #  
  4  # Licensed under the Apache License, Version 2.0 (the "License");  
  5  # you may not use this file except in compliance with the License.  
  6  # You may obtain a copy of the License at  
  7  #  
  8  #     http://www.apache.org/licenses/LICENSE-2.0  
  9  #  
 10  # Unless required by applicable law or agreed to in writing, software  
 11  # distributed under the License is distributed on an "AS IS" BASIS,  
 12  # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  
 13  # See the License for the specific language governing permissions and  
 14  # limitations under the License. 
 15   
 16  from muntjac.event.component_event_listener import IComponentEventListener 
 17  from muntjac.event.mouse_events import ClickEvent 
 18   
 19   
20 -class ILayoutClickListener(IComponentEventListener):
21
22 - def layoutClick(self, event):
23 """Layout has been clicked 24 25 @param event: 26 Component click event. 27 """ 28 raise NotImplementedError
29 30 clickMethod = layoutClick
31 32
33 -class ILayoutClickNotifier(object):
34 """The interface for adding and removing C{LayoutClickEvent} listeners. 35 By implementing this interface a class explicitly announces that it will 36 generate a C{LayoutClickEvent} when a component inside it is clicked and 37 a C{LayoutClickListener} is registered. 38 39 @see: L{LayoutClickListener} 40 @see: L{LayoutClickEvent} 41 """ 42
43 - def addListener(self, listener, iface=None):
44 """Add a click listener to the layout. The listener is called whenever 45 the user clicks inside the layout. An event is also triggered when 46 the click targets a component inside a nested layout or Panel, 47 provided the targeted component does not prevent the click event from 48 propagating. A caption is not considered part of a component. 49 50 The child component that was clicked is included in the 51 L{LayoutClickEvent}. 52 53 Use L{removeListener} to remove the listener. 54 55 @param listener: 56 The listener to add 57 """ 58 raise NotImplementedError
59 60
61 - def addCallback(self, callback, eventType=None, *args):
62 raise NotImplementedError
63 64
65 - def removeListener(self, listener, iface=None):
66 """Removes an LayoutClickListener. 67 68 @param listener: 69 LayoutClickListener to be removed 70 """ 71 raise NotImplementedError
72 73
74 - def removeCallback(self, callback, eventType=None):
75 raise NotImplementedError
76 77
78 -class LayoutClickEvent(ClickEvent):
79 """An event fired when the layout has been clicked. The event contains 80 information about the target layout (component) and the child component 81 that was clicked. If no child component was found it is set to null. 82 """ 83
84 - def __init__(self, source, mouseEventDetails, clickedComponent, 85 childComponent):
86 super(LayoutClickEvent, self).__init__(source, mouseEventDetails) 87 self._clickedComponent = clickedComponent 88 self._childComponent = childComponent
89 90
91 - def getClickedComponent(self):
92 """Returns the component that was clicked, which is somewhere inside 93 the parent layout on which the listener was registered. 94 95 For the direct child component of the layout, see L{getChildComponent}. 96 97 @return: clicked L{Component}, C{None} if none found 98 """ 99 return self._clickedComponent
100 101
102 - def getChildComponent(self):
103 """Returns the direct child component of the layout which contains the 104 clicked component. 105 106 For the clicked component inside that child component of the layout, 107 see L{getClickedComponent}. 108 109 @return: direct child L{Component} of the layout which contains 110 the clicked Component, null if none found 111 """ 112 return self._childComponent
113