Пример #1
0
 def processStruct(self, classes, className):
     global classesEncoded
     classesEncoded[className] = 1
     self.currentClassName = className
     modelRef = progSpec.findSpecOf(classes[0], className, 'model')
     self.resetVars(modelRef)
     self.currentModelSpec = modelRef
     if modelRef == None:
         cdErr('To write a processing function for class "' + className +
               '" a model is needed but is not found.')
     ### Write code for each field
     for field in modelRef['fields']:
         fldCat = progSpec.fieldsTypeCategory(field['typeSpec'])
         fieldName = field['fieldName']
         self.processField(fieldName, field, fldCat)
     self.addOrAmendClasses(classes, className, modelRef)
Пример #2
0
def codeListWidgetManagerClassOverride(classes, listManagerStructName, structTypeName):
    funcTextToUpdateViewWidget      = ''
    funcTextToUpdateEditWidget      = ''
    funcTextToUpdateCrntFromWidget  = ''
    funcTextToPushCrntToListView    = ''
    rowHeaderCode                   = ''
    rowViewCode                     = ''

    # Find the model
    modelRef = progSpec.findSpecOf(classes[0], structTypeName, 'model')
    currentModelSpec = modelRef
    if modelRef==None:
        cdErr('To build a list GUI for list of "'+structTypeName+'" a model is needed but is not found.')

    ### Write code for each field
    for field in modelRef['fields']:
        typeSpec        = field['typeSpec']
        fldCat          = progSpec.fieldsTypeCategory(typeSpec)
        fieldName       = field['fieldName']
        label           = deCamelCase(fieldName)
        CasedFieldName          = fieldName[0].upper() + fieldName[1:]
        widgetName         = CasedFieldName + 'Widget'

        if not progSpec.isAContainer(typeSpec):
            if(fldCat!='struct'):
                rowHeaderCode   += '        their GUI_Frame: '+fieldName + '_header <- makeLabelWidget("'+fieldName+'")\n'
                rowHeaderCode   += '        setLabelWidth('+fieldName+'_header, 15)\n'
                rowHeaderCode   += '        addToContainer(headerBox, '+fieldName+'_header)\n'

            if fldCat=='struct':
                funcTextToUpdateViewWidget     += ''
                funcTextToUpdateEditWidget     += '   /- updateWidgetFromVars()\n'
                funcTextToUpdateCrntFromWidget += '   /- updateVarsFromWidget()\n'
            elif fldCat=='enum' or fldCat=='mode':
                funcTextToUpdateViewWidget     += ''
                funcTextToUpdateEditWidget     += ''
                funcTextToUpdateCrntFromWidget += ''#  crntRecord.'+fieldName+' <- dialog.' + widgetName + '.getValue()\n'
            elif fldCat=='bool':
                funcTextToUpdateViewWidget     += ''
                funcTextToUpdateEditWidget     += ''
                funcTextToUpdateCrntFromWidget += '    crntRecord.'+fieldName+' <- dialog.' + widgetName + '.getValue()\n'
            elif fldCat=='string':
                funcTextToUpdateViewWidget     += ''
                funcTextToUpdateEditWidget     += '    dialog.' + widgetName + '.setValue('+structTypeName+'_ListData[N].'+fieldName+')\n'
                funcTextToUpdateCrntFromWidget += '    me string: '+widgetName+'Str <- string(dialog.' + widgetName + '.getValue())\n'
                funcTextToUpdateCrntFromWidget += '    crntRecord.'+fieldName+' <- '+widgetName+'Str\n'
                rowViewCode                    += '        their GUI_Frame: '+fieldName + '_value <- makeLabelWidget(crntRecord.'+fieldName+'.data())\n'
                rowViewCode                    += '        setLabelWidth('+fieldName+'_value, 15)\n'
                rowViewCode                    += '        addToContainer(rowBox, '+fieldName+'_value)\n'
                rowViewCode                    += '        showWidget('+fieldName+'_value)\n'
            elif fldCat=='int':
                funcTextToUpdateViewWidget     += ''
                funcTextToUpdateEditWidget     += '    dialog.' + widgetName + '.setValue('+structTypeName+'_ListData[N].'+fieldName+')\n'
                #funcTextToUpdateCrntFromWidget += '    me string: '+widgetName+'Str <- string(dialog.' + widgetName + '.getValue())\n'
                #funcTextToUpdateCrntFromWidget += '    crntRecord.'+fieldName+' <- dataStr\n'
                rowViewCode                    += '        their GUI_Frame: '+fieldName + '_value <- makeLabelWidget(toString(crntRecord.'+fieldName+').data())\n'
                rowViewCode                    += '        setLabelWidth('+fieldName+'_value, 15)\n'
                rowViewCode                    += '        addToContainer(rowBox, '+fieldName+'_value)\n'
                rowViewCode                    += '        showWidget('+fieldName+'_value)\n'
            else: print"pattern_MakeGUI.codeListWidgetManagerClassOverride fldCat not specified: ", fldCat;  exit(2)

