Home | Trees | Indices | Help |
|
---|
|
1 # Copyright 2006 James Tauber and contributors 2 # Copyright (C) 2009 Luke Kenneth Casson Leighton <lkcl@lkcl.net> 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 from pyjamas import DOM 16 from pyjamas import Factory 17 18 from pyjamas.ui.ComplexPanel import ComplexPanel 19 from pyjamas.ui import HasHorizontalAlignment 20 from pyjamas.ui import HasVerticalAlignment24 25 _props = [ 26 ("horzAlign", "Horizontal alignment", "HorizontalAlignment", None), 27 ("vertAlign", "Vertical alignment", "VerticalAlignment", None), 28 ("border", "Border width", "BorderWidth", int), 29 ("spacing", "Spacing", "Spacing", None), 30 ("padding", "Padding", "Padding", None) 31 ] 32159 160 161 Factory.registerClass('pyjamas.ui.CellPanel', 'CellPanel', CellPanel) 16234 35 kwargs['Spacing'] = kwargs.get('Spacing', 0) 36 kwargs['Padding'] = kwargs.get('Padding', 0) 37 kwargs['HorizontalAlignment'] = kwargs.get('HorizontalAlignment', 38 HasHorizontalAlignment.ALIGN_LEFT) 39 kwargs['VerticalAlignment'] = kwargs.get('VerticalAlignment', 40 HasVerticalAlignment.ALIGN_TOP) 41 42 element = kwargs.pop('Element', None) or DOM.createTable() 43 fc = DOM.getFirstChild(element) 44 if fc: 45 self.body = fc 46 else: 47 self.body = DOM.createTBody() 48 self.table = element 49 self.setElement(self.table) 50 DOM.appendChild(self.table, self.body) 51 52 ComplexPanel.__init__(self, **kwargs)53 54 @classmethod 57 60 63 66 70 74 77 8082 td = self.getWidgetTd(widget) 83 if td is None: 84 return None 85 return DOM.getAttribute(td, "align")8688 td = self.getWidgetTd(widget) 89 if td is None: 90 return None 91 return DOM.getStyleAttribute(td, "verticalAlign")92 9799 if width is None or width == "": 100 DOM.removeAttribute(self.table, "border") 101 else: 102 DOM.setAttribute(self.table, "border", "%d" % width)103105 td = DOM.getParent(widget.getElement()) 106 if height is None: 107 DOM.removeAttribute(td, "height") 108 else: 109 DOM.setAttribute(td, "height", str(height))110112 td = self.getWidgetTd(widget) 113 if td is not None: 114 if align is None: 115 DOM.removeAttribute(td, "align") 116 else: 117 DOM.setAttribute(td, "align", align)118120 td = self.getWidgetTd(widget) 121 if td is not None: 122 if align is None: 123 DOM.setStyleAttribute(td, "verticalAlign", "") 124 else: 125 DOM.setStyleAttribute(td, "verticalAlign", align)126128 td = DOM.getParent(widget.getElement()) 129 if width is None: 130 DOM.removeAttribute(td, "width") 131 else: 132 DOM.setAttribute(td, "width", str(width))133135 self.spacing = spacing 136 if spacing is None: 137 DOM.removeAttribute(self.table, "cellSpacing") 138 else: 139 DOM.setAttribute(self.table, "cellSpacing", str(spacing))140142 self.padding = padding 143 if padding is None: 144 DOM.removeAttribute(self.table, "cellPadding") 145 else: 146 DOM.setAttribute(self.table, "cellPadding", str(padding))147 150 153 156
Home | Trees | Indices | Help |
|
---|
http://epydoc.sourceforge.net |