1
########################################################################
3
# File Name: HTMLTableRowElement.py
5
# Documentation: http://docs.4suite.com/4DOM/HTMLTableRowElement.py.html
8
WWW: http://4suite.com/4DOM e-mail: support@4suite.com
10
Copyright (c) 2000 Fourthought Inc, USA. All Rights Reserved.
11
See http://4suite.com/COPYRIGHT for license and copyright information
15
from xml.dom import implementation
16
from xml.dom import IndexSizeErr
17
from xml.dom.html.HTMLElement import HTMLElement
19
class HTMLTableRowElement(HTMLElement):
21
def __init__(self, ownerDocument, nodeName='TR'):
22
HTMLElement.__init__(self, ownerDocument, nodeName)
24
### Attribute Methods ###
27
return string.capitalize(self.getAttribute('ALIGN'))
29
def _set_align(self,align):
30
self.setAttribute('ALIGN', align)
32
def _get_bgColor(self):
33
return self.getAttribute('BGCOLOR')
35
def _set_bgColor(self, color):
36
self.setAttribute('BGCOLOR', color)
40
for child in self.childNodes:
41
if child.tagName in ['TD','TH']:
43
return implementation._4dom_createHTMLCollection(cells)
46
return self.getAttribute('CHAR')
48
def _set_ch(self, ch):
49
self.setAttribute('CHAR', ch)
52
return self.getAttribute('CHAROFF')
54
def _set_chOff(self, offset):
55
self.setAttribute('CHAROFF', offset)
57
def _get_rowIndex(self):
58
#Get our index in the table
59
section = self.parentNode
62
table = section.parentNode
65
rows = table._get_rows()
66
return rows.index(self)
68
def _get_sectionRowIndex(self):
69
section = self.parentNode
72
rows = section._get_rows()
73
return rows.index(self)
75
def _get_vAlign(self):
76
return string.capitalize(self.getAttribute('VALIGN'))
78
def _set_vAlign(self, valign):
79
self.setAttribute('VALIGN', valign)
83
def insertCell(self, index):
84
cells = self._get_cells()
85
if index < 0 or index > len(cells):
87
cell = self.ownerDocument.createElement('TD')
89
if index == len(cells):
91
elif index < len(cells):
93
return self.insertBefore(cell, ref)
95
def deleteCell(self,index):
96
cells = self._get_cells()
97
if index < 0 or index >= len(cells):
99
self.removeChild(cells[index])
101
### Attribute Access Mappings ###
103
_readComputedAttrs = HTMLElement._readComputedAttrs.copy()
104
_readComputedAttrs.update ({
105
'rowIndex' : _get_rowIndex,
106
'sectionRowIndex' : _get_sectionRowIndex,
107
'cells' : _get_cells,
108
'align' : _get_align,
109
'bgColor' : _get_bgColor,
111
'chOff' : _get_chOff,
112
'vAlign' : _get_vAlign,
115
_writeComputedAttrs = HTMLElement._writeComputedAttrs.copy()
116
_writeComputedAttrs.update ({
117
'align' : _set_align,
118
'bgColor' : _set_bgColor,
120
'chOff' : _set_chOff,
121
'vAlign' : _set_vAlign,
124
# Create the read-only list of attributes
125
_readOnlyAttrs = filter(lambda k,m=_writeComputedAttrs: not m.has_key(k),
126
HTMLElement._readOnlyAttrs + _readComputedAttrs.keys())