###############
    CODE = 'struct '+listManagerStructName+''': inherits=ListWidgetManager{
    our <STRUCTNAME>: crntRecord
    our <STRUCTNAME>[our list]: <STRUCTNAME>_ListData
    me <STRUCTNAME>_Dialog_GUI: dialog
    their GUI_Frame:            listViewWidget
    their GUI_Frame[their list]:rows
    their GUI_Frame:            crntRow

    /- Override all these for each new list editing widget
    their GUI_Frame: makeListHeader() <- {
        their GUI_Frame: box <- makeFrameWidget()
        their GUI_Frame: headerRow <- makeRowWidget("")
        their GUI_Frame: headerBox <- makeXStackWidget("")
        <ROWHEADERCODE>
        addToContainer(headerRow, headerBox)
        addToContainer(box, headerRow)
        return(box)
    }

    their GUI_Frame: makeRowView(our <STRUCTNAME>: item) <- {
        crntRecord <- item
        their GUI_Frame: rowBox <- makeXStackWidget("")
        <ROWVIEWCODE>
        showWidget(rowBox)
        return(rowBox)
    }

    their listWidget: makeListViewWidget() <- {
        listViewWidget <- makeListWidget("")
        setListWidgetSelectionMode (listViewWidget, SINGLE)
        withEach item in <STRUCTNAME>_ListData {
            their GUI_Frame: row <- makeRowView(item)
            addToContainer(listViewWidget, row)
        }
        return(listViewWidget)
    }

    me int: pushCrntToList(me int: N) <- {
        <STRUCTNAME>_ListData.pushLast(crntRecord);
        me int: listLength <- getListLength()
        print("listLength: ", listLength)
        their GUI_Frame: row <- makeRowView(crntRecord)
        rows.pushLast(row)
        addToContainer(listViewWidget, row)
        return(listLength)
    }

    void: deleteNthRow(me int: N) <- {
        rows.deleteNth(N)
    }

    their GUI_Frame: getNthRow(me int: N) <-{
        crntRow <- rows[N]
    }

    me int: deleteNthItem(me int: N) <- {
        <STRUCTNAME>_ListData.deleteNth(N)
        me int: retVal <- getListLength()
        return(retVal)
    }

    void: updateViewableWidget() <- {<funcTextToUpdateViewWidget>}
    their GUI_item: makeEditableWidget() <- {return(dialog.make<STRUCTNAME>Widget(crntRecord))}
    void: updateEditableWidget(me int: N) <- {<funcTextToUpdateEditWidget>}
    void: updateCrntFromEdited(me int: N) <- {<funcTextToUpdateCrntFromWidget>}
    void: allocateNewCurrentItem() <- {Allocate(crntRecord)}
    void: copyCrntBackToList(me int: N) <- {<STRUCTNAME>_ListData[N] <- crntRecord}
    void: copyCrntBackToListView(me int: N) <- {
        print("copyCrntBackToListView ", N)
    }
    void: setCurrentItem(me int: idx) <- {crntRecord <- <STRUCTNAME>_ListData[idx]}
    void: setValue(our <STRUCTNAME>[our list]: ListData) <- {<STRUCTNAME>_ListData <- ListData}
    me int: getListLength() <- {return(<STRUCTNAME>_ListData.size())}

    their GUI_item: initWidget(our <STRUCTNAME>[our list]: Data) <- {
        <STRUCTNAME>_ListData <- Data
        Allocate(rows)
        return(ListEdBox.init_dialog(self))
    }
}
'''
    CODE = CODE.replace('<STRUCTNAME>', structTypeName)
    CODE = CODE.replace('<funcTextToUpdateViewWidget>', funcTextToUpdateViewWidget)
    CODE = CODE.replace('<funcTextToUpdateEditWidget>', funcTextToUpdateEditWidget)
    CODE = CODE.replace('<funcTextToUpdateCrntFromWidget>', funcTextToUpdateCrntFromWidget)
    CODE = CODE.replace('<funcTextToPushCrntToListView>', funcTextToPushCrntToListView)
    CODE = CODE.replace('<ROWHEADERCODE>', rowHeaderCode)
    CODE = CODE.replace('<ROWVIEWCODE>', rowViewCode)
    #print '==========================================================\n'+CODE
    codeDogParser.AddToObjectFromText(classes[0], classes[1], CODE, listManagerStructName)
Пример #3
0
def BuildGuiForStruct(classes, className, dialogStyle, newStructName):
    # This makes 4 types of changes to the class:
    #   It adds a widget variable for items in model // newWidgetFields: '    their '+typeName+': '+widgetName
    #   It adds a set Widget from Vars function      // widgetFromVarsCode: Func UpdateWidgetFromVars()
    #   It adds a set Vars from Widget function      // varsFromWidgetCode: Func UpdateVarsFromWidget()
    #   It add an initialize Widgets function.       // widgetInitFuncCode: widgetName+' <- '+makeTypeNameCall+'\n    addToContainer(box, '+widgetName+')\n'

    # dialogStyles: 'Z_stack', 'X_stack', 'Y_stack', 'TabbedStack', 'FlowStack', 'WizardStack', 'Dialog', 'SectionedDialogStack', 'V_viewable'
    # also, handle non-modal dialogs

    global classesEncoded
    global currentClassName
    global currentModelSpec
    classesEncoded[className]=1
    currentClassName = className

    # reset the string vars that accumulate the code
    global newWidgetFields
    global widgetInitFuncCode
    global widgetFromVarsCode
    global varsFromWidgetCode

    newWidgetFields=''
    widgetInitFuncCode=''
    widgetFromVarsCode=''
    varsFromWidgetCode=''

    # Find the model
    modelRef         = progSpec.findSpecOf(classes[0], className, 'model')
    currentModelSpec = modelRef
    if modelRef==None: cdErr('To build a GUI for class "'+className+'" a model is needed but is not found.')
    #TODO: write func body for: widgetFromVarsCode(selected item & click edit) & varsFromWidgetCode(ckick OK from editMode)
    ### Write code for each field
    for field in modelRef['fields']:
        typeSpec     = field['typeSpec']
        fldCat       = progSpec.fieldsTypeCategory(typeSpec)
        fieldName    = field['fieldName']
        labelText    = deCamelCase(fieldName)
        if fieldName=='settings':
            # add settings
            continue

        structTypeName=''
        if fldCat=='struct': # Add a new class to be processed
            structTypeName =typeSpec['fieldType'][0]
            if (progSpec.doesClassDirectlyImlementThisField(classes, structTypeName, structTypeName+':managedWidget')
                    or structTypeName.endswith('Widget')):
                fldCat = 'widget'
            else:
                newGUIStyle    = 'Dialog'
                guiStructName  = structTypeName+'_'+newGUIStyle+'_GUI'
                addNewStructToProcess(guiStructName, structTypeName, 'struct', 'Dialog')

        if fldCat != 'widget' and progSpec.isAContainer(typeSpec):# Add a new list to be processed
            structTypeName = typeSpec['fieldType'][0]
            guiStructName  = structTypeName+'_LIST_View'
            addNewStructToProcess(guiStructName, structTypeName, 'list', 'Dialog')

        #TODO: make actions for each function
        if fldCat=='func':
            if fieldName[-4:]== '_btn':
                buttonLabel = deCamelCase(fieldName[:-4])
                # Add a button whose click calls this.
                print "ADDING BUTTON FOR:", fieldName
                getButtonHandlingCode(classes, buttonLabel, fieldName)

        else: # Here is the main case where code to edit this field is written
            getWidgetHandlingCode(classes, fldCat, fieldName, field, structTypeName, dialogStyle, '')

    # Parse everything
    initFuncName = 'make'+className[0].upper() + className[1:]+'Widget'
    if dialogStyle == 'Z_stack': containerWidget='makeStoryBoardWidget("makeStoryBoardWidget")'
    elif dialogStyle == 'TabbedStack': containerWidget='makeTabbedWidget("makeTabbedWidget")'
    else: containerWidget='makeFrameWidget()'


    CODE =  '''
struct <CLASSNAME> {}
struct <NEWSTRUCTNAME> {
    <NEWWIDGETFIELDS>
    our <CLASSNAME>: <CLASSNAME>_data
    their GUI_Frame: <INITFUNCNAME>(our <CLASSNAME>: Data) <- {
        <CLASSNAME>_data<-Data
        their GUI_Frame:box <- <CONTAINERWIDGET>
        <WIDGETINITFUNCCODE>
        return(box)
    }
    void: setValue(our <CLASSNAME>: var) <- {
        <WIDGETFROMVARSCODE>
    }
    void: getValue() <- {
        <VARSFROMWIDGETCODE>
    }
}\n'''  # TODO: add <VARSFROMWIDGETCODE>

    CODE = CODE.replace('<NEWSTRUCTNAME>', newStructName)
    CODE = CODE.replace('<NEWWIDGETFIELDS>', newWidgetFields)
    CODE = CODE.replace('<CLASSNAME>', className)
    CODE = CODE.replace('<WIDGETINITFUNCCODE>', widgetInitFuncCode)
    CODE = CODE.replace('<INITFUNCNAME>', initFuncName)
    CODE = CODE.replace('<WIDGETFROMVARSCODE>', widgetFromVarsCode)
    CODE = CODE.replace('<VARSFROMWIDGETCODE>', varsFromWidgetCode)
    CODE = CODE.replace('<CONTAINERWIDGET>', containerWidget)
    if newStructName == "EntryPad_Dialog_GUI":print '==========================================================\n'+CODE
    codeDogParser.AddToObjectFromText(classes[0], classes[1], CODE, newStructName)
