Ejemplo n.º 1
0
        void PopupQuickFixMenu(Gdk.EventButton evt, Action <Gtk.Menu> menuAction)
        {
            var menu = new Gtk.Menu();

            menu.Events |= Gdk.EventMask.AllEventsMask;
            Gtk.Menu      fixMenu = menu;
            ResolveResult resolveResult;

            ICSharpCode.NRefactory.CSharp.AstNode node;
            int items = 0;

            if (ResolveCommandHandler.ResolveAt(document, out resolveResult, out node))
            {
                var possibleNamespaces = MonoDevelop.Refactoring.ResolveCommandHandler.GetPossibleNamespaces(
                    document,
                    node,
                    ref resolveResult
                    );

                bool addUsing = !(resolveResult is AmbiguousTypeResolveResult);
                if (addUsing)
                {
                    foreach (var t in possibleNamespaces.Where(tp => tp.IsAccessibleWithGlobalUsing))
                    {
                        string ns        = t.Namespace;
                        var    reference = t.Reference;
                        var    menuItem  = new Gtk.MenuItem(string.Format("using {0};", ns));
                        menuItem.Activated += delegate {
                            new ResolveCommandHandler.AddImport(document, resolveResult, ns, reference, true, node).Run();
                            if (reference != null)
                            {
                                document.Project.Items.Add(reference);
                            }
                            menu.Destroy();
                        };
                        menu.Add(menuItem);
                        items++;
                    }
                }

                bool resolveDirect = !(resolveResult is UnknownMemberResolveResult);
                if (resolveDirect)
                {
                    foreach (var t in possibleNamespaces)
                    {
                        string ns        = t.Namespace;
                        var    reference = t.Reference;
                        var    menuItem  = new Gtk.MenuItem(GettextCatalog.GetString("{0}", ns + "." + document.Editor.GetTextBetween(node.StartLocation, node.EndLocation)));
                        menuItem.Activated += delegate {
                            new ResolveCommandHandler.AddImport(document, resolveResult, ns, reference, false, node).Run();
                            menu.Destroy();
                        };
                        menu.Add(menuItem);
                        items++;
                    }
                }
                if (menu.Children.Any() && fixes.Any())
                {
                    fixMenu = new Gtk.Menu();
                    var menuItem = new Gtk.MenuItem(GettextCatalog.GetString("Quick Fixes"));
                    menuItem.Submenu = fixMenu;
                    menu.Add(menuItem);
                    items++;
                }
            }

            PopulateFixes(fixMenu, ref items);
            if (items == 0)
            {
                menu.Destroy();
                return;
            }
            document.Editor.SuppressTooltips = true;
            document.Editor.Parent.HideTooltip();
            if (menuAction != null)
            {
                menuAction(menu);
            }
            menu.ShowAll();
            menu.SelectFirst(true);
            menuPushed   = true;
            menu.Hidden += delegate {
                document.Editor.SuppressTooltips = false;
            };
            menu.Destroyed += delegate {
                menuPushed = false;
                Hide();
            };
            var container = document.Editor.Parent;
            var child     = (TextEditor.EditorContainerChild)container [this];

            Gdk.Rectangle rect;

/*			if (child != null) {
 *                              rect = new Gdk.Rectangle (child.X, child.Y + Allocation.Height - (int)document.Editor.VAdjustment.Value, 0, 0);
 *                      } else {*/
            var p = container.LocationToPoint(loc);

            rect = new Gdk.Rectangle(p.X + container.Allocation.X, p.Y + (int)document.Editor.LineHeight + container.Allocation.Y, 0, 0);
            //}
            GtkWorkarounds.ShowContextMenu(menu, document.Editor.Parent, null, rect);
        }
Ejemplo n.º 2
0
 protected override bool OnButtonPressEvent(Gdk.EventButton press)
 {
     return(false);
 }
 void ShowPopup(Gdk.EventButton evt)
 {
     IdeApp.CommandService.ShowContextMenu(tree, evt, menuSet, tree);
 }
Ejemplo n.º 4
0
 protected override bool OnButtonReleaseEvent(Gdk.EventButton e)
 {
     return(base.OnButtonReleaseEvent(e));
 }
