diff options
author | Matt Ward <ward.matt@gmail.com> | 2015-01-19 20:43:56 +0300 |
---|---|---|
committer | Matt Ward <ward.matt@gmail.com> | 2015-01-19 20:43:56 +0300 |
commit | 7e77c790429539a2c3dd8bea21e970de6943e45a (patch) | |
tree | e068d3eb591f4dd3777dac820d53c273d73f9413 /main/src/core/MonoDevelop.Ide/MonoDevelop.Components | |
parent | 03e767784748e1519f5d5eb19338ac58d8793064 (diff) | |
parent | c4f51d4c09fe4b22504335d6e317a9f5ebbaa9e6 (diff) |
Merge remote-tracking branch 'monodevelop/master' into new-project-dialog
Conflicts:
main/src/core/MonoDevelop.Ide/gtk-gui/gui.stetic
version-checks
Diffstat (limited to 'main/src/core/MonoDevelop.Ide/MonoDevelop.Components')
9 files changed, 702 insertions, 0 deletions
diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Components/CheckBoxContextMenuItem.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Components/CheckBoxContextMenuItem.cs new file mode 100644 index 0000000000..a06164ef29 --- /dev/null +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Components/CheckBoxContextMenuItem.cs @@ -0,0 +1,50 @@ +// +// CheckBoxContextMenuItem.cs +// +// Author: +// Greg Munn <greg.munn@xamarin.com> +// +// Copyright (c) 2015 Xamarin Inc +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +using System; + +namespace MonoDevelop.Components +{ + public class CheckBoxContextMenuItem: ContextMenuItem + { + public CheckBoxContextMenuItem () + { + } + + public CheckBoxContextMenuItem (string label) + { + Label = label; + } + + public bool Checked { get; set; } + + protected override void DoClick () + { + this.Checked = !this.Checked; + base.DoClick (); + } + } +}
\ No newline at end of file diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Components/ContextMenu.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Components/ContextMenu.cs new file mode 100644 index 0000000000..1067df0aa6 --- /dev/null +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Components/ContextMenu.cs @@ -0,0 +1,75 @@ +// +// ContextMenu.cs +// +// Author: +// Greg Munn <greg.munn@xamarin.com> +// +// Copyright (c) 2015 Xamarin Inc +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. +using System; +using MonoDevelop.Core; + +namespace MonoDevelop.Components +{ + public class ContextMenu + { + readonly ContextMenuItemCollection items; + + public ContextMenu () + { + items = new ContextMenuItemCollection (this); + } + + public ContextMenuItemCollection Items { + get { return items; } + } + + /// <summary> + /// Removes all separators of the menu which follow another separator + /// </summary> + public void CollapseSeparators () + { + bool wasSeparator = true; + for (int n=0; n<Items.Count; n++) { + if (Items[n] is SeparatorContextMenuItem) { + if (wasSeparator) + Items.RemoveAt (n--); + else + wasSeparator = true; + } else + wasSeparator = false; + } + if (Items.Count > 0 && Items[Items.Count - 1] is SeparatorContextMenuItem) + Items.RemoveAt (Items.Count - 1); + } + + public void Show (Gtk.Widget parent, Gdk.EventButton evt) + { + #if MAC + if (Platform.IsMac) { + ContextMenuExtensionsMac.ShowContextMenu (parent, evt, this); + return; + } + #endif + + ContextMenuExtensionsGtk.ShowContextMenu (parent, evt, this); + } + } +}
\ No newline at end of file diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Components/ContextMenuExtensionsGtk.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Components/ContextMenuExtensionsGtk.cs new file mode 100644 index 0000000000..52607bf131 --- /dev/null +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Components/ContextMenuExtensionsGtk.cs @@ -0,0 +1,116 @@ +// +// ContextMenuExtensionsGtk.cs +// +// Author: +// Greg Munn <greg.munn@xamarin.com> +// +// Copyright (c) 2015 Xamarin Inc +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +using System; +using Xwt.GtkBackend; + +namespace MonoDevelop.Components +{ + static class ContextMenuExtensionsGtk + { + public static void ShowContextMenu (Gtk.Widget parent, Gdk.EventButton evt, ContextMenu menu) + { + if (parent == null) + throw new ArgumentNullException ("parent"); + if (menu == null) + throw new ArgumentNullException ("menu"); + + var gtkMenu = FromMenu (menu); + gtkMenu.ShowAll (); + ShowContextMenu (parent, evt, gtkMenu); + } + + public static void ShowContextMenu (Gtk.Widget parent, Gdk.EventButton evt, Gtk.Menu menu) + { + if (parent == null) + throw new ArgumentNullException ("parent"); + if (menu == null) + throw new ArgumentNullException ("menu"); + + Mono.TextEditor.GtkWorkarounds.ShowContextMenu (menu, parent, evt); + } + + static Gtk.MenuItem CreateMenuItem (ContextMenuItem item) + { + if (!item.Visible) + return null; + + if (item.IsSeparator) { + return new Gtk.SeparatorMenuItem (); + } + + Gtk.MenuItem menuItem; + if (item is RadioButtonContextMenuItem) { + var radioItem = (RadioButtonContextMenuItem)item; + menuItem = new Gtk.CheckMenuItem (item.Label) { Active = radioItem.Checked, DrawAsRadio = true }; + } else if (item is CheckBoxContextMenuItem) { + var checkItem = (CheckBoxContextMenuItem)item; + menuItem = new Gtk.CheckMenuItem (item.Label) { Active = checkItem.Checked }; + } else { + menuItem = new Gtk.ImageMenuItem (item.Label); + } + + if (item.SubMenu != null && item.SubMenu.Items.Count > 0) { + menuItem.Submenu = FromMenu (item.SubMenu); + } + else { + menuItem.Activated += (sender, e) => item.Click (); + } + + menuItem.Sensitive = item.Sensitive; + + var label = (Gtk.Label) menuItem.Child; + label.UseUnderline = item.UseMnemonic; + if (item.UseMnemonic) + label.TextWithMnemonic = item.Label; + + if (item.Image != null) { + Gtk.ImageMenuItem imageItem = menuItem as Gtk.ImageMenuItem; + if (imageItem != null) { + var img = new ImageView (item.Image); + img.ShowAll (); + imageItem.Image = img; + GtkWorkarounds.ForceImageOnMenuItem (imageItem); + } + } + + return menuItem; + } + + static Gtk.Menu FromMenu (ContextMenu menu) + { + var result = new Gtk.Menu (); + + foreach (var menuItem in menu.Items) { + var item = CreateMenuItem (menuItem); + if (item != null) + result.Append (item); + } + + return result; + } + } +}
\ No newline at end of file diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Components/ContextMenuExtensionsMac.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Components/ContextMenuExtensionsMac.cs new file mode 100644 index 0000000000..c59ee5602e --- /dev/null +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Components/ContextMenuExtensionsMac.cs @@ -0,0 +1,142 @@ +// +// ContextMenuExtensionsMac.cs +// +// Author: +// Greg Munn <greg.munn@xamarin.com> +// +// Copyright (c) 2015 Xamarin Inc +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +using System; +#if MAC +using AppKit; +#endif + +namespace MonoDevelop.Components +{ + #if MAC + static class ContextMenuExtensionsMac + { + public static void ShowContextMenu (Gtk.Widget parent, Gdk.EventButton evt, ContextMenu menu) + { + if (parent == null) + throw new ArgumentNullException ("parent"); + if (menu == null) + throw new ArgumentNullException ("menu"); + + var nsMenu = FromMenu (menu); + ShowContextMenu (parent, evt, nsMenu); + } + + public static void ShowContextMenu (Gtk.Widget parent, Gdk.EventButton evt, NSMenu menu) + { + if (parent == null) + throw new ArgumentNullException ("parent"); + if (menu == null) + throw new ArgumentNullException ("menu"); + + parent.GrabFocus (); + int x, y; + if (evt != null) { + x = (int)evt.X; + y = (int)evt.Y; + } else { + Gdk.ModifierType mod; + parent.GdkWindow.GetPointer (out x, out y, out mod); + + var titleBarHeight = MonoDevelop.Components.Mac.GtkMacInterop.GetTitleBarHeight (); + y -= titleBarHeight; + } + + 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 nsview = MonoDevelop.Components.Mac.GtkMacInterop.GetNSView (parent); + var toplevel = parent.Toplevel as Gtk.Window; + int trans_x, trans_y; + parent.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 CoreGraphics.CGPoint ((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, + MonoDevelop.Components.Mac.GtkMacInterop.GetNSWindow (toplevel).WindowNumber, + null, 0, 0, 0); + + NSMenu.PopUpContextMenu (menu, tmp_event, nsview); + }); + } + + static NSMenuItem CreateMenuItem (ContextMenuItem item) + { + if (item.IsSeparator) { + return NSMenuItem.SeparatorItem; + } + + var menuItem = new NSMenuItem (item.Label, (s, e) => item.Click ()); + + menuItem.Hidden = !item.Visible; + menuItem.Enabled = item.Sensitive; + menuItem.Image = item.Image.ToNSImage (); + + if (item is RadioButtonContextMenuItem) { + var radioItem = (RadioButtonContextMenuItem)item; + menuItem.State = radioItem.Checked ? NSCellStateValue.On : NSCellStateValue.Off; + } else if (item is CheckBoxContextMenuItem) { + var checkItem = (CheckBoxContextMenuItem)item; + menuItem.State = checkItem.Checked ? NSCellStateValue.On : NSCellStateValue.Off; + } + + if (item.SubMenu != null && item.SubMenu.Items.Count > 0) { + menuItem.Submenu = FromMenu (item.SubMenu); + } + else { + menuItem.Activated += (sender, e) => item.Click (); + } + + return menuItem; + } + + static NSMenu FromMenu (ContextMenu menu) + { + var result = new NSMenu () { AutoEnablesItems = false }; + + foreach (var menuItem in menu.Items) { + var item = CreateMenuItem (menuItem); + result.AddItem (item); + } + + return result; + } + + static readonly Xwt.Toolkit macToolkit = Xwt.Toolkit.Load (Xwt.ToolkitType.Cocoa); + + public static NSImage ToNSImage (this Xwt.Drawing.Image image) + { + return (NSImage)macToolkit.GetNativeImage (image); + } + } + #endif +}
\ No newline at end of file diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Components/ContextMenuItem.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Components/ContextMenuItem.cs new file mode 100644 index 0000000000..2bb5db5533 --- /dev/null +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Components/ContextMenuItem.cs @@ -0,0 +1,116 @@ +// +// ContextMenuItem.cs +// +// Author: +// Greg Munn <greg.munn@xamarin.com> +// +// Copyright (c) 2015 Xamarin Inc +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +using System; + +namespace MonoDevelop.Components +{ + public class ContextMenuItem + { + ContextMenu subMenu; + Xwt.Drawing.Image image; + + public ContextMenuItem () + { + this.Visible = true; + this.Sensitive = true; + + if (!IsSeparator) + UseMnemonic = true; + } + + public ContextMenuItem (string label) : this() + { + Label = label; + } + + public bool IsSeparator { + get { return this is SeparatorContextMenuItem; } + } + + public string Label { get; set; } + + /// <summary> + /// Gets or sets a value indicating whether this <see cref="MonoDevelop.Components.ContextMenuItem"/> uses a mnemonic. + /// </summary> + /// <value><c>true</c> if it uses a mnemonic; otherwise, <c>false</c>.</value> + /// <remarks> + /// When set to true, the character after the first underscore character in the Label property value is + /// interpreted as the mnemonic for that Label. + /// </remarks> + public bool UseMnemonic { get; set; } + + public bool Sensitive { get; set; } + + public bool Visible { get; set; } + + public Xwt.Drawing.Image Image { + get { return image; } + set { + if (IsSeparator) + throw new NotSupportedException (); + image = value; + } + } + + public ContextMenu SubMenu { + get { return subMenu; } + set { + if (IsSeparator) + throw new NotSupportedException (); + subMenu = value; + } + } + + public event EventHandler Clicked; + + public void Show () + { + Visible = true; + } + + public void Hide () + { + Visible = false; + } + + internal void Click () + { + DoClick (); + } + + protected virtual void DoClick () + { + OnClicked (EventArgs.Empty); + } + + protected virtual void OnClicked (EventArgs e) + { + if (Clicked != null) + Clicked (this, e); + } + } +}
\ No newline at end of file diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Components/ContextMenuItemCollection.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Components/ContextMenuItemCollection.cs new file mode 100644 index 0000000000..9e3b472014 --- /dev/null +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Components/ContextMenuItemCollection.cs @@ -0,0 +1,41 @@ +// +// ContextMenuItemCollection.cs +// +// Author: +// Greg Munn <greg.munn@xamarin.com> +// +// Copyright (c) 2015 Xamarin Inc +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +using System; +using System.Collections.ObjectModel; + +namespace MonoDevelop.Components +{ + public class ContextMenuItemCollection: Collection<ContextMenuItem> + { + readonly ContextMenu parent; + + internal ContextMenuItemCollection (ContextMenu parent) + { + this.parent = parent; + } + } +}
\ No newline at end of file diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Components/RadioButtonContextMenuItem.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Components/RadioButtonContextMenuItem.cs new file mode 100644 index 0000000000..e052d4ac9b --- /dev/null +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Components/RadioButtonContextMenuItem.cs @@ -0,0 +1,89 @@ +// +// RadioButtonContextMenuItem.cs +// +// Author: +// Greg Munn <greg.munn@xamarin.com> +// +// Copyright (c) 2015 Xamarin Inc +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +using System; +using System.Linq; + +namespace MonoDevelop.Components +{ + public class RadioButtonContextMenuItem: ContextMenuItem + { + bool isChecked; + RadioButtonContextMenuItemGroup radioGroup; + + public RadioButtonContextMenuItem () + { + } + + public RadioButtonContextMenuItem (string label) + { + Label = label; + } + + public bool Checked { + get { + return isChecked; + } + + set { + if (value) + ValidateCheckedValue (); + isChecked = value; + } + } + + public RadioButtonContextMenuItemGroup Group { + get { return radioGroup; } + set { + if (radioGroup != null) + radioGroup.Items.Remove (this); + radioGroup = value; + if (radioGroup != null) { + radioGroup.Items.Add (this); + if (Checked) + ValidateCheckedValue (); + } + } + } + + protected override void DoClick () + { + ValidateCheckedValue (); + isChecked = true; + base.DoClick (); + } + + void ValidateCheckedValue () + { + if (radioGroup != null) { + foreach (var rb in radioGroup.Items.OfType<RadioButtonContextMenuItem> ()) { + if (rb != this && rb.Checked) + rb.Checked = false; + } + } + } + } +}
\ No newline at end of file diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Components/RadioButtonContextMenuItemGroup.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Components/RadioButtonContextMenuItemGroup.cs new file mode 100644 index 0000000000..1906b50f14 --- /dev/null +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Components/RadioButtonContextMenuItemGroup.cs @@ -0,0 +1,36 @@ +// +// RadioButtonContextMenuItemGroup.cs +// +// Author: +// Greg Munn <greg.munn@xamarin.com> +// +// Copyright (c) 2015 Xamarin Inc +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +using System; +using System.Collections.Generic; + +namespace MonoDevelop.Components +{ + public class RadioButtonContextMenuItemGroup + { + internal List<object> Items = new List<object> (); + } +}
\ No newline at end of file diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Components/SeparatorContextMenuItem.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Components/SeparatorContextMenuItem.cs new file mode 100644 index 0000000000..f075128246 --- /dev/null +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Components/SeparatorContextMenuItem.cs @@ -0,0 +1,37 @@ +// +// SeparatorContextMenuItem.cs +// +// Author: +// Greg Munn <greg.munn@xamarin.com> +// +// Copyright (c) 2015 Xamarin Inc +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +using System; + +namespace MonoDevelop.Components +{ + public class SeparatorContextMenuItem: ContextMenuItem + { + public SeparatorContextMenuItem () + { + } + } +}
\ No newline at end of file |