Skip to content

Commit

Permalink
ensure undo point and code refresh are run after editing non-window r…
Browse files Browse the repository at this point in the history
…elated items (requesters, arexx)

add parameterised options for requester title text, gadgets text and body text
  • Loading branch information
dmcoles committed Jul 23, 2024
1 parent ffbe475 commit fa78792
Show file tree
Hide file tree
Showing 5 changed files with 141 additions and 23 deletions.
31 changes: 25 additions & 6 deletions cSourceGen.e
Original file line number Diff line number Diff line change
Expand Up @@ -488,8 +488,21 @@ PROC genHeader(screenObject:PTR TO screenObject,rexxObject:PTR TO rexxObject, re
ENDIF

FOR i:=0 TO requesterObject.requesterItems.count()-1
reqItem:=requesterObject.requesterItems.item(i)
StringF(tempStr,'int requester\d(Object *reactionWindow)\n',i)
reqItem:=requesterObject.requesterItems.item(i)
StringF(tempStr,'int requester\d(Object *reactionWindow',reqItem.id)
IF reqItem.titleParam
StrAdd(tempStr,',STRPTR titleText')
ENDIF

IF reqItem.gadgetsParam
StrAdd(tempStr,',STRPTR gadgetsText')
ENDIF

IF reqItem.bodyParam
StrAdd(tempStr,',STRPTR bodyText')
ENDIF
StrAdd(tempStr,')')

self.writeLine(tempStr)
self.writeLine('{')
self.writeLine(' Object *reqobj;')
Expand All @@ -499,12 +512,18 @@ PROC genHeader(screenObject:PTR TO screenObject,rexxObject:PTR TO rexxObject, re

self.writeLine(' GetAttr(WINDOW_Window, reactionWindow, &win);')
bodyText:=reqItem.bodyText.makeTextString('\\n')
StringF(tempStr,' reqobj = NewObject(REQUESTER_GetClass(), NULL, REQ_Type, \s, REQ_Image, \s, REQ_TitleText, \q\s\q, REQ_BodyText,\q\s\q, REQ_GadgetText, \q\s\q, TAG_DONE);',
StringF(tempStr,' reqobj = NewObject(REQUESTER_GetClass(), NULL, REQ_Type, \s, REQ_Image, \s, REQ_TitleText, \s\s\s, REQ_BodyText,\s\s\s, REQ_GadgetText, \s\s\s, TAG_DONE);',
ListItem(['REQTYPE_INFO','REQTYPE_INTEGER','REQTYPE_STRING'],reqItem.reqType),
ListItem(['REQIMAGE_DEFAULT', 'REQIMAGE_INFO', 'REQIMAGE_WARNING', 'REQIMAGE_ERROR', 'REQIMAGE_QUESTION', 'REQIMAGE_INSERTDISK'],reqItem.image),
reqItem.titleText,
bodyText,
reqItem.gadgetsText)
IF reqItem.titleParam THEN '' ELSE '\q',
IF reqItem.titleParam THEN 'titleText' ELSE reqItem.titleText,
IF reqItem.titleParam THEN '' ELSE '\q',
IF reqItem.bodyParam THEN '' ELSE '\q',
IF reqItem.bodyParam THEN 'bodyText' ELSE bodyText,
IF reqItem.bodyParam THEN '' ELSE '\q',
IF reqItem.gadgetsParam THEN '' ELSE '\q',
IF reqItem.gadgetsParam THEN 'gadgetsText' ELSE reqItem.gadgetsText,
IF reqItem.gadgetsParam THEN '' ELSE '\q')
DisposeLink(bodyText)
self.writeLine(tempStr)
self.writeLine(' if (reqobj)')
Expand Down
29 changes: 24 additions & 5 deletions eSourceGen.e
Original file line number Diff line number Diff line change
Expand Up @@ -619,7 +619,20 @@ PROC genHeader(screenObject:PTR TO screenObject,rexxObject:PTR TO rexxObject, re
self.writeLine('')
FOR i:=0 TO requesterObject.requesterItems.count()-1
reqItem:=requesterObject.requesterItems.item(i)
StringF(tempStr,'PROC requester\d(reactionWindow)\n',i)
StringF(tempStr,'PROC requester\d(reactionWindow',reqItem.id)
IF reqItem.titleParam
StrAdd(tempStr,',titleText')
ENDIF

IF reqItem.gadgetsParam
StrAdd(tempStr,',gadgetsText')
ENDIF

IF reqItem.bodyParam
StrAdd(tempStr,',bodyText')
ENDIF
StrAdd(tempStr,')')

self.writeLine(tempStr)
self.writeLine(' DEF reqmsg:PTR TO orrequest')
self.writeLine(' DEF reqobj,win,res=0')
Expand All @@ -630,12 +643,18 @@ PROC genHeader(screenObject:PTR TO screenObject,rexxObject:PTR TO rexxObject, re
self.writeLine(' reqmsg.methodid:=RM_OPENREQ')
self.writeLine(' reqmsg.window:=win')
bodyText:=reqItem.bodyText.makeTextString('\\n')
StringF(tempStr,' reqmsg.attrs:=[REQ_TYPE, \s, REQ_IMAGE, \s, REQ_TITLETEXT,\a\s\a,REQ_BODYTEXT,\a\s\a,REQ_GADGETTEXT,\a\s\a,TAG_END]',
StringF(tempStr,' reqmsg.attrs:=[REQ_TYPE, \s, REQ_IMAGE, \s, REQ_TITLETEXT,\s\s\s,REQ_BODYTEXT,\s\s\s,REQ_GADGETTEXT,\s\s\s,TAG_END]',
ListItem(['REQTYPE_INFO','REQTYPE_INTEGER','REQTYPE_STRING'],reqItem.reqType),
ListItem(['REQIMAGE_DEFAULT', 'REQIMAGE_INFO', 'REQIMAGE_WARNING', 'REQIMAGE_ERROR', 'REQIMAGE_QUESTION', 'REQIMAGE_INSERTDISK'],reqItem.image),
reqItem.titleText,
bodyText,
reqItem.gadgetsText)
IF reqItem.titleParam THEN '' ELSE '\a',
IF reqItem.titleParam THEN 'titleText' ELSE reqItem.titleText,
IF reqItem.titleParam THEN '' ELSE '\a',
IF reqItem.bodyParam THEN '' ELSE '\a',
IF reqItem.bodyParam THEN 'bodyText' ELSE bodyText,
IF reqItem.bodyParam THEN '' ELSE '\a',
IF reqItem.gadgetsParam THEN '' ELSE '\a',
IF reqItem.gadgetsParam THEN 'gadgetsText' ELSE reqItem.gadgetsText,
IF reqItem.gadgetsParam THEN '' ELSE '\a')
DisposeLink(bodyText)
self.writeLine(tempStr)
self.writeLine(' reqobj:=NewObjectA(Requester_GetClass(),0,[TAG_END])')
Expand Down
6 changes: 3 additions & 3 deletions rebuild.e
Original file line number Diff line number Diff line change
Expand Up @@ -2419,9 +2419,9 @@ PROC doEdit()
selectedComp.createPreviewObject(win.wscreen)
ENDIF
rethinkPreviews()
addUndo()
genCodePreview()
ENDIF
addUndo()
genCodePreview()
ENDIF
clearBusy()

Expand Down Expand Up @@ -3105,7 +3105,7 @@ PROC restorePreviews()
WHILE (i<objectList.count())
winObj:=objectList.item(i)
previewWin:=winObj.previewObject
IF winObj.previewOpen
IF winObj.previewOpen
Sets(previewWin,WA_LEFT,winObj.previewLeft)
Sets(previewWin,WA_TOP,winObj.previewTop)
Sets(previewWin,WA_WIDTH,winObj.previewWidth)
Expand Down
96 changes: 88 additions & 8 deletions requesterObject.e
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ OPT MODULE, OSVERSION=37

EXPORT DEF texteditorbase

EXPORT ENUM REQITEMGAD_TYPE, REQITEMGAD_TITLE,REQITEMGAD_GADTEXT,REQITEMGAD_IMAGE,REQITEMGAD_BODY,
EXPORT ENUM REQITEMGAD_TYPE, REQITEMGAD_TITLEPARAM, REQITEMGAD_TITLE,REQITEMGAD_GADTEXTPARAM, REQITEMGAD_GADTEXT,REQITEMGAD_IMAGE,REQITEMGAD_BODYPARAM, REQITEMGAD_BODY,
REQITEMGAD_OK, REQITEMGAD_TEST, REQITEMGAD_CANCEL


Expand All @@ -35,7 +35,11 @@ EXPORT ENUM REQGAD_LIST, REQGAD_ADD, REQGAD_EDIT, REQGAD_DELETE, REQGAD_OK, REQG
CONST NUM_REQ_GADS=REQGAD_CANCEL+1

EXPORT OBJECT requesterItem
id:INT
reqType:CHAR
titleParam:CHAR
gadgetsParam:CHAR
bodyParam:CHAR
titleText[80]:ARRAY OF CHAR
gadgetsText[80]:ARRAY OF CHAR
image:CHAR
Expand Down Expand Up @@ -66,8 +70,12 @@ PROC create() OF requesterItem

self.reqType:=0
self.image:=0
self.id:=getObjId()
AstrCopy(self.titleText,'')
AstrCopy(self.gadgetsText,'')
self.titleParam:=0
self.gadgetsParam:=0
self.bodyParam:=0
NEW strlist.stringlist(10)
self.bodyText:=strlist
ENDPROC
Expand Down Expand Up @@ -127,6 +135,31 @@ PROC create() OF requesterItemSettingsForm
CHILD_LABEL, LabelObject,
LABEL_TEXT, 'Type',
LabelEnd,

LAYOUT_ADDCHILD, self.gadgetList[ REQITEMGAD_TITLEPARAM ]:=CheckBoxObject,
GA_ID, REQITEMGAD_TITLEPARAM,
GA_RELVERIFY, TRUE,
GA_TABCYCLE, TRUE,
GA_TEXT, 'Parameterised title',
CHECKBOX_TEXTPLACE, PLACETEXT_LEFT,
CheckBoxEnd,

LAYOUT_ADDCHILD, self.gadgetList[ REQITEMGAD_GADTEXTPARAM ]:=CheckBoxObject,
GA_ID, REQITEMGAD_GADTEXTPARAM,
GA_RELVERIFY, TRUE,
GA_TABCYCLE, TRUE,
GA_TEXT, 'Parameterised gadgets',
CHECKBOX_TEXTPLACE, PLACETEXT_LEFT,
CheckBoxEnd,

LAYOUT_ADDCHILD, self.gadgetList[ REQITEMGAD_BODYPARAM ]:=CheckBoxObject,
GA_ID, REQITEMGAD_BODYPARAM,
GA_RELVERIFY, TRUE,
GA_TABCYCLE, TRUE,
GA_TEXT, 'Parameterised body',
CHECKBOX_TEXTPLACE, PLACETEXT_LEFT,
CheckBoxEnd,

LAYOUT_ADDCHILD, self.gadgetList[REQITEMGAD_TITLE]:=StringObject,
GA_ID, REQITEMGAD_TITLE,
GA_RELVERIFY, TRUE,
Expand Down Expand Up @@ -211,6 +244,18 @@ PROC testRequester(nself,gadget,id,code) OF requesterItemSettingsForm
bodyText:=DoMethod(self.gadgetList[ REQITEMGAD_BODY ], GM_TEXTEDITOR_EXPORTTEXT)
image:=Gets(self.gadgetList[ REQITEMGAD_IMAGE ],CHOOSER_SELECTED)

IF Gets(self.gadgetList[ REQITEMGAD_TITLEPARAM ],CHECKBOX_CHECKED)
titleText:='titleParam'
ENDIF

IF Gets(self.gadgetList[ REQITEMGAD_GADTEXTPARAM ],CHECKBOX_CHECKED)
gadText:='gadgetsParam'
ENDIF

IF Gets(self.gadgetList[ REQITEMGAD_BODYPARAM ],CHECKBOX_CHECKED)
bodyText:='bodyParam'
ENDIF

type:=ListItem([REQTYPE_INFO, REQTYPE_INTEGER, REQTYPE_STRING],type)
image:=ListItem([REQIMAGE_DEFAULT, REQIMAGE_INFO, REQIMAGE_WARNING, REQIMAGE_ERROR, REQIMAGE_QUESTION, REQIMAGE_INSERTDISK],image)

Expand All @@ -224,7 +269,9 @@ PROC testRequester(nself,gadget,id,code) OF requesterItemSettingsForm
DisposeObject(reqobj)
ENDIF
END reqmsg
FreeVec(bodyText)
IF Gets(self.gadgetList[ REQITEMGAD_BODYPARAM ],CHECKBOX_CHECKED)=FALSE
FreeVec(bodyText)
ENDIF
ADD.L #$100,A7

ENDPROC
Expand All @@ -244,6 +291,10 @@ PROC editSettings(reqItem:PTR TO requesterItem) OF requesterItemSettingsForm
SetGadgetAttrsA(self.gadgetList[ REQITEMGAD_TYPE ],0,0,[CHOOSER_SELECTED,reqItem.reqType,0])
SetGadgetAttrsA(self.gadgetList[ REQITEMGAD_TITLE ],0,0,[STRINGA_TEXTVAL,reqItem.titleText,0])
SetGadgetAttrsA(self.gadgetList[ REQITEMGAD_GADTEXT ],0,0,[STRINGA_TEXTVAL,reqItem.gadgetsText,0])
SetGadgetAttrsA(self.gadgetList[ REQITEMGAD_TITLEPARAM ],0,0,[CHECKBOX_CHECKED,reqItem.titleParam,0])
SetGadgetAttrsA(self.gadgetList[ REQITEMGAD_GADTEXTPARAM ],0,0,[CHECKBOX_CHECKED,reqItem.gadgetsParam,0])
SetGadgetAttrsA(self.gadgetList[ REQITEMGAD_BODYPARAM ],0,0,[CHECKBOX_CHECKED,reqItem.bodyParam,0])

bodyText:=reqItem.bodyText.makeTextString()
SetGadgetAttrsA(self.gadgetList[ REQITEMGAD_BODY ],0,0,[GA_TEXTEDITOR_CONTENTS, bodyText,0])
DisposeLink(bodyText)
Expand All @@ -254,6 +305,10 @@ PROC editSettings(reqItem:PTR TO requesterItem) OF requesterItemSettingsForm
reqItem.reqType:=Gets(self.gadgetList[ REQITEMGAD_TYPE ],CHOOSER_SELECTED)
AstrCopy(reqItem.titleText,Gets(self.gadgetList[ REQITEMGAD_TITLE ],STRINGA_TEXTVAL),80)
AstrCopy(reqItem.gadgetsText,Gets(self.gadgetList[ REQITEMGAD_GADTEXT ],STRINGA_TEXTVAL),80)
reqItem.titleParam:=Gets(self.gadgetList[ REQITEMGAD_TITLEPARAM ],CHECKBOX_CHECKED)
reqItem.gadgetsParam:=Gets(self.gadgetList[ REQITEMGAD_GADTEXTPARAM ],CHECKBOX_CHECKED)
reqItem.bodyParam:=Gets(self.gadgetList[ REQITEMGAD_BODYPARAM ],CHECKBOX_CHECKED)

bodyText:=DoMethod(self.gadgetList[ REQITEMGAD_BODY ], GM_TEXTEDITOR_EXPORTTEXT)
reqItem.bodyText.setFromTextString(bodyText)
FreeVec(bodyText)
Expand Down Expand Up @@ -307,9 +362,6 @@ PROC create() OF requesterSettingsForm
GA_RELVERIFY, TRUE,
LISTBROWSER_POSITION, 0,
LISTBROWSER_SHOWSELECTED, TRUE,
//LISTBROWSER_COLUMNTITLES, TRUE,
//LISTBROWSER_HIERARCHICAL, TRUE,
//LISTBROWSER_COLUMNINFO, self.columninfo,
LISTBROWSER_LABELS, self.browserlist,
ListBrowserEnd,

Expand Down Expand Up @@ -385,6 +437,7 @@ PROC addItem(nself,gadget,id,code) OF requesterSettingsForm
DEF reqItemSettingsForm:PTR TO requesterItemSettingsForm
DEF reqItem:PTR TO requesterItem
DEF res,n,win
DEF titleText[100]:STRING
self:=nself

NEW reqItem.create()
Expand All @@ -396,7 +449,12 @@ PROC addItem(nself,gadget,id,code) OF requesterSettingsForm

SetGadgetAttrsA(self.gadgetList[REQGAD_LIST],win,0,[LISTBROWSER_LABELS, -1, TAG_END])
self.tempRequesterItems.add(reqItem)
IF (n:=AllocListBrowserNodeA(1, [LBNA_COLUMN,0, LBNCA_COPYTEXT, TRUE, LBNCA_TEXT, reqItem.titleText, TAG_END]))
StrCopy(titleText,reqItem.titleText)
IF EstrLen(titleText)=0
StringF(titleText,'req_\d',reqItem.id)
ENDIF

IF (n:=AllocListBrowserNodeA(1, [LBNA_COLUMN,0, LBNCA_COPYTEXT, TRUE, LBNCA_TEXT, titleText, TAG_END]))
AddTail(self.browserlist, n)
ELSE
Raise("MEM")
Expand Down Expand Up @@ -459,7 +517,11 @@ PROC editSettings(comp:PTR TO requesterObject) OF requesterSettingsForm
FOR i:=0 TO comp.requesterItems.count()-1
NEW reqItem.create()
oldItem:=comp.requesterItems.item(i)
reqItem.id:=oldItem.id
reqItem.reqType:=oldItem.reqType
reqItem.titleParam:=oldItem.titleParam
reqItem.gadgetsParam:=oldItem.gadgetsParam
reqItem.bodyParam:=oldItem.bodyParam
AstrCopy(reqItem.titleText,oldItem.titleText)
AstrCopy(reqItem.gadgetsText,oldItem.gadgetsText)
reqItem.image:=oldItem.image
Expand Down Expand Up @@ -492,10 +554,14 @@ PROC editSettings(comp:PTR TO requesterObject) OF requesterSettingsForm
FOR i:=0 TO self.tempRequesterItems.count()-1
NEW reqItem.create()
oldItem:=self.tempRequesterItems.item(i)
reqItem.id:=oldItem.id
reqItem.reqType:=oldItem.reqType
AstrCopy(reqItem.titleText,oldItem.titleText)
AstrCopy(reqItem.gadgetsText,oldItem.gadgetsText)
reqItem.image:=oldItem.image
reqItem.titleParam:=oldItem.titleParam
reqItem.gadgetsParam:=oldItem.gadgetsParam
reqItem.bodyParam:=oldItem.bodyParam
FOR j:=0 TO oldItem.bodyText.count()-1
reqItem.bodyText.add(oldItem.bodyText.item(j))
ENDFOR
Expand Down Expand Up @@ -560,12 +626,20 @@ EXPORT PROC serialise(fser:PTR TO baseStreamer) OF requesterObject
reqItem:=self.requesterItems.item(i)
StringF(tempStr,'REQTYPE: \d',reqItem.reqType)
fser.writeLine(tempStr)
StringF(tempStr,'ID: \d',reqItem.id)
fser.writeLine(tempStr)
StringF(tempStr,'TITLETEXT: \s',reqItem.titleText)
fser.writeLine(tempStr)
StringF(tempStr,'GADGETSTEXT: \s',reqItem.gadgetsText)
fser.writeLine(tempStr)
StringF(tempStr,'IMAGE: \d',reqItem.image)
fser.writeLine(tempStr)
StringF(tempStr,'TITLEPARAM: \d',reqItem.titleParam)
fser.writeLine(tempStr)
StringF(tempStr,'GADGETSPARAM: \d',reqItem.gadgetsParam)
fser.writeLine(tempStr)
StringF(tempStr,'BODYPARAM: \d',reqItem.bodyParam)
fser.writeLine(tempStr)
FOR j:=0 TO reqItem.bodyText.count()-1
StringF(tempStr,'BODYTEXT: \s',reqItem.bodyText.item(j))
fser.writeLine(tempStr)
Expand All @@ -588,7 +662,6 @@ EXPORT PROC deserialise(fser:PTR TO baseStreamer) OF requesterObject
END reqItem
ENDFOR
self.requesterItems.clear()

REPEAT
IF fser.readLine(tempStr)
IF StrCmp('-',tempStr)
Expand All @@ -597,6 +670,8 @@ EXPORT PROC deserialise(fser:PTR TO baseStreamer) OF requesterObject
NEW reqItem.create()
self.requesterItems.add(reqItem)
reqItem.reqType:=Val(tempStr+STRLEN)
ELSEIF StrCmp('ID: ',tempStr,STRLEN)
reqItem.id:=Val(tempStr+STRLEN)
ELSEIF StrCmp('TITLETEXT: ',tempStr,STRLEN)
AstrCopy(reqItem.titleText,tempStr+STRLEN)
ELSEIF StrCmp('GADGETSTEXT: ',tempStr,STRLEN)
Expand All @@ -605,14 +680,19 @@ EXPORT PROC deserialise(fser:PTR TO baseStreamer) OF requesterObject
reqItem.image:=Val(tempStr+STRLEN)
ELSEIF StrCmp('BODYTEXT: ',tempStr,STRLEN)
reqItem.bodyText.add(tempStr+STRLEN)
ELSEIF StrCmp('TITLEPARAM: ',tempStr,STRLEN)
reqItem.titleParam:=Val(tempStr+STRLEN)
ELSEIF StrCmp('GADGETSPARAM: ',tempStr,STRLEN)
reqItem.gadgetsParam:=Val(tempStr+STRLEN)
ELSEIF StrCmp('BODYPARAM: ',tempStr,STRLEN)
reqItem.bodyParam:=Val(tempStr+STRLEN)
ENDIF
ELSE
done:=TRUE
ENDIF
UNTIL done
ENDPROC


EXPORT PROC createRequesterObject(parent)
DEF requester:PTR TO requesterObject

Expand Down
2 changes: 1 addition & 1 deletion windowObject.e
Original file line number Diff line number Diff line change
Expand Up @@ -1114,7 +1114,7 @@ ENDPROC res=MR_OK

EXPORT PROC createPreviewObject(scr) OF windowObject
IF self.previewObject THEN DisposeObject(self.previewObject)

self.previewObject:=WindowObject,
WA_TITLE, self.title,
IF StrLen(self.screentitle) THEN WA_SCREENTITLE ELSE TAG_IGNORE, self.screentitle,
Expand Down

0 comments on commit fa78792

Please sign in to comment.