The template for menu
Posted May 5th, 2009 by Andrew PopoffToday I started work on a template for the menu. I usually make it quickly. But now I have decided that I will spend considerable time for writing a template. I think that I will slightly rewrite the template for the context menu and the toolbar, so that all these templates were able to work together.
In product xXPFrame I redraws the standard menu. In CFC-menu I decided that I will build menu again. This means that you have to create all the menus again. And I understand that this is a bad thing. Therefore, I decided to start work on the template with the possibility of implementing the import of existing menus.
The template contains only one button, which allows you to import an existing menu to the template. I am importing the structure of the menu, the names of items and icons. I do not know the way to import actions that are performed by pressing the menu item.
I will give part of the code template, which is responsible for imports. I use recursion (%ProcessImpMenu) to fill the queue template. It works in templates too
Frankly speaking the names of variables are not very well named:) This is ever since the xXPPopup-template.
...
#BOXED('Import')
#DISPLAY
#PROMPT('I really want to import a menu', CHECK),%CFCImportMenu,DEFAULT(0),AT(10)
#ENABLE(%CFCImportMenu)
#BUTTON('Import std menu'),WHENACCEPTED(%ImportMenu()),AT(20)
#ENDBUTTON
#ENDENABLE
#DISPLAY
#ENDBOXED
...
#!------------------------------------------------------------------------------
#GROUP(%ImportMenu)
#DECLARE(%MenuItems),UNIQUE,MULTI
#DECLARE(%ItemFEQ,%MenuItems)
#DECLARE(%ParentFEQ,%MenuItems)
#DECLARE(%ItemTxt,%MenuItems)
#DECLARE(%FlagSep,%MenuItems)
#DECLARE(%ItemIco,%MenuItems)
#DECLARE(%locCnt)
#DECLARE(%Cnt)
#DECLARE(%MenuBarFeq)
#SET(%MenuBarFeq,'')
#SET(%locCnt,0)
#FOR(%Control),WHERE(%Control AND (%ControlType = 'MENU' OR %ControlType = 'ITEM'))
#SET(%locCnt,%locCnt + 1)
#ADD(%MenuItems,%locCnt)
#SET(%ItemFEQ,%Control)
#SET(%ParentFEQ,%ControlParent)
#SET(%FlagSep,EXTRACT(%ControlStatement,'SEPARATOR'))
#IF(%ControlType = 'MENU')
#SET(%ItemTxt,EXTRACT(%ControlStatement,'MENU',1))
#SET(%ItemTxt,SUB(%ItemTxt,2,LEN(CLIP(%ItemTxt))-2))
#ENDIF
#IF(%ControlType = 'ITEM')
#SET(%ItemTxt,EXTRACT(%ControlStatement,'ITEM',1))
#SET(%ItemTxt,SUB(%ItemTxt,2,LEN(CLIP(%ItemTxt))-2))
#SET(%ItemIco,EXTRACT(%ControlStatement,'ICON',1))
#SET(%ItemIco,SUB(%ItemIco,2,LEN(CLIP(%ItemIco))-2))
#ENDIF
#ENDFOR
#SET(%Cnt,ITEMS(%QItemName))
#SET(%MenuBarFeq,EXTRACT(%MenuBarStatement,'USE',1))
#CALL(%ProcessImpMenu,0,%MenuBarFeq)
#SET(%CFCImportMenu,0)
#ERROR('Import has finished! See General-tab!')
#!------------------------------------------------------------------------------
#GROUP(%ProcessImpMenu,%MenuLevel,%ParentMenu)
#DECLARE(%locSavMenuItems)
#FOR(%MenuItems)
#IF(%ParentFEQ = %ParentMenu)
#SET(%locSavMenuItems,%MenuItems)
#SET(%Cnt,%Cnt + 1)
#ADD(%QItemName,%Cnt)
#SET(%ItemText,%ItemTxt)
#SET(%ItemLevel,%MenuLevel + 1)
#SET(%ItemStrID,SUB(%ItemFEQ,2,LEN(CLIP(%ItemFEQ))-1))
#SET(%ItemObj,%ItemStrID)
#SET(%ItemIcon,%ItemIco)
#IF(%FlagSep = 'SEPARATOR')
#SET(%ItemSeparator,1)
#ELSE
#CALL(%ProcessImpMenu,%ItemLevel,%ItemFEQ)
#ENDIF
#FIX(%MenuItems,%locSavMenuItems)
#ENDIF
#ENDFOR
Tags: CFC Library, template | No Comments »


Leave a Reply