Ejemplo n.º 5
0
        protected override bool OnTextEvent(GLib.Object sender,
                                            Gdk.Event ev,
                                            Gtk.TextIter iter)
        {
            NoteEditor editor = (NoteEditor)sender;

            Gtk.TextIter start, end;

            if (!CanActivate)
            {
                return(false);
            }

            switch (ev.Type)
            {
            case Gdk.EventType.ButtonPress:
                Gdk.EventButton button_ev = new Gdk.EventButton(ev.Handle);

                // Do not insert selected text when activating links with
                // middle mouse button
                if (button_ev.Button == 2)
                {
                    allow_middle_activate = true;
                    return(true);
                }

                return(false);

            case Gdk.EventType.ButtonRelease:
                button_ev = new Gdk.EventButton(ev.Handle);

                if (button_ev.Button != 1 && button_ev.Button != 2)
                {
                    return(false);
                }

                /* Don't activate if Shift or Control is pressed */
                if ((int)(button_ev.State & (Gdk.ModifierType.ShiftMask |
                                             Gdk.ModifierType.ControlMask)) != 0)
                {
                    return(false);
                }

                // Prevent activation when selecting links with the mouse
                if (editor.Buffer.HasSelection)
                {
                    return(false);
                }

                // Don't activate if the link has just been pasted with the
                // middle mouse button (no preceding ButtonPress event)
                if (button_ev.Button == 2 && !allow_middle_activate)
                {
                    return(false);
                }
                else
                {
                    allow_middle_activate = false;
                }

                GetExtents(iter, out start, out end);
                bool success = OnActivate(editor, start, end);

                // Hide note if link is activated with middle mouse button
                if (success && button_ev.Button == 2)
                {
                    Gtk.Widget widget = (Gtk.Widget)sender;
                    widget.Toplevel.Hide();
                }

                return(false);

            case Gdk.EventType.KeyPress:
                Gdk.EventKey key_ev = new Gdk.EventKey(ev.Handle);

                // Control-Enter activates the link at point...
                if ((int)(key_ev.State & Gdk.ModifierType.ControlMask) == 0)
                {
                    return(false);
                }

                if (key_ev.Key != Gdk.Key.Return &&
                    key_ev.Key != Gdk.Key.KP_Enter)
                {
                    return(false);
                }

                GetExtents(iter, out start, out end);
                return(OnActivate(editor, start, end));
            }

            return(false);
        }
Ejemplo n.º 6
0
        void ShowPopup(Gdk.EventButton evt)
        {
            var context_menu = new ContextMenu();

            context_menu.Items.Add(new SeparatorContextMenuItem());
            var selectAllItem = new ContextMenuItem(GettextCatalog.GetString("Select All"));

            selectAllItem.Clicked += delegate {
                OnSelectAll();
            };
            context_menu.Items.Add(selectAllItem);
            var copyItem = new ContextMenuItem(GettextCatalog.GetString("Copy"));

            copyItem.Clicked += delegate {
                OnCopy();
            };
            context_menu.Items.Add(copyItem);
            context_menu.Items.Add(new SeparatorContextMenuItem());
            var showExternalCodeCheckbox = new CheckBoxContextMenuItem(GettextCatalog.GetString("Show External Code"));

            showExternalCodeCheckbox.Clicked += delegate {
                showExternalCodeCheckbox.Checked = ShowExternalCode = !ShowExternalCode;
                StoreSettings();
                UpdateDisplay();
            };
            showExternalCodeCheckbox.Checked = ShowExternalCode;
            context_menu.Items.Add(showExternalCodeCheckbox);

            context_menu.Items.Add(new SeparatorContextMenuItem());

            var assemblyCheckbox = new CheckBoxContextMenuItem(GettextCatalog.GetString("Show Module Name"));

            assemblyCheckbox.Clicked += delegate {
                assemblyCheckbox.Checked = ShowModuleName = !ShowModuleName;
                StoreSettings();
                UpdateDisplay();
            };
            assemblyCheckbox.Checked = ShowModuleName;
            context_menu.Items.Add(assemblyCheckbox);
            var typeCheckbox = new CheckBoxContextMenuItem(GettextCatalog.GetString("Show Parameter Type"));

            typeCheckbox.Clicked += delegate {
                typeCheckbox.Checked = ShowParameterType = !ShowParameterType;
                StoreSettings();
                UpdateDisplay();
            };
            typeCheckbox.Checked = ShowParameterType;
            context_menu.Items.Add(typeCheckbox);
            var nameCheckbox = new CheckBoxContextMenuItem(GettextCatalog.GetString("Show Parameter Name"));

            nameCheckbox.Clicked += delegate {
                nameCheckbox.Checked = ShowParameterName = !ShowParameterName;
                StoreSettings();
                UpdateDisplay();
            };
            nameCheckbox.Checked = ShowParameterName;
            context_menu.Items.Add(nameCheckbox);
            var valueCheckbox = new CheckBoxContextMenuItem(GettextCatalog.GetString("Show Parameter Value"));

            valueCheckbox.Clicked += delegate {
                valueCheckbox.Checked = ShowParameterValue = !ShowParameterValue;
                StoreSettings();
                UpdateDisplay();
            };
            valueCheckbox.Checked = ShowParameterValue;
            context_menu.Items.Add(valueCheckbox);
            var lineCheckbox = new CheckBoxContextMenuItem(GettextCatalog.GetString("Show Line Number"));

            lineCheckbox.Clicked += delegate {
                lineCheckbox.Checked = ShowLineNumber = !ShowLineNumber;
                StoreSettings();
                UpdateDisplay();
            };
            lineCheckbox.Checked = ShowLineNumber;
            context_menu.Items.Add(lineCheckbox);

            context_menu.Items.Add(new SeparatorContextMenuItem());

            var columnsVisibilitySubMenu     = new ContextMenu();
            var nameColumnVisibilityCheckbox = new CheckBoxContextMenuItem(GettextCatalog.GetString("Name"));

            nameColumnVisibilityCheckbox.Clicked += delegate {
                nameColumnVisibilityCheckbox.Checked = tree.Columns [MethodColumn].Visible = !tree.Columns [MethodColumn].Visible;
                StoreColumnsVisibility();
            };
            nameColumnVisibilityCheckbox.Checked = tree.Columns [MethodColumn].Visible;
            columnsVisibilitySubMenu.Items.Add(nameColumnVisibilityCheckbox);
            var fileColumnVisibilityCheckbox = new CheckBoxContextMenuItem(GettextCatalog.GetString("File"));

            fileColumnVisibilityCheckbox.Clicked += delegate {
                fileColumnVisibilityCheckbox.Checked = tree.Columns [FileColumn].Visible = !tree.Columns [FileColumn].Visible;
                StoreColumnsVisibility();
            };
            fileColumnVisibilityCheckbox.Checked = tree.Columns [FileColumn].Visible;
            columnsVisibilitySubMenu.Items.Add(fileColumnVisibilityCheckbox);
            var languageColumnVisibilityCheckbox = new CheckBoxContextMenuItem(GettextCatalog.GetString("Language"));

            languageColumnVisibilityCheckbox.Clicked += delegate {
                languageColumnVisibilityCheckbox.Checked = tree.Columns [LangColumn].Visible = !tree.Columns [LangColumn].Visible;
                StoreColumnsVisibility();
            };
            languageColumnVisibilityCheckbox.Checked = tree.Columns [LangColumn].Visible;
            columnsVisibilitySubMenu.Items.Add(languageColumnVisibilityCheckbox);
            var addressColumnVisibilityCheckbox = new CheckBoxContextMenuItem(GettextCatalog.GetString("Address"));

            addressColumnVisibilityCheckbox.Clicked += delegate {
                addressColumnVisibilityCheckbox.Checked = tree.Columns [AddrColumn].Visible = !tree.Columns [AddrColumn].Visible;
                StoreColumnsVisibility();
            };
            addressColumnVisibilityCheckbox.Checked = tree.Columns [AddrColumn].Visible;
            columnsVisibilitySubMenu.Items.Add(addressColumnVisibilityCheckbox);
            context_menu.Items.Add(new ContextMenuItem(GettextCatalog.GetString("Columns"))
            {
                SubMenu = columnsVisibilitySubMenu
            });


            context_menu.Show(this, evt);
        }
