Skip to content

Commit

Permalink
when app is iconified use the correct icon
Browse files Browse the repository at this point in the history
remove gadget_ids array from generated source code and use an enum instead
  • Loading branch information
dmcoles committed Jan 8, 2024
1 parent 7b0324b commit 02bc450
Show file tree
Hide file tree
Showing 5 changed files with 107 additions and 40 deletions.
52 changes: 39 additions & 13 deletions cSourceGen.e
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,16 @@ PROC create(fser:PTR TO fileStreamer, libsused:PTR TO CHAR,definitionOnly,useIds
self.indent:=0
ENDPROC

PROC genHeader(screenObject:PTR TO screenObject, rexxObject:PTR TO rexxObject, windowNames:PTR TO stringlist, sharedPort) OF cSrcGen
PROC genHeader(screenObject:PTR TO screenObject,rexxObject:PTR TO rexxObject, windowNames:PTR TO stringlist, windowLayouts:PTR TO stdlist, sharedPort) OF cSrcGen
DEF tempStr[200]:STRING
DEF menuItem:PTR TO menuItem
DEF itemName[200]:STRING
DEF commKey[10]:STRING
DEF itemType
DEF hasarexx,i
DEF hasarexx,i,j
DEF layoutObject:PTR TO reactionObject
DEF listObjects:PTR TO stdlist
DEF listObject:PTR TO reactionObject

hasarexx:=(rexxObject.commands.count()>0) AND (StrLen(rexxObject.hostName)>0)

Expand Down Expand Up @@ -145,7 +148,6 @@ PROC genHeader(screenObject:PTR TO screenObject, rexxObject:PTR TO rexxObject, w
ENDFOR
self.writeLine('')


self.writeLine('struct Screen *gScreen = NULL;')
self.writeLine('struct DrawInfo *gDrawInfo = NULL;')
self.writeLine('APTR gVisinfo = NULL;')
Expand Down Expand Up @@ -486,10 +488,38 @@ PROC genHeader(screenObject:PTR TO screenObject, rexxObject:PTR TO rexxObject, w
self.writeLine(' *LayoutBase = NULL,')
self.writeLine(' *IconBase = NULL;')
self.writeLine('struct IntuitionBase *IntuitionBase = NULL;')

NEW listObjects.stdlist(20)
self.writeLine('')
FOR i:=0 TO windowNames.count()-1
self.write('enum ')
StringF(tempStr,'\s_idx { ',windowNames.item(i))
LowerStr(tempStr)
self.write(tempStr)
layoutObject:=windowLayouts.item(i)
listObjects.clear()
layoutObject.findObjectsByType(listObjects,-1)
FOR j:=0 TO listObjects.count()-1
IF j>0 THEN self.write(', ')
StrCopy(tempStr,windowNames.item(i))
StrAdd(tempStr,'_')
listObject:=listObjects.item(j)
listObject.gadindex:=j
StrAdd(tempStr,listObject.getTypeName())
LowerStr(tempStr)
StrAdd(tempStr,'_')
self.write(tempStr)
StringF(tempStr,'\d',listObject.id)
self.write(tempStr)
ENDFOR

self.writeLine(' };')
ENDFOR
END listObjects
self.writeLine('')

IF self.definitionOnly THEN RETURN

self.writeLine('')
self.writeLine('int setup( void )')
self.writeLine('{')
self.writeLine(' if( !(IntuitionBase = (struct IntuitionBase*) OpenLibrary("intuition.library",0L)) ) return 0;')
Expand Down Expand Up @@ -727,7 +757,7 @@ PROC genHeader(screenObject:PTR TO screenObject, rexxObject:PTR TO rexxObject, w

self.writeLine('}')
self.writeLine('')
self.writeLine('void runWindow( Object *window_object, int window_id, struct Menu *menu_strip, struct Gadget *win_gadgets[], int gadget_ids[] )')
self.writeLine('void runWindow( Object *window_object, int window_id, struct Menu *menu_strip, struct Gadget *win_gadgets[] )')
self.writeLine('{')
self.writeLine(' struct Window *main_window = NULL;')
IF hasarexx
Expand Down Expand Up @@ -857,8 +887,6 @@ PROC genWindowHeader(count, windowObject:PTR TO windowObject, menuObject:PTR TO
ENDIF
StringF(tempStr,' struct Gadget *main_gadgets[ \d ];',count+1)
self.writeLine(tempStr)
StringF(tempStr,' int gadget_ids[ \d ];',count+1)
self.writeLine(tempStr)
self.writeLine(' Object *window_object = NULL;')

NEW listObjects.stdlist(20)
Expand Down Expand Up @@ -1024,8 +1052,6 @@ PROC genWindowFooter(count, windowObject:PTR TO windowObject, menuObject:PTR TO

StringF(tempStr,' main_gadgets[\d] = 0;',count)
self.writeLine(tempStr)
StringF(tempStr,' gadget_ids[\d] = 0;',count)
self.writeLine(tempStr)

IF self.definitionOnly
self.writeLine('}')
Expand All @@ -1035,10 +1061,10 @@ PROC genWindowFooter(count, windowObject:PTR TO windowObject, menuObject:PTR TO

self.writeLine('')
IF menuObject.menuItems.count()>0
StringF(tempStr,' runWindow( window_object, \d, menu_strip, main_gadgets, gadget_ids );',windowObject.id)
StringF(tempStr,' runWindow( window_object, \d, menu_strip, main_gadgets );',windowObject.id)
self.writeLine(tempStr)
ELSE
StringF(tempStr,' runWindow( window_object, \d, 0, main_gadgets, gadget_ids );',windowObject.id)
StringF(tempStr,' runWindow( window_object, \d, 0, main_gadgets );',windowObject.id)
self.writeLine(tempStr)
ENDIF
self.writeLine('')
Expand Down Expand Up @@ -1164,9 +1190,9 @@ PROC assignGadgetVar(index) OF cSrcGen
self.currentGadgetVar:=index
ENDPROC

PROC componentPropertyGadgetId(idval,index) OF cSrcGen
PROC componentPropertyGadgetId(idval) OF cSrcGen
DEF tempStr[100]:STRING
StringF(tempStr,'gadget_ids[\d] = \d',index, idval)
StringF(tempStr,'\d',idval)
self.componentProperty('GA_ID',tempStr,FALSE)
ENDPROC

Expand Down
58 changes: 47 additions & 11 deletions eSourceGen.e
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,12 @@ PROC create(fser:PTR TO fileStreamer,libsused,definitionOnly,useIds) OF eSrcGen
self.terminator:=0
ENDPROC

PROC genHeader(screenObject:PTR TO screenObject,rexxObject:PTR TO rexxObject, windowNames:PTR TO stringlist, sharedPort) OF eSrcGen
PROC genHeader(screenObject:PTR TO screenObject,rexxObject:PTR TO rexxObject, windowNames:PTR TO stringlist, windowLayouts:PTR TO stdlist, sharedPort) OF eSrcGen
DEF tempStr[200]:STRING
DEF hasarexx,i
DEF hasarexx,i,j,n
DEF layoutObject:PTR TO reactionObject
DEF listObjects:PTR TO stdlist
DEF listObject:PTR TO reactionObject

hasarexx:=(rexxObject.commands.count()>0) AND (StrLen(rexxObject.hostName)>0)

Expand Down Expand Up @@ -97,6 +100,43 @@ PROC genHeader(screenObject:PTR TO screenObject,rexxObject:PTR TO rexxObject, wi
self.writeLine(' \aintuition/gadgetclass\a')
self.writeLine('')

NEW listObjects.stdlist(20)
self.writeLine('')
FOR i:=0 TO windowNames.count()-1
self.write('ENUM ')
layoutObject:=windowLayouts.item(i)
listObjects.clear()
layoutObject.findObjectsByType(listObjects,-1)
n:=0
FOR j:=0 TO listObjects.count()-1
IF j>0
self.write(', ')
n:=n+2
ENDIF

IF n>60
self.writeLine('')
self.write(' ')
n:=0
ENDIF
StrCopy(tempStr,windowNames.item(i))
StrAdd(tempStr,'_')
listObject:=listObjects.item(j)
listObject.gadindex:=j
StrAdd(tempStr,listObject.getTypeName())
UpperStr(tempStr)
StrAdd(tempStr,'_')
self.write(tempStr)
n:=n+StrLen(tempStr)
StringF(tempStr,'\d',listObject.id)
n:=n+StrLen(tempStr)
self.write(tempStr)
ENDFOR
self.writeLine('')
ENDFOR
END listObjects
self.writeLine('')

IF self.libsused[TYPE_GRADSLIDER]
self.writeLine('DEF gradientsliderbase')
ENDIF
Expand Down Expand Up @@ -470,7 +510,7 @@ PROC genHeader(screenObject:PTR TO screenObject,rexxObject:PTR TO rexxObject, wi
ENDIF


self.writeLine('PROC runWindow(windowObject,windowId, menuStrip, winGadgets:PTR TO LONG, gadgetIds:PTR TO LONG) HANDLE')
self.writeLine('PROC runWindow(windowObject,windowId, menuStrip, winGadgets:PTR TO LONG) HANDLE')
self.writeLine(' DEF running=TRUE')
self.writeLine(' DEF win:PTR TO window,wsig,code,msg,sig,result')
IF hasarexx
Expand Down Expand Up @@ -556,8 +596,6 @@ PROC genWindowHeader(count, windowObject:PTR TO windowObject, menuObject:PTR TO
self.writeLine(' DEF windowObject')
StringF(tempStr,' DEF mainGadgets[\d]:ARRAY OF LONG',count+1)
self.writeLine(tempStr)
StringF(tempStr,' DEF gadgetIds[\d]:ARRAY OF LONG',count+1)
self.writeLine(tempStr)
IF menuObject.menuItems.count()>0
self.writeLine(' DEF menuStrip=0,menuData=0:PTR TO newmenu')
ENDIF
Expand Down Expand Up @@ -782,8 +820,6 @@ PROC genWindowFooter(count, windowObject:PTR TO windowObject, menuObject:PTR TO

StringF(tempStr,' mainGadgets[\d]:=0',count)
self.writeLine(tempStr)
StringF(tempStr,' gadgetIds[\d]:=0',count)
self.writeLine(tempStr)

IF self.definitionOnly
self.writeLine('ENDPROC')
Expand All @@ -793,10 +829,10 @@ PROC genWindowFooter(count, windowObject:PTR TO windowObject, menuObject:PTR TO

self.writeLine('')
IF menuObject.menuItems.count()>0
StringF(tempStr,' runWindow(windowObject,\d,menuStrip,mainGadgets,gadgetIds)',windowObject.id)
StringF(tempStr,' runWindow(windowObject,\d,menuStrip,mainGadgets)',windowObject.id)
self.writeLine(tempStr)
ELSE
StringF(tempStr,' runWindow(windowObject,\d,NIL,mainGadgets,gadgetIds)',windowObject.id)
StringF(tempStr,' runWindow(windowObject,\d,NIL,mainGadgets)',windowObject.id)
self.writeLine(tempStr)
ENDIF
self.writeLine('')
Expand Down Expand Up @@ -924,9 +960,9 @@ PROC assignGadgetVar(index) OF eSrcGen
self.currentGadgetVar:=index
ENDPROC

PROC componentPropertyGadgetId(idval,index) OF eSrcGen
PROC componentPropertyGadgetId(idval) OF eSrcGen
DEF tempStr[100]:STRING
StringF(tempStr,'gadgetIds[\d]:=\d',index, idval)
StringF(tempStr,'\d',idval)
self.componentProperty('GA_ID',tempStr, FALSE)
ENDPROC

Expand Down
3 changes: 2 additions & 1 deletion reactionObject.e
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ EXPORT OBJECT reactionObject
previewObject:LONG
previewChildAttrs:LONG
node:LONG
gadindex:LONG
PRIVATE
imageData:PTR TO CHAR
errObj:CHAR
Expand Down Expand Up @@ -730,7 +731,7 @@ PROC findObjectsByType(res:PTR TO stdlist,type) OF reactionObject
DEF i
DEF child:PTR TO reactionObject

IF self.type=type THEN res.add(self)
IF (self.type=type) OR (type=-1) THEN res.add(self)
FOR i:=0 TO self.children.count()-1
child:=self.children.item(i)
child.findObjectsByType(res,type)
Expand Down
30 changes: 17 additions & 13 deletions rebuild.e
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ OPT OSVERSION=37,LARGE
DEF windowTitle[200]:STRING

DEF startupfilename[256]:STRING
DEF iconFileName[256]:STRING

DEF tabsbase=0
DEF gradientsliderbase=0
Expand Down Expand Up @@ -631,7 +632,8 @@ PROC loadIconPrefs()
DEF olddir
IF wbmessage=NIL
StrCopy(startupfilename,arg)
dobj:=GetDiskObject('PROGDIR:Rebuild')
StrCopy(iconFileName,'PROGDIR:Rebuild')
dobj:=GetDiskObject(iconFileName)
ELSE
wb:=wbmessage
args:=wb.arglist
Expand All @@ -641,8 +643,8 @@ PROC loadIconPrefs()
StrCopy(startupfilename,tempbuf)
ENDIF
olddir:=CurrentDir(args[].lock)
dobj:=GetDiskObject(args[].name)
CurrentDir(olddir)
StrCopy(iconFileName,args[].name)
dobj:=GetDiskObject(iconFileName)
ENDIF
IF dobj
IF(s:=FindToolType(dobj.tooltypes,'LANG'))
Expand Down Expand Up @@ -752,6 +754,7 @@ PROC createForm()
WINDOW_APPPORT, appPort,
WINDOW_APPWINDOW, TRUE,
WINDOW_ICONIFYGADGET, TRUE,
WINDOW_ICON, GetDiskObject(iconFileName),
WA_CLOSEGADGET, TRUE,
WA_DEPTHGADGET, TRUE,
WA_SIZEGADGET, TRUE,
Expand Down Expand Up @@ -1149,7 +1152,7 @@ PROC countGads(from=0:PTR TO reactionObject,n=0)
FOR i:=0 TO from.children.count()-1 DO n:=countGads(from.children.item(i),n)
ENDPROC n+1

PROC genComponentCode(comp:PTR TO reactionObject, nptr:PTR TO LONG, srcGen:PTR TO srcGen)
PROC genComponentCode(comp:PTR TO reactionObject, srcGen:PTR TO srcGen)
DEF i
DEF tempStr[200]:STRING
DEF libname,libtype,addTag
Expand All @@ -1161,7 +1164,7 @@ PROC genComponentCode(comp:PTR TO reactionObject, nptr:PTR TO LONG, srcGen:PTR T
srcGen.componentAddChild(addTag)
ENDIF

srcGen.assignGadgetVar(nptr[])
srcGen.assignGadgetVar(comp.gadindex)
IF (libtype:=comp.libTypeCreate())
srcGen.componentLibtypeCreate(libtype)
ELSEIF (libname:=comp.libNameCreate())
Expand All @@ -1173,17 +1176,16 @@ PROC genComponentCode(comp:PTR TO reactionObject, nptr:PTR TO LONG, srcGen:PTR T

->IF comp.type<>TYPE_LAYOUT
IF srcGen.useIds
srcGen.componentPropertyGadgetId(comp.id,nptr[])
srcGen.componentPropertyGadgetId(comp.id)
ELSE
srcGen.componentPropertyGadgetId(srcGen.currentGadgetVar,nptr[])
srcGen.componentPropertyGadgetId(srcGen.currentGadgetVar)
ENDIF
->ENDIF
comp.genCodeProperties(srcGen)
IF comp.children.count()>0
comp.genChildObjectsHeader(srcGen)
FOR i:=0 TO comp.children.count()-1
nptr[]:=nptr[]+1
genComponentCode(comp.children.item(i),nptr,srcGen)
genComponentCode(comp.children.item(i),srcGen)
ENDFOR
comp.genChildObjectsFooter(srcGen)
ENDIF
Expand Down Expand Up @@ -1224,8 +1226,8 @@ PROC genCode()
DEF rexxComp:PTR TO rexxObject
DEF libsused[TYPE_MAX]:ARRAY OF CHAR
DEF windowNames:PTR TO stringlist
DEF windowLayouts:PTR TO stdlist
DEF windowObj:PTR TO windowObject
DEF n
DEF sharedport=0

setBusy()
Expand Down Expand Up @@ -1264,11 +1266,13 @@ PROC genCode()

i:=ROOT_LAYOUT_ITEM
NEW windowNames.stringlist(10)
NEW windowLayouts.stdlist(10)
WHILE i<objectList.count()
findLibsUsed(objectList.item(i),libsused)
windowObj:=objectList.item(i-ROOT_LAYOUT_ITEM+ROOT_WINDOW_ITEM)
IF windowObj.sharedPort THEN sharedport:=TRUE
windowNames.add(windowObj.name)
windowLayouts.add(objectList.item(i))
i+=3
ENDWHILE

Expand Down Expand Up @@ -1298,8 +1302,9 @@ PROC genCode()
windowComp:=objectList.item(ROOT_WINDOW_ITEM)
screenComp:=objectList.item(ROOT_SCREEN_ITEM)
rexxComp:=objectList.item(ROOT_REXX_ITEM)
srcGen.genHeader(screenComp,rexxComp, windowNames,sharedport)
srcGen.genHeader(screenComp,rexxComp, windowNames,windowLayouts, sharedport)
END windowNames
END windowLayouts
WHILE (i+ROOT_WINDOW_ITEM)<objectList.count()
windowComp:=objectList.item(i+ROOT_WINDOW_ITEM)
menuComp:=objectList.item(i+ROOT_MENU_ITEM)
Expand All @@ -1321,8 +1326,7 @@ PROC genCode()
srcGen.componentProperty('LAYOUT_SpaceOuter','TRUE',FALSE)
srcGen.componentProperty('LAYOUT_DeferLayout','TRUE',FALSE)
srcGen.increaseIndent()
n:=0
genComponentCode(layoutComp,{n},srcGen)
genComponentCode(layoutComp,srcGen)
srcGen.componentEnd('LayoutEnd,')
srcGen.finalComponentEnd(objectEnd)
srcGen.decreaseIndent()
Expand Down
4 changes: 2 additions & 2 deletions sourceGen.e
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ PROC assignGadgetVar(index) OF srcGen
self.currentGadgetVar:=index
ENDPROC

PROC componentPropertyGadgetId(idval,index) OF srcGen
PROC componentPropertyGadgetId(idval) OF srcGen
ENDPROC

PROC addTerminator() OF srcGen
Expand All @@ -226,7 +226,7 @@ PROC addTerminator() OF srcGen
ENDIF
ENDPROC

PROC genHeader(screenObject,rexxObject, windowNames, sharedport) OF srcGen IS -1
PROC genHeader(screenObject,rexxObject, windowNames, windowLayouts, sharedport) OF srcGen IS -1
PROC genFooter(windowObject,rexxObject) OF srcGen IS -1
PROC genWindowHeader(count, windowObject, menuObject, layoutObject, reactionLists) OF srcGen IS -1
PROC genWindowFooter(count, windowObject, menuObject, layoutObject, reactionLists) OF srcGen IS -1

0 comments on commit 02bc450

Please sign in to comment.