public virtual Window ShowTooltipWindow(TextEditor editor, int offset, ModifierKeys modifierState, int mouseX, int mouseY, TooltipItem item)
        {
            Window tipWindow = CreateTooltipWindow(editor, offset, modifierState, item);

            if (tipWindow == null)
            {
                return(null);
            }

            double w;
            double xalign;

            GetRequiredPosition(editor, tipWindow, out w, out xalign);
            w += 10;

            var loc = editor.ConvertToScreenCoordinates(new Point(mouseX, mouseY));

            /*int x = mouseX + ox + editor.Allocation.X;
             * int y = mouseY + oy + editor.Allocation.Y;
             * Gdk.Rectangle geometry = editor.Screen.GetUsableMonitorGeometry (editor.Screen.GetMonitorAtPoint (x, y));
             */
            var geometry = editor.ScreenBounds;

            loc.X -= w * xalign;
            loc.Y += 10;

            if (loc.X + w >= geometry.X + geometry.Width)
            {
                loc.X = geometry.X + geometry.Width - w;
            }
            if (loc.X < geometry.Left)
            {
                loc.X = geometry.Left;
            }

            var h = tipWindow.Height;

            if (loc.Y + h >= geometry.Y + geometry.Height)
            {
                loc.Y = geometry.Y + geometry.Height - h;
            }
            if (loc.Y < geometry.Top)
            {
                loc.Y = geometry.Top;
            }

            tipWindow.Location = loc;

            tipWindow.Show();

            return(tipWindow);
        }
Exemplo n.º 2
0
        public virtual Xwt.Window ShowTooltipWindow(TextEditor editor, double offset, Xwt.ModifierKeys modifierState, Point mouse, TooltipItem item)
        {
            Xwt.Window tipWindow = CreateTooltipWindow(editor, offset, modifierState, item);
            if (tipWindow == null)
            {
                return(null);
            }

            var point = editor.ConvertToScreenCoordinates(mouse);

            double w;
            double xalign;

            GetRequiredPosition(editor, tipWindow, out w, out xalign);
            w += 10;

            Rectangle geometry = editor.ParentWindow.Screen.VisibleBounds;

            point.X -= (int)((double)w * xalign);
            point.Y += 10;

            if (point.X + w >= geometry.X + geometry.Width)
            {
                point.X = geometry.X + geometry.Width - w;
            }
            if (point.X < geometry.Left)
            {
                point.X = geometry.Left;
            }

            var h = tipWindow.Size.Height;

            if (point.Y + h >= geometry.Y + geometry.Height)
            {
                point.Y = geometry.Y + geometry.Height - h;
            }
            if (point.Y < geometry.Top)
            {
                point.Y = geometry.Top;
            }

            tipWindow.Location = point;

            tipWindow.Show();

            return(tipWindow);
        }