Exemple #1
0
        void StartEditing(TableRow row)
        {
            EndEditing();
            currentEditorRow = row;
            var cell = GetCell(row);

            editSession   = cell.StartEditing(row.EditorBounds, State);
            currentEditor = (Gtk.Widget)editSession.Editor;
            Add(currentEditor);
            SetAllocation(currentEditor, row.EditorBounds);
            currentEditor.Show();
            currentEditor.CanFocus = true;
            currentEditor.GrabFocus();
            ConnectTabEvent(currentEditor);
            editSession.Changed += delegate {
                if (Changed != null)
                {
                    Changed(this, EventArgs.Empty);
                }
            };
            var vs = ((Gtk.Viewport)Parent).Vadjustment;

            if (row.EditorBounds.Top < vs.Value)
            {
                vs.Value = row.EditorBounds.Top;
            }
            else if (row.EditorBounds.Bottom > vs.Value + vs.PageSize)
            {
                vs.Value = row.EditorBounds.Bottom - vs.PageSize;
            }
            QueueDraw();
        }
Exemple #2
0
        void StartEditing(TableRow row)
        {
            GrabFocus();

            currentEditorRow = row;
            row.Focused      = true;

            var cell = GetCell(row);

            if (cell == null)
            {
                GrabFocus();
                QueueDraw();
                return;
            }

            editSession = cell.StartEditing(row.EditorBounds, State);
            if (editSession == null)
            {
                return;
            }

            currentEditor = (Gtk.Widget)editSession.Editor;
            Add(currentEditor);
            SetAllocation(currentEditor, row.EditorBounds);
            currentEditor.Show();
            currentEditor.GrabFocus();

            var refreshAtt = row.Property.Attributes.OfType <RefreshPropertiesAttribute> ().FirstOrDefault();
            var refresh    = refreshAtt == null ? RefreshProperties.None : refreshAtt.RefreshProperties;

            editSession.Changed += delegate {
                if (refresh == RefreshProperties.Repaint)
                {
                    parentGrid.Refresh();
                }
                else if (refresh == RefreshProperties.All)
                {
                    parentGrid.Populate(saveEditSession: true);
                }

                if (Changed != null)
                {
                    Changed(this, EventArgs.Empty);
                }
            };

            var vs = ((Gtk.Viewport)Parent).Vadjustment;

            if (row.EditorBounds.Top < vs.Value)
            {
                vs.Value = row.EditorBounds.Top;
            }
            else if (row.EditorBounds.Bottom > vs.Value + vs.PageSize)
            {
                vs.Value = row.EditorBounds.Bottom - vs.PageSize;
            }
            QueueDraw();
        }
Exemple #3
0
        bool ShowFixesMenu(Gtk.Widget parent, Gdk.Rectangle evt, FixMenuDescriptor entrySet)
        {
                        #if MAC
            parent.GrabFocus();
            int x, y;
            x = (int)evt.X;
            y = (int)evt.Y;

            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      = CreateNSMenu(entrySet);
                menu.Delegate = new ClosingMenuDelegate(document.Editor);
                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 = AppKit.NSEvent.MouseEvent(AppKit.NSEventType.LeftMouseDown,
                                                          pt,
                                                          0, 0,
                                                          MonoDevelop.Components.Mac.GtkMacInterop.GetNSWindow(toplevel).WindowNumber,
                                                          null, 0, 0, 0);

                AppKit.NSMenu.PopUpContextMenu(menu, tmp_event, nsview);
            });
                        #else
            var menu = CreateGtkMenu(entrySet);
            menu.Events |= Gdk.EventMask.AllEventsMask;
            menu.SelectFirst(true);

            menu.Hidden += delegate {
                document.Editor.SuppressTooltips = false;
            };
            menu.ShowAll();
            menu.SelectFirst(true);
            menu.MotionNotifyEvent += (o, args) => {
                if (args.Event.Window == Editor.Parent.TextArea.GdkWindow)
                {
                    StartMenuCloseTimer();
                }
                else
                {
                    CancelMenuCloseTimer();
                }
            };

            GtkWorkarounds.ShowContextMenu(menu, parent, null, evt);
                        #endif
            return(true);
        }
