Esempio n. 1
0
        protected override bool OnMotionNotifyEvent(Gdk.EventMotion evnt)
        {
            int pointerX, pointerY;

            Gdk.ModifierType pointerMask;

            Gdk.Window window = GetWindow(TextWindowType.Text);
            window.GetPointer(out pointerX, out pointerY, out pointerMask);

            int x, y;

            this.WindowToBufferCoords(TextWindowType.Widget, pointerX, pointerY,
                                      out x, out y);

            TextIter iter     = GetIterAtLocation(x, y);
            bool     hovering = iter.HasTag(linkTag);

            if (hovering != hoveringOverLink)
            {
                hoveringOverLink = hovering;
                if (hoveringOverLink)
                {
                    window.Cursor = handCursor;
                }
                else
                {
                    window.Cursor = normalCursor;
                }
            }

            return(base.OnMotionNotifyEvent(evnt));
        }
        //This is effectively .NET 2.0's SelectionTypes.Auto
        //It duplicates VS.NET's selection behaviour
        public void SetSelectedComponents(System.Collections.ICollection components)
        {
            OnSelectionChanging();

            //use control and shift modifier to change selection
            //TODO: find a better way of checking key modifier status: this is BAD
            int  x, y;
            bool modified = false;

            Gdk.Window someWindow = Gdk.Window.AtPointer(out x, out y);
            if (someWindow != null)
            {
                Gdk.ModifierType mt;
                someWindow.GetPointer(out x, out y, out mt);
                modified = ((mt & Gdk.ModifierType.ShiftMask) == Gdk.ModifierType.ShiftMask) || ((mt & Gdk.ModifierType.ControlMask) == Gdk.ModifierType.ControlMask);
            }

            if (components == null || components.Count == 0)
            {
                selections.Clear();
                primary = null;
            }
            else
            {
                foreach (object comp in components)
                {
                    if (!(comp is IComponent))
                    {
                        throw new ArgumentException("All elements in collection must be components");
                    }

                    //what do we do with the component?
                    if (!selections.Contains(comp))
                    {
                        //a simple replacement
                        if (!modified)
                        {
                            selections.Clear();
                            selections.Add(comp);
                        }
                        //add to selection and make primary
                        else
                        {
                            selections.Add(comp);
                        }

                        primary = comp;
                    }
                    else
                    {
                        //only deselect or change selection if other components
                        //i.e. can't toggle selection status if is only component
                        if (selections.Count > 1)
                        {
                            //change primary selection
                            if (!modified)
                            {
                                primary = comp;
                            }
                            //remove and replace primary selection
                            else
                            {
                                selections.Remove(comp);
                                if (selections.Count > 0)
                                {
                                    primary = selections[selections.Count - 1];
                                }
                            }
                        }
                    }
                }
            }

            //fire event to let everyone know, especially PropertyGrid
            OnSelectionChanged();
        }