Ejemplo n.º 7
0
        bool OnListButtonPressEvent(Gdk.EventButton evnt)
        {
            if (Model == null)
            {
                return(true);
            }

            int x = (int)evnt.X - list_interaction_alloc.X;
            int y = (int)evnt.Y - list_interaction_alloc.Y;

            GrabFocus();

            int row_index = GetModelRowAt(x, y);

            if (row_index < 0 || row_index >= Model.Count)
            {
                Gtk.Drag.SourceUnset(this);
                return(true);
            }

            if (LayoutChildHandlesEvent(evnt, true))
            {
                return(true);
            }

            ProxyEventToCell(evnt, true);

            object item = model[row_index];

            if (item == null)
            {
                return(true);
            }

            if (evnt.Button == 1 && evnt.Type == Gdk.EventType.TwoButtonPress)
            {
                // Double clicked
                OnRowActivated();
            }
            else if (Selection != null)
            {
                if ((evnt.State & Gdk.ModifierType.ControlMask) != 0)
                {
                    if (evnt.Button == 3)
                    {
                        // Right clicked with ctrl pressed, so make sure row selected
                        if (!Selection.Contains(row_index))
                        {
                            Selection.Select(row_index);
                        }
                    }
                    else
                    {
                        // Normal ctrl-click, so toggle
                        Selection.ToggleSelect(row_index);
                    }
                }
                else if ((evnt.State & Gdk.ModifierType.ShiftMask) != 0)
                {
                    // Shift-click, so select from first-row-selected (if any) to the current row
                    Selection.SelectFromFirst(row_index, true);
                }
                else
                {
                    if (evnt.Button == 3)
                    {
                        // Normal right-click, make sure row is only row selected
                        if (!Selection.Contains(row_index))
                        {
                            Selection.Clear(false);
                            Selection.Select(row_index);
                        }
                    }
                    else
                    {
                        // Normal click, if row not already selected, select only it right now,
                        // but if it's already selected, wait until the Release to unselect any others so that
                        // drag and drop of 2+ items works.
                        if (!Selection.Contains(row_index))
                        {
                            Selection.Clear(false);
                            Selection.Select(row_index);
                        }
                    }
                }

                FocusModelRow(row_index);

                // Now that we've worked out the selections, open the context menu
                if (evnt.Button == 3)
                {
                    OnPopupMenu();
                }
            }

            InvalidateList();
            return(true);
        }
