CreateInstance() public abstract method

public abstract CreateInstance ( IProject proj ) : object
proj IProject
return object
Beispiel #1
0
        static public void Read(ObjectWrapper wrapper, XmlElement elem)
        {
            string className = elem.GetAttribute("class");

            if (className == null)
            {
                throw new GladeException("<widget> node with no class name");
            }

            ClassDescriptor klass = Registry.LookupClassByName(className);

            if (klass == null)
            {
                throw new GladeException("No stetic ClassDescriptor for " + className);
            }

            Gtk.Widget widget = (Gtk.Widget)wrapper.Wrapped;
            if (widget == null)
            {
                widget = (Gtk.Widget)klass.CreateInstance(wrapper.Project);
                ObjectWrapper.Bind(wrapper.Project, klass, wrapper, widget, true);
            }

            widget.Name = elem.GetAttribute("id");

            ReadMembers(klass, wrapper, widget, elem);

            if (!(widget is Gtk.Window))
            {
                widget.ShowAll();
            }
        }
Beispiel #2
0
        public override object CreateInstance(Stetic.IProject proj)
        {
            Gtk.Widget res;

            if (useCustomWidgetBox)
            {
                res = CreateFakeWidget(wrapperClassDescriptor.Name);
                res.ShowAll();
            }
            else if (steticDefinition != null)
            {
                Gtk.Container w = Stetic.WidgetUtils.ImportWidget(proj, steticDefinition) as Gtk.Container;
                MakeChildrenUnselectable(w);
                res = w;
            }
            else
            {
                res = (Gtk.Widget)typeClassDescriptor.CreateInstance(proj);

                // If it is a custom widget and there is no stetic project for it, just
                // show it as a regular custom widget.
                Stetic.CustomWidget custom = res as Stetic.CustomWidget;
                if (custom != null)
                {
                    Stetic.Custom c = new Stetic.Custom();
                    // Give it some default size
                    c.WidthRequest  = 20;
                    c.HeightRequest = 20;
                    custom.Add(c);
                    custom.ShowAll();
                    res = custom;
                }
            }

            res.Name = widgetId;
            return(res);
        }