示例#1
0
        public XwtBoxTooltip(Widget child)
        {
            if (child == null)
            {
                throw new ArgumentNullException(nameof(child));
            }

            Content = child;
            // FIXME: WPF blocks the main Gtk loop and makes TooltipPopoverWindow unusable.
            //        We use the Xwt.Popover as a workaround for now.
            if (Surface.ToolkitEngine.Type == ToolkitType.Wpf)
            {
                xwtPopover = new Popover();
                xwtPopover.BackgroundColor = Styles.PopoverWindow.DefaultBackgroundColor;
                xwtPopover.Content         = new Label {
                    Wrap = WrapMode.Word
                };
                xwtPopover.Padding = 3;
            }
            else
            {
                tooltipWindow           = TooltipPopoverWindow.Create();
                tooltipWindow.ShowArrow = true;
            }
            Position = PopupPosition.Top;
            Severity = TaskSeverity.Information;
        }
示例#2
0
        private static void BeginPopupInAnimation(FrameworkElement element, PopupPosition popupPosition)
        {
            element.RenderTransformOrigin = new Point(0.5, 0.5);
            var translate = new TranslateTransform(0, popupPosition == PopupPosition.Top ? -20 : 20);

            element.RenderTransform = translate;


            var doubleAnimation = new DoubleAnimation()
            {
                To       = 1,
                Duration = TimeSpan.FromSeconds(0.2),
            };

            element.BeginAnimation(FrameworkElement.OpacityProperty, doubleAnimation);

            var translateAnimation = new DoubleAnimation()
            {
                To             = 0,
                Duration       = TimeSpan.FromSeconds(0.3),
                EasingFunction = new CubicEase()
                {
                    EasingMode = EasingMode.EaseOut
                },
            };

            translate.BeginAnimation(TranslateTransform.YProperty, translateAnimation);
        }
示例#3
0
        private EventHandler Form_Shown(PopupPosition popupPosition)
        {
            return((object sender, EventArgs e) =>
            {
                switch (popupPosition)
                {
                case PopupPosition.BottomRight:
                    ((Form)sender).Left = Screen.PrimaryScreen.WorkingArea.Location.X +
                                          Screen.PrimaryScreen.WorkingArea.Width - ((Form)sender).Width + 3;
                    ((Form)sender).Top = Screen.PrimaryScreen.WorkingArea.Location.Y +
                                         Screen.PrimaryScreen.WorkingArea.Height - ((Form)sender).Height;
                    break;

                case PopupPosition.TopRight:
                    ((Form)sender).Left = Screen.PrimaryScreen.WorkingArea.Location.X +
                                          Screen.PrimaryScreen.WorkingArea.Width - ((Form)sender).Width + 3;
                    ((Form)sender).Top = Screen.PrimaryScreen.WorkingArea.Location.Y + 3;
                    break;

                case PopupPosition.TopLeft:
                    ((Form)sender).Left = Screen.PrimaryScreen.WorkingArea.Location.X + 3;
                    ((Form)sender).Top = Screen.PrimaryScreen.WorkingArea.Location.Y + 3;
                    break;

                case PopupPosition.BottomLeft:
                    ((Form)sender).Left = Screen.PrimaryScreen.WorkingArea.Location.X + 3;
                    ((Form)sender).Top = Screen.PrimaryScreen.WorkingArea.Location.Y +
                                         Screen.PrimaryScreen.WorkingArea.Height - ((Form)sender).Height;
                    break;

                default:
                    throw new ArgumentException("Invalid Popup position.");
                }
            });
        }
示例#4
0
        public PopupBuilder Position(PopupPosition position)
        {
            switch (position)
            {
            case PopupPosition.TopLeft:
                this.Component.AppendHtmlAtribute("data-position", "top-left");
                break;

            case PopupPosition.TopCenter:
                this.Component.AppendHtmlAtribute("data-position", "top-center");
                break;

            case PopupPosition.TopRight:
                this.Component.AppendHtmlAtribute("data-position", "top-right");
                break;

            case PopupPosition.BottomLeft:
                this.Component.AppendHtmlAtribute("data-position", "bottom-left");
                break;

            case PopupPosition.BottomCenter:
                this.Component.AppendHtmlAtribute("data-position", "bottom-center");
                break;

            case PopupPosition.BottomRight:
                this.Component.AppendHtmlAtribute("data-position", "bottom-right");
                break;
            }
            return(this);
        }
示例#5
0
        public virtual void RenderShadow(Context context, Rectangle region, PopupPosition arrowPosition)
        {
            if (ShadowColor.Alpha <= 0)
            {
                return;
            }
            double r = CornerRadius;

            // if we proceed with r == 0 the .Arc below will throw anyway
            if (r <= 0)
            {
                return;
            }
            double x = region.X + 0.5, y = region.Y + 0.5, w = region.Width - 1, h = region.Height - 1;

            context.MoveTo(x + w, y + h - r);
            context.Arc(x + w - r, y + h - r, r, 0, 90);
            if (ShowArrow && (arrowPosition & PopupPosition.Bottom) != 0)
            {
                double apos = ArrowOffset;
                context.LineTo(x + apos + ArrowWidth / 2, y + h);
                context.RelLineTo(-ArrowWidth / 2, ArrowLength);
                context.RelLineTo(-ArrowWidth / 2, -ArrowLength);
            }
            context.Arc(x + r, y + h - r, r, 90, 180);
            context.SetColor(ShadowColor);
            context.SetLineWidth(1);
            context.Stroke();
        }
示例#6
0
 /// <summary>
 /// Renders the background and clips the context to the visible border.
 /// </summary>
 public virtual void RenderBackground(Context context, Rectangle region, PopupPosition arrowPosition)
 {
     SetBorderPath(context, region, arrowPosition);
     context.SetColor(BackgroundColor);
     context.FillPreserve();
     context.Clip();
 }
示例#7
0
 public void ShowPopup(Xwt.Rectangle onScreenArea, PopupPosition position)
 {
     this.parent          = IdeApp.Workbench.RootWindow;
     this.currentCaret    = new Rectangle((int)onScreenArea.X, (int)onScreenArea.Y, (int)onScreenArea.Width, (int)onScreenArea.Height);
     Theme.TargetPosition = position;
     targetWindowOrigin   = new Point((int)onScreenArea.X, (int)onScreenArea.Y);
     RepositionWindow();
 }
