public object AddNewWidget(string type, string name) { ClassDescriptor cls = Registry.LookupClassByName(type); Gtk.Widget w = (Gtk.Widget)cls.NewInstance(this); w.Name = name; this.AddWidget(w); return(Component.GetSafeReference(ObjectWrapper.Lookup(w))); }
internal void BeginComponentDrag(ProjectBackend project, string desc, string className, ObjectWrapper wrapper, Gtk.Widget source, Gdk.DragContext ctx, ComponentDropCallback callback) { if (wrapper != null) { Stetic.Wrapper.ActionPaletteItem it = new Stetic.Wrapper.ActionPaletteItem(Gtk.UIManagerItemType.Menuitem, null, (Wrapper.Action)wrapper); DND.Drag(source, ctx, it); } else if (callback != null) { DND.Drag(source, ctx, delegate() { callback(); // If the class name has an assembly name, remove it now int i = className.IndexOf(','); if (i != -1) { className = className.Substring(0, i); } ClassDescriptor cls = Registry.LookupClassByName(className); if (cls != null) { return(cls.NewInstance(project) as Gtk.Widget); } else { // Class not found, show an error string msg = string.Format("The widget '{0}' could not be found.", className); Gtk.MessageDialog dlg = new Gtk.MessageDialog(null, Gtk.DialogFlags.Modal, Gtk.MessageType.Error, Gtk.ButtonsType.Close, msg); dlg.Run(); dlg.Destroy(); return(null); } }, (desc != null && desc.Length > 0) ? desc : className ); } else { ClassDescriptor cls = Registry.LookupClassByName(className); DND.Drag(source, ctx, cls.NewInstance(project) as Gtk.Widget); } }
protected override Gtk.Widget CreateItemWidget() { return(klass.NewInstance(project) as Widget); }