public static void PostProcessKeyEvent(Gdk.Key key, Gdk.ModifierType modifier)
        {
            // Called after the key has been processed by the editor

            if (methods.Count == 0)
            {
                return;
            }

            for (int n = 0; n < methods.Count; n++)
            {
                // If the cursor is outside of any of the methods parameter list, discard the
                // information window for that method.

                MethodData md  = methods [n];
                int        pos = md.MethodProvider.GetCurrentParameterIndex(md.CompletionContext);
                if (pos == -1)
                {
                    methods.RemoveAt(n);
                    n--;
                }
            }
            // If the user enters more parameters than the current overload has,
            // look for another overload with more parameters.
            UpdateOverload();

            // Refresh.
            UpdateWindow();
        }
示例#2
0
        bool ITextEditorExtension.KeyPress(Gdk.Key key, char ch, Gdk.ModifierType modifier)
        {
            Gdk.EventKey evnt = evntCopy;
            HideLanguageItemWindow();

            bool        res    = false;
            IEditAction action = editactions.GetAction(evnt.Key, evnt.State);

            if (action != null)
            {
                action.PreExecute(this);
                if (action.PassToBase)
                {
                    base.OnKeyPressEvent(evnt);
                }

                action.Execute(this);

                if (action.PassToBase)
                {
                    base.OnKeyPressEvent(evnt);
                }
                action.PostExecute(this);

                res = true;
            }
            else
            {
                res = base.OnKeyPressEvent(evnt);
            }
            return(res);
        }
示例#3
0
        protected override ClickAnimation OnClicked(uint button, Gdk.ModifierType mod, double xPercent, double yPercent)
        {
            if (button == 1 && clips.Count > 0)
            {
                CopyEntry();
                return(ClickAnimation.Bounce);
            }

            return(ClickAnimation.None);
        }
示例#4
0
        /// <summary>
        /// Called by owning dock when item is scrolled
        /// </summary>
        /// <param name="direction">
        /// A <see cref="Gdk.ScrollDirection"/>
        /// </param>
        /// <param name="mod">
        /// A <see cref="Gdk.ModifierType"/>
        /// </param>
        public virtual void Scrolled(Gdk.ScrollDirection direction, Gdk.ModifierType mod)
        {
            try {
                OnScrolled(direction, mod);
            } catch (Exception e) {
                Log <AbstractDockItem> .Error(e.Message);

                Log <AbstractDockItem> .Debug(e.StackTrace);
            }
        }
示例#5
0
        protected override ClickAnimation OnClicked(uint button, Gdk.ModifierType mod, double xPercent, double yPercent)
        {
            if (button == 1)
            {
                DockServices.System.Execute(click_command);
                return(ClickAnimation.Bounce);
            }

            return(ClickAnimation.None);
        }
示例#6
0
        /// <summary>
        /// Filters out all modifier keys except Ctrl/Shift/Alt. This prevents Caps Lock, Num Lock, etc
        /// from appearing as active modifier keys.
        /// </summary>
        private ModifierType FilterModifierKeys(Gdk.ModifierType current_state)
        {
            ModifierType state = ModifierType.None;

            state |= (current_state & ModifierType.ControlMask);
            state |= (current_state & ModifierType.ShiftMask);
            state |= (current_state & ModifierType.Mod1Mask);

            return(state);
        }
示例#7
0
        public void Scrolled(ScrollDirection direction, int x, int y, Gdk.ModifierType mod)
        {
            try {
                OnScrolled(direction, x, y, mod);
            } catch (Exception e) {
                Log <AbstractDockPainter> .Error(e.Message);

                Log <AbstractDockPainter> .Debug(e.StackTrace);
            }
        }
示例#8
0
        public void ButtonReleased(int x, int y, Gdk.ModifierType mod)
        {
            try {
                OnButtonReleased(x, y, mod);
            } catch (Exception e) {
                Log <AbstractDockPainter> .Error(e.Message);

                Log <AbstractDockPainter> .Debug(e.StackTrace);
            }
        }