示例#8
0
        /**
         *
         */
        internal void DeterminePosition(PopupPosition placement, float popUpWidth, float popUpHeight,
                                        /*matrix:Matrix, */ Point registrationPoint, Rectangle bounds)
        {
            switch (placement)
            {
            case PopupPosition.Below:
                registrationPoint.X = 0;
                registrationPoint.Y = Height;
                break;

            case PopupPosition.Above:
                registrationPoint.X = 0;
                registrationPoint.Y = -popUpHeight;
                break;

            case PopupPosition.Left:
                registrationPoint.X = -popUpWidth;
                registrationPoint.Y = 0;
                break;

            case PopupPosition.Right:
                registrationPoint.X = Width;
                registrationPoint.Y = 0;
                break;

            case PopupPosition.Center:
                registrationPoint.X = (Width - popUpWidth) / 2;
                registrationPoint.Y = (Height - popUpHeight) / 2;
                break;

            case PopupPosition.TopLeft:
                // already 0,0
                break;
            }

            //var popUpAsDisplayObject = _popup as DisplayObject;

            /*Point globalTl = (Point) registrationPoint.Clone(); //matrix.transformPoint(registrationPoint);
             * registrationPoint.Y += popUpAsDisplayObject.Height;
             * Point globalBl = (Point) registrationPoint.Clone(); //matrix.transformPoint(registrationPoint);
             * registrationPoint.X += popUpAsDisplayObject.Width;
             * Point globalBr = (Point) registrationPoint.Clone(); //matrix.transformPoint(registrationPoint);
             * registrationPoint.Y -= popUpAsDisplayObject.Height;
             * Point globalTr = (Point) registrationPoint.Clone(); //matrix.transformPoint(registrationPoint);
             * registrationPoint.X -= popUpAsDisplayObject.Width;
             *
             * bounds.Left = Mathf.Min(globalTl.X, globalBl.X, globalBr.X, globalTr.X);
             * bounds.Right = Mathf.Max(globalTl.X, globalBl.X, globalBr.X, globalTr.X);
             * bounds.Top = Mathf.Min(globalTl.Y, globalBl.Y, globalBr.Y, globalTr.Y);
             * bounds.Bottom = Mathf.Max(globalTl.Y, globalBl.Y, globalBr.Y, globalTr.Y);*/

            var globalRegPoint = Parent.LocalToGlobal(registrationPoint);

            bounds.X      = globalRegPoint.X;
            bounds.Y      = globalRegPoint.Y;
            bounds.Width  = popUpWidth;
            bounds.Height = popUpHeight;
        }
示例#9
0
        internal void ShowPopup(Xwt.Widget widget, Xwt.Rectangle caret, PopupPosition position)
        {
            xwtParent            = widget;
            this.currentCaret    = new Gdk.Rectangle((int)caret.X, (int)caret.Y, (int)caret.Width, (int)caret.Height);
            Theme.TargetPosition = position;
            var pos = GtkUtil.GetSceenBounds(widget);

            targetWindowOrigin = new Point((int)pos.X, (int)pos.Y);
            RepositionWindow();
        }
 public void Draw(SpriteBatch spriteBach)
 {
     if (this.IsVisible)
     {
         if (this.owner.Rectangle.Top < 200 && this.owner.Rectangle.Left < 200)
         {
             this.position = PopupPosition.Bottom;
             this.backgroundRect = new Rectangle(this.owner.Rectangle.X + 100, this.owner.Rectangle.Y + 70, 150, 150);
         }
         else if (this.owner.Rectangle.Top < 200 && GlobalConstants.WINDOW_WIDTH - this.owner.Rectangle.Right < 200)
         {
             this.position = PopupPosition.Bottom;
             this.backgroundRect = new Rectangle(this.owner.Rectangle.X - 140, this.owner.Rectangle.Y + 70, 150, 150);
         }
         else if (GlobalConstants.WINDOW_HEIGHT - this.owner.Rectangle.Bottom < 200 && this.owner.Rectangle.Left < 200)
         {
             this.position = PopupPosition.Top;
             this.backgroundRect = new Rectangle(this.owner.Rectangle.X + 100, this.owner.Rectangle.Y - 170, 150, 150);
         }
         else if (GlobalConstants.WINDOW_HEIGHT - this.owner.Rectangle.Bottom < 200 && GlobalConstants.WINDOW_WIDTH - this.owner.Rectangle.Right < 200)
         {
             this.position = PopupPosition.Top;
             this.backgroundRect = new Rectangle(this.owner.Rectangle.X - 140, this.owner.Rectangle.Y - 170, 150, 150);
         }
         else if (GlobalConstants.WINDOW_WIDTH - this.owner.Rectangle.Right < 400 && this.owner.Rectangle.Top > 300 && this.owner.Rectangle.Top < 400)
         {
             this.backgroundRect = new Rectangle(this.owner.Rectangle.X - 170, this.owner.Rectangle.Y - 50, 150, 150);
             this.position = PopupPosition.Left;
         }
         else if (this.owner.Rectangle.Left < 300 && this.owner.Rectangle.Top > 300 && this.owner.Rectangle.Top < 600)
         {
             this.backgroundRect = new Rectangle(this.owner.Rectangle.X + 70, this.owner.Rectangle.Y - 50, 150, 150);
             this.position = PopupPosition.Right;
         }
         else if (this.owner.Rectangle.Top > 200)
         {
             this.position = PopupPosition.Top;
             this.backgroundRect = new Rectangle(this.owner.Rectangle.X - 50, this.owner.Rectangle.Y - 170, 150, 150);
         }
         else if (GlobalConstants.WINDOW_HEIGHT - this.owner.Rectangle.Bottom > 200)
         {
             this.position = PopupPosition.Bottom;
             this.backgroundRect = new Rectangle(this.owner.Rectangle.X - 50, this.owner.Rectangle.Y + 70, 150, 150);
         }
             
         Vector2 text = new Vector2(this.backgroundRect.X + 5,this.backgroundRect.Y + 15);
         spriteBach.Draw(this.Texture, this.backgroundRect, Color.White);
         foreach (var item in this.Messages)
         {
             spriteBach.DrawString(this.Font, item, text, Color.Red);
             text.Y += 20;
         }
     }
 }
示例#11
0
        static Popover.Position GetXwtPosition(PopupPosition position)
        {
            switch (position)
            {
            case PopupPosition.Bottom:
                return(Popover.Position.Bottom);

            default:
                return(Popover.Position.Top);
            }
        }
示例#12
0
        public void ShowPopup(Widget widget, Rectangle targetRectangle, PopupPosition position)
        {
            target         = widget;
            targetRect     = targetRectangle;
            targetPosition = position;
            TransientFor   = widget.ParentWindow;
            var pos = GtkUtil.GetSceenBounds(widget);

            targetWindowOrigin = new Point(pos.X, pos.Y);
            ShowPopupInternal();
        }
        void OnDisplayPopup(PopupPosition position)
        {
            var popup = new SimplePopup();

            switch (position)
            {
            case PopupPosition.TopLeft:
                popup.VerticalOptions   = new LayoutOptions(LayoutAlignment.Start, true);
                popup.HorizontalOptions = new LayoutOptions(LayoutAlignment.Start, true);
                break;

            case PopupPosition.Top:
                popup.VerticalOptions   = new LayoutOptions(LayoutAlignment.Start, true);
                popup.HorizontalOptions = new LayoutOptions(LayoutAlignment.Center, true);
                break;

            case PopupPosition.TopRight:
                popup.VerticalOptions   = new LayoutOptions(LayoutAlignment.Start, true);
                popup.HorizontalOptions = new LayoutOptions(LayoutAlignment.End, true);
                break;

            case PopupPosition.Left:
                popup.VerticalOptions   = new LayoutOptions(LayoutAlignment.Center, true);
                popup.HorizontalOptions = new LayoutOptions(LayoutAlignment.Start, true);
                break;

            case PopupPosition.Center:
                popup.VerticalOptions   = new LayoutOptions(LayoutAlignment.Center, true);
                popup.HorizontalOptions = new LayoutOptions(LayoutAlignment.Center, true);
                break;

            case PopupPosition.Right:
                popup.VerticalOptions   = new LayoutOptions(LayoutAlignment.Center, true);
                popup.HorizontalOptions = new LayoutOptions(LayoutAlignment.End, true);
                break;

            case PopupPosition.BottomLeft:
                popup.VerticalOptions   = new LayoutOptions(LayoutAlignment.End, true);
                popup.HorizontalOptions = new LayoutOptions(LayoutAlignment.Start, true);
                break;

            case PopupPosition.Bottom:
                popup.VerticalOptions   = new LayoutOptions(LayoutAlignment.End, true);
                popup.HorizontalOptions = new LayoutOptions(LayoutAlignment.Center, true);
                break;

            case PopupPosition.BottomRight:
                popup.VerticalOptions   = new LayoutOptions(LayoutAlignment.End, true);
                popup.HorizontalOptions = new LayoutOptions(LayoutAlignment.End, true);
                break;
            }

            Navigation.ShowPopup(popup);
        }