Ejemplo n.º 8
0
 protected override bool OnButtonPressEvent(Gdk.EventButton evnt)
 {
     SwitchToEditMode();
     return(false);
 }
        void PopupQuickFixMenu(Gdk.EventButton evt, Action <Gtk.Menu> menuAction)
        {
            var menu = new Gtk.Menu();

            menu.Events |= Gdk.EventMask.AllEventsMask;
            Gtk.Menu      fixMenu = menu;
            ResolveResult resolveResult;

            ICSharpCode.NRefactory.CSharp.AstNode node;
            int items = 0;

            if (ResolveCommandHandler.ResolveAt(document, out resolveResult, out node))
            {
                var possibleNamespaces = MonoDevelop.Refactoring.ResolveCommandHandler.GetPossibleNamespaces(
                    document,
                    node,
                    ref resolveResult
                    );

                foreach (var t in possibleNamespaces.Where(tp => tp.OnlyAddReference))
                {
                    var menuItem = new Gtk.MenuItem(t.GetImportText());
                    menuItem.Activated += delegate {
                        new ResolveCommandHandler.AddImport(document, resolveResult, null, t.Reference, true, node).Run();
                        menu.Destroy();
                    };
                    menu.Add(menuItem);
                    items++;
                }

                bool addUsing = !(resolveResult is AmbiguousTypeResolveResult);
                if (addUsing)
                {
                    foreach (var t in possibleNamespaces.Where(tp => tp.IsAccessibleWithGlobalUsing))
                    {
                        string ns        = t.Namespace;
                        var    reference = t.Reference;
                        var    menuItem  = new Gtk.MenuItem(t.GetImportText());
                        menuItem.Activated += delegate {
                            new ResolveCommandHandler.AddImport(document, resolveResult, ns, reference, true, node).Run();
                            menu.Destroy();
                        };
                        menu.Add(menuItem);
                        items++;
                    }
                }

                bool resolveDirect = !(resolveResult is UnknownMemberResolveResult);
                if (resolveDirect)
                {
                    foreach (var t in possibleNamespaces)
                    {
                        string ns        = t.Namespace;
                        var    reference = t.Reference;
                        var    menuItem  = new Gtk.MenuItem(t.GetInsertNamespaceText(document.Editor.GetTextBetween(node.StartLocation, node.EndLocation)));
                        menuItem.Activated += delegate {
                            new ResolveCommandHandler.AddImport(document, resolveResult, ns, reference, false, node).Run();
                            menu.Destroy();
                        };
                        menu.Add(menuItem);
                        items++;
                    }
                }

                if (menu.Children.Any() && Fixes.Any())
                {
                    fixMenu = new Gtk.Menu();
                    var menuItem = new Gtk.MenuItem(GettextCatalog.GetString("Quick Fixes"));
                    menuItem.Submenu = fixMenu;
                    menu.Add(menuItem);
                    items++;
                }
            }

            PopulateFixes(fixMenu, ref items);
            if (items == 0)
            {
                menu.Destroy();
                return;
            }
            document.Editor.SuppressTooltips = true;
            document.Editor.Parent.HideTooltip();
            if (menuAction != null)
            {
                menuAction(menu);
            }
            menu.ShowAll();
            menu.SelectFirst(true);
            menu.Hidden += delegate {
                document.Editor.SuppressTooltips = false;
            };
            var container = document.Editor.Parent;

            var p    = container.LocationToPoint(currentSmartTagBegin);
            var rect = new Gdk.Rectangle(
                p.X + container.Allocation.X,
                p.Y + (int)document.Editor.LineHeight + container.Allocation.Y, 0, 0);

            GtkWorkarounds.ShowContextMenu(menu, document.Editor.Parent, null, rect);
        }
