Example #1
0
        void OnButtonPress(object sender, Gtk.ButtonPressEventArgs args)
        {
            int x, y;

            Window.Editor.WindowToBufferCoords(Gtk.TextWindowType.Text,
                                               (int)args.Event.X,
                                               (int)args.Event.Y,
                                               out x,
                                               out y);
            Gtk.TextIter click_iter = Window.Editor.GetIterAtLocation(x, y);

            // Move click_mark to click location
            Buffer.MoveMark(click_mark, click_iter);

            // Continue event processing
            args.RetVal = false;
        }
Example #2
0
        private void TreeView_ButtonPressEvent(object o, Gtk.ButtonPressEventArgs args)
        {
            if (args.Event.Button == 3)
            {
                Gtk.TreeViewDropPosition pos;
                Gtk.TreePath             path;
                Gtk.TreeIter             iter;

                if (_gtkTreeView.GetDestRowAtPos((int)args.Event.X, (int)args.Event.Y, out path, out pos) && _gtkTreeView.Model.GetIter(out iter, path))
                {
                    var paths = _gtkTreeView.Selection.GetSelectedRows().ToList();
                    if (paths.Contains(path))
                    {
                        args.RetVal = true;
                    }
                }
            }
        }
Example #3
0
 void MapWidget_ButtonPressEvent(object o, Gtk.ButtonPressEventArgs args)
 {
     if (args.Event.Button == 1)
     {
         var newPoint = MapWidget.FromLocalToLatLng((int)args.Event.X, (int)args.Event.Y);
         if (addressMarker == null)
         {
             addressMarker             = new GMarkerGoogle(newPoint, GMarkerGoogleType.arrow);
             addressMarker.ToolTipText = Entity.ShortAddress;
             addressOverlay.Markers.Add(addressMarker);
         }
         else
         {
             addressMarker.Position = newPoint;
         }
         addressMoving = true;
     }
 }
Example #4
0
        protected override void OnMouseDown(Gtk.DrawingArea canvas, Gtk.ButtonPressEventArgs args, PointD point)
        {
            // If we are already panning, ignore any additional mouse down events
            if (active)
            {
                return;
            }

            Document doc = PintaCore.Workspace.ActiveDocument;

            // Don't scroll if the whole canvas fits (no scrollbars)
            if (!doc.Workspace.CanvasFitsInWindow)
            {
                active = true;
            }

            last_point = new PointD(args.Event.XRoot, args.Event.YRoot);
        }
Example #5
0
        private void GtkControlObject_ButtonPressEvent(object sender, Gtk.ButtonPressEventArgs args)
        {
            Point        p         = new Point(Convert.ToInt32(args.Event.X), Convert.ToInt32(args.Event.Y));
            Key          modifiers = GetKeyModifiers(args.Event.State);
            MouseButtons buttons   = GetButtons(args.Event);

            if (Control.CanFocus && !Control.HasFocus)
            {
                Control.GrabFocus();
            }
            if (args.Event.Type == Gdk.EventType.ButtonPress)
            {
                Widget.OnMouseDown(new MouseEventArgs(buttons, modifiers, p));
            }
            else if (args.Event.Type == Gdk.EventType.TwoButtonPress)
            {
                Widget.OnMouseDoubleClick(new MouseEventArgs(buttons, modifiers, p));
            }
        }