示例#14
0
 public virtual void RenderBorder(Context context, Rectangle region, PopupPosition arrowPosition)
 {
     if (BorderColor.Alpha <= 0)
     {
         return;
     }
     SetBorderPath(context, region, arrowPosition);
     context.SetColor(BorderColor);
     context.SetLineWidth(1);
     context.Stroke();
 }
示例#15
0
 public void ShowPopup(Rectangle onScreenArea, PopupPosition position)
 {
     target         = IdeApp.Workbench.RootWindow;
     targetRect     = onScreenArea;
     targetPosition = position;
     if (MessageDialog.RootWindow != null)
     {
         TransientFor = MessageDialog.RootWindow;
     }
     targetWindowOrigin = new Point(onScreenArea.X, onScreenArea.Y);
     ShowPopupInternal();
 }
示例#16
0
        /// <summary>
        /// HtmlPopupクラスのインスタンスを初期化
        /// </summary>
        /// <param name="wb">オーナーのIEComponentThreadViewer</param>
        public HtmlPopup(IEComponentThreadViewer wb)
        {
            //
            // TODO: コンストラクタ ロジックをここに追加してください。
            //
            this.iectv = wb;
            this.Font  = new Font("MS Pゴシック", 9);

            position      = PopupPosition.TopRight;
            maximum       = new Size(500, 350);
            imageSize     = new Size(200, 0);
            foreColorHtml = "#000000";
            backColorHtml = "#ffffff";
            width         = height = 0;
        }
示例#17
0
        private void ShowPopup(AppKit.NSView widget, Rectangle targetRectangle, PopupPosition position)
        {
            target         = widget;
            targetRect     = targetRectangle;
            targetPosition = position;
            try {
                TransientFor = Toolkit.Load(Xwt.ToolkitType.XamMac)?.WrapWindow(widget.Window);
            } catch {
                if (MessageDialog.RootWindow != null)
                {
                    TransientFor = MessageDialog.RootWindow;
                }
            }
            var pos = GtkUtil.GetSceenBounds(widget);

            targetWindowOrigin = new Point(pos.X, pos.Y);
            ShowPopupInternal();
        }
        void ShowPopup(Gtk.Widget parent, Gdk.EventButton evt, Gdk.Rectangle caret, PopupPosition position)
        {
            this.parent          = parent;
            this.currentCaret    = caret;
            Theme.TargetPosition = position;

            if (evt != null)
            {
                eventProvided = true;
                targetWindow  = evt.Window;
            }
            else
            {
                targetWindow = parent.GdkWindow;
            }

            RepositionWindow();
        }
示例#19
0
 public void ShowPopup(Control widget, Rectangle targetRectangle, PopupPosition position)
 {
     if (widget is XwtControl)
     {
         ShowPopup(((XwtControl)widget).Widget, targetRectangle, position);
     }
     if (widget.nativeWidget is Gtk.Widget)
     {
         ShowPopup(widget.GetNativeWidget <Gtk.Widget> (), null, targetRectangle.ToGdkRectangle(), position);
     }
                 #if MAC
     else if (widget.nativeWidget is AppKit.NSView)
     {
         ShowPopup(widget.GetNativeWidget <AppKit.NSView> (), targetRectangle, position);
     }
                 #endif
     else
     {
         throw new NotSupportedException("The control is not supported");
     }
 }
示例#20
0
        void ShowPopup(Gtk.Widget parent, Gdk.EventButton evt, Gdk.Rectangle targetRectangle, PopupPosition position)
        {
            target         = parent;
            targetRect     = targetRectangle.ToXwtRectangle();
            targetPosition = position;
            Gdk.Window targetWindow;
            if (evt != null)
            {
                eventProvided = true;
                targetWindow  = evt.Window;
            }
            else
            {
                targetWindow = parent.GdkWindow;
            }

            if (targetWindow != null)
            {
                int x, y;
                targetWindow.GetOrigin(out x, out y);
                targetWindowOrigin = new Point(x, y);
            }
            Gtk.Window parentWindow = parent.Toplevel as Gtk.Window;
            if (parentWindow != null)
            {
                try {
                    TransientFor = Toolkit.Load(ToolkitType.Gtk).WrapWindow(parentWindow);
                } catch {
                    if (MessageDialog.RootWindow != null)
                    {
                        TransientFor = MessageDialog.RootWindow;
                    }
                }
            }
            else if (MessageDialog.RootWindow != null)
            {
                TransientFor = MessageDialog.RootWindow;
            }
            ShowPopupInternal();
        }
示例#21
0
        void ShowPopup(Gtk.Widget parent, Gdk.EventButton evt, Gdk.Rectangle caret, PopupPosition position)
        {
            this.parent          = parent;
            this.currentCaret    = caret;
            Theme.TargetPosition = position;
            Gdk.Window targetWindow;
            if (evt != null)
            {
                eventProvided = true;
                targetWindow  = evt.Window;
            }
            else
            {
                targetWindow = parent.GdkWindow;
            }

            if (targetWindow != null)
            {
                int x, y;
                targetWindow.GetOrigin(out x, out y);
                targetWindowOrigin = new Point(x, y);
            }
            RepositionWindow();
        }
示例#22
0
		public void ShowPopup (Gtk.Widget widget, Gdk.EventButton evt, PopupPosition position)
		{
			ShowPopup (widget, evt, Gdk.Rectangle.Zero, position);
		}
