class PagesLayoutDef(Struct): fields = [ Field("name", String(None)), Field("page1", String(None)), Field("page2", String(None)), Field("spaceDx", I32(4)) ]
class DirectionalLayoutDataDef(Struct): fields = [ Field("controlName", String(None)), Field("sla", String(None)), # this is really a float Field("snla", String(None)), # this is really a float Field("align", String(None)), ]
class ButtonVectorDef(Struct): fields = [ Field("name", String(None)), Field("clicked", String(None)), Field("path", String(None)), Field("styleDefault", String(None)), Field("styleMouseOver", String(None)), ]
class VerticalLayoutDef(Struct): fields = [ Field("name", String(None)), Field("children", Array(DirectionalLayoutDataDef, []), Compact), ]
class EbookPageDef(Struct): fields = [ Field("name", String(None)), Field("style", String(None)), ]
class ScrollBarDef(Struct): fields = [ Field("name", String(None)), Field("style", String(None)), Field("cursor", String(None)), ]
class ButtonDef(Struct): fields = [ Field("name", String(None)), Field("text", WString(None)), Field("style", String(None)), ]
def GetFields(xml): fields = [] for xml_field in xml.getElementsByTagName("field"): field = Field() for attr_name, attr_value in xml_field.attributes.items(): if attr_name.lower() == "name": field.name = attr_value elif attr_name.lower() == "rname": field.rname = attr_value elif attr_name.lower() == "domain": field.domain = attr_value elif attr_name.lower() == "description": field.description = attr_value elif attr_name.lower() == "props": for prop in attr_value.split(", "): if prop == "input": field.input = True elif prop == "edit": field.edit = True elif prop == "show_in_grid": field.show_in_grid = True elif prop == "show_in_details": field.show_in_details = True elif prop == "is_mean": field.is_mean = True elif prop == "autocalculated": field.autocalculated = True elif prop == "required": field.required = True else: raise ValueError( "Invalid format of props string in constraints: {}" .format(attr_value)) else: raise ValueError( "In tag \"{}\" Invalid attribute name \"{}\"".format( field, attr_name)) fields.append(field) return fields