Ejemplo n.º 10
0
        protected override bool OnButtonPressEvent(Gdk.EventButton press)
        {
            TreePath       path;
            TreeViewColumn column;

            if (press.Button == 1)
            {
                ResetHighlight();
            }

            // If there is not a row at the click position let the base handler take care of the press
            if (!GetPathAtPos((int)press.X, (int)press.Y, out path, out column))
            {
                return(base.OnButtonPressEvent(press));
            }

            Source source = store.GetSource(path);

            // From F-Spot's SaneTreeView class
            int  expander_size        = (int)StyleGetProperty("expander-size");
            int  horizontal_separator = (int)StyleGetProperty("horizontal-separator");
            bool on_expander          = press.X <= horizontal_separator * 2 + path.Depth * expander_size;

            if (on_expander)
            {
                bool ret = base.OnButtonPressEvent(press);
                // If the active source is a child of this source, and we are about to collapse it, switch
                // the active source to the parent.
                if (source == ServiceManager.SourceManager.ActiveSource.Parent && GetRowExpanded(path))
                {
                    ServiceManager.SourceManager.SetActiveSource(source);
                }
                return(ret);
            }

            // For Sources that can't be activated, when they're clicked just
            // expand or collapse them and return.
            if (press.Button == 1 && !source.CanActivate)
            {
                if (!source.Expanded)
                {
                    ExpandRow(path, false);
                }
                else
                {
                    CollapseRow(path);
                }
                return(false);
            }

            if (press.Button == 3)
            {
                HighlightPath(path);
                OnPopupMenu();
                return(true);
            }

            if (!source.CanActivate)
            {
                return(false);
            }


            if (press.Button == 1)
            {
                if (ServiceManager.SourceManager.ActiveSource != source)
                {
                    ServiceManager.SourceManager.SetActiveSource(source);
                }
            }

            if ((press.State & Gdk.ModifierType.ControlMask) != 0)
            {
                if (press.Type == Gdk.EventType.TwoButtonPress && press.Button == 1)
                {
                    ActivateRow(path, null);
                }
                return(true);
            }

            return(base.OnButtonPressEvent(press));
        }
        void PopupQuickFixMenu(Gdk.EventButton evt, Action <FixMenuDescriptor> menuAction)
        {
            FixMenuDescriptor menu = new FixMenuDescriptor();
            var           fixMenu  = menu;
            ResolveResult resolveResult;

            ICSharpCode.NRefactory.CSharp.AstNode node;
            int items = 0;

            if (ResolveCommandHandler.ResolveAt(document, out resolveResult, out node))
            {
                var possibleNamespaces = MonoDevelop.Refactoring.ResolveCommandHandler.GetPossibleNamespaces(
                    document,
                    node,
                    ref resolveResult
                    );

                foreach (var t in possibleNamespaces.Where(tp => tp.OnlyAddReference))
                {
                    menu.Add(new FixMenuEntry(t.GetImportText(), delegate {
                        new ResolveCommandHandler.AddImport(document, resolveResult, null, t.Reference, true, node).Run();
                    }));
                    items++;
                }

                bool addUsing = !(resolveResult is AmbiguousTypeResolveResult);
                if (addUsing)
                {
                    foreach (var t in possibleNamespaces.Where(tp => tp.IsAccessibleWithGlobalUsing))
                    {
                        string ns        = t.Namespace;
                        var    reference = t.Reference;
                        menu.Add(new FixMenuEntry(t.GetImportText(),
                                                  delegate {
                            new ResolveCommandHandler.AddImport(document, resolveResult, ns, reference, true, node).Run();
                        })
                                 );
                        items++;
                    }
                }

                bool resolveDirect = !(resolveResult is UnknownMemberResolveResult);
                if (resolveDirect)
                {
                    foreach (var t in possibleNamespaces)
                    {
                        string ns        = t.Namespace;
                        var    reference = t.Reference;
                        menu.Add(new FixMenuEntry(t.GetInsertNamespaceText(document.Editor.GetTextBetween(node.StartLocation, node.EndLocation)),
                                                  delegate {
                            new ResolveCommandHandler.AddImport(document, resolveResult, ns, reference, false, node).Run();
                        }));
                        items++;
                    }
                }

                if (menu.Items.Any() && Fixes.Any())
                {
                    fixMenu = new FixMenuDescriptor(GettextCatalog.GetString("Quick Fixes"));
                    menu.Add(fixMenu);
                    items++;
                }
            }
            PopulateFixes(fixMenu, ref items);
            if (items == 0)
            {
                return;
            }
            document.Editor.SuppressTooltips = true;
            document.Editor.Parent.HideTooltip();
            if (menuAction != null)
            {
                menuAction(menu);
            }
            var container = document.Editor.Parent;

            var p    = container.LocationToPoint(currentSmartTagBegin);
            var rect = new Gdk.Rectangle(
                p.X + container.Allocation.X,
                p.Y + (int)document.Editor.LineHeight + container.Allocation.Y, 0, 0);

            ShowFixesMenu(document.Editor.Parent, rect, menu);
        }
Ejemplo n.º 12
0
 public void ShowPopup(Gtk.Widget widget, Gdk.EventButton evt, PopupPosition position)
 {
     ShowPopup(widget, evt, Gdk.Rectangle.Zero, position);
 }