示例#23
0
        public virtual void RenderShadow(Cairo.Context context, Gdk.Rectangle region, PopupPosition arrowPosition)
        {
            RenderBorder(context, region, arrowPosition);
            double r = CornerRadius;
            double x = region.X + 0.5, y = region.Y + 0.5, w = region.Width - 1, h = region.Height - 1;

            context.MoveTo(x + w, y + h - r);
            context.Arc(x + w - r, y + h - r, r, 0, Math.PI * 0.5);
            if (ShowArrow && (arrowPosition & PopupPosition.Bottom) != 0)
            {
                double apos = ArrowOffset;
                context.LineTo(x + apos + ArrowWidth / 2, y + h);
                context.RelLineTo(-ArrowWidth / 2, ArrowLength);
                context.RelLineTo(-ArrowWidth / 2, -ArrowLength);
            }
            context.Arc(x + r, y + h - r, r, Math.PI * 0.5, Math.PI);

            // FIXME: VV: Remove gradient features
            using (var lg = new Cairo.LinearGradient(0, y + h - r, 0, y + h)) {
                lg.AddColorStop(0.5, ShadowColor.MultiplyAlpha(0.0));
                lg.AddColorStop(1, ShadowColor);
                context.SetSource(lg);
                context.LineWidth = 1;
                context.Stroke();
            }
        }
示例#24
0
 public virtual void RenderBorder(Cairo.Context context, Gdk.Rectangle region, PopupPosition arrowPosition)
 {
     SetBorderPath(context, region, arrowPosition);
     context.SetSourceColor(BackgroundColor);
     context.LineWidth = 1;
     context.Stroke();
 }
示例#25
0
        public override void RepositionWindow(Rectangle?newTargetRect = default(Rectangle?))
        {
            if (!HasParent)
            {
                return;
            }

            if (newTargetRect.HasValue)             //Update caret if parameter is given
            {
                TargetRectangle = newTargetRect.Value;
            }

            Rectangle     currentRect = TargetRectangle;
            PopupPosition position    = TargetPosition;

            CurrentPosition = TargetPosition;

            var psize = GetParentSize();

            if (EventProvided)
            {
                currentRect.X     = TargetWindowOrigin.X;
                currentRect.Y     = TargetWindowOrigin.Y;
                currentRect.Width = currentRect.Height = 1;
            }
            else
            {
                if (currentRect.IsEmpty)
                {
                    currentRect = new Rectangle(0, 0, psize.Width, psize.Height);
                }
                currentRect = GetScreenCoordinates(currentRect);
            }

            currentRect.Inflate(RectOffset, RectOffset);
            if (!Core.Platform.IsWindows)
            {
                currentRect.Inflate(-1, -1);
            }

            var request = container.Surface.GetPreferredSize(true) + new Size(Padding.HorizontalSpacing, Padding.VerticalSpacing);

            Rectangle geometry = GetUsableMonitorGeometry(currentRect);

            if (!geometry.IsEmpty)
            {
                //  // Add some spacing between the screen border and the popover window
                geometry = geometry.Inflate(-5, -5);

                // Flip the orientation if the window doesn't fit the screen.

                int intPos = (int)position;
                switch ((PopupPosition)(intPos & 0x0f))
                {
                case PopupPosition.Top:
                    if (currentRect.Bottom + request.Height > geometry.Bottom)
                    {
                        intPos = (intPos & 0xf0) | (int)PopupPosition.Bottom;
                    }
                    break;

                case PopupPosition.Bottom:
                    if (currentRect.Top - request.Height < geometry.X)
                    {
                        intPos = (intPos & 0xf0) | (int)PopupPosition.Top;
                    }
                    break;

                case PopupPosition.Right:
                    if (currentRect.X - request.Width < geometry.X)
                    {
                        intPos = (intPos & 0xf0) | (int)PopupPosition.Left;
                    }
                    break;

                case PopupPosition.Left:
                    if (currentRect.Right + request.Width > geometry.Right)
                    {
                        intPos = (intPos & 0xf0) | (int)PopupPosition.Right;
                    }
                    break;
                }

                position = (PopupPosition)intPos;
            }

            CurrentPosition = position;

            // Calculate base coordinate
            double x = 0, y = 0;

            switch ((PopupPosition)((int)position & 0x0f))
            {
            case PopupPosition.Top:
                y = currentRect.Bottom + 1;
                break;

            case PopupPosition.Bottom:
                y = currentRect.Y - request.Height; break;

            case PopupPosition.Right:
                x = currentRect.X - request.Width; break;

            case PopupPosition.Left:
                x = currentRect.Right + 1; break;
            }
            double offset;

            if ((position & PopupPosition.Top) != 0 || (position & PopupPosition.Bottom) != 0)
            {
                if (((int)position & 0x10) != 0)
                {
                    x = currentRect.X - MinArrowSpacing - Theme.ArrowWidth / 2;
                }
                else if (((int)position & 0x20) != 0)
                {
                    x = currentRect.Right - request.Width + MinArrowSpacing + Theme.ArrowWidth / 2;
                }
                else
                {
                    x = currentRect.X + (currentRect.Width - request.Width) / 2;
                }

                if (x < geometry.Left)
                {
                    x = geometry.Left;
                }
                else if (x + request.Width > geometry.Right)
                {
                    x = geometry.Right - request.Width;
                }

                offset = currentRect.X + currentRect.Width / 2 - x;
                if (offset - Theme.ArrowWidth / 2 < MinArrowSpacing)
                {
                    offset = MinArrowSpacing + Theme.ArrowWidth / 2;
                }
                if (offset > request.Width - MinArrowSpacing - Theme.ArrowWidth / 2)
                {
                    offset = request.Width - MinArrowSpacing - Theme.ArrowWidth / 2;
                }
            }
            else
            {
                if (((int)position & 0x10) != 0)
                {
                    y = currentRect.Y - MinArrowSpacing - Theme.ArrowWidth / 2;
                }
                else if (((int)position & 0x20) != 0)
                {
                    y = currentRect.Bottom - request.Height + MinArrowSpacing + Theme.ArrowWidth / 2;
                }
                else
                {
                    y = currentRect.Y + (currentRect.Height - request.Height) / 2;
                }

                if (y < geometry.Top)
                {
                    y = geometry.Top;
                }
                else if (y + request.Height > geometry.Bottom)
                {
                    y = geometry.Bottom - request.Height;
                }
                if (MaximumYTopBound > 0)
                {
                    y = Math.Max(MaximumYTopBound, y);
                }

                offset = currentRect.Y + currentRect.Height / 2 - y;
                if (offset - Theme.ArrowWidth / 2 < MinArrowSpacing)
                {
                    offset = MinArrowSpacing + Theme.ArrowWidth / 2;
                }
                if (offset > request.Height - MinArrowSpacing - Theme.ArrowWidth / 2)
                {
                    offset = request.Height - MinArrowSpacing - Theme.ArrowWidth / 2;
                }
            }
            Theme.ArrowOffset = (int)offset;

            Location = new Point(x, y);
        }
 public void ShowPopup(Gtk.Widget widget, Gdk.EventButton evt, PopupPosition position)
 {
     ShowPopup(widget, evt, Gdk.Rectangle.Zero, position);
 }