Example #6
0
        private void HandleDrawingButtonPressEvent(object o, Gtk.ButtonPressEventArgs args)
        {
            int x, y;

            Gdk.ModifierType mask;
            drawing.GdkWindow.GetPointer(out x, out y, out mask);

            if (args.Event.Button == 1)
            {
                AddControlPoint(x, y);
            }

            // user pressed right button
            if (args.Event.Button == 3)
            {
                foreach (var controlPoints in GetActiveControlPoints())
                {
                    for (int i = 0; i < controlPoints.Count; i++)
                    {
                        int cpx = controlPoints.Keys [i];
                        int cpy = size - 1 - (int)controlPoints.Values [i];

                        //we cannot allow user to remove first or last control point
                        if (cpx == 0 && cpy == size - 1)
                        {
                            continue;
                        }
                        if (cpx == size - 1 && cpy == 0)
                        {
                            continue;
                        }

                        if (CheckControlPointProximity(cpx, cpy, x, y))
                        {
                            controlPoints.RemoveAt(i);
                            break;
                        }
                    }
                }
            }

            InvalidateDrawing();
        }
            public void HandleButtonPress(object o, Gtk.ButtonPressEventArgs args)
            {
                var treeview = o as Gtk.TreeView;

                // Gtk default behaviout for multiselect treeview is that
                // left and right click act the same, which is problematic
                // when it comes to user selecting multiple items and than
                // right clicking to find only one item remains selected
                // or if ctrl is held the current item gets unselected.
                if (args.Event.Button == 3 && treeview != null)
                {
                    Gtk.TreeViewDropPosition pos;
                    Gtk.TreePath             path;

                    if (treeview.GetDestRowAtPos((int)args.Event.X, (int)args.Event.Y, out path, out pos))
                    {
                        var height = 0;
                        if (treeview.HeadersVisible && treeview.Columns.Length > 0)
                        {
                            height = treeview.GetCellArea(path, treeview.Columns[0]).Height;
                        }

                        if (treeview.GetDestRowAtPos((int)args.Event.X, (int)args.Event.Y + height, out path, out pos))
                        {
                            var paths = treeview.Selection.GetSelectedRows().ToList();

                            if (paths.Contains(path))
                            {
                                args.RetVal = true;
                            }
                        }
                    }
                }

                var handler = Handler;

                if (handler.contextMenu != null && args.Event.Button == 3 && args.Event.Type == Gdk.EventType.ButtonPress)
                {
                    var menu = ((ContextMenuHandler)handler.contextMenu.Handler).Control;
                    menu.Popup();
                    menu.ShowAll();
                }
            }
Example #8
0
 protected void OnRight(object sender, Gtk.ButtonPressEventArgs e)
 {
     if (e.Event.Button == 3)            // Botón derecho.
     {
         Gtk.TreePath RowPath;
         if (Exercises.GetPathAtPos(Convert.ToInt32(e.Event.X),
                                    Convert.ToInt32(e.Event.Y),
                                    out RowPath))
         {
             int          ActiveRow      = RowPath.Indices[0];
             Gtk.Menu     m              = new Gtk.Menu();
             Gtk.MenuItem DeleteExercise = new Gtk.MenuItem("Delete exercise");
             DeleteExercise.ButtonPressEvent += (o, a) => OnDelete(ActiveRow);
             m.Add(DeleteExercise);
             m.ShowAll();
             m.Popup();
         }
     }
 }
Example #9
0
        void HandleValueTreeButtonPressEvent(object o, Gtk.ButtonPressEventArgs args)
        {
            originX = args.Event.XRoot;
            originY = args.Event.YRoot;

            Gtk.TreePath       path;
            Gtk.TreeViewColumn col;
            int cx, cy;

            valueTree.GetPathAtPos((int)args.Event.X, (int)args.Event.Y, out path, out col, out cx, out cy);
            Gdk.Rectangle rect = valueTree.GetCellArea(path, col);
            if (!mousePressed && valueTree.Columns[0] == col && cx >= rect.Left)
            {
                mousePressed = true;
                Editor.MoveToTop(this);
//				Gdk.Pointer.Grab (this.GdkWindow, true, Gdk.EventMask.ButtonPressMask | Gdk.EventMask.ButtonReleaseMask | Gdk.EventMask.PointerMotionMask | Gdk.EventMask.EnterNotifyMask | Gdk.EventMask.LeaveNotifyMask, null, null, Gtk.Global.CurrentEventTime);
//				Gtk.Grab.Add (this);
            }
        }
