Exemple #1
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.Colormap   = Colormap;
            attributes.EventMask  = (int)(Events |
                                          Gdk.EventMask.ExposureMask |
                                          Gdk.EventMask.Button1MotionMask |
                                          Gdk.EventMask.ButtonPressMask |
                                          Gdk.EventMask.ButtonReleaseMask);

            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;

            //GdkWindow.SetBackPixmap (null, true);

            ModifyBase(StateType.Normal, Styles.DockFrameBackground.ToGdkColor());
        }
Exemple #2
0
    protected override void OnRealized()
    {
        WidgetFlags |= WidgetFlags.Realized;

        GdkWindow = ParentWindow;
        Style     = Style.Attach(GdkWindow);
    }
Exemple #3
0
        protected override void OnRealized()
        {
            SetFlag(Gtk.WidgetFlags.Realized);
            GdkWindow = new Gdk.Window(ParentWindow,
                                       new Gdk.WindowAttr {
                WindowType = Gdk.WindowType.Child,
                X          = Allocation.X,
                Y          = Allocation.Y,
                Width      = Allocation.Width,
                Height     = Allocation.Height,
                Wclass     = Gdk.WindowClass.InputOutput,
                Visual     = ParentWindow.Visual,
                Colormap   = ParentWindow.Colormap,
                Mask       = this.Events
                             | EventMask.ExposureMask
                             | EventMask.ButtonPressMask
                             | EventMask.ButtonReleaseMask
                             | EventMask.PointerMotionMask
                             | EventMask.PointerMotionHintMask
                             | EventMask.ScrollMask
                             | EventMask.KeyPressMask
                             | EventMask.LeaveNotifyMask
            },
                                       Gdk.WindowAttributesType.X | Gdk.WindowAttributesType.Y |
                                       Gdk.WindowAttributesType.Visual | Gdk.WindowAttributesType.Colormap);

            GdkWindow.SetBackPixmap(null, false);
            GdkWindow.UserData = Handle;

            Style.Attach(GdkWindow);
            Style.SetBackground(GdkWindow, Gtk.StateType.Normal);

            OnRealizedChildren();
        }
Exemple #4
0
        // Methods
        protected override void OnRealized()
        {
            WidgetFlags |= WidgetFlags.Realized;
            WindowAttr attributes = default(WindowAttr);

            attributes.X          = Allocation.X;
            attributes.Y          = Allocation.Y;
            attributes.Height     = Allocation.Height;
            attributes.Width      = Allocation.Width;
            attributes.WindowType = Gdk.WindowType.Child;
            attributes.Wclass     = WindowClass.InputOutput;
            attributes.Visual     = Visual;
            attributes.TypeHint   = (WindowTypeHint)100;
            attributes.Colormap   = Colormap;
            attributes.EventMask  = (int)(Events | EventMask.ExposureMask | EventMask.Button1MotionMask | EventMask.ButtonPressMask | EventMask.ButtonReleaseMask | EventMask.KeyPressMask | EventMask.KeyReleaseMask);
            WindowAttributesType attributes_mask = WindowAttributesType.X | WindowAttributesType.Y | WindowAttributesType.Colormap | WindowAttributesType.Visual;

            GdkWindow          = new Gdk.Window(ParentWindow, attributes, (int)attributes_mask);
            GdkWindow.UserData = Handle;
            Style = Style.Attach(GdkWindow);
            Style.SetBackground(GdkWindow, State);
            WidgetFlags &= ~WidgetFlags.NoWindow;
            NSView nSView = GtkMacInterop.GetNSView(this);

            nSView.RemoveFromSuperview();
            embedParent.AddSubview(nSView);
            nSView.Frame = new CGRect(0, 0, embedParent.Frame.Width, embedParent.Frame.Height);
        }