Пример #4
0
def BuildGuiForList(classes, className, dialogStyle, newStructName):
    # This makes 4 types of changes to the class:
    #   It adds a widget variable for items in model // newWidgetFields: '    their '+typeName+': '+widgetName
    #   It adds a set Widget from Vars function      // widgetFromVarsCode: Func UpdateWidgetFromVars()
    #   It adds a set Vars from Widget function      // varsFromWidgetCode: Func UpdateVarsFromWidget()
    #   It add an initialize Widgets function.       // widgetInitFuncCode: widgetName+' <- '+makeTypeNameCall+'\n    addToContainer(box, '+widgetName+')\n'

    # dialogStyles: 'Z_stack', 'X_stack', 'Y_stack', 'TabbedStack', 'FlowStack', 'WizardStack', 'Dialog', 'SectionedDialogStack'
    # also, handle non-modal dialogs

    global classesEncoded
    global currentClassName
    global currentModelSpec
    classesEncoded[className]=1
    currentClassName = className

    # reset the string vars that accumulate the code
    global newWidgetFields
    global widgetInitFuncCode
    global widgetFromVarsCode
    global varsFromWidgetCode

    newWidgetFields=''
    widgetInitFuncCode=''
    widgetFromVarsCode=''
    varsFromWidgetCode=''

    # Find the model
    modelRef            = progSpec.findSpecOf(classes[0], className, 'model')
    if modelRef==None: cdErr('To build a GUI for a list of "'+className+'" a model is needed but is not found.')
    currentModelSpec    = modelRef
    rowHeaderCode       = ''
    rowViewCode         = ''
    for field in modelRef['fields']:
        fieldName       = field['fieldName']
        typeSpec        = field['typeSpec']
        fldCat          = progSpec.fieldsTypeCategory(typeSpec)
        fieldType       = progSpec.fieldTypeKeyword(field['typeSpec']['fieldType'])
        [fieldSpec, params] = getFieldSpec(fldCat, field)
        structTypeName  =''
        if fldCat=='struct': # Add a new class to be processed
            structTypeName =typeSpec['fieldType'][0]
            newGUIStyle    = 'Dialog'
            guiStructName  = structTypeName+'_'+newGUIStyle+'_GUI'
            addNewStructToProcess(guiStructName, structTypeName, 'struct', 'Dialog')

        if progSpec.isAContainer(typeSpec):# Add a new list to be processed
            structTypeName = typeSpec['fieldType'][0]
            guiStructName  = structTypeName+'_LIST_View'
            addNewStructToProcess(guiStructName, structTypeName, 'list', 'Dialog')


    CODE =  '''struct <NEWSTRUCTNAME>{
    our <CLASSNAME>[our list]: <CLASSNAME>_ListData
    our <CLASSNAME>:   crntRecord
}
'''

    CODE = CODE.replace('<NEWSTRUCTNAME>', newStructName)
    CODE = CODE.replace('<CLASSNAME>', className)
    CODE = CODE.replace('<NEWWIDGETFIELDS>', newWidgetFields)
    CODE = CODE.replace('<WIDGETFROMVARSCODE>', widgetFromVarsCode)
    CODE = CODE.replace('<VARSFROMWIDGETCODE>', varsFromWidgetCode)
    #print '==========================================================\n'+CODE
    codeDogParser.AddToObjectFromText(classes[0], classes[1], CODE, newStructName)
