/// <summary> /// Gets the menu entry from its Uid. /// </summary> /// <param name = "menuUid">Uid whose corresponding menu entry is to be found</param> /// <returns></returns> public MenuEntry menuByUid(int menuUid) { MenuEntry menuEntryByUid = null; IEnumerator iMgMenu = menus.GetEnumerator(); while (iMgMenu.MoveNext()) { MgMenu mgmenu = (MgMenu)iMgMenu.Current; IEnumerator iMenuEntry = mgmenu.iterator(); while (iMenuEntry.MoveNext()) { MenuEntry menuEntry = (MenuEntry)iMenuEntry.Current; if (menuEntry.menuUid() == menuUid) { menuEntryByUid = menuEntry; return(menuEntryByUid); } if (menuEntry.menuType() == GuiMenuEntry.MenuType.MENU) { menuEntryByUid = getMenuEntryByUid(menuEntry, menuUid); if (menuEntryByUid != null) { if (menuEntryByUid.menuUid() == menuUid) { return(menuEntryByUid); } } } } } return(menuEntryByUid); }
/// <summary> /// Returns menu index by its name. Only searchs top level menus (like default pull down etc) /// </summary> /// <param name="menuName">Name of the menu</param> /// <returns> long index of the menu</returns> public int menuIdxByName(String menuName, bool isPublic) { int index = 1; IEnumerator iMgMenu = menus.GetEnumerator(); int menuIdx = 0; //internal names are currently not handled. if (isPublic) { return(0); } while (iMgMenu.MoveNext()) { MgMenu mgmenu = (MgMenu)iMgMenu.Current; String mnuName = mgmenu.getName(); if (mnuName != null && String.CompareOrdinal(mnuName, menuName) == 0) { menuIdx = index; break; } index++; } return(menuIdx); }
/// <summary> /// Returns all menu entries matching the name in this applicaiton menu /// </summary> /// <param name="entryName">Sring Entry name to be searched</param> /// <param name="pulldownMenu">Current pulldown menu</param> /// <returns>List of MenuEntries matching the entry Name</returns> public ArrayList GetMatchingMenuValues(String entryName, MgMenu pulldownMenu) { ArrayList matchingMnuValues = new ArrayList(); // Can't use List<T> - may hold MenuEntry or MgValue IEnumerator iMgMenu = menus.GetEnumerator(); while (iMgMenu.MoveNext()) { bool isPulldown; MgMenu mgmenu = (MgMenu)iMgMenu.Current; if (mgmenu == pulldownMenu) { isPulldown = true; } else { isPulldown = false; } IEnumerator iMenuEntry = mgmenu.iterator(); BuildMatchingMenuValues(entryName, iMenuEntry, isPulldown, matchingMnuValues); } matchingMnuValues.TrimToSize(); return(matchingMnuValues); }
public void setData(MenuType type, String menuName, String menuText, MgMenu mgMenu) { setType(type); setName(menuName); setText(menuText, true); setParentMgMenu(mgMenu); }
private MgMenu _parentMgMenu; // reference to the root parent menu /// <summary> /// /// </summary> /// <param name="type"></param> /// <param name="mgMenu"></param> public MenuEntry(MenuType type, MgMenu mgMenu) { setType(type); setParentMgMenu(mgMenu); //instantiatedMenuItems = new Hashtable(); _index = -1; }
/// <summary> /// refresh the internal event menus of form /// </summary> /// <param name = "form"></param> public void refreshInternalEventMenus(MgFormBase form) { for (int i = 0; i < menus.Count; i++) { MgMenu menu = menus[i]; menu.refreshInternalEventMenus(form); } }
/// <summary> /// Context menus are not automatically disposed when a form is disposed (unlike the swt version). /// For every menu , dispose all its instances for the disposing form. /// </summary> /// <param name = "form"></param> public void disposeFormContexts(MgFormBase form) { for (int i = 0; i < menus.Count; i++) { MgMenu menu = menus[i]; menu.disposeFormContexts(form); } }
/// <summary> /// Create a WindowMenuEntry under a MgMenu /// </summary> /// <param name="mgFormBase"></param> /// <param name="menuType">WindowMenu / Separator</param> /// <param name="windowMenuIdx">Index where new menuentry should be added</param> /// <param name="guiMgForm"></param> /// <param name="menuStyle">Pulldown / Context</param> /// <param name="setChecked" public override void CreateMenuEntry(MgFormBase mgFormBase, MenuType menuType, int windowMenuIdx, GuiMgForm guiMgForm, MenuStyle menuStyle, bool setChecked) { MenuEntry menuEntry = base.CreateMenuEntryItem(mgFormBase, menuType, guiMgForm, menuStyle, setChecked); MgMenu mgMenu = getParentMgMenu(); mgMenu.addMenu(menuEntry, windowMenuIdx + 1); mgMenu.setIndexes(false); }
/// <summary> /// /// </summary> public void destroyAndRebuild() { for (int i = 0; i < menus.Count; i++) { MgMenu menu = menus[i]; menu.destroyAndRebuild(); } }
/// <summary> /// This method returns an MgMenu object according to passed menuIndex /// </summary> /// <param name = "menuIndex"></param> /// <returns> matching MgMenu object</returns> public MgMenu getMgMenu(int menuIndex) { MgMenu mgMenu = null; if (menuIndex > 0 && menus.Count >= menuIndex) { mgMenu = menus[menuIndex - 1]; } return(mgMenu); }
/// <summary> /// Create MenuEntries for WindowList Items. /// </summary> /// <param name="guiMgForm"></param> /// <param name="guiMenuEntry"></param> /// <param name="menuStyle"></param> public void CreateWindowMenuEntries(GuiMgForm guiMgForm, Object guiMenuEntry, MenuStyle menuStyle) { Debug.Assert(Misc.IsGuiThread()); bool IsMenuEntryWindowMenu = guiMenuEntry is MenuEntryWindowMenu; MenuEntry menuEntry; int windowMenuIdx = 0; //We get this flag as true only when the menu contains WindowList at first level and it is being used as context menu if (IsMenuEntryWindowMenu) { //Here we add the new WindowMenu in the parent MgMenu menuEntry = (MenuEntryWindowMenu)guiMenuEntry; windowMenuIdx = menuEntry.getParentMgMenu().GetWindowMenuEntryIndex(); } else { //We add the WindowMenu in the MenuEntryMenu menuEntry = (MenuEntryMenu)guiMenuEntry; windowMenuIdx = ((MenuEntryMenu)menuEntry).GetWindowMenuEntryIndex(); } // Enable/Disable MenuEntries for CloseAll, NextWindow & PreviousWindow. TaskBase task = ((MgFormBase)guiMgForm).getTask(); MgMenu mgMenu = menuEntry.getParentMgMenu(); mgMenu.enableInternalEvent((MgFormBase)guiMgForm, InternalInterface.MG_ACT_CLOSE_ALL_WIN, task.ActionManager.isEnabled(InternalInterface.MG_ACT_CLOSE_ALL_WIN), null); mgMenu.enableInternalEvent((MgFormBase)guiMgForm, InternalInterface.MG_ACT_NEXT_RT_WINDOW, task.ActionManager.isEnabled(InternalInterface.MG_ACT_NEXT_RT_WINDOW), null); mgMenu.enableInternalEvent((MgFormBase)guiMgForm, InternalInterface.MG_ACT_PREV_RT_WINDOW, task.ActionManager.isEnabled(InternalInterface.MG_ACT_PREV_RT_WINDOW), null); lock (_windowListLock) { if (IsValidIndex(windowMenuIdx)) { // Delete the existing MenuEntries. DeleteWindowMenuEntries(menuEntry, windowMenuIdx + 1, IsMenuEntryWindowMenu); // Create new MenuEntries for WindowList Items. if (_windowList.Count > 0) { // Create menu item for a form in window list. for (int i = 0; i < _windowList.Count; i++) { MgFormBase mgForm = _windowList[i]; menuEntry.CreateMenuEntry(mgForm, GuiMenuEntry.MenuType.WINDOW_MENU_ENTRY, windowMenuIdx++, guiMgForm, menuStyle, _sortByRecentlyUsed ? i == 0 : i == _currWinIdx); } // Create a separator to distinguish the window menu items only for PullDown menu if (menuStyle != MenuStyle.MENU_STYLE_CONTEXT) { menuEntry.CreateMenuEntry(null, GuiMenuEntry.MenuType.SEPARATOR, windowMenuIdx++, guiMgForm, menuStyle, false); } } } } }
/// <summary> /// Set ParentRootMgMenu to menuEntry. If menuEntry is MenuEntryMenu, then set ParentRootMgMenu to it's sub menus also. /// </summary> public void setParentRootMgMenu(MgMenu mgMenu) { setParentMgMenu(mgMenu); if (this is MenuEntryMenu) { for (int i = 0; i < ((MenuEntryMenu)this).subMenus.Count; i++) { (((MenuEntryMenu)this).subMenus[i]).setParentRootMgMenu(mgMenu); (((MenuEntryMenu)this).subMenus[i]).ParentMenuEntry = this; } } }
/// <summary> /// Refresh all the menus text in our menu list. /// </summary> public void refreshMenuesTextMls() { IEnumerator iMgMenu = menus.GetEnumerator(); while (iMgMenu.MoveNext()) { MgMenu mgmenu = (MgMenu)iMgMenu.Current; IEnumerator iMenuEntry = mgmenu.iterator(); while (iMenuEntry.MoveNext()) { MenuEntry menuEntry = (MenuEntry)iMenuEntry.Current; refreshRecursiveMenuesEntryMls(menuEntry); } } }
/// <summary> /// returns the clone of the object. /// </summary> /// <returns></returns> public Object Clone() { MgMenu mgmenu = (MgMenu)MemberwiseClone(); //MemeberwiseClone copies the refrences of arraylist but we need new objects so for deep copy of //all elements in menuEntries, we need to copy each of it's element seperately. mgmenu._menuEntries = getDeepCopyOfMenuEntries(_menuEntries); base.init(); //Following members(references) should not be copied in new cloned object because for creation of new menu //in menuAdd function, we need these values diffrent than the actual menu. _instantiatedToolbar = new Hashtable(); _internalEventsOnMenus = new Hashtable(); _internalEventsOnToolBar = new Hashtable(); _menuEntriesWithAccessKey = new Hashtable(); return(mgmenu); }
private void popCurrentObject() { _objectsStack.Pop(); if ((_objectsStack.Count == 0)) { _currentMgMenu = null; _currentMenuEntry = null; } else { if (_objectsStack.Peek() is MgMenu) { _currentMgMenu = (MgMenu)_objectsStack.Peek(); _currentMenuEntry = null; } else { _currentMenuEntry = (MenuEntry)_objectsStack.Peek(); } } }
/** * get the tool index for method menuShow. * we pass all the menu entry in the MgMenu and calculate the index of the tool. * @param form : the form that we work on it * @param toolGroup: the tool group that this icon need to be added. * @forMenuEntry: calculate the tool index for this menu entry * @return */ private int calcToolbarIndex(MgFormBase form, int toolGroup, MenuEntry forMenuEntry) { int count = 0; MgMenu mgMenu = form.getMgMenu(MenuStyle.MENU_STYLE_PULLDOWN); bool found = false; IEnumerator iMenuEntry = mgMenu.iterator(); while (iMenuEntry.MoveNext()) { MenuEntry menuEntry = (MenuEntry)iMenuEntry.Current; //get the count from this menu recursively count += menuEntry.getGroupCount(form, toolGroup, forMenuEntry, ref found); if (found) { break; } } return(count); }
/// <summary> /// /// </summary> /// <param name="mgMenu"></param> public MenuEntryProgram(MgMenu mgMenu) : base(MenuType.PROGRAM, mgMenu) { }
private void pushCurrentObject(MgMenu obj) { _currentMgMenu = obj; _objectsStack.Push(_currentMgMenu); _currentObjectType = CurrentObjectType.MENU_TYPE_MENU; }
/// <summary> /// Updates the current object (MgMenu or MenuEntry) by the parsed element values /// </summary> public override void startElement(String elementName, NameValueCollection attributes) { String str = ""; int menuType = 0; bool doNothing = false; bool boolVal; switch (elementName) { case "Menu": _currentMgMenu = new MgMenu(); pushCurrentObject(_currentMgMenu); _mgMenus.Add(_currentMgMenu); break; case "MenuEntry": // we do not allocate the menu entry object yet - depends on the menu type _currentObjectType = CurrentObjectType.MENU_TYPE_MENU_ENTRY; break; case "Name": if (isMgMenu()) { _currentMgMenu.setName(attributes["val"]); } else { _currentMenuEntry.setName(attributes["val"]); } break; case "MenuType": { MenuEntry newEntry = null; if (!isMgMenu()) { // resolve the menu entry type menuType = getInt(attributes); switch (menuType) { case MNT_TYPE_MENU: newEntry = new MenuEntryMenu(_currentMgMenu); break; case MNT_TYPE_PROG: newEntry = new MenuEntryProgram(_currentMgMenu); break; case MNT_TYPE_ACTION: // we still do not know the type if the event (internal, system or user) newEntry = new MenuEntryEvent(_currentMgMenu); break; case MNT_TYPE_OS: newEntry = new MenuEntryOSCommand(_currentMgMenu); break; case MNT_TYPE_LINE: // nothing to do in case of a separator newEntry = new MenuEntry(GuiMenuEntry.MenuType.SEPARATOR, _currentMgMenu); newEntry.setVisible(true, true, false, null); break; case MNT_TYPE_WINDOW_LIST: newEntry = new MenuEntryWindowMenu(_currentMgMenu); newEntry.setVisible(true, true, false, null); break; default: doNothing = true; break; } if (!doNothing) { // we need to attach the new menu entry to its parent menu if (_objectsStack.Peek() is MgMenu) { _currentMgMenu.addSubMenu(newEntry); } else { ((MenuEntryMenu)_currentMenuEntry).addSubMenu(newEntry); } pushCurrentObject(newEntry); } } break; } case "MenuUid": if (isMgMenu()) { _currentMgMenu.setUid(getInt(attributes)); } else { _currentMenuEntry.setUid(getInt(attributes)); } break; case "Checked": boolVal = getBooleanValue(attributes); _currentMenuEntry.setChecked(boolVal, true); break; case "VISIBLE": boolVal = getBooleanValue(attributes); _currentMenuEntry.setVisible(boolVal, true, false, null); break; case "Enabled": boolVal = getBooleanValue(attributes); _currentMenuEntry.setEnabled(boolVal, false, false); break; case "IsParallel": boolVal = getBooleanValue(attributes); ((MenuEntryProgram)_currentMenuEntry).IsParallel = boolVal; break; case "ImageFor": str = attributes["val"]; switch (str) { case "B": _currentMenuEntry.Imagefor = GuiMenuEntry.ImageFor.MENU_IMAGE_BOTH; break; case "M": _currentMenuEntry.Imagefor = GuiMenuEntry.ImageFor.MENU_IMAGE_MENU; break; default: _currentMenuEntry.Imagefor = GuiMenuEntry.ImageFor.MENU_IMAGE_TOOLBAR; break; } break; case "Icon": String imageFile = Events.TranslateLogicalName(attributes["val"]); _currentMenuEntry.ImageFile = imageFile; break; case "ToolNumber": _currentMenuEntry.ImageNumber = getInt(attributes); break; case "ToolGroup": _currentMenuEntry.ImageGroup = getInt(attributes); break; case "Tooltip_U": _currentMenuEntry.toolTip(attributes["val"]); break; case "Description_U": if (isMgMenu()) { _currentMgMenu.setText(attributes["val"]); } else { _currentMenuEntry.setText(attributes["val"], true); } break; case "Help": { int help = getInt(attributes, "obj"); if (_currentMenuEntry is MenuEntryEvent) { ((MenuEntryEvent)_currentMenuEntry).Help = help; } else if (_currentMenuEntry is MenuEntryOSCommand) { ((MenuEntryOSCommand)_currentMenuEntry).Help = help; } else if (_currentMenuEntry is MenuEntryProgram) { ((MenuEntryProgram)_currentMenuEntry).Help = help; } break; } case "Prompt": { String prompt = attributes["val"]; if (_currentMenuEntry is MenuEntryEvent) { ((MenuEntryEvent)_currentMenuEntry).Prompt = prompt; } else if (_currentMenuEntry is MenuEntryOSCommand) { ((MenuEntryOSCommand)_currentMenuEntry).Prompt = prompt; } else if (_currentMenuEntry is MenuEntryProgram) { ((MenuEntryProgram)_currentMenuEntry).Prompt = prompt; } break; } case "DestinationContext": { String destContext = attributes["val"]; if (_currentMenuEntry is MenuEntryEvent) { ((MenuEntryEvent)_currentMenuEntry).DestinationContext = destContext; } break; } case "SourceContext": { String val = attributes["val"]; ((MenuEntryProgram)_currentMenuEntry).SourceContext = (MenuEntryProgram.SrcContext)XmlParser.getInt(val); break; } case "FieldID": { String val = attributes["val"]; ((MenuEntryProgram)_currentMenuEntry).ReturnCtxIdVee = (char)XmlParser.getInt(val); break; } case "Program": ((MenuEntryProgram)_currentMenuEntry).Idx = getInt(attributes, "obj"); ((MenuEntryProgram)_currentMenuEntry).Comp = getInt(attributes, "comp"); ((MenuEntryProgram)_currentMenuEntry).ProgramIsn = getInt(attributes, "ObjIsn"); ((MenuEntryProgram)_currentMenuEntry).CtlIndex = getInt(attributes, "CtlIndex"); (_currentMenuEntry).setEnabled((_currentMenuEntry).getEnabled(), true, false); break; case "PublicName": ((MenuEntryProgram)_currentMenuEntry).PublicName = attributes["val"]; break; case "COPY_GLOBAL_PARAMS": { bool copyGlobalParameters = false; if (attributes["val"].Equals("Y")) { copyGlobalParameters = true; } ((MenuEntryProgram)_currentMenuEntry).CopyGlobalParameters = copyGlobalParameters; break; } case "Arguments": if (_currentMenuEntry is MenuEntryProgram) { ((MenuEntryProgram)_currentMenuEntry).MainProgVars = new List <String>(); } else if (_currentMenuEntry is MenuEntryEvent) { ((MenuEntryEvent)_currentMenuEntry).MainProgVars = new List <String>(); } break; case "Argument": _inArgumentTag = true; break; case "Variable": if (_inArgumentTag) { if (_currentMenuEntry is MenuEntryProgram) { ((MenuEntryProgram)_currentMenuEntry).MainProgVars.Add(attributes["val"]); } else if (_currentMenuEntry is MenuEntryEvent) { ((MenuEntryEvent)_currentMenuEntry).MainProgVars.Add(attributes["val"]); } } break; case "Skip": if (_inArgumentTag && attributes["val"].Equals("Y")) { if (_currentMenuEntry is MenuEntryProgram) { ((MenuEntryProgram)_currentMenuEntry).MainProgVars.Add("Skip"); } else if (_currentMenuEntry is MenuEntryEvent) { ((MenuEntryEvent)_currentMenuEntry).MainProgVars.Add("Skip"); } } break; case "Ext": ((MenuEntryOSCommand)_currentMenuEntry).OsCommand = attributes["val"]; break; case "Wait": ((MenuEntryOSCommand)_currentMenuEntry).Wait = getBooleanValue(attributes); break; case "Show": { String val = attributes["val"]; ((MenuEntryOSCommand)_currentMenuEntry).Show = (CallOsShow)XmlParser.getInt(val); break; } case "EventType": { String val = attributes["val"]; if (val.Equals("U")) { _currentMenuEntry.setType(GuiMenuEntry.MenuType.USER_EVENT); } else if (val.Equals("I")) { _currentMenuEntry.setType(GuiMenuEntry.MenuType.INTERNAL_EVENT); } else if (val.Equals("S")) { _currentMenuEntry.setType(GuiMenuEntry.MenuType.SYSTEM_EVENT); } break; } case "Event": _inEventTag = true; break; case "Parent": if (_inEventTag) { ((MenuEntryEvent)_currentMenuEntry).UserEvtTaskId = attributes["val"]; } break; case "PublicObject": if (_inEventTag && (_currentMenuEntry).menuType() == GuiMenuEntry.MenuType.USER_EVENT) { ((MenuEntryEvent)_currentMenuEntry).UserEvtIdx = getInt(attributes, "obj"); ((MenuEntryEvent)_currentMenuEntry).UserEvtCompIndex = getInt(attributes, "comp"); } break; case "Modifier": if (_inEventTag && (_currentMenuEntry).menuType() == GuiMenuEntry.MenuType.SYSTEM_EVENT || _inAccessKeyTag) { _modifier = (Modifiers)attributes["val"][0]; } break; case "Key": if (_inEventTag && (_currentMenuEntry).menuType() == GuiMenuEntry.MenuType.SYSTEM_EVENT || _inAccessKeyTag) { _keyCode = getInt(attributes); } break; case "InternalEventID": if (_inEventTag && (_currentMenuEntry).menuType() == GuiMenuEntry.MenuType.INTERNAL_EVENT) { ((MenuEntryEvent)_currentMenuEntry).InternalEvent = getInt(attributes); _currentMenuEntry.setEnabled((_currentMenuEntry).getEnabled(), true, false); } break; case "AccessKey": _inAccessKeyTag = true; break; case "PrgDescription": ((MenuEntryProgram)_currentMenuEntry).Description = attributes["val"]; break; case "PrgFlow": ((MenuEntryProgram)_currentMenuEntry).Flow = attributes["val"][0]; break; } }
} //dest. Context /// <summary> /// /// </summary> /// <param name="mgMenu"></param> internal MenuEntryEvent(MgMenu mgMenu) : base(0, mgMenu) { }
public void setParentMgMenu(MgMenu mgMenu) { _parentMgMenu = mgMenu; }
} // wait till end of execution /// <summary> /// /// </summary> /// <param name="mgMenu"></param> public MenuEntryOSCommand(MgMenu mgMenu) : base(MenuType.OSCOMMAND, mgMenu) { Show = CallOsShow.Normal; }
public MenuEntryMenu(MgMenu mgMenu) : base(MenuType.MENU, mgMenu) { subMenus = new List <MenuEntry>(); }
/// <summary> /// /// </summary> /// <param name="mgMenu"></param> internal MenuEntryWindowMenu(MgMenu mgMenu) : base(MenuType.WINDOW_MENU_ENTRY, mgMenu) { }