示例#9
0
        public void MotionNotify(int x, int y, Gdk.ModifierType mod)
        {
            try {
                OnMotionNotify(x, y, mod);
            } catch (Exception e) {
                Log <AbstractDockPainter> .Error(e.Message);

                Log <AbstractDockPainter> .Debug(e.StackTrace);
            }
        }
示例#10
0
        void Item_Event(object obj, Gnome.CanvasEventArgs args)
        {
            EventButton ev   = new EventButton(args.Event.Handle);
            CanvasRE    item = (CanvasRE)obj;

            switch (ev.Type)
            {
            case EventType.ButtonPress:
                if (ev.Button == 1)
                {
                    remember_x  = ev.X;
                    remember_y  = ev.Y;
                    args.RetVal = true;
                    return;
                }
                else if (ev.Button == 3)
                {
                    item.Destroy();
                    args.RetVal = true;
                    return;
                }
                break;

            case EventType.TwoButtonPress:
                ChangeItemColor(item);
                args.RetVal = true;
                return;

            case EventType.MotionNotify:
                Gdk.ModifierType state = (Gdk.ModifierType)ev.State;
                if ((state & Gdk.ModifierType.Button1Mask) != 0)
                {
                    double new_x = ev.X, new_y = ev.Y;
                    item.Move(new_x - remember_x, new_y - remember_y);
                    remember_x  = new_x;
                    remember_y  = new_y;
                    args.RetVal = true;
                    return;
                }
                break;

            case EventType.EnterNotify:
                item.WidthUnits = 3.0;
                args.RetVal     = true;
                return;

            case EventType.LeaveNotify:
                item.WidthUnits = 1.0;
                args.RetVal     = true;
                return;
            }

            args.RetVal = false;
            return;
        }
示例#11
0
        public static int GetKeyCode(Gdk.Key key, Gdk.ModifierType modifier)
        {
            uint m = (uint)(((modifier & Gdk.ModifierType.ControlMask) != 0)? 1 : 0);

            m = (m << 1) | (uint)(((modifier & Gdk.ModifierType.ShiftMask) != 0)? 1 : 0);
            m = (m << 1) | (uint)(((modifier & Gdk.ModifierType.MetaMask) != 0)? 1 : 0);
            m = (m << 1) | (uint)(((modifier & Gdk.ModifierType.Mod1Mask) != 0)? 1 : 0);
            m = (m << 1) | (uint)(((modifier & Gdk.ModifierType.SuperMask) != 0)? 1 : 0);

            return(GetKeyCode(key) | (int)(m << 16));
        }
示例#12
0
        //	string status;

        public void InternalHandleKeypress(TextEditor editor, TextEditorData data, Gdk.Key key,
                                           uint unicodeChar, Gdk.ModifierType modifier)
        {
            this.editor         = editor;
            this.textEditorData = data;

            HandleKeypress(key, unicodeChar, modifier);

            //make sure that nothing funny goes on when the mode should have finished
            this.textEditorData = null;
            this.editor         = null;
        }
        public override void Scrolled(Gdk.ScrollDirection direction, Gdk.ModifierType mod)
        {
            if (direction == ScrollDirection.Up)
            {
                CurrentPosition--;
            }
            else
            {
                CurrentPosition++;
            }

            ItemChanged();
        }
示例#14
0
        protected override void HandleKeypress(Gdk.Key key, uint unicodeKey, Gdk.ModifierType modifier)
        {
            int keyCode = GetKeyCode(key, modifier);

            if (keyBindings.ContainsKey(keyCode))
            {
                RunAction(keyBindings [keyCode]);
            }
            else if (unicodeKey != 0 && modifier == Gdk.ModifierType.None)
            {
                InsertCharacter(unicodeKey);
            }
        }