Пример #5
0
    def getDashDeclAndUpdateCode(self, owner, fieldLabel, fieldRef, fieldName,
                                 field, skipFlags, indent):
        global classesToProcess
        global classesEncoded
        itemName = '_' + fieldName + '_item'
        dashKeyName = '_' + fieldName + '_dash_key'
        OldElementsName = '_' + fieldName + 'OldElements'
        [
            structText, updateFuncText, setPosFuncText, drawFuncText,
            handleClicksFuncText
        ] = ['', '', '', '', '']
        typeSpec = field['typeSpec']
        fldCat = progSpec.fieldsTypeCategory(typeSpec)
        if fldCat == 'func': return ['', '', '', '', '']
        if progSpec.typeIsPointer(
                typeSpec) and skipFlags != 'skipPtr':  # Header for a POINTER
            fieldName += 'Ptr'
            if fieldRef == 'data.itmItr':
                innerUpdateFuncStr = '"ItmItr"'  # TODO: unhard code this reference to itmItr
            else:
                innerUpdateFuncStr = fieldRef + '.mySymbol(' + fieldRef + ')'
            updateFuncText += '        ' + fieldName + '.dashParent <- self\n'
            updateFuncText += "        " + fieldName + '.update(' + fieldLabel + ', ' + innerUpdateFuncStr + ', isNull(' + innerUpdateFuncStr + '))\n'
            structText += "    " + owner + " ptrToItem: " + fieldName + "\n"

        elif progSpec.isAContainer(
                typeSpec
        ) and skipFlags != 'skipLists':  # Header and items for LIST
            dispStructTypeName = "display_" + progSpec.getFieldType(
                field['typeSpec'])[0]
            innerUpdateFuncStr = '"Size:"+toString(data.' + fieldName + '.size())'
            updateFuncText += "        " + fieldName + '.dashParent <- self\n'
            updateFuncText += '        ' + 'our dash[our list]: ' + OldElementsName + ' <- ' + fieldName + '.elements\n'
            updateFuncText += "        " + fieldName + '.update(' + fieldLabel + ', ' + innerUpdateFuncStr + ', isNull(' + innerUpdateFuncStr + '), true)\n'
            ## Now push each item
            innerFieldType = progSpec.getFieldType(typeSpec)
            containerTypeSpec = progSpec.getContainerSpec(typeSpec)
            if len(containerTypeSpec) > 3 and (
                    containerTypeSpec[1] == 'map' or containerTypeSpec[1]
                    == 'multimap') and containerTypeSpec[2][0] == 'string':
                itemKeyCode = itemName + '_key'
            else:
                itemKeyCode = 'toString(' + itemName + '_key)'
            fldCatInner = progSpec.innerTypeCategory(innerFieldType)
            if fieldRef == 'data.itmItr' or fieldRef == 'data.items':
                newFieldRef = itemName + ''  # TODO: unhard code this reference to itmItr
            else:
                newFieldRef = 'data.' + fieldName + '[' + itemName + '_key]'
            newFieldLabel = '"["+' + itemKeyCode + '+"]  "+ ' + itemName + '.mySymbol(' + itemName + ')'
            updateFuncText += '\n        ' + 'me int64: ' + dashKeyName + ' <- 0'
            updateFuncText += "\n        withEach " + itemName + " in data." + fieldName + "{\n"
            [
                innerStructText, innerUpdateFuncText, innerDrawFuncText,
                innerSetPosFuncText, innerHandleClicksFuncText
            ] = self.getDashDeclAndUpdateCode('our', newFieldLabel,
                                              newFieldRef, 'newItem', field,
                                              'skipLists', '        ')
            updateFuncText += '            ' + innerStructText
            updateFuncText += '            me bool: _elementExists <- false\n'
            updateFuncText += '            ' + 'if(' + OldElementsName + '!=NULL){\n'
            updateFuncText += '                ' + 'withEach _ElItem in ' + OldElementsName + '{\n'
            updateFuncText += '                    ' + 'if(asClass(' + dispStructTypeName + ', _ElItem).data === ' + itemName + '){\n'
            updateFuncText += '                        ' + '_elementExists <- true; break();\n'

            updateFuncText += '            ' + '}}}\n'
            updateFuncText += '            ' + 'if(!_elementExists){\n'
            updateFuncText += '                Allocate(newItem)\n'
            updateFuncText += '                newItem.dashParent <- self\n'
            updateFuncText += '               ' + 'addDependent(' + itemName + '.mySymbol(' + itemName + '), newItem)'
            updateFuncText += '\n            } else {\n               newItem <- asClass(' + dispStructTypeName + ', ' + OldElementsName + '[' + dashKeyName + '])\n            ' + dashKeyName + ' <- ' + dashKeyName + ' + 1'
            updateFuncText += '\n            }'
            updateFuncText += '\n            ' + innerUpdateFuncText
            updateFuncText += '            ' + fieldName + '.updatePush(newItem)'
            updateFuncText += '\n        }\n'
            structText += '    ' + owner + ' listOfItems: ' + fieldName + '\n'
        elif (fldCat == 'struct'):  # Header for a STRUCT
            updateFuncText += "        " + fieldName + '.dashParent <- self\n'
            updateFuncText += "        " + fieldName + '.update(' + fieldLabel + ', ">", ' + fieldRef + ')\n'
            structTypeName = progSpec.getNewContainerFirstElementTypeTempFunc(
                typeSpec)
            if structTypeName == None:
                structTypeName = progSpec.getFieldType(typeSpec)[0]
            structText += "    " + owner + " display_" + structTypeName + ': ' + fieldName + "\n"

            # Add new classname to a list so it can be encoded.
            if not (structTypeName in classesToProcess):
                classesToProcess.append(structTypeName)

        else:  # Display field for a BASIC TYPES
            valStr = ''
            if (fldCat == 'int' or fldCat == 'double'):
                valStr = 'toString(data.' + fieldName + ')'
            elif (fldCat == 'string' or fldCat == 'char'):
                valStr = '"\'"+' + 'data.' + fieldName + '+"\'"'
            elif (fldCat == 'flag' or fldCat == 'bool'):
                valStr = 'toString((data.' + fieldName + ')!=0)'
            elif (fldCat == 'mode'):
                valStr = fieldRef + 'Strings[data.' + fieldName + '] '

            updateFuncText = "        " + fieldName + '.update(100, 180, ' + fieldLabel + ', ' + valStr + ', isNull(' + valStr + '))\n'
            structText += "    " + owner + " dataField: " + fieldName + "\n"

        drawFuncText = "        " + fieldName + '.draw(cr)\n'
        setPosFuncText += '''        if(!<fieldName>.isNullLike or displayMode==fullDisplay){
                <fieldName>.setPos(x,y,extC)
                extC <- <fieldName>.extC
                y <- y + <fieldName>.height
                extX <- max(extX, <fieldName>.extX)
                extY <- max(extY, <fieldName>.extY)
                width<- max(width, <fieldName>.width)
                <fieldName>.isHidden<-false
            } else {<fieldName>.isHidden<-true}
    '''.replace('<fieldName>', fieldName)
        #  updateFuncText+='        if(crntWidth<'+fieldName+'.width){crntWidth <- '+fieldName+'.width}'
        handleClicksFuncText = '            ' + fieldName + '.primaryClick(event)'
        return [
            structText, updateFuncText, drawFuncText, setPosFuncText,
            handleClicksFuncText
        ]