Example #10
0
            public void HandleButtonPressEvent(object sender, Gtk.ButtonPressEventArgs args)
            {
                var          p         = new PointF((float)args.Event.X, (float)args.Event.Y);
                Key          modifiers = args.Event.State.ToEtoKey();
                MouseButtons buttons   = args.Event.ToEtoMouseButtons();

                if (Handler.Control.CanFocus && !Handler.Control.HasFocus)
                {
                    Handler.Control.GrabFocus();
                }
                if (args.Event.Type == Gdk.EventType.ButtonPress)
                {
                    Handler.Widget.OnMouseDown(new MouseEventArgs(buttons, modifiers, p));
                }
                else if (args.Event.Type == Gdk.EventType.TwoButtonPress)
                {
                    Handler.Widget.OnMouseDoubleClick(new MouseEventArgs(buttons, modifiers, p));
                }
            }
            public virtual void OnTreeButtonPress(object sender, Gtk.ButtonPressEventArgs e)
            {
                if (e.Event.Type == Gdk.EventType.TwoButtonPress || e.Event.Type == Gdk.EventType.ThreeButtonPress)
                {
                    return;
                }
                var h = Handler;

                if (h == null)
                {
                    return;
                }

                Gtk.TreePath       path;
                Gtk.TreeViewColumn clickedColumn;

                // Get path and column from mouse position
                h.Tree.GetPathAtPos((int)e.Event.X, (int)e.Event.Y, out path, out clickedColumn);
                if (path == null || clickedColumn == null)
                {
                    return;
                }

                var rowIndex    = h.GetRowIndexOfPath(path);
                var columnIndex = h.GetColumnOfItem(clickedColumn);
                var item        = h.GetItem(path);
                var column      = columnIndex == -1 || columnIndex >= h.Widget.Columns.Count ? null : h.Widget.Columns[columnIndex];

                var loc = h.PointFromScreen(new PointF((float)e.Event.XRoot, (float)e.Event.YRoot));

                if (ReferenceEquals(h.Tree.ExpanderColumn, clickedColumn))
                {
                    var cellArea = h.Tree.GetCellArea(path, clickedColumn);
                    if (loc.X < cellArea.Left && loc.X >= cellArea.Left - 18)                     // how do we get the size of the expander?
                    {
                        // clicked on the expander, don't fire the CellClick event
                        return;
                    }
                }

                h.Callback.OnCellClick(h.Widget, new GridCellMouseEventArgs(column, rowIndex, columnIndex, item, e.Event.ToEtoMouseButtons(), e.Event.State.ToEtoKey(), loc));
            }
Example #12
0
        protected override void OnMouseDown(Gtk.DrawingArea canvas, Gtk.ButtonPressEventArgs args, Cairo.PointD point)
        {
            // If we are already drawing, ignore any additional mouse down events
            if (is_dragging)
            {
                return;
            }

            Document doc = PintaCore.Workspace.ActiveDocument;

            origin_offset = point;
            is_dragging   = true;

            hist = new MovePixelsHistoryItem(Icon, Name, doc);
            hist.TakeSnapshot(!doc.ShowSelectionLayer);

            if (!doc.ShowSelectionLayer)
            {
                // Copy the selection to the temp layer
                doc.CreateSelectionLayer();
                doc.ShowSelectionLayer = true;

                using (Cairo.Context g = new Cairo.Context(doc.SelectionLayer.Surface)) {
                    g.AppendPath(doc.SelectionPath);
                    g.FillRule = FillRule.EvenOdd;
                    g.SetSource(doc.CurrentLayer.Surface);
                    g.Clip();
                    g.Paint();
                }

                Cairo.ImageSurface surf = doc.CurrentLayer.Surface;

                using (Cairo.Context g = new Cairo.Context(surf)) {
                    g.AppendPath(doc.SelectionPath);
                    g.FillRule = FillRule.EvenOdd;
                    g.Operator = Cairo.Operator.Clear;
                    g.Fill();
                }
            }

            canvas.GdkWindow.Invalidate();
        }
Example #13
0
 void FlowsheetSurface_GTK_ButtonPressEvent(object o, Gtk.ButtonPressEventArgs args)
 {
     if (args.Event.Type == Gdk.EventType.TwoButtonPress)
     {
         //if (args.Event.State == Gdk.ModifierType.ShiftMask)
         //{
         //    fsurface.Zoom = 1.0f;
         //}
         //else {
         //    fsurface.ZoomAll((int)this.Allocation.Width, (int)this.Allocation.Height);
         //}
     }
     else
     {
         _lastTouchX = (int)args.Event.X;
         _lastTouchY = (int)args.Event.Y;
         fsurface.InputPress((int)_lastTouchX, (int)_lastTouchY);
     }
     this.QueueDraw();
 }
