# Path: progSpec.py
# def cdlog(lvl, mesg):
#     global MaxLogLevelToShow
#     global lastLogMesgs
#     global highestLvl
#     highestLvl=lvl
#     resizeLogArray(lvl)
#     lastLogMesgs[lvl]=mesg
#     for i in range(highestLvl+1, len(lastLogMesgs)):
#         lastLogMesgs[i]=''
#     if(lvl<=MaxLogLevelToShow):
#         if(lvl==0): print('')
#         printAtLvl(lvl, mesg, '|    ')
# 
# def cdErr(mesg):
#     global lastLogMesgs
#     global highestLvl
#     highestLvl+=1
#     lastLogMesgs[highestLvl]="\n\nError: "+mesg
#     exit(1)


import progSpec
import codeDogParser
from progSpec import cdlog, cdErr
                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'

# Path: progSpec.py
# def cdlog(lvl, mesg):
#     global MaxLogLevelToShow
#     global lastLogMesgs
#     global highestLvl
#     highestLvl=lvl
#     resizeLogArray(lvl)
#     lastLogMesgs[lvl]=mesg
#     for i in range(highestLvl+1, len(lastLogMesgs)):
#         lastLogMesgs[i]=''
#     if(lvl<=MaxLogLevelToShow):
#         if(lvl==0): print('')
#         printAtLvl(lvl, mesg, '|    ')
# 
# def cdErr(mesg):
#     global lastLogMesgs
#     global highestLvl
#     highestLvl+=1
#     lastLogMesgs[highestLvl]="\n\nError: "+mesg
#     exit(1)


# Path: pattern_MakeGUI.py
import progSpec
import codeDogParser
from progSpec import cdlog, cdErr

                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'