Exemple #1
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));
        }
Exemple #2
0
 void DestroyPopover()
 {
     if (popover != null)
     {
         popover.Close();
         popover.Dispose();
         popover = null;
     }
     if (controller != null)
     {
         controller.Dispose();
         controller = null;
     }
 }
Exemple #3
0
 public ContainerView(FactoryViewController controller)
 {
     this.controller = controller;
 }
Exemple #4
0
        public void Show(Popover.Position orientation, Widget referenceWidget, Rectangle positionRect, Widget child)
        {
            var refBackend = Toolkit.GetBackend(referenceWidget) as IWidgetBackend;

            NSView refView = (refBackend as EmbedNativeWidgetBackend)?.EmbeddedView;

            if (refView == null)
            {
                refView = (refBackend as ViewBackend)?.Widget;
            }

            if (refView == null)
            {
                if (referenceWidget.Surface.ToolkitEngine.Type == ToolkitType.Gtk)
                {
                    try {
                        refView = GtkQuartz.GetView(refBackend.NativeWidget);
                        var rLocation = refView.ConvertRectToView(refView.Frame, null).Location.ToXwtPoint();
                        if (referenceWidget.WindowBounds.Location != rLocation)
                        {
                            positionRect.X += referenceWidget.WindowBounds.Location.X - rLocation.X;
                            positionRect.Y += referenceWidget.WindowBounds.Location.Y - rLocation.Y;
                        }
                    } catch (Exception ex) {
                        throw new ArgumentException("Widget belongs to an unsupported Toolkit", nameof(referenceWidget), ex);
                    }
                }
                else if (referenceWidget.Surface.ToolkitEngine != ApplicationContext.Toolkit)
                {
                    throw new ArgumentException("Widget belongs to an unsupported Toolkit", nameof(referenceWidget));
                }
            }

            // If the rect is empty, the coordinates of the rect will be ignored.
            // Set the width and height, for the positioning to function correctly.
            if (Math.Abs(positionRect.Width) < double.Epsilon)
            {
                positionRect.Width = referenceWidget.Size.Width;
            }
            if (Math.Abs(positionRect.Height) < double.Epsilon)
            {
                positionRect.Height = referenceWidget.Size.Height;
            }

            DestroyPopover();

            popover = new NSAppearanceCustomizationPopover {
                Behavior = NSPopoverBehavior.Transient
            };
            controller = new FactoryViewController(this, child, popover)
            {
                BackgroundColor = backgroundColor
            };
            popover.ContentViewController = controller;
            popover.Delegate = controller;

            // if the reference has a custom appearance, use it for the popover
            if (refView.EffectiveAppearance.Name != NSAppearance.NameAqua)
            {
                controller.EffectiveAppearanceName = refView.EffectiveAppearance.Name;

                if (popover is INSAppearanceCustomization)
                {
                    ((INSAppearanceCustomization)popover).SetAppearance(refView.EffectiveAppearance);
                }
            }

            popover.Show(positionRect.ToCGRect(),
                         refView,
                         ToRectEdge(orientation));
        }
Exemple #5
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;
     IMacViewBackend backend = (IMacViewBackend)Toolkit.GetBackend (referenceWidget);
     var reference = backend.View;
     popover.Show (System.Drawing.RectangleF.Empty,
                   reference,
                   ToRectEdge (orientation));
 }