Пример #6
0
    def addOrAmendClasses(self, classes, className, modelRef):
        self.setPosFuncTextAcc += '\n        y <- y+5' + '\n        height <- y-posY' + '\n        me int:depX <- posX+width+40\n'
        countOfRefs = 0
        for field in modelRef['fields']:
            typeSpec = field['typeSpec']
            typeName = progSpec.getFieldType(field['typeSpec'])[0]
            fldCat = progSpec.fieldsTypeCategory(typeSpec)
            if fldCat == 'func': continue
            if progSpec.typeIsPointer(typeSpec):  # Draw dereferenced POINTER
                fieldName = field['fieldName']
                dispStructTypeName = "display_" + typeName
                declSymbolStr = '    '
                if (countOfRefs == 0): declSymbolStr += 'me string: '
                countOfRefs += 1
                [
                    structText, updateFuncText, drawFuncText, setPosFuncText,
                    handleClicksFuncText
                ] = self.getDashDeclAndUpdateCode('their',
                                                  '"' + fieldName + '"',
                                                  'data.' + fieldName,
                                                  fieldName, field, 'skipPtr',
                                                  '    ')
                self.structTextAcc += structText
                tempFuncText = updateFuncText
                updateFuncText = declSymbolStr + 'mySymbol <- data.' + fieldName + '.mySymbol(data.' + fieldName + ')\n'
                updateFuncText += (
                    '    if(data.' + fieldName + ' != NULL){\n' + '        ' +
                    fieldName + ' <- asClass(' + dispStructTypeName +
                    ', dependentIsRegistered(mySymbol))\n'
                    '        if(!' + fieldName + '){'
                    '\n            Allocate(' + fieldName + ')' +
                    '\n            ' + fieldName + '.dashParent <- self' +
                    '\n            addDependent(mySymbol, ' + fieldName + ')' +
                    '\n' + tempFuncText + '\n        }\n    } else {' +
                    fieldName + ' <- NULL}\n')
                self.updateFuncTextPart2Acc += updateFuncText
                self.setPosFuncTextAcc += '''
    if(<fieldName> != NULL and !<fieldName>Ptr.refHidden){
        if(!<fieldName>.posIsSet){
            <fieldName>.setPos(depX, extC, extC)
            extC <- <fieldName>.extY + 40
            extX <- max(extX, <fieldName>.extX)
            extY <- max(extY, <fieldName>.extY)
        }
        addRelation("arrow", <fieldName>Ptr, <fieldName>)
    }
'''.replace('<fieldName>', fieldName)
                self.handleClicksFuncTxtAcc2 += '    if(' + fieldName + ' != NULL and !' + fieldName + 'Ptr.refHidden){\n' + fieldName + '.isHidden<-false\n    }\n'

        Code = '''
struct display_''' + className + ": inherits=dash" + '''{
    me bool: isChanged
    me dataField: header
    me mode[headerOnly, fullDisplay, noZeros]: displayMode
    their ''' + className + ''': data
''' + self.structTextAcc + '''

    void: update(me string: _label, me string: textValue, their ''' + className + ''': _Data) <- {
        title <- "''' + className + ''':" + _label
        isChanged <- !(data === _Data)
        data <- _Data
        if(data==NULL){
            header.update(100, 180, _label, "NULL", false)
            return()
        }
        header.update(100, 180, _label, textValue, false)
        if(isChanged){displayMode<-headerOnly}
''' + self.updateFuncTextAcc + '''

''' + self.updateFuncTextPart2Acc + '''
    }

    void: setPos(me int:x, me int:y, me int: extCursor) <- {
        posIsSet <- true
        posX <- x;
        posY <- y;
        extC <- extCursor
        isHidden<-false
        header.setPos(x,y,extC)
        y <- y+header.height
        width <- header.width
        height <- y-posY
        extX <- header.extX
        extY <- max(y, extC)
        if(displayMode!=headerOnly){
            x <- x+10    // Indent fields in a struct
''' + self.setPosFuncTextAcc + '''
            width <- width+10
        }
    }


    me bool: primaryClick(their GUI_ButtonEvent: event) <- {
        if(isHidden){return(false)}
        me GUI_Scalar: eventX <- event.x
        me GUI_Scalar: eventY <- event.y
        if( header.isTouching(eventX, eventY)){
            if(displayMode==headerOnly){displayMode <- noZeros}
            else if(displayMode==noZeros){displayMode <- fullDisplay}
            else if(displayMode==fullDisplay){displayMode <- headerOnly}
        } else {
''' + self.handleClicksFuncTextAcc + '''
        }

''' + self.handleClicksFuncTxtAcc2 + '''

        return(true)
    }

    void: draw(their GUI_ctxt: cr) <- {
        header.isHidden <- false
        me cdColor: hedrColor <- styler.frGndColor
        cr.setColor(hedrColor)
        header.draw(cr)
        cr.strokeNow()
        hedrColor <- styler.frGndColor
        cr.setColor(hedrColor)
        if(displayMode!=headerOnly){
''' + self.drawFuncTextAcc + '''
            me cdColor: rectColor <- styler.color(data.mySymbol(data), styler.frGndColor)
            cr.setColor(rectColor)
            cr.rectangle(posX, posY, width, height)
            cr.strokeNow()
            rectColor <- styler.frGndColor
            cr.setColor(rectColor)
''' + self.drawFuncTextPart2Acc + '''
        }
    }
}\n'''
        #if className == 'pureInfon': print Code
        codeDogParser.AddToObjectFromText(classes[0], classes[1], Code,
                                          'display_' + className)
