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

Source Code for Module muntjac.ui.ordered_layout

  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 a component container, which shows the subcomponents in the order 
 17  of their addition in specified orientation.""" 
 18   
 19  from warnings import warn 
 20   
 21  from muntjac.ui.abstract_ordered_layout import AbstractOrderedLayout 
 22   
 23   
24 -class OrderedLayout(AbstractOrderedLayout):
25 """Ordered layout. 26 27 C{OrderedLayout} is a component container, which shows the 28 subcomponents in the order of their addition in specified orientation. 29 30 @author: Vaadin Ltd. 31 @author: Richard Lincoln 32 @version: 1.1.2 33 @deprecated: Replaced by VerticalLayout/HorizontalLayout. For type checking 34 please not that VerticalLayout/HorizontalLayout do not extend 35 OrderedLayout but AbstractOrderedLayout (which also 36 OrderedLayout extends). 37 """ 38 39 CLIENT_WIDGET = None #ClientWidget(VOrderedLayout, LoadStyle.EAGER) 40 41 # Components are to be laid out vertically. 42 ORIENTATION_VERTICAL = 0 43 44 # Components are to be laid out horizontally. 45 ORIENTATION_HORIZONTAL = 1 46 47
48 - def __init__(self, orientation=None):
49 """Creates a new ordered layout. The order of the layout defaults to 50 C{ORIENTATION_VERTICAL}. 51 52 @param orientation: the Orientation of the layout. 53 @deprecated: Use VerticalLayout/HorizontalLayout instead. 54 """ 55 warn('use VerticalLayout/HorizontalLayout instead', DeprecationWarning) 56 57 super(OrderedLayout, self).__init__() 58 59 # Orientation of the layout. 60 self._orientation = None 61 62 if orientation is None: 63 orientation = self.ORIENTATION_VERTICAL 64 65 self._orientation = orientation 66 if orientation == self.ORIENTATION_VERTICAL: 67 self.setWidth(100, self.UNITS_PERCENTAGE)
68 69
70 - def getOrientation(self):
71 """Gets the orientation of the container. 72 73 @return: the Value of property orientation. 74 """ 75 return self._orientation
76 77
78 - def setOrientation(self, orientation, needsRepaint=True):
79 """Sets the orientation of this OrderedLayout. This method should only 80 be used before initial paint. 81 82 @param orientation: 83 the New value of property orientation. 84 @deprecated: Use VerticalLayout/HorizontalLayout or define orientation 85 in constructor instead 86 """ 87 # Checks the validity of the argument 88 if (orientation < self.ORIENTATION_VERTICAL 89 or orientation > self.ORIENTATION_HORIZONTAL): 90 raise ValueError() 91 92 self._orientation = orientation 93 if needsRepaint: 94 self.requestRepaint()
95 96
97 - def paintContent(self, target):
98 super(OrderedLayout, self).paintContent(target) 99 100 # Adds the orientation attributes (the default is vertical) 101 if self._orientation == self.ORIENTATION_HORIZONTAL: 102 target.addAttribute('orientation', 'horizontal')
103