Esempio n. 1
0
 public void Show(Xwt.Popover.Position orientation, Xwt.Widget reference, Xwt.Rectangle positionRect, Widget child)
 {
     ActualPosition = orientation;
     Border.Child   = (System.Windows.FrameworkElement)Xwt.Engine.WidgetRegistry.GetNativeWidget(child);
     NativeWidget.PlacementTarget = (System.Windows.FrameworkElement)Xwt.Engine.WidgetRegistry.GetNativeWidget(reference);
     NativeWidget.IsOpen          = true;
 }
Esempio n. 2
0
        public void Show(Xwt.Popover.Position orientation, Xwt.Widget reference, Xwt.Rectangle positionRect, Widget child)
        {
            var parent = reference.ParentWindow;

            popover = new PopoverWindow((Gtk.Widget)((WidgetBackend)Toolkit.GetBackend(child)).NativeWidget, orientation);
            popover.SetPadding(frontend.Padding);
            popover.TransientFor      = ((WindowFrameBackend)Toolkit.GetBackend(parent)).Window;
            popover.DestroyWithParent = true;
            popover.Hidden           += (o, args) => {
                popover.ReleaseInnerWidget();
                sink.OnClosed();
                popover.Destroy();
            };

            var screenBounds = reference.ScreenBounds;

            if (positionRect == Rectangle.Zero)
            {
                positionRect = new Rectangle(Point.Zero, screenBounds.Size);
            }
            positionRect = positionRect.Offset(screenBounds.Location);
            var position = new Point(positionRect.Center.X, popover.ArrowPosition == Popover.Position.Top ? positionRect.Bottom : positionRect.Top);

            popover.ShowAll();
            popover.GrabFocus();
            int w, h;

            popover.GetSize(out w, out h);
            popover.Move((int)position.X - w / 2, (int)position.Y);
            popover.SizeAllocated += (o, args) => { popover.Move((int)position.X - args.Allocation.Width / 2, (int)position.Y); popover.GrabFocus(); };
        }
Esempio n. 3
0
        public void Show(Xwt.Popover.Position orientation, Xwt.Widget reference, Xwt.Rectangle positionRect, Widget child)
        {
            popover.Content         = (Gtk.Widget)((WidgetBackend)Toolkit.GetBackend(child)).NativeWidget;
            popover.ArrowPosition   = orientation;
            popover.BackgroundColor = BackgroundColor.ToCairoColor();
            popover.Padding         = frontend.Padding;

            var parent = (WindowFrameBackend)Toolkit.GetBackend(reference.ParentWindow);

            if (popover.TransientFor != parent.Window)
            {
                if (popover.TransientFor != null)
                {
                    popover.TransientFor.FocusInEvent -= HandleParentFocusInEvent;
                }
                popover.TransientFor = parent.Window;
                popover.TransientFor.FocusInEvent += HandleParentFocusInEvent;
            }

            popover.Hidden += (o, args) => sink.OnClosed();

            var screenBounds = reference.ScreenBounds;

            if (positionRect == Rectangle.Zero)
            {
                positionRect = new Rectangle(Point.Zero, screenBounds.Size);
            }
            positionRect = positionRect.Offset(screenBounds.Location);
            var position = new Point(positionRect.Center.X, popover.ArrowPosition == Popover.Position.Top ? positionRect.Bottom : positionRect.Top);

            popover.Show();
            popover.Present();
            popover.GrabFocus();
            int w, h;

            popover.GetSize(out w, out h);
            if (popover.ArrowPosition == Popover.Position.Top)
            {
                popover.Move((int)position.X - w / 2, (int)position.Y);
            }
            else
            {
                popover.Move((int)position.X - w / 2, (int)position.Y - h);
            }
            popover.SizeAllocated += (o, args) => {
                if (popover.ArrowPosition == Popover.Position.Top)
                {
                    popover.Move((int)position.X - args.Allocation.Width / 2, (int)position.Y);
                }
                else
                {
                    popover.Move((int)position.X - args.Allocation.Width / 2, (int)position.Y - args.Allocation.Height);
                }
                popover.GrabFocus();
            };
        }
Esempio n. 4
0
        public void Show(Xwt.Popover.Position orientation, Xwt.Widget referenceWidget, Xwt.Rectangle positionRect, Xwt.Widget child)
        {
            popover = MakePopover(child);
            ViewBackend backend   = (ViewBackend)Toolkit.GetBackend(referenceWidget);
            var         reference = backend.Widget;

            popover.Show(positionRect.ToRectangleF(),
                         reference,
                         ToRectEdge(orientation));
        }
        public static NSRectEdge ToRectEdge(Xwt.Popover.Position pos)
        {
            switch (pos)
            {
            case Popover.Position.Top:
                return(NSRectEdge.MaxYEdge);

            case Popover.Position.Bottom:
            default:
                return(NSRectEdge.MinYEdge);
            }
        }
Esempio n. 6
0
        public void Show(Xwt.Popover.Position orientation, Xwt.Widget referenceWidget, Xwt.Rectangle positionRect, Xwt.Widget child)
        {
            var controller = new FactoryViewController(child);

            popover          = new NSPopover();
            popover.Behavior = NSPopoverBehavior.Transient;
            popover.ContentViewController = controller;
            ViewBackend backend   = (ViewBackend)Toolkit.GetBackend(referenceWidget);
            var         reference = backend.Widget;

            popover.Show(System.Drawing.RectangleF.Empty,
                         reference,
                         ToRectEdge(orientation));
        }
