Skip to content

Commit

Permalink
add move into vlayout and move into hlayout menu options
Browse files Browse the repository at this point in the history
add C and E source generator for new menu options (check, checked, disabled, toggle, mutual exlucdes)
  • Loading branch information
dmcoles committed Jul 5, 2024
1 parent 3040ba9 commit b2a5b12
Show file tree
Hide file tree
Showing 4 changed files with 110 additions and 4 deletions.
32 changes: 31 additions & 1 deletion cSourceGen.e
Original file line number Diff line number Diff line change
Expand Up @@ -872,6 +872,8 @@ PROC genWindowHeader(count, windowObject:PTR TO windowObject, menuObject:PTR TO
DEF menuItem:PTR TO menuItem
DEF itemType
DEF itemName[200]:STRING
DEF menuFlags[60]:STRING
DEF currMenu,mut
DEF commKey[10]:STRING
DEF directiveStr[20]:STRING
DEF listObjects:PTR TO stdlist
Expand Down Expand Up @@ -906,10 +908,38 @@ PROC genWindowHeader(count, windowObject:PTR TO windowObject, menuObject:PTR TO

IF StrLen(menuItem.commKey) THEN StringF(commKey,'\q\s\q',menuItem.commKey)
ELSE
currMenu:=menuItem
mut:=0
itemType:='NM_TITLE'
StringF(itemName,'\q\s\q',menuItem.itemName)
ENDIF
StringF(tempStr,' { \s, \s,\s,0,0,NULL },',itemType,itemName,commKey)

StrCopy(menuFlags,'')
IF menuItem.type<>MENU_TYPE_MENU
mut:=menuObject.makeMutual(currMenu,i)
IF menuItem.check
StrAdd(menuFlags,'CHECKIT')
ENDIF
IF menuItem.toggle
IF EstrLen(menuFlags) THEN StrAdd(menuFlags,' | ')
StrAdd(menuFlags,'MENUTOGGLE')
ENDIF
IF menuItem.checked
IF EstrLen(menuFlags) THEN StrAdd(menuFlags,' | ')
StrAdd(menuFlags,'CHECKED')
ENDIF
ENDIF
IF menuItem.disabled
IF EstrLen(menuFlags) THEN StrAdd(menuFlags,' | ')
IF menuItem.type=MENU_TYPE_MENU
StrAdd(menuFlags,'NM_MENUDISABLED')
ELSE
StrAdd(menuFlags,'NM_ITEMDISABLED')
ENDIF
ENDIF
IF EstrLen(menuFlags)=0 THEN StrCopy(menuFlags,'0')

StringF(tempStr,' { \s, \s, \s, \s, \d, NULL },',itemType,itemName,commKey,menuFlags,mut)
self.writeLine(tempStr)
ENDFOR
self.writeLine(' { NM_END, NULL, 0, 0, 0, (APTR)0 }')
Expand Down
37 changes: 37 additions & 0 deletions eSourceGen.e
Original file line number Diff line number Diff line change
Expand Up @@ -617,6 +617,8 @@ PROC genWindowHeader(count, windowObject:PTR TO windowObject, menuObject:PTR TO
DEF menuItem:PTR TO menuItem
DEF itemType
DEF itemName[200]:STRING
DEF menuFlags[60]:STRING
DEF currMenu,mut
DEF commKey[10]:STRING
DEF directiveStr[20]:STRING
DEF listObjects:PTR TO stdlist
Expand Down Expand Up @@ -836,11 +838,46 @@ PROC genWindowHeader(count, windowObject:PTR TO windowObject, menuObject:PTR TO

IF StrLen(menuItem.commKey) THEN StringF(commKey,'\a\s\a',menuItem.commKey)
ELSE
currMenu:=menuItem
mut:=0
itemType:='NM_TITLE'
StringF(itemName,'\a\s\a',menuItem.itemName)
ENDIF

StrCopy(menuFlags,'')
IF menuItem.type<>MENU_TYPE_MENU
mut:=menuObject.makeMutual(currMenu,i)
IF menuItem.check
StrAdd(menuFlags,'CHECKIT')
ENDIF
IF menuItem.toggle
IF StrLen(menuFlags) THEN StrAdd(menuFlags,' OR ')
StrAdd(menuFlags,'MENUTOGGLE')
ENDIF
IF menuItem.checked
IF StrLen(menuFlags) THEN StrAdd(menuFlags,' OR ')
StrAdd(menuFlags,'CHECKED')
ENDIF
ENDIF
IF menuItem.disabled
IF StrLen(menuFlags) THEN StrAdd(menuFlags,' OR ')
IF menuItem.type=MENU_TYPE_MENU
StrAdd(menuFlags,'NM_MENUDISABLED')
ELSE
StrAdd(menuFlags,'NM_ITEMDISABLED')
ENDIF
ENDIF

StringF(tempStr,' menuData[\d].type:=\s',i,itemType)
self.writeLine(tempStr)
IF StrLen(menuFlags)
StringF(tempStr,' menuData[\d].flags:=\s',i,menuFlags)
self.writeLine(tempStr)
ENDIF
IF mut
StringF(tempStr,' menuData[\d].mutualexclude:=\d',i,mut)
self.writeLine(tempStr)
ENDIF
StringF(tempStr,' menuData[\d].label:=\s',i,itemName)
self.writeLine(tempStr)
IF EstrLen(commKey)>0
Expand Down
2 changes: 1 addition & 1 deletion menuObject.e
Original file line number Diff line number Diff line change
Expand Up @@ -676,7 +676,7 @@ PROC editSettings(comp:PTR TO menuObject) OF menuSettingsForm
ENDIF
ENDPROC res=MR_OK

PROC makeMutual(menu:PTR TO menuItem,index) OF menuObject
EXPORT PROC makeMutual(menu:PTR TO menuItem,index) OF menuObject
DEF i,cnt,res=0,group,menuItem:PTR TO menuItem,currMenu:PTR TO menuItem


Expand Down
43 changes: 41 additions & 2 deletions rebuild.e
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,8 @@ OPT OSVERSION=37,LARGE
CONST MENU_EDIT_MOVEBOTTOM=3
CONST MENU_EDIT_MOVELPREV=4
CONST MENU_EDIT_MOVELNEXT=5
CONST MENU_EDIT_MOVEINTOLAYOUT_VERT=6
CONST MENU_EDIT_MOVEINTOLAYOUT_HORIZ=7

CONST FILE_FORMAT_VER=2

Expand Down Expand Up @@ -400,7 +402,7 @@ PROC updateSel(node)
DEF dis,idx
DEF check,i,j
DEF dismoveup,dismovedown,disdel
DEF disprevgroup,disnextgroup
DEF disprevgroup,disnextgroup,dismoveinto
DEF menuItem
DEF type
DEF allowchildren=FALSE
Expand Down Expand Up @@ -432,17 +434,20 @@ PROC updateSel(node)
dismoveup:=idx=0
dismovedown:=idx=(((objectList.count()-ROOT_WINDOW_ITEM)/3)-1)
disdel:=(objectList.count()=(ROOT_WINDOW_ITEM+3))
dismoveinto:=TRUE
ELSE
dismoveup:=TRUE
dismovedown:=TRUE
disdel:=TRUE
dismoveinto:=TRUE
ENDIF
disprevgroup:=TRUE
disnextgroup:=TRUE
ELSE
dismoveup:=comp.getChildIndex()=0
dismovedown:=comp.getChildIndex()=(comp.parent.children.count()-1)
disdel:=(comp.parent=0)
dismoveinto:=FALSE
IF comp.parent.parent=0
disprevgroup:=TRUE
disnextgroup:=TRUE
Expand Down Expand Up @@ -471,6 +476,8 @@ PROC updateSel(node)
menuDisable(win,MENU_EDIT,MENU_EDIT_MOVE,MENU_EDIT_MOVEBOTTOM,dismovedown)
menuDisable(win,MENU_EDIT,MENU_EDIT_MOVE,MENU_EDIT_MOVELPREV,disprevgroup)
menuDisable(win,MENU_EDIT,MENU_EDIT_MOVE,MENU_EDIT_MOVELNEXT,disnextgroup)
menuDisable(win,MENU_EDIT,MENU_EDIT_MOVEINTOLAYOUT_VERT,0,dismoveinto)
menuDisable(win,MENU_EDIT,MENU_EDIT_MOVEINTOLAYOUT_HORIZ,0,dismoveinto)

dis:=(comp.parent=0) AND (allowchildren=FALSE) AND (comp.type<>TYPE_SCREEN) AND (comp.type<>TYPE_WINDOW)
SetGadgetAttrsA(gMain_Gadgets[GAD_ADD],win,0,[GA_DISABLED,dis,TAG_END])
Expand Down Expand Up @@ -1100,6 +1107,32 @@ PROC moveNextLayout(comp:PTR TO reactionObject)
rethinkPreviews()
ENDPROC

PROC moveIntoLayout(comp:PTR TO reactionObject,horiz)
DEF newComp:PTR TO reactionObject

DEF idx, mainRootLayout, window
DEF parent:PTR TO reactionObject

parent:=comp.parent
IF parent.allowChildren()
newComp:=doAddLayoutQuick(comp,horiz)

changes:=TRUE
idx:=findWindowIndex(comp)
mainRootLayout:=objectList.item(ROOT_LAYOUT_ITEM+(idx*3))
window:=objectList.item(ROOT_WINDOW_ITEM+(idx*3))
removeMembers(mainRootLayout,window)

parent.swapChildren(comp.getChildIndex(),newComp.getChildIndex())
parent.removeChild(comp)
newComp.addChild(comp)

makeList(comp)
addMembers(mainRootLayout,window)
rethinkPreviews()
ENDIF
ENDPROC

PROC findWindowIndex(comp:PTR TO reactionObject)
DEF res,i
IF comp.type=TYPE_WINDOW
Expand Down Expand Up @@ -1869,7 +1902,7 @@ PROC doAddLayoutQuick(comp:PTR TO reactionObject, horiz)
addObject(comp,newObj)
ENDIF
ENDIF
ENDPROC
ENDPROC newObj

PROC countObjectsOfType(objType,comp:PTR TO reactionObject)
DEF count=0,i
Expand Down Expand Up @@ -2447,6 +2480,8 @@ PROC remakePreviewMenus()
NM_SUB,'Layout Bottom',0,0,
NM_SUB,'Prev Layout',0,0,
NM_SUB,'Next Layout',0,0,
NM_SUB,'Into VLayout',0,0,
NM_SUB,'Into HLayout',0,0,
NM_ITEM,NM_BARLABEL,0,0,
NM_ITEM,'Edit Lists',0,0,
NM_ITEM,NM_BARLABEL,0,0,
Expand Down Expand Up @@ -2899,6 +2934,10 @@ PROC main() HANDLE
movePrevLayout(selectedComp)
CASE MENU_EDIT_MOVELNEXT
moveNextLayout(selectedComp)
CASE MENU_EDIT_MOVEINTOLAYOUT_VERT
moveIntoLayout(selectedComp,FALSE)
CASE MENU_EDIT_MOVEINTOLAYOUT_HORIZ
moveIntoLayout(selectedComp,TRUE)
ENDSELECT
CASE MENU_EDIT_LISTS
editLists()
Expand Down

0 comments on commit b2a5b12

Please sign in to comment.