Ejemplo n.º 13
0
 public void Show(Gtk.Widget parent, Gdk.EventButton evt)
 {
     Show(parent, evt, null);
 }
Ejemplo n.º 14
0
		protected override bool OnTextEvent (GLib.Object  sender,
		                                     Gdk.Event    ev,
		                                     Gtk.TextIter iter)
		{
			NoteEditor editor = (NoteEditor) sender;
			Gtk.TextIter start, end;

			if (!CanActivate)
				return false;

			switch (ev.Type) {
			case Gdk.EventType.ButtonPress:
				Gdk.EventButton button_ev = new Gdk.EventButton (ev.Handle);

				// Do not insert selected text when activating links with
				// middle mouse button
				if (button_ev.Button == 2) {
					allow_middle_activate = true;
					return true;
				}

				return false;

			case Gdk.EventType.ButtonRelease:
				button_ev = new Gdk.EventButton (ev.Handle);

				if (button_ev.Button != 1 && button_ev.Button != 2)
					return false;

				/* Don't activate if Shift or Control is pressed */
				if ((int) (button_ev.State & (Gdk.ModifierType.ShiftMask |
				                              Gdk.ModifierType.ControlMask)) != 0)
					return false;

				// Prevent activation when selecting links with the mouse
				if (editor.Buffer.HasSelection)
					return false;

				// Don't activate if the link has just been pasted with the
				// middle mouse button (no preceding ButtonPress event)
				if (button_ev.Button == 2 && !allow_middle_activate)
					return false;
				else
					allow_middle_activate = false;

				GetExtents (iter, out start, out end);
				bool success = OnActivate (editor, start, end);

				// Hide note if link is activated with middle mouse button
				if (success && button_ev.Button == 2) {
					Gtk.Widget widget = (Gtk.Widget) sender;
					widget.Toplevel.Hide ();
				}

				return false;

			case Gdk.EventType.KeyPress:
				Gdk.EventKey key_ev = new Gdk.EventKey (ev.Handle);

				// Control-Enter activates the link at point...
				if ((int) (key_ev.State & Gdk.ModifierType.ControlMask) == 0)
					return false;

				if (key_ev.Key != Gdk.Key.Return &&
				                key_ev.Key != Gdk.Key.KP_Enter)
					return false;

				GetExtents (iter, out start, out end);
				return OnActivate (editor, start, end);
			}

			return false;
		}
 protected override bool OnButtonPressEvent(Gdk.EventButton ev)
 {
     // Insert button press handling code here.
     return(base.OnButtonPressEvent(ev));
 }
Ejemplo n.º 16
0
 protected override bool OnButtonPressEvent(Gdk.EventButton ev)
 {
     // Avoid forwarding event to parent widget
     return(true);
 }
Ejemplo n.º 17
0
 protected void OnCanvasEvent(object obj, CanvasEventArgs args)
 {
     Gdk.EventButton ev = new Gdk.EventButton (args.Event.Handle);
     if (args.Event.Type == Gdk.EventType.EnterNotify)
         WidthUnits = extraWidth;
     if (args.Event.Type == Gdk.EventType.LeaveNotify)
         if (!Selected)
             WidthUnits = normalWidth;
     if (ev.Type == Gdk.EventType.TwoButtonPress)
     {
         ReadonlyTaskInfoDialog dialog = new ReadonlyTaskInfoDialog (Task);
         dialog.Run ();
         dialog.Destroy ();
     }
     else if (ev.Type == Gdk.EventType.ButtonPress)
     {
         switch (ev.Button)
         {
             case 1:
                 Selected = !Selected;
                 break;
             case 2:
                 ChangePriority ();
                 break;
             default:
                 break;
         }
     }
 }
Ejemplo n.º 18
0
 protected override bool OnButtonPressEvent(Gdk.EventButton ev)
 {
     GuiUtils.PopupMenu(menu, ev);
     return(true);
 }
 protected override bool OnButtonPressEvent(Gdk.EventButton evnt)
 {
     pressed = image != null;
     return(base.OnButtonPressEvent(evnt));
 }
Ejemplo n.º 20
0
 // Place the menu underneath an arbitrary parent widget.  The
 // parent widget must be set using menu.AttachToWidget before
 // calling this.
 public static void PopupMenu(Gtk.Menu menu, Gdk.EventButton ev)
 {
     PopupMenu(menu, ev, new Gtk.MenuPositionFunc(GetMenuPosition));
 }