Пример #7
0
def BuildGuiForStruct(classes, className, dialogStyle, newStructName):
    # This makes 4 types of changes to the class:
    #   It adds a widget variable for items in model // newWidgetFields: '    their '+typeName+': '+widgetName
    #   It adds a set Widget from Vars function      // widgetFromVarsCode: Func setValue()
    #   It adds a set Vars from Widget function      // varsFromWidgetCode: Func getValue()
    #   It add an initialize Widgets function.       // widgetInitFuncCode: widgetName+' <- '+makeTypeNameCall+'\n    addToContainer(box, '+widgetName+')\n'

    # dialogStyles: 'Z_stack', 'X_stack', 'Y_stack', 'TabbedStack', 'FlowStack', 'WizardStack', 'Dialog', 'SectionedDialogStack', 'V_viewable'
    # also, handle non-modal dialogs
    global classesEncoded
    global currentClassName
    global currentModelSpec
    classesEncoded[className] = 1
    currentClassName = className

    # reset the string vars that accumulate the code
    global newWidgetFields
    global widgetInitFuncCode
    global widgetFromVarsCode
    global varsFromWidgetCode
    global clearWidgetCode

    newWidgetFields = ''
    widgetInitFuncCode = ''
    widgetFromVarsCode = ''
    varsFromWidgetCode = ''
    clearWidgetCode = ''
    containerWidget = ''
    boxFooterCode = ''
    scrollerCode = ''
    onLoadedCode = ''
    tagCode = ''
    makeBoxFooter = False
    makeBackBtn = False
    makeNextBtn = False
    makeVScroller = False

    # Find the model
    modelRef = findModelRef(classes[0], className)
    currentModelSpec = modelRef
    classPrimaryGuiItem = progSpec.searchATagStore(modelRef['tags'],
                                                   'primaryGuiItem')
    if classPrimaryGuiItem != None:  # This GUI Item is important visually
        classPrimaryGuiItem = classPrimaryGuiItem[0]
    classOptionsTags = progSpec.searchATagStore(modelRef['tags'],
                                                'classOptions')
    guiStyleTag = progSpec.searchATagStore(modelRef['tags'], 'dialogStyle')
    if guiStyleTag != None:  # This GUI Item is important visually
        guiStyleTag = guiStyleTag[0]
        if guiStyleTag == 'WizardStack': dialogStyle = 'WizardStack'
        if guiStyleTag == 'Z_stack': dialogStyle = 'Z_stack'
        if guiStyleTag == 'WizardChild':
            dialogStyle = 'WizardChild'
            makeBoxFooter = True
            makeBackBtn = True
            makeNextBtn = True
            clickNextLabel = "Next"
        if guiStyleTag == 'WizardChildLast':
            dialogStyle = 'WizardChild'
            makeBoxFooter = True
            makeBackBtn = True
            makeNextBtn = True
            clickNextLabel = "Done"
        if guiStyleTag == 'WizardChildFirst':
            dialogStyle = 'WizardChild'
            makeBoxFooter = True
            makeNextBtn = True
            clickNextLabel = "Next"
    classProperties = progSpec.searchATagStore(modelRef['tags'], 'properties')
    if classProperties != None:
        for classProperty in classProperties:
            if classProperty[0] == 'vScroller': makeVScroller = True
    ### Write code for each field
    for field in modelRef['fields']:
        typeSpec = field['typeSpec']
        fldCat = progSpec.fieldsTypeCategory(typeSpec)
        fieldName = field['fieldName']
        labelText = deCamelCase(fieldName)
        fieldType = typeSpec['fieldType']
        if fieldName == 'settings':
            # add settings
            continue

        structTypeName = ''
        if fldCat == 'struct':  # Add a new class to be processed
            structTypeName = typeSpec['fieldType'][0]
            if (progSpec.doesClassDirectlyImlementThisField(
                    classes, structTypeName, structTypeName + ':managedWidget')
                    or structTypeName.endswith('Widget')):
                fldCat = 'widget'
            else:
                newGUIStyle = 'Dialog'
                guiStructName = structTypeName + '_' + newGUIStyle + '_GUI'
                addNewStructToProcess(guiStructName, structTypeName, 'struct',
                                      'Dialog')

        if fldCat != 'widget' and progSpec.isAContainer(
                typeSpec):  # Add a new list to be processed
            if not isinstance(fieldType, str): fieldType = fieldType[0]
            structTypeName = fieldType
            guiStructName = structTypeName + '_ROW_View'
            addNewStructToProcess(guiStructName, structTypeName, 'list',
                                  'Dialog')

        #TODO: make actions for each function
        if fldCat == 'func':
            if fieldName[-4:] == '_btn':
                buttonLabel = deCamelCase(fieldName[:-4])
                # Add a button whose click calls this.
                print('ADDING BUTTON FOR:', fieldName)
                getButtonHandlingCode(classes, buttonLabel, fieldName)

        else:  # Here is the main case where code to edit this field is written
            getWidgetHandlingCode(classes, fldCat, fieldName, field,
                                  structTypeName, dialogStyle,
                                  classPrimaryGuiItem, classOptionsTags, '')

    onLoadedCode = 'onLoaded()\n'
    returnCode = '        return(box)'
    if dialogStyle == 'Z_stack':
        newWidgetFields += '    their GUI_ZStack: Zbox\n'
        newWidgetFields += '    me List<me string>: children\n'
        newWidgetFields += '    me int: activeScreenIdx <-1\n'
        newWidgetFields += '    void: setActiveChild(me int: N) <- {\n'
        newWidgetFields += '        if (N >= 0 and N < children.size()){'
        newWidgetFields += '            me string: childName <- children[N]\n'
        #newWidgetFields   += '            print("^^^setZStackActive: ",N)\n'
        newWidgetFields += '            setZStackActive(Zbox, childName)\n'
        newWidgetFields += '            activeScreenIdx <- N\n'
        newWidgetFields += '        }\n'
        newWidgetFields += '    }\n'
        containerWidget = 'Zbox <- makeZStack("' + className + '")\n'
        onLoadedCode = 'setActiveChild(0)\n'
        onLoadedCode += '        onLoaded()\n'
        returnCode = '        return(Zbox)\n'
    elif dialogStyle == 'TabbedStack':
        containerWidget = 'their GUI_Frame:box <- makeTabbedWidget("makeTabbedWidget")'
    elif dialogStyle == 'WizardStack':
        newWidgetFields += '    our wizardWidget: wiz\n'
        newWidgetFields += '    their GUI_Frame: box\n'
        newWidgetFields += '''    void: clickNext() <-{
            me int: size <- wiz.children.size()
            if (wiz.activeScreenIdx == size-1){
                _data.wizardFinished(wiz.widgetID)
            }
            else if (wiz.activeScreenIdx < size-1){
                wiz.activeScreenIdx <- wiz.activeScreenIdx+1
                wiz.setActiveChild(wiz.activeScreenIdx)
            }
        }\n'''
        newWidgetFields += '''    void: clickBack() <-{
            me int: size <- wiz.children.size()
            if (wiz.activeScreenIdx > 0){wiz.activeScreenIdx <- wiz.activeScreenIdx-1}
            wiz.setActiveChild(wiz.activeScreenIdx)
        }\n'''
        containerWidget = 'Allocate(wiz)\n'
        containerWidget += '        box <- wiz.initWidget("' + currentClassName + '")\n'
        containerWidget += '        wiz._data <- _data\n'
        containerWidget += '        wiz.parentGuiMgr <- self\n'
        widgetInitFuncCode += '        wiz.activeScreenIdx <- 0\n'
        widgetInitFuncCode += '        wiz.setActiveChild(wiz.activeScreenIdx)\n'
    elif dialogStyle == 'X_stack':
        newWidgetFields += '    their GUI_XStack:box\n'
        containerWidget = 'box <- makeXStack("")'
    elif dialogStyle == 'rowWidget':
        newWidgetFields += '    their GUI_XStack: box\n'
        containerWidget = 'box <- makeXStack("")'
    else:
        newWidgetFields += '    their GUI_Frame:box\n'
        containerWidget = 'box <- makeYStack("")'
    if makeBoxFooter:
        newWidgetFields += '    their GUI_Frame:  boxFooter\n'
        boxFooterCode += 'boxFooter       <- makeXStack("")\n'
        if makeBackBtn:
            newWidgetFields += '    their GUI_button: backBtn\n'
            newWidgetFields += '    void: clickBack() <-{parentGuiMgr.clickBack()}\n'
            boxFooterCode += '        backBtn         <- makeButtonWidget("Back")\n'
            boxFooterCode += '        GUI.setBtnCallback(backBtn, "clicked", clickBack, this)\n'
            boxFooterCode += '        addToContainer(boxFooter, backBtn)\n'
            tagCode += ''
        if makeNextBtn:
            newWidgetFields += '    their GUI_button: nextBtn\n'
            newWidgetFields += '''    void: clickNext() <-{
                if(isComplete()){
                    save()
                    parentGuiMgr.clickNext()
                }
            }\n'''
            newWidgetFields += '''    void: setNextBtnActive(me bool: checkState) <-{
                nextBtn.setWidgetActive(checkState)
            }\n'''
            newWidgetFields += '''    void: onChanged() <- {
                getValue()
                setNextBtnActive(isComplete())
            }\n'''
            boxFooterCode += '        nextBtn         <- makeButtonWidget("' + clickNextLabel + '")\n'
            boxFooterCode += '        nextBtn.setWidgetActive(false)\n'
            boxFooterCode += '        GUI.setBtnCallback(nextBtn, "clicked", clickNext, this)\n'
            boxFooterCode += '        addToContainer(boxFooter, nextBtn)\n'
            tagCode += ''
        boxFooterCode += '        addToContainer(box, boxFooter)\n'
    if makeVScroller:
        scrollerCode = 'their GUI_VerticalScroller: scroller <- makeVerticalScroller()\n'
        scrollerCode += 'addToContainerAndExpand(scroller, box)\n'
        returnCode = 'return (scroller)'

    CODE =  '''
struct <CLASSNAME>:inherits=appComponentData{}
struct <NEWSTRUCTNAME>:inherits=appComponentGUI '''+tagCode+'''{
    '''+newWidgetFields+'''
    our <CLASSNAME>: _data
    their GUI_Frame: initWidget(our <CLASSNAME>: Data) <- {
        _data <- Data
        _data.guiMgr <- self
        '''+containerWidget+'''
        '''+widgetInitFuncCode+'''
        '''+boxFooterCode+'''
        '''+scrollerCode+'''
        '''+onLoadedCode+'''
        '''+returnCode+'''
    }
    void: setValue(our <CLASSNAME>: var) <- {
        '''+widgetFromVarsCode+'''
    }
    void: getValue() <- {
        '''+varsFromWidgetCode+'''
    }
    void: clear() <- {
        '''+clearWidgetCode+'''
    }
}\n'''  # TODO: add <VARSFROMWIDGETCODE>

    CODE = CODE.replace('<NEWSTRUCTNAME>', newStructName)
    CODE = CODE.replace('<CLASSNAME>', className)
    #print ('==========================================================\n'+CODE)
    codeDogParser.AddToObjectFromText(classes[0], classes[1], CODE,
                                      newStructName)
