Lookup() public static method

public static Lookup ( object obj ) : ObjectWrapper
obj object
return ObjectWrapper
示例#1
0
        void OnSelectionChanged(object ob, EventArgs a)
        {
            if (frontend != null)
            {
                bool                  canCut, canCopy, canPaste, canDelete;
                ObjectWrapper         obj      = ObjectWrapper.Lookup(widget.Selection);
                Stetic.Wrapper.Widget wrapper  = obj as Stetic.Wrapper.Widget;
                IEditableObject       editable = widget.Selection as IEditableObject;
                if (editable == null)
                {
                    editable = obj as IEditableObject;
                }
                if (editable != null)
                {
                    canCut    = editable.CanCut;
                    canCopy   = editable.CanCopy;
                    canPaste  = editable.CanPaste;
                    canDelete = editable.CanDelete;
                }
                else
                {
                    canCut = canCopy = canPaste = canDelete = false;
                }

                frontend.NotifySelectionChanged(Component.GetSafeReference(obj), canCut, canCopy, canPaste, canDelete);
                if (SelectionChanged != null)
                {
                    SelectionChanged(this, new Stetic.Wrapper.WidgetEventArgs(wrapper));
                }
            }
        }
示例#2
0
        // Sets the value of the property on @obj
        public override void SetValue(object obj, object value)
        {
            ObjectWrapper ww = ObjectWrapper.Lookup(obj);
            IDisposable   t  = ww != null && !ww.Loading? ww.UndoManager.AtomicChange : null;

            try
            {
                if (isWrapperProperty)
                {
                    obj = ww;
                }
                if (memberInfo != null)
                {
                    obj = memberInfo.GetValue(obj, null);
                }
                propertyInfo.SetValue(obj, value, null);
            }
            catch (Exception ex)
            {
                throw new InvalidOperationException("Could not set value for property " + klass.Name + "." + Name + " to object '" + obj + "'", ex);
            }
            finally
            {
                if (t != null)
                {
                    t.Dispose();
                }
            }
        }
示例#3
0
        public virtual void SetTranslated(object obj, bool translated)
        {
            ObjectWrapper wrapper = ObjectWrapper.Lookup(obj);

            if (wrapper == null)
            {
                return;
            }

            if (wrapper.translationInfo == null)
            {
                wrapper.translationInfo = new Hashtable();
            }

            TranslationInfo info = (TranslationInfo)wrapper.translationInfo[obj];

            if (info == null)
            {
                info = new TranslationInfo();
                wrapper.translationInfo[obj] = info;
            }

            if (translated)
            {
                info.Translated = true;
            }
            else
            {
                info.Translated = false;
            }
            // We leave the old Context and Comment around, so that if
            // you toggle Translated off and then back on, the old info
            // is still there.
        }
示例#4
0
        public virtual bool IsTranslated(object obj)
        {
            if (!translatable)
            {
                return(false);
            }

            ObjectWrapper wrapper = ObjectWrapper.Lookup(obj);

            if (wrapper == null)
            {
                return(false);
            }

            // Since translatable properties are assumed to be translated
            // by default, we return true if there is no TranslationInfo
            // for the object

            if (wrapper.translationInfo == null)
            {
                return(true);
            }

            TranslationInfo info = (TranslationInfo)wrapper.translationInfo[obj];

            return(info == null || info.Translated == true);
        }
示例#5
0
        internal WidgetDesignerBackend(Gtk.Container container, int designWidth, int designHeight)
        {
            ShadowType       = ShadowType.None;
            HscrollbarPolicy = PolicyType.Automatic;
            VscrollbarPolicy = PolicyType.Automatic;

            resizableFixed = new ResizableFixed();
            resizableFixed.ObjectViewer = defaultObjectViewer;

            wrapper = ObjectWrapper.Lookup(container);
            Gtk.Window window = container as Gtk.Window;

            if (window != null)
            {
                try {
                    metacityPreview = CreateMetacityPreview(window);
                    preview         = metacityPreview;
                    if (wrapper != null)
                    {
                        wrapper.Notify += OnWindowPropChange;
                    }
                } catch {
                    // If metacity is not available, use a regular box.
                    EventBox eventBox = new EventBox();
                    eventBox.Add(container);
                    preview = eventBox;
                }
            }
            else
            {
                EventBox eventBox = new EventBox();
                eventBox.Add(container);
                preview = eventBox;
            }

            resizableFixed.Put(preview, container);

            if (designWidth != -1)
            {
                preview.WidthRequest       = designWidth;
                preview.HeightRequest      = designHeight;
                resizableFixed.AllowResize = true;
            }
            else
            {
                resizableFixed.AllowResize = false;
            }

            preview.SizeAllocated += new Gtk.SizeAllocatedHandler(OnResized);

            AddWithViewport(resizableFixed);

            if (wrapper != null)
            {
                wrapper.AttachDesigner(resizableFixed);
            }

            resizableFixed.SelectionChanged += OnSelectionChanged;
        }
