public CommandMenuItem(object commandId, CommandManager commandManager)
     : base("")
 {
     this.commandId = commandId;
     this.commandManager = commandManager;
     ActionCommand cmd = commandManager.GetCommand (commandId) as ActionCommand;
     if (cmd != null)
         isArray = cmd.CommandArray;
 }
 public CommandCheckMenuItem(object commandId, CommandManager commandManager)
     : base("")
 {
     this.commandId = commandId;
     this.commandManager = commandManager;
     ActionCommand cmd = commandManager.GetCommand (commandId) as ActionCommand;
     if (cmd != null && cmd.ActionType == ActionType.Radio)
         this.DrawAsRadio = true;
 }
        internal static Gtk.MenuItem CreateMenuItem(CommandManager manager, object cmdId, bool isArrayMaster)
        {
            if (cmdId == Command.Separator)
                return new Gtk.SeparatorMenuItem ();

            Command cmd = manager.GetCommand (cmdId);
            if (cmd is CustomCommand) {
                Gtk.Widget child = (Gtk.Widget) Activator.CreateInstance (((CustomCommand)cmd).WidgetType);
                CustomMenuItem ti = new CustomMenuItem ();
                ti.Child = child;
                return ti;
            }

            ActionCommand acmd = cmd as ActionCommand;
            if (acmd.ActionType == ActionType.Normal || (isArrayMaster && acmd.CommandArray))
                return new CommandMenuItem (cmdId, manager);
            else
                return new CommandCheckMenuItem (cmdId, manager);
        }
        protected internal virtual Gtk.ToolItem CreateToolItem(CommandManager manager)
        {
            if (cmdId == Command.Separator)
                return new Gtk.SeparatorToolItem ();

            Command cmd = manager.GetCommand (cmdId);
            if (cmd is CustomCommand) {
                Gtk.Widget child = (Gtk.Widget) Activator.CreateInstance (((CustomCommand)cmd).WidgetType);
                Gtk.ToolItem ti = new Gtk.ToolItem ();
                ti.Child = child;
                if (cmd.Text != null && cmd.Text.Length > 0) {
                    Gtk.Tooltips tips = new Gtk.Tooltips ();
                    ti.SetTooltip (tips, cmd.Text, cmd.Text);
                    tips.Enable ();
                }
                return ti;
            }

            ActionCommand acmd = cmd as ActionCommand;
            if (acmd == null)
                throw new InvalidOperationException ("Unknown cmd type.");

            if (acmd.CommandArray) {
                CommandMenu menu = new CommandMenu (manager);
                menu.Append (CreateMenuItem (manager));
                return new MenuToolButton (menu, acmd.Icon);
            }
            else if (acmd.ActionType == ActionType.Normal)
                return new CommandToolButton (cmdId, manager);
            else
                return new CommandToggleToolButton (cmdId, manager);
        }