Esempio n. 1
0
        public void Update(MDMenu parent, ref NSMenuItem lastSeparator, ref int index)
        {
            var info = manager.GetCommandInfo(ce.CommandId, new CommandTargetRoute(initialCommandTarget));

            if (!isArrayItem)
            {
                SetItemValues(this, info, ce.DisabledVisible);
                if (!Hidden)
                {
                    MDMenu.ShowLastSeparator(ref lastSeparator);
                }
                return;
            }

            Hidden = true;

            if (index < parent.Count - 1)
            {
                for (int i = index + 1; i < parent.Count; i++)
                {
                    var nextItem = parent.ItemAt(i);
                    if (nextItem == null || nextItem.Target != this)
                    {
                        break;
                    }
                    parent.RemoveItemAt(i);
                    i--;
                }
            }

            PopulateArrayItems(info.ArrayInfo, parent, ref lastSeparator, ref index);
        }
Esempio n. 2
0
		public void Update (MDMenu parent, ref NSMenuItem lastSeparator, ref int index)
		{
			var info = manager.GetCommandInfo (ce.CommandId);

			if (!isArrayItem) {
				SetItemValues (this, info);
				if (!Hidden)
					MDMenu.ShowLastSeparator (ref lastSeparator);
				return;
			}

			Hidden = true;

			if (index < parent.Count - 1) {
				for (int i = index + 1; i < parent.Count; i++) {
					var nextItem = parent.ItemAt (i);
					if (nextItem == null || nextItem.Target != this)
						break;
					parent.RemoveItemAt (i);
					i--;
				}
			}

			PopulateArrayItems (info.ArrayInfo, parent, ref lastSeparator, ref index);
		}
Esempio n. 3
0
		public void Update (MDMenu parent, ref NSMenuItem lastSeparator, ref int index)
		{
			Enabled = true;
			Hidden = Submenu != NSApplication.SharedApplication.ServicesMenu;
			if (!Hidden)
				MDMenu.ShowLastSeparator (ref lastSeparator);
		}
Esempio n. 4
0
		void PopulateArrayItems (CommandArrayInfo infos, NSMenu parent, ref NSMenuItem lastSeparator, ref int index)
		{
			foreach (CommandInfo ci in infos) {
				if (ci.IsArraySeparator) {
					var n = NSMenuItem.SeparatorItem;
					n.Hidden = true;
					n.Target = this;
					lastSeparator = n;
					parent.InsertItem (n, index++);
					continue;
				}

				var item = new MDExpandedArrayItem {
					Info = ci,
					Target = this,
					Action = ActionSel,
				};

				if (ci is CommandInfoSet) {
					item.Submenu = new NSMenu ();
					int i = 0;
					NSMenuItem sep = null;
					PopulateArrayItems (((CommandInfoSet)ci).CommandInfos, item.Submenu, ref sep, ref i);
				}
				SetItemValues (item, ci);

				if (!item.Hidden)
					MDMenu.ShowLastSeparator (ref lastSeparator);
				parent.InsertItem (item, index++);
			}
		}
 public void Update(MDMenu parent, ref NSMenuItem lastSeparator, ref int index)
 {
     Enabled = true;
     Hidden  = Submenu != NSApplication.SharedApplication.ServicesMenu;
     if (!Hidden)
     {
         MDMenu.ShowLastSeparator(ref lastSeparator);
     }
 }
Esempio n. 6
0
		public void Update (MDMenu parent, ref NSMenuItem lastSeparator, ref int index)
		{
			if (ces.AutoHide) {
				((MDMenu)Submenu).UpdateCommands ();
				Hidden = Submenu.ItemArray ().All (item => item.Hidden);
			}
			if (!Hidden) {
				MDMenu.ShowLastSeparator (ref lastSeparator);
			}
		}
Esempio n. 7
0
 public void Update(MDMenu parent, ref NSMenuItem lastSeparator, ref int index)
 {
     if (ces.AutoHide)
     {
         ((MDMenu)Submenu).UpdateCommands();
         Hidden = Submenu.ItemArray().All(item => item.Hidden);
     }
     if (!Hidden)
     {
         MDMenu.ShowLastSeparator(ref lastSeparator);
     }
 }
Esempio n. 8
0
		public override bool ShowContextMenu (CommandManager commandManager, Gtk.Widget widget, double x, double y, CommandEntrySet entrySet, object initialCommandTarget = null)
		{
			Gtk.Application.Invoke (delegate {
				// Explicitly release the grab because the menu is shown on the mouse position, and the widget doesn't get the mouse release event
				Gdk.Pointer.Ungrab (Gtk.Global.CurrentEventTime);
				var menu = new MDMenu (commandManager, entrySet, CommandSource.ContextMenu, initialCommandTarget);
				var nsview = MacInterop.GtkQuartz.GetView (widget);
				var toplevel = widget.Toplevel as Gtk.Window;
				int trans_x, trans_y;
				widget.TranslateCoordinates (toplevel, (int)x, (int)y, out trans_x, out trans_y);

				// Window coordinates in gtk are the same for cocoa, with the exception of the Y coordinate, that has to be flipped.
				var pt = new PointF ((float)trans_x, (float)trans_y);
				int w,h;
				toplevel.GetSize (out w, out h);
				pt.Y = h - pt.Y;

				var tmp_event = NSEvent.MouseEvent (NSEventType.LeftMouseDown,
					pt,
					0, 0,
					MacInterop.GtkQuartz.GetWindow (toplevel).WindowNumber,
					null, 0, 0, 0);

				NSMenu.PopUpContextMenu (menu, tmp_event, nsview);
			});

			return true;
		}
Esempio n. 9
0
 public void Update(MDMenu parent, ref NSMenuItem lastSeparator, ref int index)
 {
     MDMenu.ShowLastSeparator(ref lastSeparator);
 }
Esempio n. 10
0
		public void Update (MDMenu parent, ref NSMenuItem lastSeparator, ref int index)
		{
			MDMenu.ShowLastSeparator (ref lastSeparator);
		}
Esempio n. 11
0
 public void Update(MDMenu parent, ref NSMenuItem lastSeparator, ref int index)
 {
     Enabled = !MDMenuItem.IsGloballyDisabled;
     MDMenu.ShowLastSeparator(ref lastSeparator);
 }
Esempio n. 12
0
		public override bool ShowContextMenu (CommandManager commandManager, Gtk.Widget widget, double x, double y, CommandEntrySet entrySet)
		{
			Gtk.Application.Invoke (delegate {
				var menu = new MDMenu (commandManager, entrySet);
				var nsview = MacInterop.GtkQuartz.GetView (widget);
				var toplevel = widget.Toplevel as Gtk.Window;
				int trans_x, trans_y;
				widget.TranslateCoordinates (toplevel, (int)x, (int)y, out trans_x, out trans_y);

				var pt = nsview.ConvertPointFromBase (new PointF ((float)trans_x, (float)trans_y));

				var tmp_event = NSEvent.MouseEvent (NSEventType.LeftMouseDown,
					pt,
					0, 0,
					MacInterop.GtkQuartz.GetWindow (toplevel).WindowNumber,
					null, 0, 0, 0);

				NSMenu.PopUpContextMenu (menu, tmp_event, nsview);
			});

			return true;
		}
Esempio n. 13
0
		public void Update (MDMenu parent, ref NSMenuItem lastSeparator, ref int index)
		{
			Enabled = !MDMenuItem.IsGloballyDisabled;
			MDMenu.ShowLastSeparator (ref lastSeparator);
		}