Esempio n. 7
0
 public PopoverWindow(Gtk.Widget child, Xwt.Popover.Position orientation) : base(WindowType.Toplevel)
 {
     this.AppPaintable    = true;
     this.Decorated       = false;
     this.SkipPagerHint   = true;
     this.SkipTaskbarHint = true;
     this.TypeHint        = Gdk.WindowTypeHint.PopupMenu;
     //this.TransientFor = (Gtk.Window)child.Toplevel;
     this.AddEvents((int)Gdk.EventMask.FocusChangeMask);
     //this.DefaultHeight = this.DefaultWidth = 400;
     this.arrowPosition = orientation;
     this.alignment     = new Gtk.Alignment(0, 0, 1, 1);
     this.Add(alignment);
     this.alignment.Add(child);
     OnScreenChanged(null);
 }
Esempio n. 8
0
			public PopoverWindow (Gtk.Widget child, Xwt.Popover.Position orientation) : base (WindowType.Toplevel)
			{
				this.AppPaintable = true;
				this.Decorated = false;
				this.SkipPagerHint = true;
				this.SkipTaskbarHint = true;
				this.TypeHint = Gdk.WindowTypeHint.PopupMenu;
				//this.TransientFor = (Gtk.Window)child.Toplevel;
				this.AddEvents ((int)Gdk.EventMask.FocusChangeMask);
				//this.DefaultHeight = this.DefaultWidth = 400;
				this.arrowPosition = orientation;
				this.alignment = new Gtk.Alignment (0, 0, 1, 1);
				this.Add (alignment);
				this.alignment.Add (child);
				this.FocusOutEvent += HandleFocusOutEvent;
				OnScreenChanged (null);
			}
        public void Show(Xwt.Popover.Position orientation, Xwt.Widget referenceWidget, Xwt.Rectangle positionRect, Xwt.Widget child)
        {
            popover = MakePopover(child, BackgroundColor);
            ViewBackend backend   = (ViewBackend)Toolkit.GetBackend(referenceWidget);
            var         reference = backend.Widget;

            // If the position rect is empty, the coordinates of the rect will be ignored.
            // Width and Height of the rect must be > Epsilon, for the positioning to function correctly.
            if (Math.Abs(positionRect.Width) < double.Epsilon)
            {
                positionRect.Width = 1;
            }
            if (Math.Abs(positionRect.Height) < double.Epsilon)
            {
                positionRect.Height = 1;
            }

            popover.Show(positionRect.ToCGRect(),
                         reference,
                         ToRectEdge(orientation));
        }
Esempio n. 10
0
        public void Show(Xwt.Popover.Position orientation, Xwt.Widget reference, Xwt.Rectangle positionRect, Widget child)
        {
            ActualPosition = orientation;
            Border.Child   = (System.Windows.FrameworkElement)Context.Toolkit.GetNativeWidget(child);
            NativeWidget.CustomPopupPlacementCallback = (popupSize, targetSize, offset) => {
                System.Windows.Point location;
                if (ActualPosition == Popover.Position.Top)
                {
                    location = new System.Windows.Point(positionRect.Left, positionRect.Bottom);
                }
                else
                {
                    location = new System.Windows.Point(positionRect.Left, positionRect.Top - popupSize.Height);
                }

                return(new[] {
                    new System.Windows.Controls.Primitives.CustomPopupPlacement(location, System.Windows.Controls.Primitives.PopupPrimaryAxis.Horizontal)
                });
            };
            NativeWidget.PlacementTarget = (System.Windows.FrameworkElement)Context.Toolkit.GetNativeWidget(reference);
            NativeWidget.IsOpen          = true;
        }
Esempio n. 11
0
        public void Show(Xwt.Popover.Position orientation, Xwt.Widget reference, Xwt.Rectangle positionRect, Widget child)
        {
            ActualPosition = orientation;
            SetupBorderMargin();
            Border.Child = (System.Windows.FrameworkElement)Context.Toolkit.GetNativeWidget(child);
            NativeWidget.CustomPopupPlacementCallback = (popupSize, targetSize, offset) => {
                System.Windows.Point location;
                if (ActualPosition == Popover.Position.Top)
                {
                    location = new System.Windows.Point(positionRect.Left - popupSize.Width / 2,
                                                        positionRect.Height > 0 ? positionRect.Bottom : targetSize.Height);
                }
                else
                {
                    location = new System.Windows.Point(positionRect.Left - popupSize.Width / 2,
                                                        positionRect.Top - popupSize.Height);
                }

                return(new[] {
                    new System.Windows.Controls.Primitives.CustomPopupPlacement(location, System.Windows.Controls.Primitives.PopupPrimaryAxis.Horizontal)
                });
            };
            NativeWidget.PlacementTarget = (System.Windows.FrameworkElement)Context.Toolkit.GetNativeWidget(reference);
            NativeWidget.IsOpen          = true;

            // Popups are special in that the automation properties need to be set on the PopupRoot, which only exists when the popup is shown
            // See https://social.msdn.microsoft.com/Forums/vstudio/en-US/d4ba12c8-7a87-478e-b064-5620f929a0cf/how-to-set-automationid-and-name-for-popup?forum=wpf
            var accessibleBackend = (AccessibleBackend)Toolkit.GetBackend(Frontend.Accessible);

            if (accessibleBackend != null)
            {
                FrameworkElement popupRoot = GetPopupRoot();
                if (popupRoot != null)
                {
                    accessibleBackend.InitAutomationProperties(popupRoot);
                }
            }
        }