示例#6
0
        public void Run(object obj)
        {
            ObjectWrapper ww = ObjectWrapper.Lookup(obj);

            using (ww.UndoManager.AtomicChange) {
                InvokeMethod(ww, name, null, false);
            }
        }
示例#7
0
        public void Run(object obj, Gtk.Widget context)
        {
            ObjectWrapper ww = ObjectWrapper.Lookup(obj);

            using (ww.UndoManager.AtomicChange) {
                InvokeMethod(ww, name, context, true);
            }
        }
示例#8
0
        public override void AttachObject(object ob)
        {
            base.AttachObject(ob);
            Gtk.Widget    w       = (Gtk.Widget)ob;
            ObjectWrapper wrapper = ObjectWrapper.Lookup(w);

            image.Pixbuf = wrapper.ClassDescriptor.Icon;
            label.Text   = wrapper.WrappedTypeName;
        }
        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)));
        }
        public object AddNewWidgetFromTemplate(string template)
        {
            XmlDocument doc = new XmlDocument();

            doc.LoadXml(template);
            Gtk.Widget widget = Stetic.WidgetUtils.ImportWidget(this, doc.DocumentElement);
            AddWidget(widget);
            return(Component.GetSafeReference(ObjectWrapper.Lookup(widget)));
        }
示例#11
0
 public bool Enabled(object obj)
 {
     if (checkName == "")
     {
         return(EnabledFor(obj));
     }
     else
     {
         return((bool)InvokeMethod(ObjectWrapper.Lookup(obj), checkName, null, false));
     }
 }
示例#12
0
        public bool Enabled(object obj, Gtk.Widget context)
        {
            if (checkName == "")
            {
                return(EnabledFor(obj));
            }

            ObjectWrapper wrapper = ObjectWrapper.Lookup(obj);

            return((bool)InvokeMethod(wrapper, checkName, context, true));
        }
示例#13
0
        public virtual void SetTranslationComment(object obj, string comment)
        {
            SetTranslated(obj, true);

            ObjectWrapper wrapper = ObjectWrapper.Lookup(obj);

            if (wrapper == null)
            {
                return;
            }
            ((TranslationInfo)wrapper.translationInfo[obj]).Comment = comment;
        }
示例#14
0
        public virtual string TranslationComment(object obj)
        {
            ObjectWrapper wrapper = ObjectWrapper.Lookup(obj);

            if (wrapper == null || wrapper.translationInfo == null)
            {
                return(null);
            }

            TranslationInfo info = (TranslationInfo)wrapper.translationInfo[obj];

            return(info != null ? info.Comment : null);
        }
示例#15
0
        public CodeExpression GetWidgetExp(object wrapped)
        {
            ObjectWrapper w = ObjectWrapper.Lookup(wrapped);

            if (w != null)
            {
                return(GetWidgetExp(w));
            }
            else
            {
                return(null);
            }
        }
示例#16
0
        internal void ClipboardCopySelection()
        {
            IEditableObject editable = widget.Selection as IEditableObject;

            if (editable == null)
            {
                editable = ObjectWrapper.Lookup(widget.Selection) as IEditableObject;
            }
            if (editable != null)
            {
                editable.Copy();
            }
        }
示例#17
0
        public void ClipboardPaste()
        {
            IEditableObject editable = widget.Selection as IEditableObject;

            if (editable == null)
            {
                editable = ObjectWrapper.Lookup(widget.Selection) as IEditableObject;
            }
            if (editable != null)
            {
                editable.Paste();
            }
        }
示例#18
0
        public void DeleteSelection()
        {
            IEditableObject editable = widget.Selection as IEditableObject;

            if (editable == null)
            {
                editable = ObjectWrapper.Lookup(widget.Selection) as IEditableObject;
            }
            if (editable != null)
            {
                editable.Delete();
            }
        }