Exemple #5
0
        protected override void OnRealized()
        {
            SetFlag(Gtk.WidgetFlags.Realized);

            Gdk.WindowAttr attributes = new Gdk.WindowAttr();
            attributes.WindowType = Gdk.WindowType.Child;
            attributes.X          = Allocation.X;
            attributes.Y          = Allocation.Y;
            attributes.Width      = Allocation.Width;
            attributes.Height     = Allocation.Height;
            attributes.Wclass     = WindowClass.InputOutput;
            attributes.Visual     = Visual;
            attributes.Colormap   = Colormap;

            // This enables all events except PointerMotionHitMask which prevents correct behavior
            // of MotionNotifyEvent
            attributes.EventMask = (int)(Gdk.EventMask.AllEventsMask & (~Gdk.EventMask.PointerMotionHintMask));

            Gdk.WindowAttributesType mask = WindowAttributesType.X | WindowAttributesType.Y
                                            | WindowAttributesType.Visual | WindowAttributesType.Colormap;

            GdkWindow          = new Gdk.Window(ParentWindow, attributes, (int)mask);
            GdkWindow.UserData = Handle;
            GdkWindow.SetBackPixmap(null, false);

            Style = Style.Attach(GdkWindow);
            Style.SetBackground(GdkWindow, StateType.Normal);

            Color = new Cairo.Color(1.0, 1.0, 1.0);
        }
Exemple #6
0
        protected override void OnRealized()
        {
            base.OnRealized();

            WindowAttr attributes = new WindowAttr();

            attributes.WindowType = Gdk.WindowType.Child;
            attributes.X          = Allocation.X;
            attributes.Y          = Allocation.Y;
            attributes.Width      = Allocation.Width;
            attributes.Height     = Allocation.Height;
            attributes.Wclass     = WindowClass.InputOutput;
            attributes.Visual     = Visual;
            attributes.Colormap   = Colormap;
            attributes.EventMask  = (int)Events;
            attributes.EventMask  = attributes.EventMask | ((int)Gdk.EventMask.ExposureMask |
                                                            (int)Gdk.EventMask.KeyPressMask |
                                                            (int)Gdk.EventMask.KeyReleaseMask |
                                                            (int)Gdk.EventMask.EnterNotifyMask |
                                                            (int)Gdk.EventMask.LeaveNotifyMask |
                                                            (int)Gdk.EventMask.StructureMask |
                                                            (int)Gdk.EventMask.FocusChangeMask);

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

            Style = Style.Attach(GdkWindow);
            Style.Background(StateType.Normal);

            browser.Load(this.Handle, width, height);
        }
Exemple #7
0
        private void ApplyTheme()
        {
            object defaultStyleKey = this.DefaultStyleKey;

            if (defaultStyleKey == null)
            {
                throw new InvalidOperationException("DefaultStyleKey must be set.");
            }

            Style style = (Style)this.FindResource(this.DefaultStyleKey);

            style.Attach(this);
        }
Exemple #8
0
 protected Element EnsureNodeExists()
 {
     if (node == null)
     {
         Node = CreateNode();
         node.SetAttribute("data-class-name", GetType().FullName);
         if (style != null)
         {
             style.Attach(node.Style);
         }
     }
     return(node);
 }
Exemple #9
0
        protected override void OnRealized()
        {
            WidgetFlags |= WidgetFlags.Realized;

            Gdk.WindowAttr attributes = new Gdk.WindowAttr();
            attributes.WindowType = Gdk.WindowType.Child;
            attributes.Wclass     = Gdk.WindowClass.InputOutput;
            attributes.EventMask  = (int)Gdk.EventMask.ExposureMask;
            GdkWindow             = new Gdk.Window(Parent.GdkWindow, attributes, 0);
            GdkWindow.UserData    = Handle;
            GdkWindow.Background  = Style.Background(State);
            Style.Attach(GdkWindow);
        }
Exemple #10
0
        public void Style_With_Only_Type_Selector_Should_Update_Value()
        {
            Style style = new Style(x => x.OfType <Class1>())
            {
                Setters = new[]
                {
                    new Setter(Class1.FooProperty, "Foo"),
                },
            };

            var target = new Class1();

            style.Attach(target, null);

            Assert.Equal("Foo", target.Foo);
        }
Exemple #11
0
        public void Style_With_No_Selector_Should_Apply_To_Containing_Control()
        {
            Style style = new Style
            {
                Setters = new[]
                {
                    new Setter(Class1.FooProperty, "Foo"),
                },
            };

            var target = new Class1();

            style.Attach(target, target);

            Assert.Equal("Foo", target.Foo);
        }
Exemple #12
0
        public void Style_With_No_Selector_Should_Apply_To_Containing_Control()
        {
            Style style = new Style
            {
                Setters = new[]
                {
                    new Setter(Class1.FooProperty, "Foo"),
                },
            };

            var target = new Class1();

            style.Attach(target, target);

            Assert.Equal("Foo", target.Foo);
        }