示例#15
0
        // Called when a key is pressed in the editor.
        // Returns false if the key press has to continue normal processing.
        public static bool ProcessKeyEvent(ICompletionWidget widget, Gdk.Key key, Gdk.ModifierType modifier)
        {
            if (methods.Count == 0)
            {
                return(false);
            }

            MethodData cmd = methods [methods.Count - 1];

            if (key == Gdk.Key.Down)
            {
                if (cmd.MethodProvider.OverloadCount <= 1)
                {
                    return(false);
                }
                if (cmd.CurrentOverload < cmd.MethodProvider.OverloadCount - 1)
                {
                    cmd.CurrentOverload++;
                }
                else
                {
                    cmd.CurrentOverload = 0;
                }
                UpdateWindow(widget);
                return(true);
            }
            else if (key == Gdk.Key.Up)
            {
                if (cmd.MethodProvider.OverloadCount <= 1)
                {
                    return(false);
                }
                if (cmd.CurrentOverload > 0)
                {
                    cmd.CurrentOverload--;
                }
                else
                {
                    cmd.CurrentOverload = cmd.MethodProvider.OverloadCount - 1;
                }
                UpdateWindow(widget);
                return(true);
            }
            else if (key == Gdk.Key.Escape)
            {
                HideWindow(widget);
                return(true);
            }
            return(false);
        }
示例#16
0
        /// <summary>
        /// Called by owning Dock when the item is clicked
        /// </summary>
        /// <param name="button">
        /// A <see cref="System.UInt32"/>
        /// </param>
        /// <param name="mod">
        /// A <see cref="Gdk.ModifierType"/>
        /// </param>
        /// <param name="xPercent">
        /// A <see cref="System.Double"/> representing the percentage across the icon on which the click took place
        /// </param>
        /// <param name="yPercent">
        /// A <see cref="System.Double"/> representing the percentage down the icon on which the click took place
        /// </param>
        public virtual void Clicked(uint button, Gdk.ModifierType mod, double xPercent, double yPercent)
        {
            try {
                ClickAnimation = OnClicked(button, mod, xPercent, yPercent);
            } catch (Exception e) {
                Log <AbstractDockItem> .Error(e.Message);

                Log <AbstractDockItem> .Debug(e.StackTrace);

                ClickAnimation = ClickAnimation.Darken;
            }

            LastClick = DateTime.UtcNow;
        }
 static Gtk.StockItem FromDef(string id,
                              string label,
                              uint keyval,
                              Gdk.ModifierType modifier,
                              string domain)
 {
     Gtk.StockItem item;
     item.StockId           = id;
     item.Label             = label;
     item.Keyval            = keyval;
     item.Modifier          = modifier;
     item.TranslationDomain = domain;
     return(item);
 }
示例#18
0
        protected override void OnScrolled(Gdk.ScrollDirection direction, Gdk.ModifierType mod)
        {
            int count = ManagedWindows.Count();

            if (count < 1 || (DateTime.UtcNow - last_scroll) < scroll_rate)
            {
                return;
            }

            last_scroll = DateTime.UtcNow;

            // This block will make sure that if we're scrolling on an app that is already active
            // that when we scroll we move on the next window instead of appearing to do nothing
            Wnck.Window focused = ManagedWindows.Where(w => w.IsActive).FirstOrDefault();
            if (focused != null)
            {
                for (; last_raised < count - 1; last_raised++)
                {
                    if (ManagedWindows.ElementAt(last_raised).Pid == focused.Pid)
                    {
                        break;
                    }
                }
            }

            switch (direction)
            {
            case ScrollDirection.Up:
            case ScrollDirection.Right:
                last_raised++;
                break;

            case ScrollDirection.Down:
            case ScrollDirection.Left:
                last_raised--;
                break;
            }

            if (last_raised < 0)
            {
                last_raised = count - 1;
            }
            else if (last_raised >= count)
            {
                last_raised = 0;
            }

            ManagedWindows.ElementAt(last_raised).CenterAndFocusWindow();
        }