Ejemplo n.º 21
0
        protected override bool OnButtonPressEvent(Gdk.EventButton ev)
        {
            if (swap_rect.ContainsPoint(ev.X, ev.Y))
            {
                Color temp = PintaCore.Palette.PrimaryColor;
                PintaCore.Palette.PrimaryColor   = PintaCore.Palette.SecondaryColor;
                PintaCore.Palette.SecondaryColor = temp;
                GdkWindow.Invalidate();
            }
            else if (reset_rect.ContainsPoint(ev.X, ev.Y))
            {
                PintaCore.Palette.PrimaryColor   = new Color(0, 0, 0);
                PintaCore.Palette.SecondaryColor = new Color(1, 1, 1);
                GdkWindow.Invalidate();
            }

            if (primary_rect.ContainsPoint(ev.X, ev.Y))
            {
                Gtk.ColorSelectionDialog csd = new Gtk.ColorSelectionDialog(Catalog.GetString("Choose Primary Color"));
                csd.TransientFor = PintaCore.Chrome.MainWindow;
                csd.ColorSelection.PreviousColor     = PintaCore.Palette.PrimaryColor.ToGdkColor();
                csd.ColorSelection.CurrentColor      = PintaCore.Palette.PrimaryColor.ToGdkColor();
                csd.ColorSelection.CurrentAlpha      = PintaCore.Palette.PrimaryColor.GdkColorAlpha();
                csd.ColorSelection.HasOpacityControl = true;

                int response = csd.Run();

                if (response == (int)Gtk.ResponseType.Ok)
                {
                    PintaCore.Palette.PrimaryColor = csd.ColorSelection.GetCairoColor();
                }

                csd.Destroy();
            }
            else if (secondary_rect.ContainsPoint(ev.X, ev.Y))
            {
                Gtk.ColorSelectionDialog csd = new Gtk.ColorSelectionDialog(Catalog.GetString("Choose Secondary Color"));
                csd.TransientFor = PintaCore.Chrome.MainWindow;
                csd.ColorSelection.PreviousColor     = PintaCore.Palette.SecondaryColor.ToGdkColor();
                csd.ColorSelection.CurrentColor      = PintaCore.Palette.SecondaryColor.ToGdkColor();
                csd.ColorSelection.CurrentAlpha      = PintaCore.Palette.SecondaryColor.GdkColorAlpha();
                csd.ColorSelection.HasOpacityControl = true;

                int response = csd.Run();

                if (response == (int)Gtk.ResponseType.Ok)
                {
                    PintaCore.Palette.SecondaryColor = csd.ColorSelection.GetCairoColor();
                }

                csd.Destroy();
            }

            int pal = PointToPalette((int)ev.X, (int)ev.Y);

            if (pal >= 0)
            {
                if (ev.Button == 3)
                {
                    PintaCore.Palette.SecondaryColor = palette[pal];
                }
                else if (ev.Button == 1)
                {
                    PintaCore.Palette.PrimaryColor = palette[pal];
                }
                else
                {
                    Gtk.ColorSelectionDialog csd = new Gtk.ColorSelectionDialog(Catalog.GetString("Choose Palette Color"));
                    csd.TransientFor = PintaCore.Chrome.MainWindow;
                    csd.ColorSelection.PreviousColor     = palette[pal].ToGdkColor();
                    csd.ColorSelection.CurrentColor      = palette[pal].ToGdkColor();
                    csd.ColorSelection.CurrentAlpha      = palette[pal].GdkColorAlpha();
                    csd.ColorSelection.HasOpacityControl = true;

                    int response = csd.Run();

                    if (response == (int)Gtk.ResponseType.Ok)
                    {
                        palette[pal] = csd.ColorSelection.GetCairoColor();
                    }

                    csd.Destroy();
                }

                GdkWindow.Invalidate();
            }

            // Insert button press handling code here.
            return(base.OnButtonPressEvent(ev));
        }
Ejemplo n.º 22
0
		void CreateEvent (Gdk.EventButton refEvent)
		{
			int rx, ry;
			tree.BinWindow.GetOrigin (out rx, out ry);
			NativeEventButtonStruct nativeEvent = new NativeEventButtonStruct (); 
			nativeEvent.type = refEvent.Type;
			nativeEvent.send_event = 1;
			nativeEvent.window = tree.BinWindow.Handle;
			nativeEvent.x = refEvent.XRoot - rx;
			nativeEvent.y = refEvent.YRoot - ry;
			nativeEvent.x_root = refEvent.XRoot;
			nativeEvent.y_root = refEvent.YRoot;
			nativeEvent.time = refEvent.Time;
			nativeEvent.state = (uint) refEvent.State;
			nativeEvent.button = refEvent.Button;
			nativeEvent.device = refEvent.Device.Handle;

			IntPtr ptr = GLib.Marshaller.StructureToPtrAlloc (nativeEvent); 
			try {
				Gdk.EventButton evnt = new Gdk.EventButton (ptr); 
				Gdk.EventHelper.Put (evnt); 
			} finally {
				Marshal.FreeHGlobal (ptr);
			}
		}