Exemple #13
0
        public void Style_With_Only_Type_Selector_Should_Update_Value()
        {
            Style style = new Style(x => x.OfType<Class1>())
            {
                Setters = new[]
                {
                    new Setter(Class1.FooProperty, "Foo"),
                },
            };

            var target = new Class1();

            style.Attach(target, null);

            Assert.Equal("Foo", target.Foo);
        }
Exemple #14
0
        protected override void OnRealized()
        {
            SetFlag(Gtk.WidgetFlags.Realized);

            var attributes = new Gdk.WindowAttr {
                WindowType = Gdk.WindowType.Child,
                X          = Allocation.X,
                Y          = Allocation.Y,
                Width      = Allocation.Width,
                Height     = Allocation.Height,
                Wclass     = Gdk.WindowClass.InputOutput,
                Visual     = this.Visual,
                Colormap   = this.Colormap,
                Mask       = Gdk.EventMask.VisibilityNotifyMask
            };

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

            GdkWindow.SetBackPixmap(null, false);
            GdkWindow.UserData = Handle;

            attributes = new Gdk.WindowAttr {
                WindowType = Gdk.WindowType.Child,
                X          = (int)-Hadjustment.Value,
                Y          = (int)-Vadjustment.Value,
                Width      = (int)Math.Max(Width, Allocation.Width),
                Height     = (int)Math.Max(Height, Allocation.Height),
                Wclass     = Gdk.WindowClass.InputOutput,
                Visual     = this.Visual,
                Colormap   = this.Colormap,
                Mask       = Gdk.EventMask.ExposureMask | Gdk.EventMask.ScrollMask | this.Events
            };
            bin_window = new Gdk.Window(GdkWindow, attributes,
                                        Gdk.WindowAttributesType.X | Gdk.WindowAttributesType.Y | Gdk.WindowAttributesType.Visual | Gdk.WindowAttributesType.Colormap)
            {
                UserData = Handle
            };

            Style.Attach(GdkWindow);
            Style.SetBackground(bin_window, Gtk.StateType.Normal);

            foreach (var child in children)
            {
                child.Widget.ParentWindow = bin_window;
            }
        }
Exemple #15
0
        protected override void OnRealized()
        {
            string env = Environment.GetEnvironmentVariable(ScreenSaverEnviroment);

            if (env != null)
            {
                try {
                    env = env.ToLower();

                    if (env.StartsWith("0x"))
                    {
                        env = env.Substring(2);
                    }

                    uint xid = UInt32.Parse(env, System.Globalization.NumberStyles.HexNumber);

                    GdkWindow = Gdk.Window.ForeignNew(xid);
                    Style.Attach(GdkWindow);
                    GdkWindow.Events = EventMask.ExposureMask
                                       | EventMask.StructureMask
                                       | EventMask.EnterNotifyMask
                                       | EventMask.LeaveNotifyMask
                                       | EventMask.FocusChangeMask;

                    Style.SetBackground(GdkWindow, Gtk.StateType.Normal);
                    GdkWindow.SetDecorations((Gdk.WMDecoration) 0);
                    GdkWindow.UserData = this.Handle;
                    SetFlag(WidgetFlags.Realized);
                    SizeRequest();
                    Gdk.Rectangle geom;
                    int           depth;
                    GdkWindow.GetGeometry(out geom.X, out geom.Y, out geom.Width, out geom.Height, out depth);
                    SizeAllocate(new Gdk.Rectangle(geom.X, geom.Y, geom.Width, geom.Height));
                    Resize(geom.Width, geom.Height);
                    return;
                } catch (System.Exception e) {
                    System.Console.WriteLine(e);
                }
            }
            else
            {
                System.Console.WriteLine("{0} not set, falling back to window", ScreenSaverEnviroment);
            }

            SetSizeRequest(640, 480);
            base.OnRealized();
        }
Exemple #16
0
        public void Style_With_No_Selector_Should_Not_Apply_To_Other_Control()
        {
            Style style = new Style
            {
                Setters = new[]
                {
                    new Setter(Class1.FooProperty, "Foo"),
                },
            };

            var target = new Class1();
            var other = new Class1();

            style.Attach(target, other);

            Assert.Equal("foodefault", target.Foo);
        }