示例#19
0
 public void ProcessKey(Gdk.ModifierType modifiers, Key key, char ch)
 {
     Context.Build(modifiers, key, ch);
     if (Context.Error != null)
     {
         Reset(Context.Error);
     }
     else if (Context.Action != null)
     {
         Context.Action(this);
         Reset("");
     }
     else
     {
         Message = Context.Message;
     }
 }
示例#20
0
        public void ProcessKey(Gdk.ModifierType modifiers, Key key, char ch)
        {
            if (Context == null)
            {
                Reset("");
            }

            Context.ProcessKey(key, ch, modifiers);
            if (Context.Completed)
            {
                Reset(Context.Message);
            }
            else
            {
                Message = Context.Message;
            }
        }
示例#21
0
 protected override ClickAnimation OnClicked(uint button, Gdk.ModifierType mod, double xPercent, double yPercent)
 {
     if (button == 1)
     {
         if (WeatherPreferences.Locations.Length == 0)
         {
             if (Config == null)
             {
                 Config = new WeatherConfigDialog();
             }
             Config.Show();
         }
         else
         {
             ShowPainter(painter);
         }
     }
     return(ClickAnimation.None);
 }
示例#22
0
        protected override ClickAnimation OnClicked(uint button, Gdk.ModifierType mod, double xPercent, double yPercent)
        {
            if (!AreMultipleDesksAvailable || DeskGrid == null)
            {
                return(ClickAnimation.None);
            }

            if (button == 1 && DeskGrid != null && DeskGrid.GetLength(0) > 0 && DeskGrid.GetLength(1) > 0)
            {
                int col = (int)(xPercent * DeskGrid.GetLength(0));
                int row = (int)(yPercent * DeskGrid.GetLength(1));
                if (DeskGrid [col, row] != null)
                {
                    DeskGrid [col, row].Activate();
                }
            }

            return(ClickAnimation.None);
        }
示例#23
0
        void Update(Gdk.Screen screen, int x, int y, Gdk.ModifierType mod)
        {
            last_update = DateTime.UtcNow;

            if (!Enabled)
            {
                return;
            }

            Gdk.Point lastPostion = Cursor;

            Cursor   = new Gdk.Point(x, y);
            Modifier = mod;
            Screen   = screen;

            if (lastPostion != Cursor)
            {
                OnCursorPositionChanged(lastPostion);
            }
        }
示例#24
0
        protected override void OnScrolled(Gdk.ScrollDirection direction, Gdk.ModifierType mod)
        {
            if (WeatherPreferences.Locations.Length <= 1)
            {
                return;
            }

            Status = WeatherDockletStatus.ManualReload;
            State |= ItemState.Wait;
            QueueRedraw();

            if (direction == Gdk.ScrollDirection.Up)
            {
                WeatherController.PreviousLocation();
            }
            else
            {
                WeatherController.NextLocation();
            }
        }
示例#25
0
        public void ReDraw(Gdk.ModifierType state)
        {
            Document doc = PintaCore.Workspace.ActiveDocument;

            doc.Selection.Visible = true;
            doc.ToolLayer.Hidden  = false;
            bool constraint = (state & Gdk.ModifierType.ShiftMask) == Gdk.ModifierType.ShiftMask;

            if (constraint)
            {
                double dx = Math.Abs(shape_end.X - shape_origin.X);
                double dy = Math.Abs(shape_end.Y - shape_origin.Y);
                if (dx <= dy)
                {
                    if (shape_end.X >= shape_origin.X)
                    {
                        shape_end.X = shape_origin.X + dy;
                    }
                    else
                    {
                        shape_end.X = shape_origin.X - dy;
                    }
                }
                else
                if (shape_end.Y >= shape_origin.Y)
                {
                    shape_end.Y = shape_origin.Y + dx;
                }
                else
                {
                    shape_end.Y = shape_origin.Y - dx;
                }
            }

            Cairo.Rectangle rect  = Utility.PointsToRectangle(shape_origin, shape_end, constraint);
            Cairo.Rectangle dirty = DrawShape(rect, doc.SelectionLayer);

            DrawHandler(doc.ToolLayer);

            last_dirty = dirty;
        }
