protected override void OnRealized()
 {
     base.OnRealized();
     nsview = GtkMacInterop.GetNSView(this);
     containers [nsview] = this;
     ConnectSubviews(nsview);
 }
Exemple #2
0
        public GtkEmbed(Gtk.Widget w)
        {
            if (!GtkMacInterop.SupportsGtkIntoNSViewEmbedding())
            {
                throw new NotSupportedException("GTK/NSView embedding is not supported by the installed GTK");
            }

            embeddedWidget = w;
            var s = w.SizeRequest();

            SetFrameSize(new CGSize(s.Width, s.Height));
            WatchForFocus(w);
        }
Exemple #3
0
        void WatchForFocus(Widget widget)
        {
            widget.FocusInEvent += (o, args) => {
                var view = GtkMacInterop.GetNSView(widget);
                if (view != null)
                {
                    view.Window.MakeFirstResponder(view);
                }
            };

            if (widget is Container)
            {
                Container c = (Container)widget;
                foreach (Widget w in c.Children)
                {
                    WatchForFocus(w);
                }
            }
        }
Exemple #4
0
        protected override void OnRealized()
        {
            WidgetFlags |= WidgetFlags.Realized;

            Gdk.WindowAttr attributes = new Gdk.WindowAttr();
            attributes.X          = Allocation.X;
            attributes.Y          = Allocation.Y;
            attributes.Height     = Allocation.Height;
            attributes.Width      = Allocation.Width;
            attributes.WindowType = Gdk.WindowType.Child;
            attributes.Wclass     = Gdk.WindowClass.InputOutput;
            attributes.Visual     = Visual;
            attributes.TypeHint   = (Gdk.WindowTypeHint) 100;          // Custom value which means the this gdk window has to use a native window
            attributes.Colormap   = Colormap;
            attributes.EventMask  = (int)(Events |
                                          Gdk.EventMask.ExposureMask |
                                          Gdk.EventMask.Button1MotionMask |
                                          Gdk.EventMask.ButtonPressMask |
                                          Gdk.EventMask.ButtonReleaseMask |
                                          Gdk.EventMask.KeyPressMask |
                                          Gdk.EventMask.KeyReleaseMask);

            Gdk.WindowAttributesType attributes_mask =
                Gdk.WindowAttributesType.X |
                Gdk.WindowAttributesType.Y |
                Gdk.WindowAttributesType.Colormap |
                Gdk.WindowAttributesType.Visual;
            GdkWindow          = new Gdk.Window(ParentWindow, attributes, (int)attributes_mask);
            GdkWindow.UserData = Handle;

            Style = Style.Attach(GdkWindow);
            Style.SetBackground(GdkWindow, State);
            this.WidgetFlags &= ~WidgetFlags.NoWindow;

            // Remove the gdk window from the original location and move it to the GtkEmbed view that contains it
            var gw = GtkMacInterop.GetNSView(this);

            gw.RemoveFromSuperview();
            embedParent.AddSubview(gw);
            gw.Frame = new CoreGraphics.CGRect(0, 0, embedParent.Frame.Width, embedParent.Frame.Height);
        }
Exemple #5
0
        void UpdateAllocation()
        {
            if (container.GdkWindow == null || cw.GdkWindow == null)
            {
                return;
            }

            var gw = GtkMacInterop.GetNSView(cw);

            gw.Frame = new CGRect(0, 0, Frame.Width, Frame.Height);
            var rect = GetRelativeAllocation(GtkMacInterop.GetNSView(container), gw);

            var allocation = new Gdk.Rectangle {
                X      = (int)rect.Left,
                Y      = (int)rect.Top,
                Width  = (int)rect.Width,
                Height = (int)rect.Height
            };

            cw.SizeAllocate(allocation);
        }