Package pyjamas :: Package ui :: Module RowFormatter
[hide private]
[frames] | no frames]

Source Code for Module pyjamas.ui.RowFormatter

 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.ui import Applier 
17   
18 -class RowFormatter(Applier):
19
20 - def __init__(self, outer, **kwargs):
21 self.outer = outer 22 Applier.__init__(self, **kwargs)
23
24 - def addStyleName(self, row, styleName):
25 self.outer.setStyleName(self.ensureElement(row), styleName, True)
26
27 - def getElement(self, row):
28 self.outer.checkRowBounds(row) 29 return self.getRow(self.outer.bodyElem, row)
30
31 - def getStyleName(self, row):
32 return DOM.getAttribute(self.getElement(row), "className")
33
34 - def isVisible(self, row):
35 element = self.getElement(row) 36 return self.outer.isVisible(element)
37
38 - def removeStyleName(self, row, styleName):
39 self.outer.setStyleName(self.getElement(row), styleName, False)
40
41 - def setStyleName(self, row, styleName):
42 elem = self.ensureElement(row) 43 DOM.setAttribute(elem, "className", styleName)
44
45 - def setVerticalAlign(self, row, align):
46 DOM.setStyleAttribute(self.ensureElement(row), "verticalAlign", align)
47
48 - def setVisible(self, row, visible):
49 element = self.ensureElement(row) 50 self.outer.setVisible(element, visible)
51
52 - def ensureElement(self, row):
53 self.outer.prepareRow(row) 54 return self.getRow(self.outer.bodyElem, row)
55
56 - def getRow(self, element, row):
57 return element.rows.item(row)
58
59 - def setStyleAttr(self, row, attrName, value):
60 element = self.ensureElement(row) 61 DOM.setStyleAttribute(element, attrName, value)
62
63 - def setAttr(self, row, attrName, value):
64 element = self.ensureElement(row) 65 DOM.setAttribute(element, attrName, value)
66