Exemple #4
0
 public static void VidgetBackendSetFocus(this Widget widget)
 {
     if (widget.Parent != null)
     {
         VidgetBackendSetFocus(widget.Parent);
     }
     widget.GrabFocus();
     widget.IsFocus  = true;
     widget.HasFocus = true;
 }
Exemple #5
0
 void OnWidgetShown(object o, EventArgs args)
 {
     // when the dialog is shown, select and give the focus
     // to the previously focused widget
     if (previouslyFocused != null)
     {
         previouslyFocused.GrabFocus();
     }
     else
     {
         SearchPatternEntry.GrabFocus();
     }
 }
Exemple #6
0
        void PositionWidget(Gtk.Widget widget)
        {
            if (!(widget is Gtk.Window))
            {
                return;
            }
            int ox, oy;

            ParentWindow.GetOrigin(out ox, out oy);
            int w;
            int itemXPosition = GetHoverXPosition(out w);
            int dx            = ox + this.Allocation.X + itemXPosition;
            int dy            = oy + this.Allocation.Bottom;

            var req = widget.SizeRequest();

            Xwt.Rectangle geometry  = IdeServices.DesktopService.GetUsableMonitorGeometry(Screen.Number, Screen.GetMonitorAtPoint(dx, dy));
            int           geomWidth = (int)geometry.Width;
            int           geomLeft  = (int)geometry.Left;
            int           geomRight = (int)geometry.Right;
            int           width     = System.Math.Max(req.Width, w);

            if (width >= geomWidth - spacing * 2)
            {
                width = geomWidth - spacing * 2;
                dx    = geomLeft + spacing;
            }
            widget.WidthRequest = width;
            if (dy + req.Height > geometry.Bottom)
            {
                dy = oy + this.Allocation.Y - req.Height;
            }
            if (dx + width > geomRight)
            {
                dx = geomRight - width;
            }
            (widget as Gtk.Window).Move(dx, dy);
            (widget as Gtk.Window).Resize(width, req.Height);
            widget.GrabFocus();
        }
        bool ShowFixesMenu(Gtk.Widget parent, Gdk.Rectangle evt, FixMenuDescriptor entrySet)
        {
            if (parent == null || parent.GdkWindow == null)
            {
                Editor.SuppressTooltips = false;
                return(true);
            }

            try {
                parent.GrabFocus();
                int x, y;
                x = (int)evt.X;
                y = (int)evt.Y;

                // 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 = CreateContextMenu(entrySet);
                menu.Show(parent, x, y, () => Editor.SuppressTooltips = false, true);
            } catch (Exception ex) {
                LoggingService.LogError("Error while context menu popup.", ex);
            }
            return(true);
        }
        void StartEditing(TableRow row)
        {
            EndEditing ();
            currentEditorRow = row;
            var cell = GetCell (row);
            editSession = cell.StartEditing (row.EditorBounds, State);
            if (editSession == null)
                return;

            currentEditor = (Gtk.Widget) editSession.Editor;
            Add (currentEditor);
            SetAllocation (currentEditor, row.EditorBounds);
            currentEditor.Show ();
            currentEditor.CanFocus = true;
            currentEditor.GrabFocus ();
            ConnectTabEvent (currentEditor);
            editSession.Changed += delegate {
                if (Changed != null)
                    Changed (this, EventArgs.Empty);
            };
            var vs = ((Gtk.Viewport)Parent).Vadjustment;
            if (row.EditorBounds.Top < vs.Value)
                vs.Value = row.EditorBounds.Top;
            else if (row.EditorBounds.Bottom > vs.Value + vs.PageSize)
                vs.Value = row.EditorBounds.Bottom - vs.PageSize;
            QueueDraw ();
        }
Exemple #9
0
 protected override void OnFocusGrabbed()
 {
     welcomePage.GrabFocus();
 }