Exemplo n.º 1
0
 public void Present()
 {
     if (Platform.IsMac)
     {
         GtkWorkarounds.GrabDesktopFocus();
     }
     Window.Present();
 }
Exemplo n.º 2
0
        public DesignerBox()
        {
            GtkWorkarounds.FixContainerLeak(this);

            surface = new Gtk.EventBox();
            surface.ShowAll();
            surface.VisibleWindow = false;
            surface.Parent        = this;
        }
            public FramelessEntry(SearchEntry parent) : base()
            {
                this.parent = parent;
                HasFrame    = false;

                parent.StyleSet += OnParentStyleSet;
                WidthChars       = 1;

                GtkWorkarounds.SetTransparentBgHint(this, true);
            }
        public SearchEntry()
        {
            AppPaintable = true;

            BuildWidget();
            BuildMenu();

            NoShowAll = true;
            GtkWorkarounds.SetTransparentBgHint(this, true);
        }
Exemplo n.º 5
0
        public void Popup(IWidgetBackend widget, double x, double y)
        {
            var target = widget as WidgetBackend;

            if (target == null)
            {
                throw new ArgumentException("Widget belongs to an unsupported Toolkit", nameof(widget));
            }
            GtkWorkarounds.ShowContextMenu(Menu, target.Widget, new Gdk.Rectangle((int)x, (int)y, 0, 0));
        }
Exemplo n.º 6
0
 static CustomTreeView()
 {
     // On Mac we want to be able to handle the backspace key (labeled "delete") in a custom way
     // through a normal keypressed event but a default binding prevents this from happening because
     // it maps it to "select-cursor-parent". However, that event is also bound to Ctrl+Backspace anyway
     // so we can just kill one of those binding
     if (Platform.IsMac)
     {
         GtkWorkarounds.RemoveKeyBindingFromClass(Gtk.TreeView.GType, Gdk.Key.BackSpace, Gdk.ModifierType.None);
     }
 }
Exemplo n.º 7
0
            protected override bool OnDrawn(Context cr)
            {
                int w, h;

                this.GdkWindow.GetSize(out w, out h);

                // We clear the surface with a transparent color if possible
                if (supportAlpha)
                {
                    cr.SetSourceRGBA(1.0, 1.0, 1.0, 0.0);
                }
                else
                {
                    cr.SetSourceRGB(1.0, 1.0, 1.0);
                }
                cr.Operator = Operator.Source;
                cr.Paint();

                cr.LineWidth = GtkWorkarounds.GetScaleFactor(Content) > 1 ? 2 : 1;
                var bounds         = new Xwt.Rectangle(cr.LineWidth / 2, cr.LineWidth / 2, w - cr.LineWidth, h - cr.LineWidth);
                var calibratedRect = RecalibrateChildRectangle(bounds);

                // Fill it with one round rectangle
                RoundRectangle(cr, calibratedRect, radius);

                // Triangle
                // We first begin by positionning ourselves at the top-center or bottom center of the previous rectangle
                var arrowX = bounds.Center.X + arrowDelta;
                var arrowY = arrowPosition == Xwt.Popover.Position.Top ? calibratedRect.Top + cr.LineWidth : calibratedRect.Bottom;

                cr.MoveTo(arrowX, arrowY);
                // We draw the rectangle path
                DrawTriangle(cr);

                // We use it
                if (supportAlpha)
                {
                    cr.SetSourceRGBA(0.0, 0.0, 0.0, 0.2);
                }
                else
                {
                    cr.SetSourceRGB(238d / 255d, 238d / 255d, 238d / 255d);
                }
                cr.StrokePreserve();
                cr.SetSourceRGBA(BackgroundColor.R, BackgroundColor.G, BackgroundColor.B, BackgroundColor.A);
                cr.Fill();

                return(base.OnDrawn(cr));
            }
Exemplo n.º 8
0
 /// <summary>
 /// Places and runs a transient dialog. Does not destroy it, so values can be retrieved from its widgets.
 /// </summary>
 public static int RunCustomDialog(Gtk.Dialog dialog, Gtk.Window parent)
 {
     if (parent == null)
     {
         if (dialog.TransientFor != null)
         {
             parent = dialog.TransientFor;
         }
         else
         {
             parent = GetDefaultParent(dialog);
         }
     }
     dialog.TransientFor      = parent;
     dialog.DestroyWithParent = true;
     return(GtkWorkarounds.RunDialogWithNotification(dialog));
 }
Exemplo n.º 9
0
        public static Gtk.Window GetGtkWindow(object window)
        {
            if (window == null)
            {
                return(null);
            }

            var prop   = window.GetType().GetProperty("Handle");
            var handle = prop.GetValue(window, null);

            if (handle is IntPtr)
            {
                var toplevels = Gtk.Window.ListToplevels();
                return(toplevels.FirstOrDefault(w => w.IsRealized && GtkWorkarounds.GetGtkWindowNativeHandle(w) == (IntPtr)handle));
            }
            return(null);
        }
Exemplo n.º 10
0
 public void SetImage(ImageDescription image)
 {
     Gtk.ImageMenuItem it = item as Gtk.ImageMenuItem;
     if (it == null)
     {
         return;
     }
     if (!image.IsNull)
     {
         var img = new ImageBox(context, image);
         img.ShowAll();
         it.Image = img;
         GtkWorkarounds.ForceImageOnMenuItem(it);
     }
     else
     {
         it.Image = null;
     }
 }
Exemplo n.º 11
0
 public static double GetScaleFactor(Gtk.Widget w)
 {
     return(GtkWorkarounds.GetScaleFactor(w));
 }
Exemplo n.º 12
0
 public void Popup(IWidgetBackend widget, double x, double y)
 {
     GtkWorkarounds.ShowContextMenu(Menu, ((WidgetBackend)widget).Widget, new Gdk.Rectangle((int)x, (int)y, 0, 0));
 }
Exemplo n.º 13
0
 public void Popup()
 {
     GtkWorkarounds.ShowContextMenu(Menu, null, Gdk.Rectangle.Zero);
 }
Exemplo n.º 14
0
        public CustomCanvas()
        {
            GtkWorkarounds.FixContainerLeak(this);

            WidgetFlags |= Gtk.WidgetFlags.AppPaintable;
        }
Exemplo n.º 15
0
 public CustomContainer()
 {
     GtkWorkarounds.FixContainerLeak(this);
     WidgetFlags |= Gtk.WidgetFlags.NoWindow;
 }
Exemplo n.º 16
0
 public static void FixContainerLeak(this Gtk.Container c)
 {
     GtkWorkarounds.FixContainerLeak(c);
 }