Example #14
0
        protected void lblMarkAllRead_ButtonPress(object o, Gtk.ButtonPressEventArgs args)
        {
            var group = ctlGroupGrid.FocusedItem;

            if (group == null)
            {
                return;
            }

            if (Utilities.ShowMessageBox(
                    string.Format("Are you sure you want to mark all messages as read in the group \"{0}\"?",
                                  group.GroupName),
                    "Yamster",
                    Gtk.ButtonsType.YesNo, Gtk.MessageType.Question) != Gtk.ResponseType.Yes)
            {
                return;
            }

            group.SetReadStatusForAllMessages(true);
        }
Example #15
0
        protected override void OnMouseDown(Gtk.DrawingArea canvas, Gtk.ButtonPressEventArgs args, Cairo.PointD point)
        {
            Document doc = PintaCore.Workspace.ActiveDocument;

            // Protect against history corruption
            if (tracking)
            {
                return;
            }

            startpoint = point;
            if (!doc.Workspace.PointInCanvas(point))
            {
                return;
            }

            tracking     = true;
            button       = args.Event.Button;
            undo_surface = doc.CurrentUserLayer.Surface.Clone();
        }
Example #16
0
        void HandleWidgetButtonPressEvent(object o, Gtk.ButtonPressEventArgs args)
        {
            var a = new ButtonEventArgs();

            a.X      = args.Event.X;
            a.Y      = args.Event.Y;
            a.Button = (int)args.Event.Button;
            if (args.Event.Type == Gdk.EventType.TwoButtonPress)
            {
                a.MultiplePress = 2;
            }
            else if (args.Event.Type == Gdk.EventType.ThreeButtonPress)
            {
                a.MultiplePress = 3;
            }
            else
            {
                a.MultiplePress = 1;
            }
            EventSink.OnButtonPressed(a);
        }
Example #17
0
        void OnSelectIcon(object sender, Gtk.ButtonPressEventArgs e)
        {
            Gtk.Menu menu = new Gtk.Menu();

            Gtk.CheckMenuItem item = new Gtk.CheckMenuItem(Catalog.GetString("Action"));
            item.DrawAsRadio = true;
            item.Active      = (node.Action.Type == Stetic.Wrapper.Action.ActionType.Action);
            item.Activated  += OnSetActionType;
            menu.Insert(item, -1);

            item             = new Gtk.CheckMenuItem(Catalog.GetString("Radio Action"));
            item.DrawAsRadio = true;
            item.Active      = (node.Action.Type == Stetic.Wrapper.Action.ActionType.Radio);
            item.Activated  += OnSetRadioType;
            menu.Insert(item, -1);

            item             = new Gtk.CheckMenuItem(Catalog.GetString("Toggle Action"));
            item.DrawAsRadio = true;
            item.Active      = (node.Action.Type == Stetic.Wrapper.Action.ActionType.Toggle);
            item.Activated  += OnSetToggleType;
            menu.Insert(item, -1);

            menu.Insert(new Gtk.SeparatorMenuItem(), -1);

            Gtk.MenuItem itIcons = new Gtk.MenuItem(Catalog.GetString("Select Icon"));
            menu.Insert(itIcons, -1);
            IconSelectorMenu menuIcons = new IconSelectorMenu(GetProject());

            menuIcons.IconSelected += OnStockSelected;
            itIcons.Submenu         = menuIcons;

            Gtk.MenuItem it = new Gtk.MenuItem(Catalog.GetString("Clear Icon"));
            it.Sensitive  = (node.Action.GtkAction.StockId != null);
            it.Activated += OnClearIcon;
            menu.Insert(it, -1);

            menu.ShowAll();
            menu.Popup(null, null, new Gtk.MenuPositionFunc(OnDropMenuPosition), 3, Gtk.Global.CurrentEventTime);
            e.RetVal = false;
        }
Example #18
0
        protected override void OnMouseDown(Gtk.DrawingArea canvas,
                                            Gtk.ButtonPressEventArgs args,
                                            Cairo.PointD point)
        {
            if (is_dragging || is_rotating)
            {
                return;
            }

            original_point = point;

            if (args.Event.Button == GtkExtensions.MouseRightButton)
            {
                is_rotating = true;
            }
            else
            {
                is_dragging = true;
            }

            OnStartTransform();
        }
