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)); }
void DestroyPopover() { if (popover != null) { popover.Close(); popover.Dispose(); popover = null; } if (controller != null) { controller.Dispose(); controller = null; } }
public ContainerView(FactoryViewController controller) { this.controller = controller; }
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)); }
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)); }