Пример #8
0
def buildListRowView(classes, className, dialogStyle, newStructName):
    # This makes 4 types of changes to the class:
    #   It adds a widget variable for items in model // newWidgetFields: '    their '+typeName+': '+widgetName
    #   It adds a set Widget from Vars function      // widgetFromVarsCode: Func UpdateWidgetFromVars()
    #   It adds a set Vars from Widget function      // varsFromWidgetCode: Func UpdateVarsFromWidget()
    #   It add an initialize Widgets function.       // widgetInitFuncCode: widgetName+' <- '+makeTypeNameCall+'\n    addToContainer(box, '+widgetName+')\n'

    # dialogStyles: 'Z_stack', 'X_stack', 'Y_stack', 'TabbedStack', 'FlowStack', 'WizardStack', 'Dialog', 'SectionedDialogStack'
    # also, handle non-modal dialogs

    global classesEncoded
    global currentClassName
    global currentModelSpec
    classesEncoded[className] = 1
    currentClassName = className

    # reset the string vars that accumulate the code
    global newWidgetFields
    global widgetInitFuncCode
    global widgetFromVarsCode
    global varsFromWidgetCode
    global clearWidgetCode

    newWidgetFields = ''
    widgetInitFuncCode = ''
    widgetFromVarsCode = ''
    varsFromWidgetCode = ''
    clearWidgetCode = ''
    funcTextToUpdateViewWidget = ''
    funcTextToUpdateEditWidget = ''
    funcTextToUpdateCrntFromWidget = ''

    # Find the model
    modelRef = findModelRef(classes[0], className)
    currentModelSpec = modelRef
    rowHeaderCode = ''
    rowViewCode = ''
    for field in modelRef['fields']:
        fieldName = field['fieldName']
        typeSpec = field['typeSpec']
        fldCat = progSpec.fieldsTypeCategory(typeSpec)
        fieldType = progSpec.fieldTypeKeyword(field['typeSpec']['fieldType'])
        [fieldSpec, params] = getFieldSpec(fldCat, field)
        structTypeName = ''
        if fldCat == 'struct':  # Add a new class to be processed
            structTypeName = typeSpec['fieldType'][0]
            newGUIStyle = 'Dialog'
            guiStructName = structTypeName + '_' + newGUIStyle + '_GUI'
            addNewStructToProcess(guiStructName, structTypeName, 'struct',
                                  'Dialog')

        if progSpec.isAContainer(typeSpec):  # Add a new list to be processed
            structTypeName = typeSpec['fieldType'][0]
            guiStructName = structTypeName + '_ROW_View'
            addNewStructToProcess(guiStructName, structTypeName, 'list',
                                  'Dialog')
        else:
            print("field::", fieldName, fldCat)
            if (fldCat != 'struct'):
                rowHeaderCode += '        their GUI_Label: ' + fieldName + '_header <- makeLabelWidget("' + fieldName + '")\n'
                rowHeaderCode += '        setLabelWidth(' + fieldName + '_header, 15)\n'
                rowHeaderCode += '        addToContainer(headerBox, ' + fieldName + '_header)\n'
            if fldCat == 'struct':
                funcTextToUpdateViewWidget += ''
            elif fldCat == 'enum' or fldCat == 'mode':
                funcTextToUpdateViewWidget += ''
                #funcTextToUpdateEditWidget     += ''
                funcTextToUpdateCrntFromWidget += ''  #  crntRecord.'+fieldName+' <- dialog.' + widgetName + '.getValue()\n'
            elif fldCat == 'bool':
                funcTextToUpdateViewWidget += ''
            elif fldCat == 'string':
                #funcTextToUpdateViewWidget     += ''
                #funcTextToUpdateEditWidget     += '    dialog.' + widgetName + '.setValue('+structTypeName+'_ListData[N].'+fieldName+')\n'
                #funcTextToUpdateCrntFromWidget += '    me string: '+widgetName+'Str <- dialog.' + widgetName + '.getValue()\n'
                #funcTextToUpdateCrntFromWidget += '    crntRecord.'+fieldName+' <- '+widgetName+'Str\n'
                rowViewCode += '        their GUI_Label: ' + fieldName + '_value <- makeLabelWidget2(Data.' + fieldName + ')\n'
                rowViewCode += '        setLabelWidth(' + fieldName + '_value, 15)\n'
                rowViewCode += '        addToContainer(box, ' + fieldName + '_value)\n'
                rowViewCode += '        showWidget(' + fieldName + '_value)\n'
            elif fldCat == 'int':
                funcTextToUpdateViewWidget += ''
                #funcTextToUpdateEditWidget     += '    dialog.' + widgetName + '.setValue('+structTypeName+'_ListData[N].'+fieldName+')\n'
                #funcTextToUpdateCrntFromWidget += '    me string: '+widgetName+'Str <- string(dialog.' + widgetName + '.getValue())\n'
                #funcTextToUpdateCrntFromWidget += '    crntRecord.'+fieldName+' <- dataStr\n'
                rowViewCode += '        their GUI_Label: ' + fieldName + '_value <- makeLabelWidget2(toString(Data.' + fieldName + '))\n'
                rowViewCode += '        setLabelWidth(' + fieldName + '_value, 15)\n'
                rowViewCode += '        addToContainer(box, ' + fieldName + '_value)\n'
                rowViewCode += '        showWidget(' + fieldName + '_value)\n'
            else:
                print(
                    'pattern_MakeGUI.codeListWidgetManagerClassOverride fldCat not specified: ',
                    fldCat)
                exit(2)

    CODE = '''struct ''' + newStructName + '''{
    their GUI_Frame:            box
    their GUI_Frame: makeHeaderView() <- {
        their GUI_Frame: headerBox <- makeXStack("")
        ''' + rowHeaderCode + '''
        showWidget(headerBox)
        return(headerBox)
    }
    their GUI_Frame: initWidget(their ''' + className + ''': Data) <- {
        box <- makeXStack("")
        ''' + rowViewCode + '''
        showWidget(box)
        return(box)
    }
}
'''
    #print ('==========================================================\n'+CODE)
    codeDogParser.AddToObjectFromText(classes[0], classes[1], CODE,
                                      newStructName)
