def __init__(self, doc, parent, width=None, flowStyle=None, paraStyle=None): """ - parent : the environment to which this environment belongs - width : the outer width of this environment as a flowable. - flowStyle (or outer style) is the paragraph style of this Environment as a flowable inside its parent. - paraStyle (or inner style) is the default paragraph style for elements in this environment. Forwarded to BaseEnvironment. A ChildEnvironment dynamically inherits attributs from its parent. If somebody asks for some attribute from a ChildEnvironment, and if the ChildEnvironment does not have this attribut, then it will forward this request to its parent. """ if paraStyle is None: paraStyle = parent.getDefaultParaStyle() BaseEnvironment.__init__(self, doc, paraStyle) self._parent = parent if flowStyle is None: flowStyle = parent.getDefaultParaStyle() self._flowStyle = flowStyle.child() self._flowStyle.setName("%s.flowStyle" % self.__class__.__name__) if width is None: width = parent.getTextWidth() - self._flowStyle.leftIndent - self._flowStyle.rightIndent # 20030417 - 20 assert isnumber(width) self.width = width
def __init__(self, doc, parent, columns, model, width, flowStyle): # TODO : make a copy of model.columns here so that # TableInstance.addColumn does not modify the model (?) # Currently this is done by child()ing the model... # self.rows = [] self.currentRow = None self._rowIndex = -1 if width is None: width = parent.getTextWidth() assert isnumber(width), "%s is not a number" % repr(width) assert isinstance(model, TableModel) # child() the model because updates to the table instance should # not update the TableModel self.model = model.child() if flowStyle is None: flowStyle = model.flowStyle ChildEnvironment.__init__(self, doc, parent, width, flowStyle, self.model.paraStyle) if columns is not None: assert self.model.getColumnCount() is 0 self.model.isgrowing = False # self.columns = [] if issequence(columns): # it is a sequence of relative widths ## s = 0 ## for w in columns: ## s += w s = reduce(lambda x, y: x + y, columns) # print s for w in columns: self.addColumn(width=w * self.width / s) elif type(columns) is types.StringType: # string of colspecs characters for c in columns: s = self._paraStyle.child(alignment=colspecs[c]) s.setName("%s.defaultParaStyle" % \ c.__class__.__name__) self.addColumn(style=s) else: raise "%s : invalid colSpecs" % repr(columns) #else: # self.columns = list(self.model.columns) if self.model.getColumnCount() > 0: self.computeColWidths() #else: # print 'foo' # "beginTable() must specify the number of columns" """make a copy using list() so that adding cell formats won't
def __init__(self, doc, parent, width=None, flowStyle=None, paraStyle=None): """ - parent : the environment to which this environment belongs - width : the outer width of this environment as a flowable. - flowStyle (or outer style) is the paragraph style of this Environment as a flowable inside its parent. - paraStyle (or inner style) is the default paragraph style for elements in this environment. Forwarded to BaseEnvironment. A ChildEnvironment dynamically inherits attributs from its parent. If somebody asks for some attribute from a ChildEnvironment, and if the ChildEnvironment does not have this attribut, then it will forward this request to its parent. """ if paraStyle is None: paraStyle = parent.getDefaultParaStyle() BaseEnvironment.__init__(self, doc, paraStyle) self._parent = parent if flowStyle is None: flowStyle = parent.getDefaultParaStyle() self._flowStyle = flowStyle.child() self._flowStyle.setName("%s.flowStyle" % \ self.__class__.__name__) if width is None: width = parent.getTextWidth() \ - self._flowStyle.leftIndent \ - self._flowStyle.rightIndent # 20030417 - 20 assert isnumber(width) self.width = width
def __init__(self, doc, parent, columns, model, width, flowStyle ): # TODO : make a copy of model.columns here so that # TableInstance.addColumn does not modify the model (?) # Currently this is done by child()ing the model... # self.rows = [] self.currentRow = None self._rowIndex = -1 if width is None: width = parent.getTextWidth() assert isnumber(width), "%s is not a number" % repr(width) assert isinstance(model,TableModel) # child() the model because updates to the table instance should # not update the TableModel self.model = model.child() if flowStyle is None: flowStyle = model.flowStyle ChildEnvironment.__init__(self, doc, parent,width, flowStyle, self.model.paraStyle) if columns is not None: assert self.model.getColumnCount() is 0 self.model.isgrowing = False # self.columns = [] if issequence(columns): # it is a sequence of relative widths ## s = 0 ## for w in columns: ## s += w s = reduce(lambda x, y: x+y, columns) # print s for w in columns: self.addColumn(width=w * self.width / s) elif type(columns) is types.StringType: # string of colspecs characters for c in columns: s = self._paraStyle.child(alignment=colspecs[c]) s.setName("%s.defaultParaStyle" % \ c.__class__.__name__) self.addColumn(style=s) else: raise "%s : invalid colSpecs" % repr(columns) #else: # self.columns = list(self.model.columns) if self.model.getColumnCount() > 0: self.computeColWidths() #else: # print 'foo' # "beginTable() must specify the number of columns" """make a copy using list() so that adding cell formats won't