Package muntjac :: Package ui :: Module component_container
[hide private]
[frames] | no frames]

Source Code for Module muntjac.ui.component_container

  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  """Defines an extension to the C{IComponent} interface which adds to it the 
 17  capacity to contain other components.""" 
 18   
 19  from muntjac.ui.component import IComponent, Event 
 20   
 21   
22 -class IComponentContainer(IComponent):
23 """Extension to the L{IComponent} interface which adds to it the 24 capacity to contain other components. All UI elements that can have child 25 elements implement this interface. 26 27 @author: Vaadin Ltd. 28 @author: Richard Lincoln 29 @version: 1.1.2 30 """ 31
32 - def addComponent(self, c):
33 """Adds the component into this container. 34 35 @param c: the component to be added. 36 """ 37 raise NotImplementedError
38 39
40 - def removeComponent(self, c):
41 """Removes the component from this container. 42 43 @param c: the component to be removed. 44 """ 45 raise NotImplementedError
46 47
48 - def removeAllComponents(self):
49 """Removes all components from this container.""" 50 raise NotImplementedError
51 52
53 - def replaceComponent(self, oldComponent, newComponent):
54 """Replaces the component in the container with another one without 55 changing position. 56 57 This method replaces component with another one is such way that the 58 new component overtakes the position of the old component. If the old 59 component is not in the container, the new component is added to the 60 container. If the both component are already in the container, their 61 positions are swapped. IComponent attach and detach events should be 62 taken care as with add and remove. 63 64 @param oldComponent: 65 the old component that will be replaced. 66 @param newComponent: 67 the new component to be replaced. 68 """ 69 raise NotImplementedError
70 71
72 - def getComponentIterator(self):
73 """Gets an iterator to the collection of contained components. Using 74 this iterator it is possible to step through all components contained 75 in this container. 76 77 @return: the component iterator. 78 """ 79 raise NotImplementedError
80 81
82 - def requestRepaintAll(self):
83 """Causes a repaint of this component, and all components below it. 84 85 This should only be used in special cases, e.g when the state of a 86 descendant depends on the state of a ancestor. 87 """ 88 raise NotImplementedError
89 90
91 - def moveComponentsFrom(self, source):
92 """Moves all components from an another container into this container. 93 The components are removed from C{source}. 94 95 @param source: 96 the container which contains the components that are to be 97 moved to this container. 98 """ 99 raise NotImplementedError
100 101
102 - def addListener(self, listener, iface=None):
103 """Listens the component attach/detach events. 104 105 @param listener: 106 the listener to add. 107 """ 108 raise NotImplementedError
109 110
111 - def addCallback(self, callback, eventType=None, *args):
112 raise NotImplementedError
113 114
115 - def removeListener(self, listener, iface=None):
116 """Stops the listening component attach/detach events. 117 118 @param listener: 119 the listener to removed. 120 """ 121 raise NotImplementedError
122 123
124 - def removeCallback(self, callback, eventType=None):
125 raise NotImplementedError
126 127
128 -class IComponentAttachListener(object):
129 """IComponent attach listener interface.""" 130
131 - def componentAttachedToContainer(self, event):
132 """A new component is attached to container. 133 134 @param event: 135 the component attach event. 136 """ 137 raise NotImplementedError
138 139
140 -class IComponentDetachListener(object):
141 """IComponent detach listener interface.""" 142
143 - def componentDetachedFromContainer(self, event):
144 """A component has been detached from container. 145 146 @param event: 147 the component detach event. 148 """ 149 raise NotImplementedError
150 151
152 -class ComponentAttachEvent(Event):
153 """IComponent attach event sent when a component is attached to container. 154 """ 155
156 - def __init__(self, container, attachedComponent):
157 """Creates a new attach event. 158 159 @param container: 160 the component container the component has been 161 detached to. 162 @param attachedComponent: 163 the component that has been attached. 164 """ 165 super(ComponentAttachEvent, self).__init__(container) 166 self._component = attachedComponent
167 168
169 - def getContainer(self):
170 """Gets the component container. 171 172 @return: the component container. 173 """ 174 return self.getSource()
175 176
177 - def getAttachedComponent(self):
178 """Gets the attached component. 179 180 @return: the attach component. 181 """ 182 return self._component
183 184
185 -class ComponentDetachEvent(Event):
186 """IComponent detach event sent when a component is detached from 187 container.""" 188
189 - def __init__(self, container, detachedComponent):
190 """Creates a new detach event. 191 192 @param container: 193 the component container the component has been 194 detached from. 195 @param detachedComponent: 196 the component that has been detached. 197 """ 198 super(ComponentDetachEvent, self).__init__(container) 199 self._component = detachedComponent
200 201
202 - def getContainer(self):
203 """Gets the component container. 204 205 @return: the component container. 206 """ 207 return self.getSource()
208 209
210 - def getDetachedComponent(self):
211 """Gets the detached component. 212 213 @return: the detached component. 214 """ 215 return self._component
216