Ejemplo n.º 23
0
 protected override bool OnButtonReleaseEvent(Gdk.EventButton evnt)
 {
     mouse_down = false;
     return(base.OnButtonReleaseEvent(evnt));
 }
Ejemplo n.º 24
0
 protected override bool OnButtonReleaseEvent(Gdk.EventButton evnt)
 {
     dragging = false;
     return(true);
 }
Ejemplo n.º 25
0
 /// <summary>
 /// Show the popup menu
 /// </summary>
 /// <param name="b">The button</param>
 private void DoPopup(Gdk.EventButton b)
 {
     popupMenu.Popup();
 }
Ejemplo n.º 26
0
        protected override bool OnButtonPressEvent(Gdk.EventButton press)
        {
            TreePath       path;
            TreeViewColumn column;

            if (press.Button == 1)
            {
                ResetHighlight();
            }

            // If there is not a row at the click position let the base handler take care of the press
            if (!GetPathAtPos((int)press.X, (int)press.Y, out path, out column))
            {
                return(base.OnButtonPressEvent(press));
            }

            Source source = store.GetSource(path);

            if (source == null || source is SourceManager.GroupSource)
            {
                return(false);
            }

            // From F-Spot's SaneTreeView class
            if (source_renderer.InExpander((int)press.X))
            {
                if (!source.Expanded)
                {
                    ExpandRow(path, false);
                }
                else
                {
                    CollapseRow(path);
                }

                // If the active source is a child of this source, and we are about to collapse it, switch
                // the active source to the parent.
                if (source == ServiceManager.SourceManager.ActiveSource.Parent && GetRowExpanded(path))
                {
                    ServiceManager.SourceManager.SetActiveSource(source);
                }
                return(true);
            }

            // For Sources that can't be activated, when they're clicked just
            // expand or collapse them and return.
            if (press.Button == 1 && !source.CanActivate)
            {
                if (!source.Expanded)
                {
                    ExpandRow(path, false);
                }
                else
                {
                    CollapseRow(path);
                }
                return(false);
            }

            if (press.Button == 3)
            {
                TreeIter iter;
                if (Model.GetIter(out iter, path))
                {
                    HighlightIter(iter);
                    OnPopupMenu();
                    return(true);
                }
            }

            if (!source.CanActivate)
            {
                return(false);
            }


            if (press.Button == 1)
            {
                if (ServiceManager.SourceManager.ActiveSource != source)
                {
                    ServiceManager.SourceManager.SetActiveSource(source);
                }
            }

            if ((press.State & Gdk.ModifierType.ControlMask) != 0)
            {
                if (press.Type == Gdk.EventType.TwoButtonPress && press.Button == 1)
                {
                    ActivateRow(path, null);
                }
                return(true);
            }

            return(base.OnButtonPressEvent(press));
        }
Ejemplo n.º 27
0
 public void Activate(Gdk.EventButton eb, Literal literal)
 {
     Activate(eb, literal, new Gtk.Menu(), true);
 }
Ejemplo n.º 28
0
 protected override bool OnButtonReleaseEvent(Gdk.EventButton ev)
 {
     return(ProcessButtonRelease(ev));
 }
Ejemplo n.º 29
0
 public static void ShowContextMenu(Gtk.Widget parent, Gdk.EventButton evt, ContextMenu menu)
 {
     ShowContextMenu(parent, evt, menu, null);
 }
Ejemplo n.º 30
0
 protected override bool OnButtonPressEvent(Gdk.EventButton evnt)
 {
     _physicalWorkspace.OnMouseDown(ConvertToXMouseEventArgs(evnt.Button, evnt.Type, evnt.State, evnt.X, evnt.Y));
     _lastButtonPressed = evnt.Button;
     return(base.OnButtonPressEvent(evnt));
 }
Ejemplo n.º 31
0
 protected override bool OnButtonReleaseEvent(Gdk.EventButton ev)
 {
     wasButtonActivation = true;
     return(base.OnButtonReleaseEvent(ev));
 }
Ejemplo n.º 32
0
 protected override bool OnButtonReleaseEvent(Gdk.EventButton evnt)
 {
     _physicalWorkspace.OnMouseUp(ConvertToXMouseEventArgs(evnt.Button, evnt.Type, evnt.State, evnt.X, evnt.Y));
     _lastButtonPressed = 0; // no button pressed
     return(base.OnButtonReleaseEvent(evnt));
 }
Ejemplo n.º 33
0
 protected virtual bool OnButtonPressEvent(Gdk.EventButton evnt)
 {
     return(InternalButtonPressEvent(evnt));
 }
Ejemplo n.º 34
0
 public iFolderButtonPressEventArgs(Gdk.EventButton eb)
 {
     this.eb = eb;
 }