示例#19
0
 public bool Check(object obj)
 {
     if (Property != null)
     {
         object depValue = Property.GetValue(obj);
         return(Value.Equals(depValue));
     }
     else
     {
         object wrapper = ObjectWrapper.Lookup(obj);
         object res     = wrapper.GetType().InvokeMember(CheckName, BindingFlags.InvokeMethod | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance, null, wrapper, null);
         return(!(bool)res);
     }
 }
        // Call this from a DragDrop event to receive the dragged widget
        public static void Drop(Gdk.DragContext ctx, uint time, ObjectWrapper targetWrapper, string dropData)
        {
            if (dropCallback == null)
            {
                Gtk.Widget w = Drop(ctx, (Gtk.Widget)targetWrapper.Wrapped, time);
                targetWrapper.DropObject(dropData, w);
                return;
            }

            Cancel();
            Gtk.Drag.Finish(ctx, true, true, time);

            Gtk.Application.Invoke(delegate
            {
                IProject project = targetWrapper.Project;
                string uid       = targetWrapper.UndoId;
                string tname     = ((Wrapper.Widget)targetWrapper).GetTopLevel().Wrapped.Name;

                // This call may cause the project to be reloaded
                dragWidget = dropCallback();
                if (dragWidget == null)
                {
                    return;
                }

                if (targetWrapper.IsDisposed)
                {
                    // The project has been reloaded. Find the wrapper again.
                    Gtk.Widget twidget = project.GetTopLevel(tname);
                    ObjectWrapper ow   = ObjectWrapper.Lookup(twidget);
                    if (ow != null)
                    {
                        targetWrapper = ow.FindObjectByUndoId(uid);
                    }
                    else
                    {
                        targetWrapper = null;
                    }

                    if (targetWrapper == null)
                    {
                        // Target wrapper not found. Just ignore the drop.
                        return;
                    }
                }

                targetWrapper.DropObject(dropData, dragWidget);
            });
        }
 // Gets the value of the property on @obj
 public override object GetValue(object obj)
 {
     try {
         if (isWrapperProperty)
         {
             obj = ObjectWrapper.Lookup(obj);
         }
         if (memberInfo != null)
         {
             obj = memberInfo.GetValue(obj, null);
         }
         return(propertyInfo.GetValue(obj, null));
     } catch (Exception ex) {
         throw new InvalidOperationException("Could not get value for property " + klass.Name + "." + Name + " from object '" + obj + "'", ex);
     }
 }
 public override void ResetValue(object instance)
 {
     // This is a hack because there is no managed way of getting
     // the default value of a GObject property. The call to LoadDefaultValues
     // will guess the default values from a dummy instance
     if (!defaultSet)
     {
         ObjectWrapper        ww = ObjectWrapper.Lookup(instance);
         TypedClassDescriptor td = ww.ClassDescriptor as TypedClassDescriptor;
         if (td != null)
         {
             td.LoadDefaultValues();
         }
         defaultSet = true;
     }
     base.ResetValue(instance);
 }
示例#23
0
        internal ArrayList GetWidgetChildren(Wrapper.Widget ww)
        {
            Stetic.Wrapper.Container cw = ww as Stetic.Wrapper.Container;
            if (cw == null)
            {
                return(null);
            }

            ArrayList list = new ArrayList();

            foreach (object ob in cw.RealChildren)
            {
                ObjectWrapper ow = ObjectWrapper.Lookup(ob);
                if (ow != null)
                {
                    list.Add(Component.GetSafeReference(ow));
                }
            }
            return(list);
        }
        internal void LoadDefaultValues()
        {
            // This is a hack because there is no managed way of getting
            // the default value of a GObject property.
            // This method creates an dummy instance of this class and
            // gets the values for their properties. Those values are
            // considered the default

            if (defaultValuesLoaded)
            {
                return;
            }
            defaultValuesLoaded = true;

            object ob = NewInstance(null, false);

            foreach (ItemGroup group in ItemGroups)
            {
                foreach (ItemDescriptor item in group)
                {
                    TypedPropertyDescriptor prop = item as TypedPropertyDescriptor;
                    if (prop == null)
                    {
                        continue;
                    }

                    if (!prop.HasDefault)
                    {
                        prop.SetDefault(null);
                    }
                    else
                    {
                        object val = prop.GetValue(ob);
                        prop.SetDefault(val);
                    }
                }
            }
            ObjectWrapper ww = ObjectWrapper.Lookup(ob);

            ww.Dispose();
        }
示例#25
0
        PropertyInfo FindBoolProperty(object obj, out object target)
        {
            PropertyInfo prop = obj.GetType().GetProperty(name, flags);

            if (prop != null && prop.PropertyType == typeof(bool))
            {
                target = obj;
                return(prop);
            }

            ObjectWrapper wrap = ObjectWrapper.Lookup(obj);

            if (wrap != null)
            {
                prop = wrap.GetType().GetProperty(name, flags);
                if (prop != null && prop.PropertyType == typeof(bool))
                {
                    target = wrap;
                    return(prop);
                }
            }
            target = null;
            return(null);
        }