Beispiel #1
0
        public MDLinkMenuItem(LinkCommandEntry lce)
        {
            this.lce   = lce;
            this.Title = lce.Text;

            Activated += MDLinkMenuItem_Activated;
        }
Beispiel #2
0
        public MDLinkMenuItem(LinkCommandEntry lce)
        {
            this.lce   = lce;
            this.Title = lce.Text;

            Target = this;
            Action = MDMenuItem.ActionSel;
        }
Beispiel #3
0
        static void CreateChildren(IntPtr parentMenu, CommandEntrySet entrySet, HashSet <object> ignoreCommands)
        {
            var menuId = HIToolbox.GetMenuID(parentMenu);

            foreach (CommandEntry entry in entrySet)
            {
                CommandEntrySet ces = entry as CommandEntrySet;

                if (ces == null)
                {
                    ushort pos;

                    if (ignoreCommands.Contains(entry.CommandId))
                    {
                        continue;
                    }

                    if (entry.CommandId == Command.Separator)
                    {
                        HIToolbox.AppendMenuSeparator(parentMenu);
                        continue;
                    }

                    if (entry is LinkCommandEntry)
                    {
                        LinkCommandEntry lce = (LinkCommandEntry)entry;
                        pos = HIToolbox.AppendMenuItem(parentMenu, (lce.Text ?? "").Replace("_", ""), 0, linkCommandId);
                        HIToolbox.SetMenuItemReferenceConstant(new HIMenuItem(parentMenu, pos), (uint)linkCommands.Count);
                        linkCommands.Add(lce.Url);
                        continue;
                    }

                    Command cmd = manager.GetCommand(entry.CommandId);
                    if (cmd == null)
                    {
                        MonoDevelop.Core.LoggingService.LogError(
                            "Mac main menu '{0}' child '{1}' maps to null command", entrySet.Name, entry.CommandId);
                        continue;
                    }

                    if (cmd is CustomCommand)
                    {
                        MonoDevelop.Core.LoggingService.LogWarning(
                            "Mac main menu does not support custom command widgets for command '{0}'", entry.CommandId);
                        continue;
                    }

                    menuIdMap[entry.CommandId] = menuId;

                    ActionCommand acmd = cmd as ActionCommand;
                    if (acmd == null)
                    {
                        MonoDevelop.Core.LoggingService.LogWarning(
                            "Mac main menu does not support command type '{0}' for command '{1}'", cmd.GetType(), entry.CommandId);
                        continue;
                    }

                    uint macCmdId = GetNewMenuItemId(cmd);

                    pos = HIToolbox.AppendMenuItem(parentMenu, (cmd.Text ?? "").Replace("_", ""), 0, macCmdId);
                }
                else
                {
                    var    macCmdId = (ces.AutoHide) ? autohideSubmenuCommandId : submenuCommandId;
                    IntPtr menuRef  = HIToolbox.CreateMenu(idSeq++, GetName(ces), MenuAttributes.CondenseSeparators);
                    mainMenus.Add(menuRef);
                    CreateChildren(menuRef, ces, ignoreCommands);
                    ushort pos = HIToolbox.AppendMenuItem(parentMenu, GetName(ces), 0, macCmdId);
                    HIToolbox.CheckResult(HIToolbox.SetMenuItemHierarchicalMenu(parentMenu, pos, menuRef));
                }
            }
        }