From d26a57378d8db2236bd8a891785f21668633ec87 Mon Sep 17 00:00:00 2001 From: dmcoles Date: Mon, 15 Jul 2024 17:24:21 +0100 Subject: [PATCH] fix typo in C code generated to open listview gadget add support for LALIGN_CENTER in layout (horizontal and vertical) save expanded state of nodes in project file save currently selected gadget in project file fix issue with 'show settings on add' setting not getting saved to project file correctly add undo/redo capability --- cSourceGen.e | 6 +- drawListObject.e | 6 +- eSourceGen.e | 4 +- fileStreamer.e | 8 +- layoutObject.e | 14 +- makefile | 26 ++-- menuObject.e | 6 +- reactionListObject.e | 6 +- reactionObject.e | 6 + rebuild.e | 338 +++++++++++++++++++++++++++++++------------ requesterObject.e | 6 +- sourceGen.e | 6 +- 12 files changed, 296 insertions(+), 136 deletions(-) diff --git a/cSourceGen.e b/cSourceGen.e index 12cc6f1..5d64c1c 100644 --- a/cSourceGen.e +++ b/cSourceGen.e @@ -1,7 +1,7 @@ OPT MODULE,LARGE MODULE 'images/drawlist' - MODULE '*fileStreamer','*sourceGen','*reactionObject','*windowObject','*menuObject','*stringlist','*screenObject' + MODULE '*baseStreamer','*sourceGen','*reactionObject','*windowObject','*menuObject','*stringlist','*screenObject' MODULE '*chooserObject','*clickTabObject','*radioObject','*listBrowserObject','*tabsObject','*reactionListObject', '*drawListObject','*speedBarObject','*listViewObject','*rexxObject','*requesterObject' @@ -10,7 +10,7 @@ ENDOBJECT ENUM ENUM_IDS, ENUM_IDENTS, ENUM_IDXS -PROC create(fser:PTR TO fileStreamer, libsused:PTR TO CHAR,definitionOnly,useIds,useMacros) OF cSrcGen +PROC create(fser:PTR TO baseStreamer, libsused:PTR TO CHAR,definitionOnly,useIds,useMacros) OF cSrcGen SUPER self.create(fser,libsused,definitionOnly,useIds,useMacros) self.type:=CSOURCE_GEN self.stringDelimiter:=34 @@ -734,7 +734,7 @@ PROC genHeader(screenObject:PTR TO screenObject,rexxObject:PTR TO rexxObject, re ENDIF IF self.libsused[TYPE_LISTVIEW] - self.writeLine(' if( !(ListViewBase = (struct Library*) OpenLibrary("gadgest/listview.gadget",0L) ) ) return 0;') + self.writeLine(' if( !(ListViewBase = (struct Library*) OpenLibrary("gadgets/listview.gadget",0L) ) ) return 0;') ENDIF IF self.libsused[TYPE_VIRTUAL] diff --git a/drawListObject.e b/drawListObject.e index ba824de..69e833c 100644 --- a/drawListObject.e +++ b/drawListObject.e @@ -23,7 +23,7 @@ OPT MODULE, OSVERSION=37 'exec/nodes', 'amigalib/lists' - MODULE '*reactionObject','*reactionForm','*colourPicker','*fileStreamer','*sourceGen','*stringlist','*validator' + MODULE '*reactionObject','*reactionForm','*colourPicker','*baseStreamer','*sourceGen','*stringlist','*validator' EXPORT ENUM DRAWLISTGAD_IDENT, DRAWLISTGAD_LIST,DRAWLISTGAD_ADD, DRAWLISTGAD_EDIT, DRAWLISTGAD_DEL, DRAWLISTGAD_OK, DRAWLISTGAD_CHILD, DRAWLISTGAD_CANCEL @@ -705,7 +705,7 @@ EXPORT PROC getTypeName() OF drawListObject RETURN 'DrawList' ENDPROC -EXPORT PROC serialise(fser:PTR TO fileStreamer) OF drawListObject +EXPORT PROC serialise(fser:PTR TO baseStreamer) OF drawListObject DEF tempStr[200]:STRING DEF drawItem:PTR TO drawlist DEF i @@ -731,7 +731,7 @@ EXPORT PROC serialise(fser:PTR TO fileStreamer) OF drawListObject self.serialiseChildren(fser) ENDPROC -EXPORT PROC deserialise(fser:PTR TO fileStreamer) OF drawListObject +EXPORT PROC deserialise(fser:PTR TO baseStreamer) OF drawListObject DEF tempStr[200]:STRING DEF done=FALSE DEF i diff --git a/eSourceGen.e b/eSourceGen.e index 923dc5b..4ab3f21 100644 --- a/eSourceGen.e +++ b/eSourceGen.e @@ -2,7 +2,7 @@ OPT MODULE,LARGE OPT MODULE,LARGE MODULE 'images/drawlist','gadgets/tabs' - MODULE '*fileStreamer','*sourceGen','*reactionObject','*menuObject','*windowObject','*stringlist','*screenObject' + MODULE '*baseStreamer','*sourceGen','*reactionObject','*menuObject','*windowObject','*stringlist','*screenObject' MODULE '*chooserObject','*clickTabObject','*radioObject','*listBrowserObject','*rexxObject','*tabsObject', '*reactionListObject','*reactionLists','*drawlistObject','*speedBarObject','*listViewObject','*requesterObject' @@ -11,7 +11,7 @@ ENDOBJECT ENUM ENUM_IDS, ENUM_IDENTS, ENUM_IDXS -PROC create(fser:PTR TO fileStreamer,libsused,definitionOnly,useIds,useMacros) OF eSrcGen +PROC create(fser:PTR TO baseStreamer,libsused,definitionOnly,useIds,useMacros) OF eSrcGen SUPER self.create(fser,libsused,definitionOnly,useIds,useMacros) self.type:=ESOURCE_GEN self.stringDelimiter:=39 diff --git a/fileStreamer.e b/fileStreamer.e index bcdd614..786edf8 100644 --- a/fileStreamer.e +++ b/fileStreamer.e @@ -1,8 +1,9 @@ OPT MODULE,OSVERSION=37 MODULE 'dos/dos' + MODULE '*baseStreamer' -EXPORT OBJECT fileStreamer +EXPORT OBJECT fileStreamer OF baseStreamer PRIVATE fname:PTR TO CHAR fh:LONG @@ -40,8 +41,3 @@ PROC readLine(outStr:PTR TO CHAR) OF fileStreamer IF (l>0) AND (outStr[l-1]="\n") THEN outStr[l-1]:=0 ENDIF ENDPROC r - -PROC read(outStr:PTR TO CHAR, len) OF fileStreamer - DEF r - r:=Fread(self.fh,outStr,1,len) -ENDPROC r \ No newline at end of file diff --git a/layoutObject.e b/layoutObject.e index 9c99939..9443d3e 100644 --- a/layoutObject.e +++ b/layoutObject.e @@ -63,8 +63,8 @@ EXPORT PROC createPreviewObject(scr) OF layoutObject LAYOUT_RIGHTSPACING, self.rightSpacing, LAYOUT_BOTTOMSPACING, self.bottomSpacing, LAYOUT_ORIENTATION, ListItem([LAYOUT_ORIENT_HORIZ,LAYOUT_ORIENT_VERT],self.orientation), - LAYOUT_HORIZALIGNMENT, ListItem([LALIGN_LEFT, LALIGN_RIGHT],self.horizAlignment), - LAYOUT_VERTALIGNMENT, ListItem([LALIGN_TOP, LALIGN_BOTTOM],self.vertAlignment), + LAYOUT_HORIZALIGNMENT, ListItem([LALIGN_LEFT, LALIGN_RIGHT, LALIGN_CENTER],self.horizAlignment), + LAYOUT_VERTALIGNMENT, ListItem([LALIGN_TOP, LALIGN_BOTTOM, LALIGN_CENTER],self.vertAlignment), LAYOUT_BEVELSTYLE, ListItem([BVS_NONE, BVS_THIN, BVS_BUTTON, BVS_GROUP, BVS_FIELD, BVS_DROPBOX, BVS_SBAR_HORIZ,BVS_SBAR_VERT,BVS_BOX,BVS_RADIOBUTTON,BVS_STANDARD],self.bevelStyle), LAYOUT_BEVELSTATE, ListItem([IDS_NORMAL,IDS_SELECTED,IDS_DISABLED],self.bevelState), LAYOUT_LABEL,self.label, @@ -208,7 +208,7 @@ PROC create() OF layoutSettingsForm CHOOSER_MAXLABELS, 12, CHOOSER_ACTIVE, 0, CHOOSER_WIDTH, -1, - CHOOSER_LABELS, self.labels2:=chooserLabelsA(['LALIGN_LEFT', 'LALIGN_RIGHT',0]), + CHOOSER_LABELS, self.labels2:=chooserLabelsA(['LALIGN_LEFT', 'LALIGN_RIGHT','LALIGN_CENTER',0]), ChooserEnd, CHILD_LABEL, LabelObject, LABEL_TEXT, 'HorzAlignment', @@ -221,7 +221,7 @@ PROC create() OF layoutSettingsForm CHOOSER_MAXLABELS, 12, CHOOSER_ACTIVE, 0, CHOOSER_WIDTH, -1, - CHOOSER_LABELS, self.labels3:=chooserLabelsA(['LALIGN_TOP', 'LALIGN_BOTTOM',0]), + CHOOSER_LABELS, self.labels3:=chooserLabelsA(['LALIGN_TOP', 'LALIGN_BOTTOM','LALIGN_CENTER',0]), ChooserEnd, CHILD_LABEL, LabelObject, LABEL_TEXT, 'VertAlignment', @@ -600,12 +600,12 @@ EXPORT PROC genCodeProperties(srcGen:PTR TO srcGen) OF layoutObject srcGen.componentProperty('LAYOUT_Orientation','LAYOUT_ORIENT_HORIZ',FALSE) ENDIF - IF self.horizAlignment - srcGen.componentProperty('LAYOUT_HorizAlignment','LALIGN_RIGHT',FALSE) + IF self.horizAlignment + srcGen.componentProperty('LAYOUT_HorizAlignment',ListItem(['LALIGN_LEFT', 'LALIGN_RIGHT', 'LALIGN_CENTER'],self.horizAlignment),FALSE) ENDIF IF self.vertAlignment - srcGen.componentProperty('LAYOUT_VertAlignment','LALIGN_BOTTOM',FALSE) + srcGen.componentProperty('LAYOUT_VertAlignment',ListItem(['LALIGN_TOP', 'LALIGN_BOTTOM', 'LALIGN_CENTER'],self.vertAlignment),FALSE) ENDIF IF self.bevelStyle diff --git a/makefile b/makefile index 9adbdd5..cfd7979 100644 --- a/makefile +++ b/makefile @@ -15,7 +15,7 @@ all: rebuild release: options=$(releaseoptions) release: rebuild -rebuild: rebuild.e validator.m dialogs.m libraryVersions.m reactionLists.m tabsObject.m sketchboardObject.m virtualObject.m listViewObject.m ledObject.m textEditorObject.m tapeDeckObject.m gradSliderObject.m getColorObject.m dateBrowserObject.m colorWheelObject.m speedBarObject.m sliderObject.m bitmapObject.m penMapObject.m boingBallObject.m getScreenModeObject.m getFontObject.m getFileObject.m textFieldObject.m drawListObject.m fuelGaugeObject.m bevelObject.m listBrowserObject.m clickTabObject.m chooserObject.m radioObject.m menuObject.m rexxObject.m reactionListObject.m listManagerForm.m codeGenForm.m eSourceGen.m cSourceGen.m sourcegen.m fileStreamer.m reactionForm.m objectPicker.m windowObject.m screenObject.m paletteObject.m scrollerObject.m glyphObject.m spaceObject.m integerObject.m labelObject.m checkboxObject.m stringObject.m buttonObject.m layoutObject.m reactionObject.m stringlist.m requesterObject.m +rebuild: rebuild.e validator.m dialogs.m libraryVersions.m reactionLists.m tabsObject.m sketchboardObject.m virtualObject.m listViewObject.m ledObject.m textEditorObject.m tapeDeckObject.m gradSliderObject.m getColorObject.m dateBrowserObject.m colorWheelObject.m speedBarObject.m sliderObject.m bitmapObject.m penMapObject.m boingBallObject.m getScreenModeObject.m getFontObject.m getFileObject.m textFieldObject.m drawListObject.m fuelGaugeObject.m bevelObject.m listBrowserObject.m clickTabObject.m chooserObject.m radioObject.m menuObject.m rexxObject.m reactionListObject.m listManagerForm.m codeGenForm.m eSourceGen.m cSourceGen.m sourcegen.m fileStreamer.m stringStreamer.m baseStreamer.m reactionForm.m objectPicker.m windowObject.m screenObject.m paletteObject.m scrollerObject.m glyphObject.m spaceObject.m integerObject.m labelObject.m checkboxObject.m stringObject.m buttonObject.m layoutObject.m reactionObject.m stringlist.m requesterObject.m $(compiler) rebuild $(options) reactionLists.m: reactionLists.e stringlist.m @@ -75,13 +75,13 @@ getColorObject.m: getColorObject.e reactionObject.m reactionForm.m sourceGen.m dateBrowserObject.m: dateBrowserObject.e reactionObject.m reactionForm.m sourceGen.m validator.m $(compiler) dateBrowserObject $(options) -eSourceGen.m: eSourceGen.e fileStreamer.m sourceGen.m reactionObject.m stringlist.m menuObject.m windowObject.m reactionListObject.m chooserObject.m clickTabObject.m radioObject.m listBrowserObject.m drawListObject.m screenObject.m rexxObject.m speedBarObject.m listViewObject.m tabsObject.m windowObject.m requesterObject.m +eSourceGen.m: eSourceGen.e baseStreamer.m sourceGen.m reactionObject.m stringlist.m menuObject.m windowObject.m reactionListObject.m chooserObject.m clickTabObject.m radioObject.m listBrowserObject.m drawListObject.m screenObject.m rexxObject.m speedBarObject.m listViewObject.m tabsObject.m windowObject.m requesterObject.m $(compiler) eSourceGen $(options) -cSourceGen.m: cSourceGen.e fileStreamer.m sourceGen.m reactionObject.m stringlist.m menuObject.m windowObject.m reactionListObject.m chooserObject.m clickTabObject.m radioObject.m listBrowserObject.m drawListObject.m speedBarObject.m rexxObject.m screenObject.m listViewObject.m tabsObject.m windowObject.m requesterObject.m +cSourceGen.m: cSourceGen.e baseStreamer.m sourceGen.m reactionObject.m stringlist.m menuObject.m windowObject.m reactionListObject.m chooserObject.m clickTabObject.m radioObject.m listBrowserObject.m drawListObject.m speedBarObject.m rexxObject.m screenObject.m listViewObject.m tabsObject.m windowObject.m requesterObject.m $(compiler) cSourceGen $(options) -sourceGen.m: sourceGen.e fileStreamer.m stringlist.m +sourceGen.m: sourceGen.e baseStreamer.m stringlist.m $(compiler) sourceGen $(options) layoutObject.m: layoutObject.e reactionObject.m reactionForm.m sourceGen.m validator.m @@ -105,10 +105,10 @@ labelObject.m: labelObject.e reactionObject.m reactionForm.m colourPicker.m so rexxObject.m: rexxObject.e reactionObject.m reactionForm.m stringlist.m $(compiler) rexxObject $(options) -requesterObject.m: requesterObject.e reactionObject.m reactionForm.m stringlist.m fileStreamer.m +requesterObject.m: requesterObject.e reactionObject.m reactionForm.m stringlist.m baseStreamer.m $(compiler) requesterObject $(options) -menuObject.m: menuObject.e reactionObject.m reactionForm.m stringlist.m fileStreamer.m dialogs.m +menuObject.m: menuObject.e reactionObject.m reactionForm.m stringlist.m baseStreamer.m dialogs.m $(compiler) menuObject $(options) buttonObject.m: buttonObject.e reactionObject.m reactionForm.m colourPicker.m sourceGen.m validator.m @@ -135,7 +135,7 @@ textFieldObject.m: textFieldObject.e reactionObject.m reactionForm.m colourPic tabsObject.m: tabsObject.e reactionObject.m reactionForm.m sourceGen.m stringlist.m listPicker.m reactionLists.m reactionListObject.m validator.m $(compiler) tabsObject $(options) -drawListObject.m: drawListObject.e reactionObject.m reactionForm.m colourPicker.m sourceGen.m fileStreamer.m stringlist.m validator.m +drawListObject.m: drawListObject.e reactionObject.m reactionForm.m colourPicker.m sourceGen.m baseStreamer.m stringlist.m validator.m $(compiler) drawListObject $(options) fuelGaugeObject.m: fuelGaugeObject.e reactionObject.m reactionForm.m colourPicker.m sourceGen.m validator.m @@ -162,11 +162,17 @@ listBrowserObject.m: listBrowserObject.e reactionObject.m reactionForm.m listP clickTabObject.m: clickTabObject.e reactionObject.m reactionForm.m listPicker.m stringlist.m reactionLists.m sourceGen.m reactionListObject.m sourceGen.m validator.m $(compiler) clickTabObject $(options) -reactionListObject.m: reactionListObject.e stringlist.m reactionObject.m fileStreamer.m +reactionListObject.m: reactionListObject.e stringlist.m reactionObject.m baseStreamer.m $(compiler) reactionListObject $(options) -fileStreamer.m: fileStreamer.e +fileStreamer.m: fileStreamer.e baseStreamer.m $(compiler) fileStreamer $(options) + +stringStreamer.m: stringStreamer.e baseStreamer.m stringlist.m + $(compiler) stringStreamer $(options) + +baseStreamer.m: baseStreamer.e + $(compiler) baseStreamer $(options) dialogs.m: dialogs.e $(compiler) dialogs $(options) @@ -196,4 +202,4 @@ validator.m: validator.e reactionObject.m reactionForm.m stringlist.m dialogs. $(compiler) validator $(options) clean: - delete validator.m bitmapObject.m dialogs.m libraryVersions.m tabsObject.m sketchboardObject.m virtualObject.m listViewObject.m ledObject.m textEditorObject.m tapeDeckObject.m gradSliderObject.m getColorObject.m dateBrowserObject.m colorWheelObject.m speedBarObject.m sliderObject.m penMapObject.m boingBallObject.m getScreenModeObject.m getFontObject.m getFileObject.m textFieldObject.m fuelGaugeObject.m drawListObject.m bevelObject.m listBrowserObject.m clickTabObject.m chooserObject.m radioObject.m menuObject.m rexxObject.m reactionListObject.m listPicker.m reactionForm.m listManagerForm.m codeGenForm.m cSourcegen.m eSourceGen.m sourceGen.m objectPicker.m colourPicker.m fileStreamer.m windowObject.m screenObject.m paletteObject.m scrollerObject.m glyphObject.m spaceObject.m integerObject.m labelObject.m checkboxObject.m stringObject.m buttonObject.m layoutObject.m reactionObject.m reactionLists.m stringlist.m requesterObject.m rebuild + delete validator.m bitmapObject.m dialogs.m libraryVersions.m tabsObject.m sketchboardObject.m virtualObject.m listViewObject.m ledObject.m textEditorObject.m tapeDeckObject.m gradSliderObject.m getColorObject.m dateBrowserObject.m colorWheelObject.m speedBarObject.m sliderObject.m penMapObject.m boingBallObject.m getScreenModeObject.m getFontObject.m getFileObject.m textFieldObject.m fuelGaugeObject.m drawListObject.m bevelObject.m listBrowserObject.m clickTabObject.m chooserObject.m radioObject.m menuObject.m rexxObject.m reactionListObject.m listPicker.m reactionForm.m listManagerForm.m codeGenForm.m cSourcegen.m eSourceGen.m sourceGen.m objectPicker.m colourPicker.m baseStreamer.m fileStreamer.m stringStreamer.m windowObject.m screenObject.m paletteObject.m scrollerObject.m glyphObject.m spaceObject.m integerObject.m labelObject.m checkboxObject.m stringObject.m buttonObject.m layoutObject.m reactionObject.m reactionLists.m stringlist.m requesterObject.m rebuild diff --git a/menuObject.e b/menuObject.e index 3a9c3e4..cc99d8e 100644 --- a/menuObject.e +++ b/menuObject.e @@ -20,7 +20,7 @@ OPT MODULE, OSVERSION=37 'intuition/gadgetclass', 'exec/lists','exec/nodes' - MODULE '*reactionObject','*reactionForm','*stringlist','*fileStreamer','*dialogs' + MODULE '*reactionObject','*reactionForm','*stringlist','*baseStreamer','*dialogs' EXPORT ENUM MENUGAD_ITEMLIST, MENUGAD_ITEM_NAME, MENUGAD_ITEM_COMMKEY, MENUGAD_ITEM_TYPE, MENUGAD_ITEM_MENUBAR, MENUGAD_ITEM_CHECK, MENUGAD_ITEM_TOGGLE, MENUGAD_ITEM_CHECKED, MENUGAD_ITEM_DISABLED, MENUGAD_ITEM_MUTUALGROUP, @@ -790,7 +790,7 @@ EXPORT PROC editSettings() OF menuObject END editForm ENDPROC res -EXPORT PROC serialise(fser:PTR TO fileStreamer) OF menuObject +EXPORT PROC serialise(fser:PTR TO baseStreamer) OF menuObject DEF tempStr[200]:STRING DEF menuItem:PTR TO menuItem DEF i @@ -822,7 +822,7 @@ EXPORT PROC serialise(fser:PTR TO fileStreamer) OF menuObject self.serialiseChildren(fser) ENDPROC -EXPORT PROC deserialise(fser:PTR TO fileStreamer) OF menuObject +EXPORT PROC deserialise(fser:PTR TO baseStreamer) OF menuObject DEF tempStr[200]:STRING DEF done=FALSE DEF i diff --git a/reactionListObject.e b/reactionListObject.e index 2c3dd8e..ffcc2d5 100644 --- a/reactionListObject.e +++ b/reactionListObject.e @@ -1,6 +1,6 @@ OPT MODULE - MODULE '*stringlist','*reactionObject','*fileStreamer' + MODULE '*stringlist','*reactionObject','*baseStreamer' EXPORT OBJECT reactionListObject OF reactionObject listnode:LONG @@ -21,7 +21,7 @@ PROC end() OF reactionListObject SUPER self.end() ENDPROC -EXPORT PROC serialise(fser:PTR TO fileStreamer) OF reactionListObject +EXPORT PROC serialise(fser:PTR TO baseStreamer) OF reactionListObject DEF tempStr[200]:STRING DEF i @@ -36,7 +36,7 @@ EXPORT PROC serialise(fser:PTR TO fileStreamer) OF reactionListObject ENDPROC -EXPORT PROC deserialise(fser:PTR TO fileStreamer) OF reactionListObject +EXPORT PROC deserialise(fser:PTR TO baseStreamer) OF reactionListObject DEF tempStr[200]:STRING DEF done=FALSE DEF i diff --git a/reactionObject.e b/reactionObject.e index 115b514..50d24ae 100644 --- a/reactionObject.e +++ b/reactionObject.e @@ -81,6 +81,7 @@ EXPORT OBJECT reactionObject noDispose:CHAR weightBar:CHAR + expanded:CHAR tempParentId:INT drawInfo:LONG visInfo:LONG @@ -491,6 +492,7 @@ EXPORT PROC create(parent) OF reactionObject scr:=LockPubScreen(NIL) self.drawInfo:=GetScreenDrawInfo(scr) self.visInfo:=GetVisualInfoA(scr,[TAG_END]) + self.expanded:=self.allowChildren()<>0 UnlockPubScreen(NIL,scr) ENDPROC @@ -634,6 +636,8 @@ EXPORT PROC serialise(fser:PTR TO fileStreamer) OF reactionObject fser.writeLine(tempStr) StringF(tempStr,'WEIGHTBAR: \d',self.weightBar) fser.writeLine(tempStr) + StringF(tempStr,'EXPANDED: \d',self.expanded) + fser.writeLine(tempStr) fser.writeLine('--') list:=self.serialiseData() @@ -736,6 +740,8 @@ PROC deserialise(fser:PTR TO fileStreamer) OF reactionObject self.noDispose:=Val(tempStr+STRLEN) ELSEIF StrCmp('WEIGHTBAR: ',tempStr,STRLEN) self.weightBar:=Val(tempStr+STRLEN) + ELSEIF StrCmp('EXPANDED: ',tempStr,STRLEN) + self.expanded:=Val(tempStr+STRLEN) ENDIF ELSE done:=TRUE diff --git a/rebuild.e b/rebuild.e index cb9388f..b2e0570 100644 --- a/rebuild.e +++ b/rebuild.e @@ -42,7 +42,7 @@ OPT OSVERSION=37,LARGE 'listbrowser','gadgets/listbrowser', 'intuition/intuition','intuition/imageclass','intuition/gadgetclass','intuition/classusr' - MODULE '*fileStreamer','*objectPicker','*cSourceGen', '*eSourceGen', + MODULE '*fileStreamer','*stringStreamer','*baseStreamer','*objectPicker','*cSourceGen', '*eSourceGen', '*sourceGen','*codeGenForm','*listManagerForm','*reactionLists','*dialogs','*libraryVersions', '*getScreenModeObject','*getFontObject','*getFileObject','*textFieldObject','*drawListObject','*fuelGaugeObject', '*bevelObject','*listBrowserObject','*clickTabObject','*chooserObject','*radioObject','*menuObject', @@ -60,6 +60,8 @@ OPT OSVERSION=37,LARGE FATAL 'Rebuild should only be compiled with E-VO Amiga E Compiler v3.7.0 or higher' #endif + CONST MAX_UNDO_COUNT=20 + CONST ROOT_APPLICATION_ITEM=0 CONST ROOT_REXX_ITEM=1 CONST ROOT_REQUESTER_ITEM=2 @@ -90,20 +92,23 @@ OPT OSVERSION=37,LARGE CONST MENU_PROJECT_ABOUT=10 CONST MENU_PROJECT_QUIT=12 - CONST MENU_EDIT_ADD_GADGET=0 - CONST MENU_EDIT_ADD_IMAGE=1 - CONST MENU_EDIT_ADD_WINDOW=2 - CONST MENU_EDIT_ADD_HLAYOUT=3 - CONST MENU_EDIT_ADD_VLAYOUT=4 - CONST MENU_EDIT_EDIT=6 - CONST MENU_EDIT_DELETE=7 - CONST MENU_EDIT_MOVE=9 - CONST MENU_EDIT_LISTS=11 - CONST MENU_EDIT_BUFFER=13 - CONST MENU_EDIT_SHOW_ADD_SETTINGS=14 - CONST MENU_EDIT_WARN_ON_DEL=15 - CONST MENU_EDIT_SAVE_ICONS=16 - CONST MENU_EDIT_PREVIEW=18 + CONST MENU_EDIT_UNDO=0 + CONST MENU_EDIT_REDO=1 + + CONST MENU_EDIT_ADD_GADGET=3 + CONST MENU_EDIT_ADD_IMAGE=4 + CONST MENU_EDIT_ADD_WINDOW=5 + CONST MENU_EDIT_ADD_HLAYOUT=6 + CONST MENU_EDIT_ADD_VLAYOUT=7 + CONST MENU_EDIT_EDIT=9 + CONST MENU_EDIT_DELETE=10 + CONST MENU_EDIT_MOVE=12 + CONST MENU_EDIT_LISTS=14 + CONST MENU_EDIT_BUFFER=16 + CONST MENU_EDIT_SHOW_ADD_SETTINGS=17 + CONST MENU_EDIT_WARN_ON_DEL=18 + CONST MENU_EDIT_SAVE_ICONS=19 + CONST MENU_EDIT_PREVIEW=21 CONST MENU_EDIT_MOVEUP=0 CONST MENU_EDIT_MOVEDOWN=1 @@ -163,6 +168,8 @@ OPT OSVERSION=37,LARGE DEF codeOptions: codeOptions DEF systemOptions: systemOptions DEF recentFiles:PTR TO stringlist + DEF undoData:PTR TO stdlist + DEF undoPos=-1 PROC openClasses() IF (requesterbase:=OpenLibrary('requester.class',0))=NIL THEN Throw("LIB","reqr") @@ -270,7 +277,7 @@ PROC makeComponentList(comp:PTR TO reactionObject,generation,list, selcomp, newn StringF(idStr,'\d',comp.id) StrCopy(typeStr,comp.getTypeName()) IF (n:=AllocListBrowserNodeA(3, - [LBNA_FLAGS, IF (comp.parent=0) OR (comp.allowChildren()) THEN LBFLG_HASCHILDREN OR LBFLG_SHOWCHILDREN ELSE 0, + [LBNA_FLAGS, IF (comp.parent=0) OR (comp.allowChildren()) THEN LBFLG_HASCHILDREN OR (IF comp.expanded THEN LBFLG_SHOWCHILDREN ELSE 0) ELSE 0, LBNA_USERDATA, comp, LBNA_GENERATION, generation, LBNA_COLUMN,0, LBNCA_COPYTEXT, TRUE, LBNCA_TEXT, IF StrLen(comp.ident) THEN comp.ident ELSE typeStr, LBNA_COLUMN,1, LBNCA_COPYTEXT, TRUE, LBNCA_TEXT, typeStr, @@ -404,6 +411,7 @@ ENDPROC PROC updateSel(node) DEF comp=0:PTR TO reactionObject + DEF flags DEF child:PTR TO reactionObject DEF dis,idx DEF check,i,j @@ -413,8 +421,12 @@ PROC updateSel(node) DEF type DEF allowchildren=FALSE - IF node THEN GetListBrowserNodeAttrsA(node,[LBNA_USERDATA,{comp},TAG_END]) + menuDisable(win,MENU_EDIT,MENU_EDIT_UNDO,0,undoPos=0) + menuDisable(win,MENU_EDIT,MENU_EDIT_REDO,0,undoPos>=(undoData.count()-1)) + + IF node THEN GetListBrowserNodeAttrsA(node,[LBNA_USERDATA,{comp},LBNA_FLAGS,{flags},TAG_END]) IF comp + IF flags AND LBFLG_SHOWCHILDREN THEN comp.expanded ELSE comp.expanded:=FALSE allowchildren:=(comp.allowChildren()=TRUE) ORELSE ((comp.allowChildren()>0) ANDALSO (comp.children.count()0) + updateUndo() changes:=TRUE idx:=findWindowIndex(selectedComp) mainRootLayout:=objectList.item(ROOT_LAYOUT_ITEM+(idx*3)) @@ -968,6 +981,7 @@ PROC doGenUp(parent:PTR TO reactionObject,child:PTR TO reactionObject) makeList(child) addMembers(mainRootLayout,window) rethinkPreviews() + addUndo() ENDIF ENDPROC @@ -975,6 +989,7 @@ PROC doGenDown(parent:PTR TO reactionObject, child:PTR TO reactionObject) DEF idx, mainRootLayout, window DEF newparent: PTR TO reactionObject + updateUndo() changes:=TRUE idx:=findWindowIndex(selectedComp) mainRootLayout:=objectList.item(ROOT_LAYOUT_ITEM+(idx*3)) @@ -987,6 +1002,7 @@ PROC doGenDown(parent:PTR TO reactionObject, child:PTR TO reactionObject) makeList(child) addMembers(mainRootLayout,window) rethinkPreviews() + addUndo() ENDPROC PROC swapWindows(idx1,idx2) @@ -1030,6 +1046,7 @@ PROC moveUp(child:PTR TO reactionObject,count=1) ENDIF IF parent.allowChildren() + updateUndo() changes:=TRUE idx:=findWindowIndex(selectedComp) mainRootLayout:=objectList.item(ROOT_LAYOUT_ITEM+(idx*3)) @@ -1042,6 +1059,7 @@ PROC moveUp(child:PTR TO reactionObject,count=1) makeList(child) addMembers(mainRootLayout,window) rethinkPreviews() + addUndo() ENDIF ENDPROC @@ -1066,6 +1084,7 @@ PROC moveDown(child:PTR TO reactionObject,count=1) ENDIF IF parent.allowChildren() + updateUndo() changes:=TRUE idx:=findWindowIndex(selectedComp) mainRootLayout:=objectList.item(ROOT_LAYOUT_ITEM+(idx*3)) @@ -1078,6 +1097,7 @@ PROC moveDown(child:PTR TO reactionObject,count=1) makeList(child) addMembers(mainRootLayout,window) rethinkPreviews() + addUndo() ENDIF ENDPROC @@ -1090,6 +1110,7 @@ PROC movePrevLayout(comp:PTR TO reactionObject) WHILE comp.parent.parent.children.item(i)::reactionObject.type<>TYPE_LAYOUT DO i-- newLayout:=comp.parent.parent.children.item(i) + updateUndo() changes:=TRUE idx:=findWindowIndex(comp) mainRootLayout:=objectList.item(ROOT_LAYOUT_ITEM+(idx*3)) @@ -1100,6 +1121,7 @@ PROC movePrevLayout(comp:PTR TO reactionObject) makeList(comp) addMembers(mainRootLayout,window) rethinkPreviews() + addUndo() ENDPROC PROC moveNextLayout(comp:PTR TO reactionObject) @@ -1111,6 +1133,7 @@ PROC moveNextLayout(comp:PTR TO reactionObject) WHILE comp.parent.parent.children.item(i)::reactionObject.type<>TYPE_LAYOUT DO i++ newLayout:=comp.parent.parent.children.item(i) + updateUndo() changes:=TRUE idx:=findWindowIndex(comp) mainRootLayout:=objectList.item(ROOT_LAYOUT_ITEM+(idx*3)) @@ -1121,6 +1144,7 @@ PROC moveNextLayout(comp:PTR TO reactionObject) makeList(comp) addMembers(mainRootLayout,window) rethinkPreviews() + addUndo() ENDPROC PROC moveIntoLayout(comp:PTR TO reactionObject,horiz) @@ -1131,6 +1155,7 @@ PROC moveIntoLayout(comp:PTR TO reactionObject,horiz) parent:=comp.parent IF parent.allowChildren() + updateUndo() newComp:=doAddLayoutQuick(parent,horiz) changes:=TRUE @@ -1146,6 +1171,7 @@ PROC moveIntoLayout(comp:PTR TO reactionObject,horiz) makeList(comp) addMembers(mainRootLayout,window) rethinkPreviews() + addUndo() ENDIF ENDPROC @@ -1472,8 +1498,7 @@ PROC addRecent(filename:PTR TO CHAR) recentFiles.insert(0,filename) ENDPROC -PROC loadFile(loadfilename:PTR TO CHAR) HANDLE - DEF fs=0:PTR TO fileStreamer +PROC loadStream(fs:PTR TO baseStreamer) HANDLE DEF newObj:PTR TO reactionObject DEF tmpObj:PTR TO reactionObject DEF tempStr[300]:STRING @@ -1482,51 +1507,11 @@ PROC loadFile(loadfilename:PTR TO CHAR) HANDLE DEF type,i DEF a=0:PTR TO menuitem - DEF ver,newid,v - - DEF tags - DEF fr:PTR TO filerequester - DEF fname[255]:STRING - - errorState:=FALSE - IF loadfilename=NIL - aslbase:=OpenLibrary('asl.library',37) - IF aslbase=NIL THEN Throw("LIB","ASL") - tags:=NEW [ASL_HAIL,'Select a file to load', - ASL_WINDOW, win, - ASLFR_INITIALDRAWER, systemOptions.savePath, - TAG_DONE] - fr:=AllocAslRequest(ASL_FILEREQUEST,tags) - IF(AslRequest(fr,0))=FALSE - IF tags THEN FastDisposeList(tags) - IF aslbase THEN CloseLibrary(aslbase) - RETURN - ENDIF - - StrCopy(fname,fr.drawer) - AstrCopy(systemOptions.savePath,fr.drawer) - AddPart(fname,fr.file,100) - SetStr(fname) - IF fr THEN FreeAslRequest(fr) - IF tags THEN FastDisposeList(tags) - IF aslbase THEN CloseLibrary(aslbase) - ELSE - StrCopy(fname,loadfilename) - ENDIF - StrCopy(filename,fname) + DEF ver,newid,v,selid=0,selcomp=0 - NEW fs.create(fname,MODE_OLDFILE) - IF fs.isOpen()=FALSE - errorRequest(mainWindow,'Error','This file could not be opened.') - END fs - RETURN - ENDIF - fs.readLine(tempStr) IF StrCmp(tempStr,'-REBUILD-')=FALSE - errorRequest(mainWindow,'Error','This file is not a valid rebuild file.') - END fs - RETURN + Raise("INVF") ENDIF fs.readLine(tempStr) @@ -1534,21 +1519,20 @@ PROC loadFile(loadfilename:PTR TO CHAR) HANDLE IF StrCmp(tempStr,'VER=',STRLEN) ver:=Val(tempStr+STRLEN) IF (ver<1) - errorRequest(mainWindow,'Error','This file is not a valid rebuild file.') - END fs - RETURN + Raise("INVF") ENDIF IF (ver>FILE_FORMAT_VER) - errorRequest(mainWindow,'Error','This file is too new for this version of ReBuild.') - END fs - RETURN + Raise("VERS") ENDIF ELSEIF StrCmp(tempStr,'NEXTID=',STRLEN) newid:=Val(tempStr+STRLEN) IF newid<1 - errorRequest(mainWindow,'Error','This file is not a valid rebuild file.') - END fs - RETURN + Raise("INVF") + ENDIF + ELSEIF StrCmp(tempStr,'SELECTEDID=',STRLEN) + selid:=Val(tempStr+STRLEN) + IF selid<1 + Raise("INVF") ENDIF ELSEIF StrCmp(tempStr,'VIEWTMP=',STRLEN) v:=Val(tempStr+STRLEN) @@ -1586,9 +1570,7 @@ PROC loadFile(loadfilename:PTR TO CHAR) HANDLE ENDIF IF fs.readLine(tempStr)=FALSE - errorRequest(mainWindow,'Error','This file is not a valid rebuild file.') - END fs - RETURN + Raise("INVF") ENDIF ENDWHILE @@ -1633,6 +1615,8 @@ PROC loadFile(loadfilename:PTR TO CHAR) HANDLE IF (type=TYPE_LAYOUT) AND (objectList.item(objectList.count()-1)=0) THEN objectList.setItem(objectList.count()-1,newObj) IF newObj THEN newObj.deserialise(fs) + IF newObj.id=selid THEN selcomp:=newObj + loadObjectList.add(newObj) ENDIF ENDWHILE @@ -1656,7 +1640,7 @@ PROC loadFile(loadfilename:PTR TO CHAR) HANDLE processObjects(objectList.item(i),loadObjectList) i+=3 ENDWHILE - makeList() + makeList(selcomp) i:=ROOT_WINDOW_ITEM WHILE i0) AND (comp.children.count()0 IF (warnRequest(mainWindow,'Warning','Are you sure you wish\nto delete this item and all of its children?',TRUE)=1) + updateUndo() changes:=TRUE removeObject(selectedComp) + addUndo() ENDIF ELSE IF (systemOptions.warnOnDelete=FALSE) ORELSE (warnRequest(mainWindow,'Warning','Are you sure you wish\nto delete this item?',TRUE)=1) + updateUndo() changes:=TRUE removeObject(selectedComp) + addUndo() ENDIF ENDIF ENDIF @@ -2139,10 +2200,12 @@ PROC doMoveToBuffer(comp:PTR TO reactionObject) IF comp.children.count()>0 IF warnRequest(mainWindow,'Warning','This will move this and all child items into the buffer.\nDo you wish to continue?',TRUE)=0 THEN RETURN ENDIF + updateUndo() changes:=TRUE copyToBuffer(comp,TRUE) removeObject(comp) + addUndo() ENDPROC PROC copyFromBuffer(bufferComp:PTR TO reactionObject) @@ -2160,6 +2223,7 @@ PROC copyFromBuffer(bufferComp:PTR TO reactionObject) RETURN ENDIF + updateUndo() bufferComp.serialise(fs) END fs @@ -2201,13 +2265,16 @@ PROC copyFromBuffer(bufferComp:PTR TO reactionObject) ENDIF DeleteFile('t:tempcomp') changes:=TRUE + addUndo() ENDPROC PROC moveFromBuffer(bufferComp:PTR TO reactionObject) DEF i + updateUndo() copyFromBuffer(bufferComp) removeBufferItem(bufferComp) changes:=TRUE + addUndo() ENDPROC PROC removeBufferItem(bufferComp:PTR TO reactionObject) @@ -2318,6 +2385,8 @@ PROC newProject() rethinkPreviews() remakePreviewMenus() changes:=FALSE + clearUndo() + addUndo() ENDPROC PROC updateSettings() @@ -2458,6 +2527,9 @@ PROC remakePreviewMenus() NM_ITEM,NM_BARLABEL,0,0,0, NM_ITEM,'Quit',0,0,'Q', NM_TITLE,'Edit',0,0,0, + NM_ITEM,'Undo',0,0,'Z', + NM_ITEM,'Redo',0,MIF_SHIFTCOMMSEQ,'Z', + NM_ITEM,NM_BARLABEL,0,0,0, NM_ITEM,'Add Gadget',-1,0,0, NM_SUB,'Button',TYPE_BUTTON,0,0, NM_SUB,'CheckBox',TYPE_CHECKBOX,0,0, @@ -2691,11 +2763,13 @@ PROC editLists() DEF idx,mainRootLayout, window setBusy() + updateUndo() NEW listManagerForm.create() listManagerForm.manageLists() changes:=TRUE END listManagerForm clearBusy() + addUndo() idx:=ROOT_WINDOW_ITEM WHILE idx0 + undoPos-- + strStream:=undoData.item(undoPos) + ENDIF + strStream.reset() + closePreviews() + loadStream(strStream) + restorePreviews() +EXCEPT +ENDPROC + +PROC doRedo() HANDLE + DEF strStream:PTR TO stringStreamer + IF undoPos<(undoData.count()-1) + undoPos++ + strStream:=undoData.item(undoPos) + ENDIF + strStream.reset() + closePreviews() + loadStream(strStream) + restorePreviews() +EXCEPT +ENDPROC + +PROC clearUndo() + DEF strStream:PTR TO stringStreamer + DEF i + FOR i:=0 TO undoData.count()-1 + strStream:=undoData.item(i) + END strStream + ENDFOR + undoData.clear() + undoPos:=-1 +ENDPROC + +PROC updateUndo() + DEF strStream:PTR TO stringStreamer + IF undoData.count()>0 + strStream:=undoData.item(undoData.count()-1) + strStream.clear() + saveStream(strStream) + ENDIF +ENDPROC + +PROC addUndo() + DEF strStream:PTR TO stringStreamer + WHILE undoPos<(undoData.count()-1) + strStream:=undoData.item(undoData.count()-1) + END strStream + undoData.remove(undoData.count()-1) + ENDWHILE + + IF undoData.count()>MAX_UNDO_COUNT THEN undoData.remove(0) + + NEW strStream.create() + saveStream(strStream) + undoData.add(strStream) + undoPos++ + + menuDisable(win,MENU_EDIT,MENU_EDIT_UNDO,0,undoPos=0) + menuDisable(win,MENU_EDIT,MENU_EDIT_REDO,0,undoPos>=(undoData.count()-1)) +ENDPROC + PROC main() HANDLE DEF running=TRUE DEF wsig,code=0,tmp,sig,result @@ -2827,6 +2966,7 @@ PROC main() HANDLE DEF item,type DEF hintInfo:PTR TO hintinfo + DEF strStream:stringStreamer openClasses() initialise() @@ -2837,6 +2977,8 @@ PROC main() HANDLE NEW recentFiles.stringlist(5) loadRecent() + NEW undoData.stdlist(MAX_UNDO_COUNT) + hintInfo:=New(SIZEOF hintinfo*17) hintInfo[0].gadgetid:=GAD_ADD hintInfo[0].code:=-1 @@ -2985,6 +3127,10 @@ PROC main() HANDLE ENDSELECT CASE MENU_EDIT SELECT menuitem + CASE MENU_EDIT_UNDO + doUndo() + CASE MENU_EDIT_REDO + doRedo() CASE MENU_EDIT_ADD_GADGET ->Add item:=ItemAddress(win.menustrip,result) type:=GTMENUITEM_USERDATA(item) @@ -3190,6 +3336,12 @@ EXCEPT DO saveRecent() END recentFiles ENDIF + + IF undoData + clearUndo() + END undoData + ENDIF + IF objectList THEN END objectList IF bufferList disposeBufferObjects() diff --git a/requesterObject.e b/requesterObject.e index 4cb1881..caab2d7 100644 --- a/requesterObject.e +++ b/requesterObject.e @@ -21,7 +21,7 @@ OPT MODULE, OSVERSION=37 'exec/lists','exec/nodes', 'requester','classes/requester' - MODULE '*reactionObject','*reactionForm','*sourcegen','*validator','*stringlist','*fileStreamer' + MODULE '*reactionObject','*reactionForm','*sourcegen','*validator','*stringlist','*baseStreamer' EXPORT DEF texteditorbase @@ -547,7 +547,7 @@ EXPORT PROC getTypeName() OF requesterObject RETURN 'Requester' ENDPROC -EXPORT PROC serialise(fser:PTR TO fileStreamer) OF requesterObject +EXPORT PROC serialise(fser:PTR TO baseStreamer) OF requesterObject DEF tempStr[200]:STRING DEF reqItem:PTR TO requesterItem DEF i,j @@ -573,7 +573,7 @@ EXPORT PROC serialise(fser:PTR TO fileStreamer) OF requesterObject self.serialiseChildren(fser) ENDPROC -EXPORT PROC deserialise(fser:PTR TO fileStreamer) OF requesterObject +EXPORT PROC deserialise(fser:PTR TO baseStreamer) OF requesterObject DEF tempStr[200]:STRING DEF done=FALSE DEF i diff --git a/sourceGen.e b/sourceGen.e index 25b4857..6b8824d 100644 --- a/sourceGen.e +++ b/sourceGen.e @@ -3,13 +3,13 @@ OPT MODULE MODULE 'gadgets/layout','gadgets/virtual' - MODULE '*fileStreamer','*stringlist' + MODULE '*baseStreamer','*stringlist' EXPORT ENUM NONE, ESOURCE_GEN, CSOURCE_GEN EXPORT OBJECT srcGen type:INT - fser:PTR TO fileStreamer + fser:PTR TO baseStreamer libsused:PTR TO CHAR stringDelimiter:CHAR orOperator:PTR TO CHAR @@ -24,7 +24,7 @@ EXPORT OBJECT srcGen currentGadgetVar:INT ENDOBJECT -PROC create(fser:PTR TO fileStreamer,libsused:PTR TO CHAR,definitionOnly,useIds,useMacros) OF srcGen +PROC create(fser:PTR TO baseStreamer,libsused:PTR TO CHAR,definitionOnly,useIds,useMacros) OF srcGen self.type:=NONE self.fser:=fser self.libsused:=libsused