Package muntjac :: Package ui :: Module abstract_ordered_layout :: Class AbstractOrderedLayout
[hide private]
[frames] | no frames]

Class AbstractOrderedLayout

source code

                             object --+                        
                                      |                        
                    util.IEventListener --+                    
                                          |                    
              terminal.paintable.IPaintable --+                
                                              |                
                                 object --+   |                
                                          |   |                
     terminal.variable_owner.IVariableOwner --+                
                                              |                
                                 object --+   |                
                                          |   |                
                terminal.sizeable.ISizeable --+                
                                              |                
                           component.IComponent --+            
                                                  |            
                                     object --+   |            
                                              |   |            
   event.method_event_source.IMethodEventSource --+            
                                                  |            
               abstract_component.AbstractComponent --+        
                                                      |        
                             object --+               |        
                                      |               |        
                    util.IEventListener --+           |        
                                          |           |        
              terminal.paintable.IPaintable --+       |        
                                              |       |        
                                 object --+   |       |        
                                          |   |       |        
     terminal.variable_owner.IVariableOwner --+       |        
                                              |       |        
                                 object --+   |       |        
                                          |   |       |        
                terminal.sizeable.ISizeable --+       |        
                                              |       |        
                           component.IComponent --+   |        
                                                  |   |        
            component_container.IComponentContainer --+        
                                                      |        
abstract_component_container.AbstractComponentContainer --+    
                                                          |    
                             object --+                   |    
                                      |                   |    
                    util.IEventListener --+               |    
                                          |               |    
              terminal.paintable.IPaintable --+           |    
                                              |           |    
                                 object --+   |           |    
                                          |   |           |    
     terminal.variable_owner.IVariableOwner --+           |    
                                              |           |    
                                 object --+   |           |    
                                          |   |           |    
                terminal.sizeable.ISizeable --+           |    
                                              |           |    
                           component.IComponent --+       |    
                                                  |       |    
            component_container.IComponentContainer --+   |    
                                                      |   |    
                                         layout.ILayout --+    
                                                          |    
                                             object --+   |    
                                                      |   |    
                                  layout.IMarginHandler --+    
                                                          |    
                             abstract_layout.AbstractLayout --+
                                                              |
                                                 object --+   |
                                                          |   |
                                   layout.IAlignmentHandler --+
                                                              |
                                                 object --+   |
                                                          |   |
                                     layout.ISpacingHandler --+
                                                              |
                                                 object --+   |
                                                          |   |
                   event.layout_events.ILayoutClickNotifier --+
                                                              |
                                                             AbstractOrderedLayout

Instance Methods [hide private]
 
__init__(self)
Constructs a new component container.
source code
 
addComponent(self, c, index=None)
Add a component into this container.
source code
 
addComponentAsFirst(self, c)
Adds a component into this container.
source code
 
removeComponent(self, c)
Removes the component from this container.
source code
 
getComponentIterator(self)
Gets the component container iterator for going through all the components in the container.
source code
 
getComponentCount(self)
Gets the number of contained components.
source code
 
paintContent(self, target)
Paints the content of this component.
source code
 
replaceComponent(self, oldComponent, newComponent)
Replaces the component in the container with another one without changing position.
source code
 
setComponentAlignment(self, childComponent, alignment, verticalAlignment=None)
Sets the component alignment using a short hand string notation.
source code
 
getComponentAlignment(self, childComponent)
Returns the current Alignment of given component.
source code
 
setSpacing(self, enabled)
Enable spacing between child components within this layout.
source code
 
isSpacingEnabled(self)
Returns: true if spacing between child components within this layout is enabled, false otherwise
source code
 
isSpacing(self)
Returns: true if spacing between child components within this layout is enabled, false otherwise
source code
 
setExpandRatio(self, component, ratio)
This method is used to control how excess space in layout is distributed among components.
source code
 
getExpandRatio(self, component)
Returns the expand ratio of given component.
source code
 
addListener(self, listener, iface=None)
Registers a new (generic) component event listener for the component:
source code
 
addCallback(self, callback, eventType=None, *args) source code
 
removeListener(self, listener, iface=None)
Removes a previously registered component event listener from this component.
source code
 
removeCallback(self, callback, eventType=None) source code
 
getComponentIndex(self, component)
Returns the index of the given component.
source code
 
getComponent(self, index)
Returns the component at the given position.
source code

