예제 #1
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 += PopoverHidden;

            var screenBounds = reference.ScreenBounds;

            if (positionRect == Rectangle.Zero)
            {
                positionRect = new Rectangle(Point.Zero, screenBounds.Size);
            }
            positionRect = positionRect.Offset(screenBounds.Location);
            popover.Show();
            popover.Present();
            popover.GrabFocus();
            int w, h;

            popover.GetSize(out w, out h);

            UpdatePopoverPosition(positionRect, w, h);
            popover.SizeAllocated += (o, args) => {
                UpdatePopoverPosition(positionRect, args.Allocation.Width, args.Allocation.Height);
                popover.GrabFocus();
            };
        }