Package muntjac :: Package ui :: Module css_layout :: Class CssLayout
[hide private]
[frames] | no frames]

Class CssLayout

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 --+   |
                                                          |   |
                   event.layout_events.ILayoutClickNotifier --+
                                                              |
                                                             CssLayout
Known Subclasses:

CssLayout is a layout component that can be used in browser environment only. It simply renders components and their captions into a same div element. Component layout can then be adjusted with css.

In comparison to HorizontalLayout and VerticalLayout

With CustomLayout one can often achieve similar results (good looking layouts with web technologies), but with CustomLayout developer needs to work with fixed templates.

By extending CssLayout one can also inject some css rules straight to child components using getCss.

(*) Relative sizes (set from server side) are treated bit differently than in other layouts in Muntjac. In cssLayout the size is calculated relatively to CSS layouts content area which is pretty much as in html and css. In other layouts the size of component is calculated relatively to the "slot" given by layout.

Also note that client side framework in Muntjac modifies inline style properties width and height. This happens on each update to component. If one wants to set component sizes with CSS, component must have undefined size on server side (which is not the default for all components) and the size must be defined with class styles - not by directly injecting width and height.

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 trough 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
 
getCss(self, c)
Returns styles to be applied to given component.
source code
 
replaceComponent(self, oldComponent, newComponent)
Replaces the component in the container with another one without changing position.
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

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]
  CLIENT_WIDGET = None
hash(x)
  _CLICK_EVENT = 'layout_click'

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

Instance Variables [hide private]
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/under the previous component or into 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 trough 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

getCss(self, c)

source code 

Returns styles to be applied to given component. Override this method to inject custom style rules to components.

Note that styles are injected over previous styles before actual child rendering. Previous styles are not cleared, but overridden.

Note that one most often achieves better code style, by separating styling to theme (with custom theme and addStyleName. With own custom styles it is also very easy to break browser compatibility.

Parameters:
  • c - the component
Returns:
css rules to be applied to component

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)

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