Пример #9
0
    def getDashDeclAndUpdateCode(self, owner, fieldLabel, fieldRef, fieldName,
                                 field, skipFlags, indent):
        global classesToProcess
        global classesEncoded
        [
            structText, updateFuncText, setPosFuncText, drawFuncText,
            handleClicksFuncText
        ] = ['', '', '', '', '']
        typeSpec = field['typeSpec']
        fldCat = progSpec.fieldsTypeCategory(typeSpec)
        if fldCat == 'func': return ['', '', '', '', '']
        if progSpec.typeIsPointer(
                typeSpec) and skipFlags != 'skipPtr':  # Header for a POINTER
            fieldName += 'Ptr'
            if fieldRef == 'data.itmItr':
                innerUpdateFuncStr = '"ItmItr"'  # TODO: unhard code this reference to itmItr
            else:
                innerUpdateFuncStr = fieldRef + '.mySymbol(' + fieldRef + ')'
            updateFuncText += "        " + fieldName + '.dashParent <- self\n'
            updateFuncText += "        " + fieldName + '.update(' + fieldLabel + ', ' + innerUpdateFuncStr + ', isNull(' + innerUpdateFuncStr + '))\n'
            structText += "    " + owner + " ptrToItem: " + fieldName + "\n"

        elif progSpec.isAContainer(
                typeSpec
        ) and skipFlags != 'skipLists':  # Header and items for LIST
            dispStructTypeName = "display_" + progSpec.getFieldType(
                field['typeSpec'])[0]
            innerUpdateFuncStr = '"Size:"+toString(data.' + fieldName + '.size())'
            updateFuncText += "        " + fieldName + '.dashParent <- self\n'
            updateFuncText += "        " + "our dash[our list]: oldElements <- " + fieldName + ".elements\n"
            updateFuncText += "        " + fieldName + '.update(' + fieldLabel + ', ' + innerUpdateFuncStr + ', isNull(' + innerUpdateFuncStr + '), true)\n'
            ## Now push each item
            innerFieldType = progSpec.getFieldType(typeSpec)
            #print "ARRAYSPEC:",innerFieldType, field
            fldCatInner = progSpec.innerTypeCategory(innerFieldType)
            if fieldRef == 'data.itmItr' or fieldRef == 'data.items':
                newFieldRef = '_item'  # TODO: unhard code this reference to itmItr
            else:
                newFieldRef = 'data.' + fieldName + '[_item_key]'
            newFieldLabel = '"["+toString(_item_key)+"]  "+ _item.mySymbol(_item)'
            updateFuncText += "\n        " + "me int64: dash_key <- 0"
            updateFuncText += "\n        withEach _item in data." + fieldName + "{\n"
            [
                innerStructText, innerUpdateFuncText, innerDrawFuncText,
                innerSetPosFuncText, innerHandleClicksFuncText
            ] = self.getDashDeclAndUpdateCode('our', newFieldLabel,
                                              newFieldRef, 'newItem', field,
                                              'skipLists', '        ')
            updateFuncText += "            " + innerStructText
            updateFuncText += "            " + "if(oldElements==NULL or (oldElements!=NULL and !(asClass(" + dispStructTypeName + ", oldElements[dash_key]).data === _item))){\n"
            updateFuncText += '                Allocate(newItem)\n'
            updateFuncText += '                newItem.dashParent <- self\n'
            updateFuncText += '               ' + 'addDependent(_item.mySymbol(_item), newItem)'
            updateFuncText += '\n            } else {\n               newItem <- asClass(' + dispStructTypeName + ', oldElements[dash_key])\n            dash_key <- dash_key + 1'
            updateFuncText += '\n            }'
            updateFuncText += '\n            ' + innerUpdateFuncText
            updateFuncText += '            ' + fieldName + '.updatePush(newItem)'
            updateFuncText += '\n        }\n'
            structText += "    " + owner + " listOfItems: " + fieldName + "\n"
        elif (fldCat == 'struct'):  # Header for a STRUCT
            updateFuncText += "        " + fieldName + '.dashParent <- self\n'
            updateFuncText += "        " + fieldName + '.update(' + fieldLabel + ', ">", ' + fieldRef + ')\n'
            if 'fieldType' in typeSpec and not (isinstance(
                    typeSpec['fieldType'], basestring
            )) and typeSpec['fieldType'][0] == 'DblLinkedList':
                structTypeName = 'infon'
            else:
                structTypeName = progSpec.getFieldType(typeSpec)[0]
            structText += "    " + owner + " display_" + structTypeName + ': ' + fieldName + "\n"

            # Add new classname to a list so it can be encoded.
            if not (structTypeName in classesToProcess):
                classesToProcess.append(structTypeName)

        else:  # Display field for a BASIC TYPES
            valStr = ''
            if (fldCat == 'int' or fldCat == 'double'):
                valStr = 'toString(data.' + fieldName + ')'
            elif (fldCat == 'string' or fldCat == 'char'):
                valStr = '"\'"+' + 'data.' + fieldName + '+"\'"'
            elif (fldCat == 'flag' or fldCat == 'bool'):
                valStr = 'dispBool((data.' + fieldName + ')!=0)'
            elif (fldCat == 'mode'):
                valStr = fieldRef + 'Strings[data.' + fieldName + '] '

            updateFuncText = "        " + fieldName + '.update(100, 180, ' + fieldLabel + ', ' + valStr + ', isNull(' + valStr + '))\n'
            structText += "    " + owner + " dataField: " + fieldName + "\n"

        drawFuncText = "        " + fieldName + '.draw(cr)\n'
        setPosFuncText += '''        if(!<fieldName>.isNullLike or displayMode==fullDisplay){
                <fieldName>.setPos(x,y,extC)
                extC <- <fieldName>.extC
                y <- y + <fieldName>.height
                extX <- max(extX, <fieldName>.extX)
                extY <- max(extY, <fieldName>.extY)
                width<- max(width, <fieldName>.width)
                <fieldName>.isHidden<-false
            } else {<fieldName>.isHidden<-true}
    '''.replace('<fieldName>', fieldName)
        #  updateFuncText+='        if(crntWidth<'+fieldName+'.width){crntWidth <- '+fieldName+'.width}'
        handleClicksFuncText = '            ' + fieldName + '.primaryClick(event)'
        return [
            structText, updateFuncText, drawFuncText, setPosFuncText,
            handleClicksFuncText
        ]