示例#27
0
        public virtual bool SetBorderPath(Context context, Rectangle region, PopupPosition arrowPosition)
        {
            double r = CornerRadius;

            if (ShowArrow)
            {
                double apos = ArrowOffset;
                double x = region.X + 0.5, y = region.Y + 0.5, w = region.Width - 1, h = region.Height - 1;

                context.MoveTo(x + r, y);
                if ((arrowPosition & PopupPosition.Top) != 0)
                {
                    context.LineTo(x + apos - ArrowWidth / 2, y);
                    context.RelLineTo(ArrowWidth / 2, -ArrowLength);
                    context.RelLineTo(ArrowWidth / 2, ArrowLength);
                }
                context.LineTo(x + w - r, y);
                context.Arc(x + w - r, y + r, r, -90, 0);
                if ((arrowPosition & PopupPosition.Right) != 0)
                {
                    context.LineTo(x + w, y + apos - ArrowWidth / 2);
                    context.RelLineTo(ArrowLength, ArrowWidth / 2);
                    context.RelLineTo(-ArrowLength, ArrowWidth / 2);
                }
                context.LineTo(x + w, y + h - r);
                context.Arc(x + w - r, y + h - r, r, 0, 90);
                if ((arrowPosition & PopupPosition.Bottom) != 0)
                {
                    context.LineTo(x + apos + ArrowWidth / 2, y + h);
                    context.RelLineTo(-ArrowWidth / 2, ArrowLength);
                    context.RelLineTo(-ArrowWidth / 2, -ArrowLength);
                }
                context.LineTo(x + r, y + h);
                context.Arc(x + r, y + h - r, r, 90, 180);
                if ((arrowPosition & PopupPosition.Left) != 0)
                {
                    context.LineTo(x, y + apos + ArrowWidth / 2);
                    context.RelLineTo(-ArrowLength, -ArrowWidth / 2);
                    context.RelLineTo(ArrowLength, -ArrowWidth / 2);
                }
                context.LineTo(x, y + r);
                context.Arc(x + r, y + r, r, 180, 270);
            }
            else
            {
                context.RoundRectangle(region.X + 0.5, region.Y + 0.5, region.Width - 1, region.Height - 1, r);
            }

            var args = new {
                Region       = region,
                ArrowPostion = arrowPosition,
                ArrowWidth   = this.ArrowWidth,
                ArrowLength  = this.arrowLength,
                ArrowOffset  = this.ArrowOffset,
            };

            bool result = setBorderPathLastArgs == null ? true : setBorderPathLastArgs.Equals(args);

            setBorderPathLastArgs = args;
            return(result);
        }
示例#28
0
		public void RepositionWindow ()
		{
			if (parent == null)
				return;

			int x, y;
			Gdk.Rectangle caret = currentCaret;
			Gdk.Window window = targetWindow;
			if (targetWindow == null)
				return;
			PopupPosition position = Theme.TargetPosition;
			this.position = Theme.TargetPosition;
			UpdatePadding ();

			window.GetOrigin (out x, out y);
			var alloc = parent.Allocation;

			if (eventProvided) {
				caret.X = x;
				caret.Y = y;
				caret.Width = caret.Height = 1;
			} else {
				if (caret.Equals (Gdk.Rectangle.Zero))
					caret = new Gdk.Rectangle (0, 0, alloc.Width, alloc.Height);
				caret = GtkUtil.ToScreenCoordinates (parent, parent.GdkWindow, caret);
			}

			Gtk.Requisition request = SizeRequest ();
			var screen = parent.Screen;
			Gdk.Rectangle geometry = GtkWorkarounds.GetUsableMonitorGeometry (screen, screen.GetMonitorAtPoint (x, y));

			// Flip the orientation if the window doesn't fit the screen.

			int intPos = (int) position;
			switch ((PopupPosition)(intPos & 0x0f)) {
			case PopupPosition.Top:
				if (caret.Bottom + request.Height > geometry.Bottom)
					intPos = (intPos & 0xf0) | (int)PopupPosition.Bottom;
				break;
			case PopupPosition.Bottom:
				if (caret.Top - request.Height < geometry.X)
					intPos = (intPos & 0xf0) | (int)PopupPosition.Top;
				break;
			case PopupPosition.Right:
				if (caret.X - request.Width < geometry.X)
					intPos = (intPos & 0xf0) | (int)PopupPosition.Left;
				break;
			case PopupPosition.Left:
				if (caret.Right + request.Width > geometry.Right)
					intPos = (intPos & 0xf0) | (int)PopupPosition.Right;
				break;
			}

			position = (PopupPosition) intPos;
			UpdatePadding ();

			// Calculate base coordinate

			switch ((PopupPosition)((int)position & 0x0f)) {
			case PopupPosition.Top:
				y = caret.Bottom;
				break;
			case PopupPosition.Bottom:
				y = caret.Y - request.Height; break;
			case PopupPosition.Right:
				x = caret.X - request.Width; break;
			case PopupPosition.Left:
				x = caret.Right; break;
			}
			int offset;
			if ((position & PopupPosition.Top) != 0 || (position & PopupPosition.Bottom) != 0) {
				if (((int)position & 0x10) != 0)
					x = caret.X - MinArrowSpacing - Theme.ArrowWidth/2;
				else if (((int)position & 0x20) != 0)
					x = caret.Right - request.Width + MinArrowSpacing + Theme.ArrowWidth/2;
				else
					x = caret.X + (caret.Width - request.Width) / 2;

				if (x < geometry.Left)
					x = geometry.Left;
				else if (x + request.Width > geometry.Right)
					x = geometry.Right - request.Width;

				offset = caret.X + caret.Width / 2 - x;
				if (offset - Theme.ArrowWidth/2 < MinArrowSpacing)
					offset = MinArrowSpacing + Theme.ArrowWidth/2;
				if (offset > request.Width - MinArrowSpacing - Theme.ArrowWidth/2)
					offset = request.Width - MinArrowSpacing - Theme.ArrowWidth/2;
			}
			else {
				if (((int)position & 0x10) != 0)
					y = caret.Y - MinArrowSpacing - Theme.ArrowWidth/2;
				else if (((int)position & 0x20) != 0)
					y = caret.Bottom - request.Height + MinArrowSpacing + Theme.ArrowWidth/2;
				else
					y = caret.Y + (caret.Height - request.Height) / 2;

				if (y < geometry.Top)
					y = geometry.Top;
				else if (y + request.Height > geometry.Bottom)
					y = geometry.Bottom - request.Height;
				if (MaximumYTopBound > 0)
					y = Math.Max (MaximumYTopBound, y);

				offset = caret.Y + caret.Height / 2 - y;
				if (offset - Theme.ArrowWidth/2 < MinArrowSpacing)
					offset = MinArrowSpacing + Theme.ArrowWidth/2;
				if (offset > request.Height - MinArrowSpacing - Theme.ArrowWidth/2)
					offset = request.Height - MinArrowSpacing - Theme.ArrowWidth/2;
			}
			Theme.ArrowOffset = offset;
			this.position = position;
			UpdatePadding ();

			Move (x, y);
			Show ();
			if (!ShowWindowShadow)
				DesktopService.RemoveWindowShadow (this);
		}