Inherited from abstract_layout.AbstractLayout: changeVariables, fireClick, getMargin, setMargin

Inherited from abstract_component_container.AbstractComponentContainer: attach, detach, fireComponentAttachEvent, fireComponentDetachEvent, getInvalidSizedChildren, moveComponentsFrom, removeAllComponents, repaintChangedChildTrees, repaintChildTrees, requestRepaintAll, setEnabled, setHeight, setWidth

Inherited from abstract_component.AbstractComponent: __getstate__, __setstate__, addStyleName, childRequestedRepaint, fireComponentErrorEvent, fireComponentEvent, fireEvent, fireRequestRepaintEvent, focus, getApplication, getCSSHeight, getCSSWidth, getCaption, getComponentError, getData, getDebugId, getDescription, getErrorHandler, getErrorMessage, getHeight, getHeightUnits, getIcon, getListeners, getLocale, getParent, getStyle, getStyleName, getWidth, getWidthUnits, getWindow, handleError, hasListeners, isEnabled, isImmediate, isReadOnly, isVisible, paint, parseStringSize, registerCallback, registerListener, removeStyleName, requestRepaint, requestRepaintRequests, setCaption, setComponentError, setData, setDebugId, setDescription, setErrorHandler, setHeightUnits, setIcon, setImmediate, setLocale, setParent, setReadOnly, setSizeFull, setSizeUndefined, setStyle, setStyleName, setVisible, setWidthUnits, withdrawCallback, withdrawListener

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Class Variables [hide private]
  _CLICK_EVENT = 'layout_click'
  ALIGNMENT_DEFAULT = Alignment((Bits.ALIGNMENT_TOP+ Bits.ALIGNM...

Inherited from abstract_component.AbstractComponent: SIZE_PATTERN

Inherited from terminal.sizeable.ISizeable: SIZE_UNDEFINED, UNITS_CM, UNITS_EM, UNITS_EX, UNITS_INCH, UNITS_MM, UNITS_PERCENTAGE, UNITS_PICAS, UNITS_PIXELS, UNITS_POINTS, UNIT_SYMBOLS

Inherited from layout.IAlignmentHandler: ALIGNMENT_BOTTOM, ALIGNMENT_HORIZONTAL_CENTER, ALIGNMENT_LEFT, ALIGNMENT_RIGHT, ALIGNMENT_TOP, ALIGNMENT_VERTICAL_CENTER

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self)
(Constructor)

source code 

Constructs a new component container.

Overrides: object.__init__
(inherited documentation)

addComponent(self, c, index=None)

source code 

Add a component into this container. The component is added to the right or under the previous component or into the indexed position in this container.

Parameters:
  • c - the component to be added.
  • index - the Index of the component position. The components currently in and after the position are shifted forwards.
Overrides: component_container.IComponentContainer.addComponent

addComponentAsFirst(self, c)

source code 

Adds a component into this container. The component is added to the left or on top of the other components.

Parameters:
  • c - the component to be added.

removeComponent(self, c)

source code 

Removes the component from this container.

Parameters:
  • c - the component to be removed.
Overrides: component_container.IComponentContainer.removeComponent

getComponentIterator(self)

source code 

Gets the component container iterator for going through all the components in the container.

Returns:
the Iterator of the components inside the container.
Overrides: component_container.IComponentContainer.getComponentIterator

getComponentCount(self)

source code 

Gets the number of contained components. Consistent with the iterator returned by getComponentIterator.

Returns:
the number of contained components

paintContent(self, target)

source code 

Paints the content of this component.

Parameters:
  • target - the Paint Event.
Raises:
Overrides: abstract_component.AbstractComponent.paintContent

replaceComponent(self, oldComponent, newComponent)

source code 

Replaces the component in the container with another one without changing position.

This method replaces component with another one is such way that the new component overtakes the position of the old component. If the old component is not in the container, the new component is added to the container. If the both component are already in the container, their positions are swapped. IComponent attach and detach events should be taken care as with add and remove.

Parameters:
  • oldComponent - the old component that will be replaced.
  • newComponent - the new component to be replaced.
Overrides: component_container.IComponentContainer.replaceComponent
(inherited documentation)

setComponentAlignment(self, childComponent, alignment, verticalAlignment=None)

source code 

Sets the component alignment using a short hand string notation.

Parameters:
  • childComponent - A child component in this layout
  • alignment - A short hand notation described in AlignmentUtils
Overrides: layout.IAlignmentHandler.setComponentAlignment

Deprecated: Replaced by setComponentAlignment

getComponentAlignment(self, childComponent)

source code 

Returns the current Alignment of given component.

Returns:
the Alignment
Overrides: layout.IAlignmentHandler.getComponentAlignment
(inherited documentation)

setSpacing(self, enabled)

source code 

Enable spacing between child components within this layout.

NOTE: This will only affect the space between components, not the space around all the components in the layout (i.e. do not confuse this with the cellspacing attribute of a HTML Table). Use setMargin to add space around the layout.

See the reference manual for more information about CSS rules for defining the amount of spacing to use.

Parameters:
  • enabled - true if spacing should be turned on, false if it should be turned off
Overrides: layout.ISpacingHandler.setSpacing
(inherited documentation)

isSpacingEnabled(self)

source code 
Returns:
true if spacing between child components within this layout is enabled, false otherwise
Overrides: layout.ISpacingHandler.isSpacingEnabled
(inherited documentation)

isSpacing(self)

source code 
Returns:
true if spacing between child components within this layout is enabled, false otherwise
Overrides: layout.ISpacingHandler.isSpacing
(inherited documentation)

setExpandRatio(self, component, ratio)

source code 

This method is used to control how excess space in layout is distributed among components. Excess space may exist if layout is sized and contained non relatively sized components don't consume all available space.

Example how to distribute 1:3 (33%) for component1 and 2:3 (67%) for component2:

 layout.setExpandRatio(component1, 1)
 layout.setExpandRatio(component2, 2)

If no ratios have been set, the excess space is distributed evenly among all components.

Note, that width or height (depending on orientation) needs to be defined for this method to have any effect.

Parameters:
  • component - the component in this layout which expand ratio is to be set
  • ratio

See Also: ISizeable

getExpandRatio(self, component)

source code 

Returns the expand ratio of given component.

Parameters:
  • component - which expand ratios is requested
Returns:
expand ratio of given component, 0.0 by default

addListener(self, listener, iface=None)

source code 

Registers a new (generic) component event listener for the component:

 class Listening(CustomComponent, IListener):

     # Stored for determining the source of an event
     ok = None

     status = None  # For displaying info about the event

     def __init__(self):
         layout = VerticalLayout()

         # Some miscellaneous component
         name = TextField("Say it all here")
         name.addListener(self)
         name.setImmediate(true)
         layout.addComponent(name)

         # Handle button clicks as generic events instead
         # of Button.ClickEvent events
         ok = new Button("OK")
         ok.addListener(self)
         layout.addComponent(ok)

         # For displaying information about an event
         status = new Label("")
         layout.addComponent(status)

         setCompositionRoot(layout)


     def componentEvent(event):
         # Act according to the source of the event
         if (event.getSource() == ok):
             getWindow().showNotification("Click!")

         status.setValue("Event from " +
                 event.getSource().__class__.__name__
                 + ": " + event.__class__.__name__)


 listening = Listening()
 layout.addComponent(listening)
Parameters:
  • listener - the new IListener to be registered.
Raises:
  • ValueError - unless method has a match in object
Overrides: event.layout_events.ILayoutClickNotifier.addListener
(inherited documentation)

addCallback(self, callback, eventType=None, *args)

source code 
Overrides: event.layout_events.ILayoutClickNotifier.addCallback

removeListener(self, listener, iface=None)

source code 

Removes a previously registered component event listener from this component.

Parameters:
  • listener - the listener to be removed.
Overrides: event.layout_events.ILayoutClickNotifier.removeListener
(inherited documentation)

removeCallback(self, callback, eventType=None)

source code 
Overrides: event.layout_events.ILayoutClickNotifier.removeCallback

getComponentIndex(self, component)

source code 

Returns the index of the given component.

Parameters:
  • component - The component to look up.
Returns:
The index of the component or -1 if the component is not a child.

getComponent(self, index)

source code 

Returns the component at the given position.

Parameters:
  • index - The position of the component.
Returns:
The component at the given index.
Raises:
  • IndexError - If the index is out of range.

Class Variable Details [hide private]

ALIGNMENT_DEFAULT

Value:
Alignment((Bits.ALIGNMENT_TOP+ Bits.ALIGNMENT_LEFT))