Example #19
0
        protected virtual ButtonEventArgs GetButtonPressEventArgs(Gtk.ButtonPressEventArgs args)
        {
            var a = new ButtonEventArgs();

            a.X = args.Event.X;
            a.Y = args.Event.Y;

            a.Button = (PointerButton)args.Event.Button;
            if (args.Event.Type == Gdk.EventType.TwoButtonPress)
            {
                a.MultiplePress = 2;
            }
            else if (args.Event.Type == Gdk.EventType.ThreeButtonPress)
            {
                a.MultiplePress = 3;
            }
            else
            {
                a.MultiplePress = 1;
            }
            return(a);
        }
Example #20
0
        void HandleButtonPressEvent(object o, Gtk.ButtonPressEventArgs args)
        {
            var a = new ButtonEventArgs();

            a.X      = args.Event.X;
            a.Y      = args.Event.Y;
            a.Button = (PointerButton)args.Event.Button;
            if (args.Event.Type == Gdk.EventType.TwoButtonPress)
            {
                a.MultiplePress = 2;
            }
            else if (args.Event.Type == Gdk.EventType.ThreeButtonPress)
            {
                a.MultiplePress = 3;
            }
            else
            {
                a.MultiplePress = 1;
            }
            Toolkit.Invoke(delegate {
                EventSink.OnButtonPressed(a);
            });
        }
Example #21
0
        void HandleButtonPressEvent(object o, Gtk.ButtonPressEventArgs args)
        {
            int cx, cy;

            Gtk.TreeIter iter;
            if (rendererTarget.GetCellPosition(CellRenderer, (int)args.Event.X, (int)args.Event.Y, out cx, out cy, out iter))
            {
                var rect = rendererTarget.GetCellBounds(target, CellRenderer, iter);
                if (rect.Contains(cx, cy))
                {
                    rendererTarget.PressedIter = iter;
                    rendererTarget.PressedCell = this;
                    pressX  = (int)args.Event.X;
                    pressY  = (int)args.Event.Y;
                    pressCX = cx;
                    pressCY = cy;
                    if (!buttonReleaseSubscribed)
                    {
                        rendererTarget.EventRootWidget.AddEvents((int)Gdk.EventMask.ButtonReleaseMask);
                        rendererTarget.EventRootWidget.ButtonReleaseEvent += HandleButtonReleaseEvent;
                    }
                    ApplicationContext.InvokeUserCode(delegate {
                        LoadData(rendererTarget.Model, iter);
                        var a = new ButtonEventArgs {
                            X      = args.Event.X,
                            Y      = args.Event.Y,
                            Button = (PointerButton)args.Event.Button
                        };
                        EventSink.OnButtonPressed(a);
                        if (a.Handled)
                        {
                            args.RetVal = true;
                        }
                    });
                }
            }
        }
Example #22
0
        private void HandleButtonPressEventTitleBar(object o, Gtk.ButtonPressEventArgs args)
        {
            // sizing
            if (base.GdkWindow.State != Gdk.WindowState.Maximized &&
                !isSizing &&
                sizingSide == SizingSide.SizingSideType.E_NONE)
            {
                if (args.Event.Type == Gdk.EventType.ButtonPress &&
                    args.Event.Button == 1)
                {
                    isMoving       = true;
                    lastMousePos.X = (int)args.Event.XRoot;
                    lastMousePos.Y = (int)args.Event.YRoot;
                    base.GdkWindow.GetPosition(out lastWindowPos.X, out lastWindowPos.Y);
                }
            }

            // maximize
            if (base.Resizable && args.Event.Type == Gdk.EventType.TwoButtonPress &&
                args.Event.Button == 1)
            {
                if (base.GdkWindow.State == Gdk.WindowState.Maximized)
                {
                    base.GdkWindow.Unmaximize();
                    ShowTitleBar = true;
                }
                else
                {
                    base.GdkWindow.Maximize();
                    if (PlatformUtils.IsX11 || PlatformUtils.IsMac)
                    {
                        ShowTitleBar = false;
                    }
                }
                base.QueueDraw();
            }
        }
