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

Source Code for Module muntjac.ui.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 an extension to the C{IComponentContainer} interface which adds the 
 17  layouting control to the elements in the container.""" 
 18   
 19  from muntjac.ui.component_container import IComponentContainer 
 20   
 21  from muntjac.terminal.gwt.client.ui.v_margin_info import VMarginInfo 
 22  from muntjac.terminal.gwt.client.ui.alignment_info import Bits 
 23   
 24   
25 -class ILayout(IComponentContainer):
26 """Extension to the L{IComponentContainer} interface which adds the 27 layouting control to the elements in the container. This is required by 28 the various layout components to enable them to place other components in 29 specific locations in the UI. 30 31 @author: Vaadin Ltd. 32 @author: Richard Lincoln 33 @version: 1.1.2 34 """ 35
36 - def setMargin(self, *args):
37 """Enable layout margins. Affects all four sides of the layout. This 38 will tell the client-side implementation to leave extra space around 39 the layout. The client-side implementation decides the actual amount, 40 and it can vary between themes. 41 42 Alternatively, enable specific layout margins. This will tell the 43 client-side implementation to leave extra space around the layout in 44 specified edges, clockwise from top (top, right, bottom, left). The 45 client-side implementation decides the actual amount, and it can vary 46 between themes. 47 48 @param args: tuple of the form 49 - (enabled) 50 - (top, right, bottom, left) 51 """ 52 raise NotImplementedError
53 54
55 -class IAlignmentHandler(object):
56 """IAlignmentHandler is most commonly an advanced L{ILayout} that 57 can align its components. 58 """ 59 60 #: Contained component should be aligned horizontally to the left. 61 # 62 # @deprecated: Use of L{Alignment} class and its constants 63 ALIGNMENT_LEFT = Bits.ALIGNMENT_LEFT 64 65 #: Contained component should be aligned horizontally to the right. 66 # 67 # @deprecated: Use of L{Alignment} class and its constants 68 ALIGNMENT_RIGHT = Bits.ALIGNMENT_RIGHT 69 70 #: Contained component should be aligned vertically to the top. 71 # 72 # @deprecated: Use of L{Alignment} class and its constants 73 ALIGNMENT_TOP = Bits.ALIGNMENT_TOP 74 75 #: Contained component should be aligned vertically to the bottom. 76 # 77 # @deprecated: Use of L{Alignment} class and its constants 78 ALIGNMENT_BOTTOM = Bits.ALIGNMENT_BOTTOM 79 80 #: Contained component should be horizontally aligned to center. 81 # 82 # @deprecated: Use of L{Alignment} class and its constants 83 ALIGNMENT_HORIZONTAL_CENTER = Bits.ALIGNMENT_HORIZONTAL_CENTER 84 85 #: Contained component should be vertically aligned to center. 86 # 87 # @deprecated: Use of L{Alignment} class and its constants 88 ALIGNMENT_VERTICAL_CENTER = Bits.ALIGNMENT_VERTICAL_CENTER 89 90
91 - def setComponentAlignment(self, *args):
92 """Set alignment for one contained component in this layout. Alignment 93 is calculated as a bit mask of the two passed values or predefined 94 alignments from Alignment class. 95 96 Example:: 97 layout.setComponentAlignment(myComponent, Alignment.TOP_RIGHT) 98 99 @deprecated: Use L{setComponentAlignment} instead 100 101 @param args: tuple of the form 102 - (childComponent, horizontalAlignment, verticalAlignment) 103 1. the component to align within it's layout cell. 104 2. the horizontal alignment for the child component (left, 105 center, right). Use ALIGNMENT constants. 106 3. the vertical alignment for the child component (top, 107 center, bottom). Use ALIGNMENT constants. 108 - (childComponent, alignment) 109 1. the component to align within it's layout cell. 110 2. the Alignment value to be set 111 """ 112 raise NotImplementedError
113 114
115 - def getComponentAlignment(self, childComponent):
116 """Returns the current Alignment of given component. 117 118 @return: the L{Alignment} 119 """ 120 raise NotImplementedError
121 122
123 -class ISpacingHandler(object):
124 """This type of layout supports automatic addition of space between its 125 components. 126 """ 127
128 - def setSpacing(self, enabled):
129 """Enable spacing between child components within this layout. 130 131 B{NOTE:} This will only affect the space between 132 components, not the space around all the components in the layout 133 (i.e. do not confuse this with the cellspacing attribute of a HTML 134 Table). Use L{setMargin} to add space around the layout. 135 136 See the reference manual for more information about CSS rules for 137 defining the amount of spacing to use. 138 139 @param enabled: 140 true if spacing should be turned on, false if it should be 141 turned off 142 """ 143 raise NotImplementedError
144 145
146 - def isSpacingEnabled(self):
147 """@return: true if spacing between child components within this layout 148 is enabled, false otherwise 149 @deprecated: Use L{isSpacing} instead. 150 """ 151 raise NotImplementedError
152 153
154 - def isSpacing(self):
155 """@return: true if spacing between child components within this layout 156 is enabled, false otherwise 157 """ 158 raise NotImplementedError
159 160
161 -class IMarginHandler(object):
162 """This type of layout supports automatic addition of margins (space around 163 its components). 164 """ 165
166 - def setMargin(self, marginInfo):
167 """Enable margins for this layout. 168 169 B{NOTE:} This will only affect the space around the 170 components in the layout, not space between the components in the 171 layout. Use L{setSpacing} to add space between the components in 172 the layout. 173 174 See the reference manual for more information about CSS rules for 175 defining the size of the margin. 176 177 @param marginInfo: 178 MarginInfo object containing the new margins. 179 """ 180 raise NotImplementedError
181 182
183 - def getMargin(self):
184 """@return: MarginInfo containing the currently enabled margins.""" 185 raise NotImplementedError
186 187
188 -class MarginInfo(VMarginInfo):
189
190 - def __init__(self, *args):
191 super(MarginInfo, self).__init__(*args)
192