示例#29
0
		void ShowPopup (Gtk.Widget parent, Gdk.EventButton evt, Gdk.Rectangle caret, PopupPosition position)
		{
			this.parent = parent;
			this.currentCaret = caret;
			Theme.TargetPosition = position;
			Gdk.Window targetWindow;
			if (evt != null) {
				eventProvided = true;
				targetWindow = evt.Window;
			} else
				targetWindow = parent.GdkWindow;
			
			if (targetWindow != null) {
				int x, y;
				targetWindow.GetOrigin (out x, out y);
				targetWindowOrigin = new Point (x, y);
			}
			RepositionWindow ();
		}
示例#30
0
 public XwtPopup(PopupType type) : base(type)
 {
     currentPosition = targetPosition = PopupPosition.Top;
 }
示例#31
0
        public virtual void RepositionWindow(Rectangle?newTargetRect = null)
        {
            if (!HasParent)
            {
                return;
            }

            if (newTargetRect.HasValue)
            {
                targetRect = newTargetRect.Value;
            }

            Rectangle currentRect = targetRect;

            if (targetWindowOrigin.X < 0)
            {
                return;
            }
            var           x        = targetWindowOrigin.X;
            var           y        = targetWindowOrigin.Y;
            PopupPosition position = targetPosition;

            CurrentPosition = targetPosition;

            var psize = GetParentSize();

            if (eventProvided)
            {
                currentRect.X     = x;
                currentRect.Y     = y;
                currentRect.Width = currentRect.Height = 1;
            }
            else
            {
                if (currentRect.IsEmpty)
                {
                    currentRect = new Rectangle(0, 0, psize.Width, psize.Height);
                }
                currentRect = GetScreenCoordinates(currentRect);
            }

            currentRect.Inflate(RectOffset, RectOffset);
            if (!Core.Platform.IsWindows)
            {
                currentRect.Inflate(-1, -1);
            }

            var request = Content.Surface.GetPreferredSize(true) + new Size(Padding.HorizontalSpacing, Padding.VerticalSpacing);;

            Rectangle geometry = GetUsableMonitorGeometry(currentRect);

            if (!geometry.IsEmpty)
            {
                // Add some spacing between the screen border and the popover window
                geometry = geometry.Inflate(-5, -5);

                // Flip the orientation if the window doesn't fit the screen.

                int intPos = (int)position;
                switch ((PopupPosition)(intPos & 0x0f))
                {
                case PopupPosition.Top:
                    if (currentRect.Bottom + request.Height > geometry.Bottom)
                    {
                        intPos = (intPos & 0xf0) | (int)PopupPosition.Bottom;
                    }
                    break;

                case PopupPosition.Bottom:
                    if (currentRect.Top - request.Height < geometry.X)
                    {
                        intPos = (intPos & 0xf0) | (int)PopupPosition.Top;
                    }
                    break;

                case PopupPosition.Right:
                    if (currentRect.X - request.Width < geometry.X)
                    {
                        intPos = (intPos & 0xf0) | (int)PopupPosition.Left;
                    }
                    break;

                case PopupPosition.Left:
                    if (currentRect.Right + request.Width > geometry.Right)
                    {
                        intPos = (intPos & 0xf0) | (int)PopupPosition.Right;
                    }
                    break;
                }

                position = (PopupPosition)intPos;
            }

            CurrentPosition = position;

            // Calculate base coordinate

            switch ((PopupPosition)((int)position & 0x0f))
            {
            case PopupPosition.Top:
                y = currentRect.Bottom + 1;
                break;

            case PopupPosition.Bottom:
                y = currentRect.Y - request.Height; break;

            case PopupPosition.Right:
                x = currentRect.X - request.Width; break;

            case PopupPosition.Left:
                x = currentRect.Right + 1; break;
            }

            if ((position & PopupPosition.Top) != 0 || (position & PopupPosition.Bottom) != 0)
            {
                if (((int)position & 0x10) != 0)
                {
                    x = currentRect.X;
                }
                else if (((int)position & 0x20) != 0)
                {
                    x = currentRect.Right - request.Width;
                }
                else
                {
                    x = currentRect.X + (currentRect.Width - request.Width) / 2;
                }

                if (x < geometry.Left)
                {
                    x = geometry.Left;
                }
                else if (x + request.Width > geometry.Right)
                {
                    x = geometry.Right - request.Width;
                }
            }
            else
            {
                if (((int)position & 0x10) != 0)
                {
                    y = currentRect.Y;
                }
                else if (((int)position & 0x20) != 0)
                {
                    y = currentRect.Bottom - request.Height;
                }
                else
                {
                    y = currentRect.Y + (currentRect.Height - request.Height) / 2;
                }

                if (y < geometry.Top)
                {
                    y = geometry.Top;
                }
                else if (y + request.Height > geometry.Bottom)
                {
                    y = geometry.Bottom - request.Height;
                }
                if (MaximumYTopBound > 0)
                {
                    y = Math.Max(MaximumYTopBound, y);
                }
            }

            Location = new Point(x, y);
        }
示例#32
0
		public XwtBoxTooltip (Widget child)
		{
			if (child == null)
				throw new ArgumentNullException (nameof (child));
			
			Content = child;
			// FIXME: WPF blocks the main Gtk loop and makes TooltipPopoverWindow unusable.
			//        We use the Xwt.Popover as a workaround for now.
			if (Surface.ToolkitEngine.Type == ToolkitType.Wpf) {
				xwtPopover = new Popover ();
				xwtPopover.BackgroundColor = Styles.PopoverWindow.DefaultBackgroundColor;
				xwtPopover.Content = new Label { Wrap = WrapMode.Word };
				xwtPopover.Padding = 3;
			} else {
				tooltipWindow = new TooltipPopoverWindow ();
				tooltipWindow.ShowArrow = true;
			}
			Position = PopupPosition.Top;
			Severity = TaskSeverity.Information;
		}
示例#33
0
		public void ShowPopup (Xwt.Rectangle onScreenArea, PopupPosition position)
		{
			this.parent = IdeApp.Workbench.RootWindow;
			this.currentCaret = new Rectangle ((int)onScreenArea.X, (int)onScreenArea.Y, (int)onScreenArea.Width, (int)onScreenArea.Height);
			Theme.TargetPosition = position;
			targetWindowOrigin = new Point ((int)onScreenArea.X, (int)onScreenArea.Y);
			RepositionWindow ();
		}
示例#34
0
		public void ShowPopup (Gtk.Widget widget, Gdk.Rectangle caret, PopupPosition position)
		{
			ShowPopup (widget, null, caret, position);
		}
示例#35
0
		void ShowPopup (Gtk.Widget parent, Gdk.EventButton evt, Gdk.Rectangle caret, PopupPosition position)
		{
			this.parent = parent;
			this.currentCaret = caret;
			Theme.TargetPosition = position;

			if (evt != null) {
				eventProvided = true;
				targetWindow = evt.Window;
			} else
				targetWindow = parent.GdkWindow;

			RepositionWindow ();
		}
示例#36
0
 /// <summary>
 /// Sets the position.
 /// </summary>
 /// <param name="position">The position.</param>
 /// <returns>PopupBuilder.</returns>
 public PopupBuilder SetPosition(PopupPosition position)
 {
     _position = position;
     return this;
 }