Exemple #17
0
        public void Style_With_No_Selector_Should_Not_Apply_To_Other_Control()
        {
            Style style = new Style
            {
                Setters = new[]
                {
                    new Setter(Class1.FooProperty, "Foo"),
                },
            };

            var target = new Class1();
            var other  = new Class1();

            style.Attach(target, other);

            Assert.Equal("foodefault", target.Foo);
        }
Exemple #18
0
        public void LocalValue_Should_Override_Style()
        {
            Style style = new Style(x => x.OfType<Class1>())
            {
                Setters = new[]
                {
                    new Setter(Class1.FooProperty, "Foo"),
                },
            };

            var target = new Class1
            {
                Foo = "Original",
            };

            style.Attach(target);
            Assert.Equal("Original", target.Foo);
        }
Exemple #19
0
        public void Style_With_ObservableSetter_Should_Update_Value()
        {
            var source = new BehaviorSubject <string>("Foo");

            Style style = new Style(x => x.OfType <Class1>())
            {
                Setters = new[]
                {
                    new ObservableSetter(Class1.FooProperty, source),
                },
            };

            var target = new Class1();

            style.Attach(target, null);

            Assert.Equal("Foo", target.Foo);
        }
Exemple #20
0
        public void LocalValue_Should_Override_Style()
        {
            Style style = new Style(x => x.OfType <Class1>())
            {
                Setters = new[]
                {
                    new Setter(Class1.FooProperty, "Foo"),
                },
            };

            var target = new Class1
            {
                Foo = "Original",
            };

            style.Attach(target, null);
            Assert.Equal("Original", target.Foo);
        }
Exemple #21
0
        public void Style_With_Class_Selector_Should_Update_And_Restore_Value()
        {
            Style style = new Style(x => x.OfType <Class1>().Class("foo"))
            {
                Setters = new[]
                {
                    new Setter(Class1.FooProperty, "Foo"),
                },
            };

            var target = new Class1();

            style.Attach(target, null);
            Assert.Equal("foodefault", target.Foo);
            target.Classes.Add("foo");
            Assert.Equal("Foo", target.Foo);
            target.Classes.Remove("foo");
            Assert.Equal("foodefault", target.Foo);
        }
Exemple #22
0
        public void Style_With_Class_Selector_Should_Update_And_Restore_Value()
        {
            Style style = new Style(x => x.OfType<Class1>().Class("foo"))
            {
                Setters = new[]
                {
                    new Setter(Class1.FooProperty, "Foo"),
                },
            };

            var target = new Class1();

            style.Attach(target, null);
            Assert.Equal("foodefault", target.Foo);
            target.Classes.Add("foo");
            Assert.Equal("Foo", target.Foo);
            target.Classes.Remove("foo");
            Assert.Equal("foodefault", target.Foo);
        }
Exemple #23
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 #24
0
        public void Style_Should_Detach_When_Removed_From_Logical_Tree()
        {
            Border border;

            var style = new Style(x => x.OfType <Border>())
            {
                Setters = new[]
                {
                    new Setter(Border.BorderThicknessProperty, 4),
                }
            };

            var root = new TestRoot
            {
                Child = border = new Border(),
            };

            style.Attach(border, null);

            Assert.Equal(4, border.BorderThickness);
            root.Child = null;
            Assert.Equal(0, border.BorderThickness);
        }
Exemple #25
0
        public void Style_Should_Detach_Setters_When_Detach_Is_Called()
        {
            Border border;

            var style = new Style(x => x.OfType <Border>())
            {
                Setters = new[]
                {
                    new Setter(Border.BorderThicknessProperty, new Thickness(4)),
                }
            };

            var root = new TestRoot
            {
                Child = border = new Border(),
            };

            style.Attach(border, null);

            Assert.Equal(new Thickness(4), border.BorderThickness);
            style.Detach();
            Assert.Equal(new Thickness(0), border.BorderThickness);
        }
