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(); }; }
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(); }; }
void PopoverHidden(object sender, EventArgs e) { sink.OnClosed(); popover.Hidden -= PopoverHidden; }