示例#37
0
		public virtual void RepositionWindow (Gdk.Rectangle? newCaret = null)
		{
			if (!HasParent)
				return;

			if (newCaret.HasValue) {//Update caret if parameter is given
				currentCaret = newCaret.Value;
			}
			Gdk.Rectangle caret = currentCaret;
			if (targetWindowOrigin.X < 0)
				return;
			int x = targetWindowOrigin.X;
			int y = targetWindowOrigin.Y;
			PopupPosition position = Theme.TargetPosition;
			this.position = Theme.TargetPosition;
			UpdatePadding ();

			var psize = GetParentSize ();

			if (eventProvided) {
				caret.X = x;
				caret.Y = y;
				caret.Width = caret.Height = 1;
			} else {
				if (caret.Equals (Gdk.Rectangle.Zero))
					caret = new Gdk.Rectangle (0, 0, psize.Width, psize.Height);
				caret = GetScreenCoordinates (caret);
			}

			caret.Inflate (CaretSpacing, CaretSpacing);
			if (!Core.Platform.IsWindows)
				caret.Inflate (-1, -1);

			Gtk.Requisition request = SizeRequest ();
			Gdk.Rectangle geometry = GetUsableMonitorGeometry (caret);

			// Add some spacing between the screen border and the popover window
			geometry.Inflate (-5, -5);

			// Flip the orientation if the window doesn't fit the screen.

			int intPos = (int) position;
			switch ((PopupPosition)(intPos & 0x0f)) {
			case PopupPosition.Top:
				if (caret.Bottom + request.Height > geometry.Bottom)
					intPos = (intPos & 0xf0) | (int)PopupPosition.Bottom;
				break;
			case PopupPosition.Bottom:
				if (caret.Top - request.Height < geometry.X)
					intPos = (intPos & 0xf0) | (int)PopupPosition.Top;
				break;
			case PopupPosition.Right:
				if (caret.X - request.Width < geometry.X)
					intPos = (intPos & 0xf0) | (int)PopupPosition.Left;
				break;
			case PopupPosition.Left:
				if (caret.Right + request.Width > geometry.Right)
					intPos = (intPos & 0xf0) | (int)PopupPosition.Right;
				break;
			}

			position = (PopupPosition) intPos;
			UpdatePadding ();

			// Calculate base coordinate

			switch ((PopupPosition)((int)position & 0x0f)) {
			case PopupPosition.Top:
				y = caret.Bottom + 1;
				break;
			case PopupPosition.Bottom:
				y = caret.Y - request.Height; break;
			case PopupPosition.Right:
				x = caret.X - request.Width; break;
			case PopupPosition.Left:
				x = caret.Right + 1; break;
			}
			int offset;
			if ((position & PopupPosition.Top) != 0 || (position & PopupPosition.Bottom) != 0) {
				if (((int)position & 0x10) != 0)
					x = caret.X - MinArrowSpacing - Theme.ArrowWidth/2;
				else if (((int)position & 0x20) != 0)
					x = caret.Right - request.Width + MinArrowSpacing + Theme.ArrowWidth/2;
				else
					x = caret.X + (caret.Width - request.Width) / 2;

				if (x < geometry.Left)
					x = geometry.Left;
				else if (x + request.Width > geometry.Right)
					x = geometry.Right - request.Width;

				offset = caret.X + caret.Width / 2 - x;
				if (offset - Theme.ArrowWidth/2 < MinArrowSpacing)
					offset = MinArrowSpacing + Theme.ArrowWidth/2;
				if (offset > request.Width - MinArrowSpacing - Theme.ArrowWidth/2)
					offset = request.Width - MinArrowSpacing - Theme.ArrowWidth/2;
			}
			else {
				if (((int)position & 0x10) != 0)
					y = caret.Y - MinArrowSpacing - Theme.ArrowWidth/2;
				else if (((int)position & 0x20) != 0)
					y = caret.Bottom - request.Height + MinArrowSpacing + Theme.ArrowWidth/2;
				else
					y = caret.Y + (caret.Height - request.Height) / 2;

				if (y < geometry.Top)
					y = geometry.Top;
				else if (y + request.Height > geometry.Bottom)
					y = geometry.Bottom - request.Height;
				if (MaximumYTopBound > 0)
					y = Math.Max (MaximumYTopBound, y);

				offset = caret.Y + caret.Height / 2 - y;
				if (offset - Theme.ArrowWidth/2 < MinArrowSpacing)
					offset = MinArrowSpacing + Theme.ArrowWidth/2;
				if (offset > request.Height - MinArrowSpacing - Theme.ArrowWidth/2)
					offset = request.Height - MinArrowSpacing - Theme.ArrowWidth/2;
			}
			Theme.ArrowOffset = offset;
			this.position = position;
			UpdatePadding ();

			Move (x, y);
			Show ();
			if (!ShowWindowShadow)
				DesktopService.RemoveWindowShadow (this);
		}
示例#38
0
 protected override void LoadControlState(object savedState)
 {
     Color = (string)(savedState as object[])[0];
     AutoPostBack = (bool)(savedState as object[])[1];
     PopupPosition = (PopupPosition)(savedState as object[])[2];
 }
示例#39
0
		internal void ShowPopup (Xwt.Widget widget, Xwt.Rectangle caret, PopupPosition position)
		{
			xwtParent = widget;
			this.currentCaret = new Gdk.Rectangle ((int)caret.X, (int)caret.Y, (int)caret.Width, (int)caret.Height);
			Theme.TargetPosition = position;
			var pos = GtkUtil.GetSceenBounds (widget);
			targetWindowOrigin = new Point ((int)pos.X, (int)pos.Y);
			RepositionWindow ();
		}
示例#40
0
		static Popover.Position GetXwtPosition (PopupPosition position)
		{
			switch (position) {
				case PopupPosition.Bottom:
					return Popover.Position.Bottom;
				default: 
					return Popover.Position.Top;
			}
		}
 public void ShowPopup(Gtk.Widget widget, Gdk.Rectangle caret, PopupPosition position)
 {
     ShowPopup(widget, null, caret, position);
 }