示例#26
0
        protected override void OnScrolled(Gdk.ScrollDirection direction, Gdk.ModifierType mod)
        {
            if (!AreMultipleDesksAvailable || DeskGrid == null)
            {
                return;
            }

            switch (direction)
            {
            case ScrollDirection.Down:
                if (((mod & ModifierType.ShiftMask) == ModifierType.ShiftMask) || DeskGrid.GetLength(1) == 1)
                {
                    SwitchDesk(Wnck.MotionDirection.Right);
                }
                else
                {
                    SwitchDesk(Wnck.MotionDirection.Down);
                }
                break;

            case ScrollDirection.Right:
                SwitchDesk(Wnck.MotionDirection.Right);
                break;

            case ScrollDirection.Up:
                if (((mod & ModifierType.ShiftMask) == ModifierType.ShiftMask) || DeskGrid.GetLength(1) == 1)
                {
                    SwitchDesk(Wnck.MotionDirection.Left);
                }
                else
                {
                    SwitchDesk(Wnck.MotionDirection.Up);
                }
                break;

            case ScrollDirection.Left:
                SwitchDesk(Wnck.MotionDirection.Left);
                break;
            }
        }
示例#27
0
        protected override ClickAnimation OnClicked(uint button, Gdk.ModifierType mod, double xPercent, double yPercent)
        {
            if (button == 1)
            {
                string command = prefs.Get <string> ("DockyItemCommand", "");
                if (!string.IsNullOrEmpty(command))
                {
                    DockServices.System.Execute(command);
                }
                else if (ShowSettings)
                {
                    ConfigurationWindow.Instance.Show();
                }
                else
                {
                    return(ClickAnimation.None);
                }

                return(ClickAnimation.Bounce);
            }
            return(ClickAnimation.None);
        }
示例#28
0
        protected override void OnScrolled(Gdk.ScrollDirection direction, Gdk.ModifierType mod)
        {
            if (direction == Gdk.ScrollDirection.Up)
            {
                curPos++;
            }
            else
            {
                curPos--;
            }

            if (curPos < 1)
            {
                curPos = clips.Count;
            }
            else if (curPos > clips.Count)
            {
                curPos = 1;
            }

            Updated();
        }
示例#29
0
        public override void MouseDown(MouseEvent ev)
        {
            base.MouseDown(ev);
            IDrawingView view = ev.View;

            SetLastCoords(ev.X, ev.Y);

            Gdk.ModifierType state = (ev.GdkEvent as EventButton).State;

            bool shift_pressed = (state & ModifierType.ShiftMask) != 0;

            if (shift_pressed)
            {
                view.ToggleSelection(AnchorFigure);
            }

            else if (!view.IsFigureSelected(AnchorFigure))
            {
                view.ClearSelection();
                view.AddToSelection(AnchorFigure);
            }
            CreateUndoActivity();
        }