Example #23
0
        protected override void OnMouseDown(Gtk.DrawingArea canvas, Gtk.ButtonPressEventArgs args, Cairo.PointD point)
        {
            Document doc = PintaCore.Workspace.ActiveDocument;

            // We only do stuff with the left mouse button
            if (args.Event.Button != 1)
            {
                return;
            }

            // Ctrl click is set origin, regular click is begin drawing
            if (!args.Event.IsControlPressed())
            {
                if (origin.IsNotSet())
                {
                    return;
                }

                painting = true;

                if (offset.IsNotSet())
                {
                    offset = new Point((int)point.X - origin.X, (int)point.Y - origin.Y);
                }

                doc.ToolLayer.Clear();
                doc.ToolLayer.Hidden = false;

                surface_modified = false;
                undo_surface     = doc.CurrentUserLayer.Surface.Clone();
            }
            else
            {
                origin = point.ToGdkPoint();
            }
        }
Example #24
0
        protected virtual ButtonEventArgs GetButtonPressEventArgs(Gtk.ButtonPressEventArgs args)
        {
            var a = new ButtonEventArgs();

            var pointer_coords = EventsRootWidget.CheckPointerCoordinates(args.Event.Window, args.Event.X, args.Event.Y);

            a.X = pointer_coords.X;
            a.Y = pointer_coords.Y;

            a.Button = (PointerButton)args.Event.Button;
            if (args.Event.Type == Gdk.EventType.TwoButtonPress)
            {
                a.MultiplePress = 2;
            }
            else if (args.Event.Type == Gdk.EventType.ThreeButtonPress)
            {
                a.MultiplePress = 3;
            }
            else
            {
                a.MultiplePress = 1;
            }
            return(a);
        }
Example #25
0
 protected virtual void OnButtonPressEvent(object o, Gtk.ButtonPressEventArgs args)
 {
     Close();
 }
Example #26
0
 protected virtual void OnTxtSecButtonPressEvent(object o, Gtk.ButtonPressEventArgs args)
 {
     args.RetVal = true;
 }
 protected virtual void OnCalendar3ButtonPressEvent(object o, Gtk.ButtonPressEventArgs args)
 {
     args.RetVal = true;
 }
Example #28
0
 private void OnRight(object o, Gtk.ButtonPressEventArgs e)
 {
     if (e.Event.Button == 3)             //Identificador de botón derecho
     {
     }
 }
Example #29
0
        protected override void OnMouseDown(Gtk.DrawingArea canvas, Gtk.ButtonPressEventArgs args, Cairo.PointD point)
        {
            Document doc = PintaCore.Workspace.ActiveDocument;

            //SetCursor (Cursors.WaitCursor);

            //Here is where the CombineMode for the Magic Wand Tool's selection is determined based on None/Ctrl/Shift + Left/Right Click.

            switch (SelectionMode)
            {
            case 1:
                combineMode = CombineMode.Union;
                break;

            case 2:
                combineMode = CombineMode.Exclude;
                break;

            case 3:
                combineMode = CombineMode.Xor;
                break;

            case 4:
                combineMode = CombineMode.Intersect;
                break;

            default:
                //Left Click (usually) - also the default
                combineMode = CombineMode.Replace;
                break;
            }

            if (args.Event.Button == 1)
            {
                if (args.Event.IsControlPressed())
                {
                    //Control + Left Click
                    combineMode = CombineMode.Union;
                }
                else if (args.Event.IsShiftPressed())
                {
                    //Shift + Left Click
                    combineMode = CombineMode.Intersect;
                }
            }
            else if (args.Event.Button == 3)
            {
                if (args.Event.IsControlPressed())
                {
                    //Control + Right Click
                    combineMode = CombineMode.Xor;
                }
                else
                {
                    //Right Click
                    combineMode = CombineMode.Exclude;
                }
            }

            base.OnMouseDown(canvas, args, point);

            doc.ShowSelection = true;
        }
Example #30
0
 void HandleButtonPress(object sender, Gtk.ButtonPressEventArgs args)
 {
     Hide();
 }