示例#42
0
 public void ShowPopup(Widget widget, PopupPosition position)
 {
     ShowPopup(widget, Rectangle.Zero, position);
 }
        public virtual void RepositionWindow(Gdk.Rectangle?newCaret = null)
        {
            if (parent == null)
            {
                return;
            }

            int x, y;

            if (newCaret.HasValue)              //Update caret if parameter is given
            {
                currentCaret = newCaret.Value;
            }
            Gdk.Rectangle caret  = currentCaret;
            Gdk.Window    window = targetWindow;
            if (targetWindow == null)
            {
                return;
            }
            PopupPosition position = Theme.TargetPosition;

            this.position = Theme.TargetPosition;
            UpdatePadding();

            window.GetOrigin(out x, out y);
            var alloc = parent.Allocation;

            if (eventProvided)
            {
                caret.X     = x;
                caret.Y     = y;
                caret.Width = caret.Height = 1;
            }
            else
            {
                if (caret.Equals(Gdk.Rectangle.Zero))
                {
                    caret = new Gdk.Rectangle(0, 0, alloc.Width, alloc.Height);
                }
                caret = GtkUtil.ToScreenCoordinates(parent, parent.GdkWindow, caret);
            }

            Gtk.Requisition request = SizeRequest();
            var             screen  = parent.Screen;

            Gdk.Rectangle geometry = GtkWorkarounds.GetUsableMonitorGeometry(screen, screen.GetMonitorAtPoint(caret.X, caret.Y));

            // Add some spacing between the screen border and the popover window
            geometry.Inflate(-5, -5);

            // Flip the orientation if the window doesn't fit the screen.

            int intPos = (int)position;

            switch ((PopupPosition)(intPos & 0x0f))
            {
            case PopupPosition.Top:
                if (caret.Bottom + request.Height > geometry.Bottom)
                {
                    intPos = (intPos & 0xf0) | (int)PopupPosition.Bottom;
                }
                break;

            case PopupPosition.Bottom:
                if (caret.Top - request.Height < geometry.X)
                {
                    intPos = (intPos & 0xf0) | (int)PopupPosition.Top;
                }
                break;

            case PopupPosition.Right:
                if (caret.X - request.Width < geometry.X)
                {
                    intPos = (intPos & 0xf0) | (int)PopupPosition.Left;
                }
                break;

            case PopupPosition.Left:
                if (caret.Right + request.Width > geometry.Right)
                {
                    intPos = (intPos & 0xf0) | (int)PopupPosition.Right;
                }
                break;
            }

            position = (PopupPosition)intPos;
            UpdatePadding();

            // Calculate base coordinate

            switch ((PopupPosition)((int)position & 0x0f))
            {
            case PopupPosition.Top:
                y = caret.Bottom;
                break;

            case PopupPosition.Bottom:
                y = caret.Y - request.Height; break;

            case PopupPosition.Right:
                x = caret.X - request.Width; break;

            case PopupPosition.Left:
                x = caret.Right; break;
            }
            int offset;

            if ((position & PopupPosition.Top) != 0 || (position & PopupPosition.Bottom) != 0)
            {
                if (((int)position & 0x10) != 0)
                {
                    x = caret.X - MinArrowSpacing - Theme.ArrowWidth / 2;
                }
                else if (((int)position & 0x20) != 0)
                {
                    x = caret.Right - request.Width + MinArrowSpacing + Theme.ArrowWidth / 2;
                }
                else
                {
                    x = caret.X + (caret.Width - request.Width) / 2;
                }

                if (x < geometry.Left)
                {
                    x = geometry.Left;
                }
                else if (x + request.Width > geometry.Right)
                {
                    x = geometry.Right - request.Width;
                }

                offset = caret.X + caret.Width / 2 - x;
                if (offset - Theme.ArrowWidth / 2 < MinArrowSpacing)
                {
                    offset = MinArrowSpacing + Theme.ArrowWidth / 2;
                }
                if (offset > request.Width - MinArrowSpacing - Theme.ArrowWidth / 2)
                {
                    offset = request.Width - MinArrowSpacing - Theme.ArrowWidth / 2;
                }
            }
            else
            {
                if (((int)position & 0x10) != 0)
                {
                    y = caret.Y - MinArrowSpacing - Theme.ArrowWidth / 2;
                }
                else if (((int)position & 0x20) != 0)
                {
                    y = caret.Bottom - request.Height + MinArrowSpacing + Theme.ArrowWidth / 2;
                }
                else
                {
                    y = caret.Y + (caret.Height - request.Height) / 2;
                }

                if (y < geometry.Top)
                {
                    y = geometry.Top;
                }
                else if (y + request.Height > geometry.Bottom)
                {
                    y = geometry.Bottom - request.Height;
                }
                if (MaximumYTopBound > 0)
                {
                    y = Math.Max(MaximumYTopBound, y);
                }

                offset = caret.Y + caret.Height / 2 - y;
                if (offset - Theme.ArrowWidth / 2 < MinArrowSpacing)
                {
                    offset = MinArrowSpacing + Theme.ArrowWidth / 2;
                }
                if (offset > request.Height - MinArrowSpacing - Theme.ArrowWidth / 2)
                {
                    offset = request.Height - MinArrowSpacing - Theme.ArrowWidth / 2;
                }
            }
            Theme.ArrowOffset = offset;
            this.position     = position;
            UpdatePadding();

            Move(x, y);
            Show();
            if (!ShowWindowShadow)
            {
                DesktopService.RemoveWindowShadow(this);
            }
        }
示例#44
0
        /**
         *   
         */
        internal void DeterminePosition(PopupPosition placement, float popUpWidth, float popUpHeight,
                                               /*matrix:Matrix, */Point registrationPoint, Rectangle bounds)
        {
            switch(placement)
            {
                case PopupPosition.Below:
                    registrationPoint.X = 0;
                    registrationPoint.Y = Height;
                    break;
                case PopupPosition.Above:
                    registrationPoint.X = 0;
                    registrationPoint.Y = -popUpHeight;
                    break;
                case PopupPosition.Left:
                    registrationPoint.X = -popUpWidth;
                    registrationPoint.Y = 0;
                    break;
                case PopupPosition.Right:
                    registrationPoint.X = Width;
                    registrationPoint.Y = 0;
                    break;            
                case PopupPosition.Center:
                    registrationPoint.X = (Width - popUpWidth) / 2;
                    registrationPoint.Y = (Height - popUpHeight) / 2;
                    break;            
                case PopupPosition.TopLeft:
                    // already 0,0
                    break;
            }
        
            //var popUpAsDisplayObject = _popup as DisplayObject;
                
            /*Point globalTl = (Point) registrationPoint.Clone(); //matrix.transformPoint(registrationPoint);
            registrationPoint.Y += popUpAsDisplayObject.Height;
            Point globalBl = (Point) registrationPoint.Clone(); //matrix.transformPoint(registrationPoint);
            registrationPoint.X += popUpAsDisplayObject.Width;
            Point globalBr = (Point) registrationPoint.Clone(); //matrix.transformPoint(registrationPoint);
            registrationPoint.Y -= popUpAsDisplayObject.Height;
            Point globalTr = (Point) registrationPoint.Clone(); //matrix.transformPoint(registrationPoint);
            registrationPoint.X -= popUpAsDisplayObject.Width;
        
            bounds.Left = Mathf.Min(globalTl.X, globalBl.X, globalBr.X, globalTr.X);
            bounds.Right = Mathf.Max(globalTl.X, globalBl.X, globalBr.X, globalTr.X);
            bounds.Top = Mathf.Min(globalTl.Y, globalBl.Y, globalBr.Y, globalTr.Y);
            bounds.Bottom = Mathf.Max(globalTl.Y, globalBl.Y, globalBr.Y, globalTr.Y);*/

            var globalRegPoint = Parent.LocalToGlobal(registrationPoint);
            bounds.X = globalRegPoint.X;
            bounds.Y = globalRegPoint.Y;
            bounds.Width = popUpWidth;
            bounds.Height = popUpHeight;
        }