Exemple #26
0
        protected override void OnRealized()
        {
            WidgetFlags |= WidgetFlags.Realized;
            WindowAttr attributes = new WindowAttr()
            {
                WindowType = Gdk.WindowType.Child,
                X          = Allocation.X,
                Y          = Allocation.Y,
                Width      = Allocation.Width,
                Height     = Allocation.Height,
                Wclass     = WindowClass.InputOutput,
                Visual     = this.Visual,
                Colormap   = this.Colormap,
                EventMask  = (int)(this.Events | Gdk.EventMask.ExposureMask),
                Mask       = this.Events | Gdk.EventMask.ExposureMask,
            };

            WindowAttributesType mask = WindowAttributesType.X | WindowAttributesType.Y | WindowAttributesType.Colormap | WindowAttributesType.Visual;

            GdkWindow          = new Gdk.Window(ParentWindow, attributes, mask);
            GdkWindow.UserData = Raw;
            Style = Style.Attach(GdkWindow);
        }
Exemple #27
0
        protected override void OnRealized()
        {
            WidgetFlags |= WidgetFlags.Realized;
            WindowAttr attributes = new WindowAttr();

            attributes.WindowType = Gdk.WindowType.Child;
            attributes.X          = Allocation.X;
            attributes.Y          = Allocation.Y;
            attributes.Width      = Allocation.Width;
            attributes.Height     = Allocation.Height;
            attributes.Wclass     = WindowClass.InputOutput;
            attributes.Visual     = this.Visual;
            attributes.Colormap   = this.Colormap;
            attributes.EventMask  = (int)(this.Events | Gdk.EventMask.ExposureMask);
            attributes.Mask       = this.Events | Gdk.EventMask.ExposureMask;
//			attributes.Mask = EventMask;

            WindowAttributesType mask = WindowAttributesType.X | WindowAttributesType.Y | WindowAttributesType.Colormap | WindowAttributesType.Visual;

            this.GdkWindow          = new Gdk.Window(ParentWindow, attributes, mask);
            this.GdkWindow.UserData = this.Raw;
            this.Style        = Style.Attach(this.GdkWindow);
            this.WidgetFlags &= ~WidgetFlags.NoWindow;
        }
Exemple #28
0
        public void Style_With_ObservableSetter_Should_Update_And_Restore_Value()
        {
            var source = new BehaviorSubject <string>("Foo");

            var style = new Style(x => x.OfType <Class1>().Class("foo"))
            {
                Setters = new[]
                {
                    new ObservableSetter(Class1.FooProperty, source),
                },
            };

            var target = new Class1();

            style.Attach(target, null);

            Assert.Equal("foodefault", target.Foo);
            target.Classes.Add("foo");
            Assert.Equal("Foo", target.Foo);
            source.OnNext("Bar");
            Assert.Equal("Bar", target.Foo);
            target.Classes.Remove("foo");
            Assert.Equal("foodefault", target.Foo);
        }
Exemple #29
0
        public void Style_With_ObservableSetter_Should_Update_Value()
        {
            var source = new BehaviorSubject<string>("Foo");

            Style style = new Style(x => x.OfType<Class1>())
            {
                Setters = new[]
                {
                    new ObservableSetter(Class1.FooProperty, source),
                },
            };

            var target = new Class1();

            style.Attach(target);

            Assert.Equal("Foo", target.Foo);
        }
Exemple #30
0
        public void Style_With_ObservableSetter_Should_Update_And_Restore_Value()
        {
            var source = new BehaviorSubject<string>("Foo");

            Style style = new Style(x => x.OfType<Class1>().Class("foo"))
            {
                Setters = new[]
                {
                    new ObservableSetter(Class1.FooProperty, source),
                },
            };

            var target = new Class1();

            style.Attach(target);

            Assert.Equal("foodefault", target.Foo);
            target.Classes.Add("foo");
            Assert.Equal("Foo", target.Foo);
            source.OnNext("Bar");
            Assert.Equal("Bar", target.Foo);
            target.Classes.Remove("foo");
            Assert.Equal("foodefault", target.Foo);
        }
Exemple #31
0
        public void Style_Should_Detach_When_Removed_From_Logical_Tree()
        {
            Border border;

            var style = new Style(x => x.OfType<Border>())
            {
                Setters = new[]
                {
                    new Setter(Border.BorderThicknessProperty, 4),
                }
            };

            var root = new TestRoot
            {
                Child = border = new Border(),
            };

            style.Attach(border, null);

            Assert.Equal(4, border.BorderThickness);
            root.Child = null;
            Assert.Equal(0, border.BorderThickness);
        }