示例#30
0
        protected override void OnKeyDown(DrawingArea canvas, KeyPressEventArgs args)
        {
            if (!PintaCore.Workspace.HasOpenDocuments)
            {
                args.RetVal = false;
                return;
            }

            Gdk.ModifierType modifier = args.Event.State;

            // If we are dragging the text, we
            // aren't going to handle key presses
            if (tracking)
            {
                return;
            }

            // Ignore anything with Alt pressed
            if ((modifier & Gdk.ModifierType.Mod1Mask) != 0)
            {
                return;
            }

            ctrlKey = (args.Event.Key == Gdk.Key.Control_L || args.Event.Key == Gdk.Key.Control_R);
            UpdateMouseCursor();

            // Assume that we are going to handle the key
            bool keyHandled = true;

            if (is_editing)
            {
                switch (args.Event.Key)
                {
                case Gdk.Key.BackSpace:
                    CurrentTextEngine.PerformBackspace();
                    break;

                case Gdk.Key.Delete:
                    CurrentTextEngine.PerformDelete();
                    break;

                case Gdk.Key.KP_Enter:
                case Gdk.Key.Return:
                    CurrentTextEngine.PerformEnter();
                    break;

                case Gdk.Key.Left:
                    CurrentTextEngine.PerformLeft((modifier & Gdk.ModifierType.ControlMask) != 0, (modifier & Gdk.ModifierType.ShiftMask) != 0);
                    break;

                case Gdk.Key.Right:
                    CurrentTextEngine.PerformRight((modifier & Gdk.ModifierType.ControlMask) != 0, (modifier & Gdk.ModifierType.ShiftMask) != 0);
                    break;

                case Gdk.Key.Up:
                    CurrentTextEngine.PerformUp((modifier & Gdk.ModifierType.ShiftMask) != 0);
                    break;

                case Gdk.Key.Down:
                    CurrentTextEngine.PerformDown((modifier & Gdk.ModifierType.ShiftMask) != 0);
                    break;

                case Gdk.Key.Home:
                    CurrentTextEngine.PerformHome((modifier & Gdk.ModifierType.ControlMask) != 0, (modifier & Gdk.ModifierType.ShiftMask) != 0);
                    break;

                case Gdk.Key.End:
                    CurrentTextEngine.PerformEnd((modifier & Gdk.ModifierType.ControlMask) != 0, (modifier & Gdk.ModifierType.ShiftMask) != 0);
                    break;

                case Gdk.Key.Next:
                case Gdk.Key.Prior:
                    break;

                case Gdk.Key.Escape:
                    StopEditing(false);
                    return;

                case Gdk.Key.Insert:
                    if (modifier.IsShiftPressed())
                    {
                        Gtk.Clipboard cb = Gtk.Clipboard.Get(Gdk.Atom.Intern("CLIPBOARD", false));
                        CurrentTextEngine.PerformPaste(cb);
                    }
                    else if (modifier.IsControlPressed())
                    {
                        Gtk.Clipboard cb = Gtk.Clipboard.Get(Gdk.Atom.Intern("CLIPBOARD", false));
                        CurrentTextEngine.PerformCopy(cb);
                    }
                    break;

                default:
                    if (modifier.IsControlPressed())
                    {
                        if (args.Event.Key == Gdk.Key.z)
                        {
                            //Ctrl + Z for undo while editing.
                            TryHandleUndo();

                            if (PintaCore.Workspace.ActiveDocument.History.CanUndo)
                            {
                                PintaCore.Workspace.ActiveDocument.History.Undo();
                            }

                            return;
                        }
                        else if (args.Event.Key == Gdk.Key.i)
                        {
                            italic_btn.Toggle();
                            UpdateFont();
                        }
                        else if (args.Event.Key == Gdk.Key.b)
                        {
                            bold_btn.Toggle();
                            UpdateFont();
                        }
                        else if (args.Event.Key == Gdk.Key.u)
                        {
                            underscore_btn.Toggle();
                            UpdateFont();
                        }
                        else if (args.Event.Key == Gdk.Key.a)
                        {
                            // Select all of the text.
                            CurrentTextEngine.PerformHome(false, false);
                            CurrentTextEngine.PerformEnd(true, true);
                        }
                        else
                        {
                            //Ignore command shortcut.
                            return;
                        }
                    }
                    else
                    {
                        keyHandled = TryHandleChar(args.Event);
                    }

                    break;
                }

                // If we processed a key, update the display
                if (keyHandled)
                {
                    RedrawText(true, true);
                }
            }
            else
            {
                // If we're not editing, allow the key press to be handled elsewhere (e.g. for selecting another tool).
                keyHandled = false;
            }

            args.RetVal = keyHandled;
        }