public static NSRectEdge ToRectEdge(Popover.Position pos) { switch (pos) { case Popover.Position.Top: return(NSRectEdge.MaxYEdge); default: return(NSRectEdge.MinYEdge); } }
public PopoverWindow(Popover.Position orientation) : base(WindowType.Popup) { this.AppPaintable = true; this.Decorated = false; this.SkipPagerHint = true; this.SkipTaskbarHint = true; this.TypeHint = WindowTypeHint.PopupMenu; this.AddEvents(16384); this.DefaultHeight = 20; this.arrowPosition = orientation; this.FocusOutEvent += new FocusOutEventHandler(this.HandleFocusOutEvent); this.OnScreenChanged((Gdk.Screen)null); }
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)); }