Beispiel #1
0
        public static void AddFault(Stetic.Wrapper.Widget owner, object faultId,
                                    Gtk.Orientation orientation,
                                    int x, int y, int width, int height)
        {
            Gtk.Widget widget = owner.Wrapped;
            if (!widget.IsRealized)
            {
                return;
            }

            Gdk.Window win = NewWindow(widget, Gdk.WindowClass.InputOnly);
            win.MoveResize(x, y, width, height);

            Hashtable widgetFaults = faultGroups[widget] as Hashtable;

            if (widgetFaults == null)
            {
                faultGroups[widget]      = widgetFaults = new Hashtable();
                widget.Destroyed        += FaultWidgetDestroyed;
                widget.DragMotion       += FaultDragMotion;
                widget.DragLeave        += FaultDragLeave;
                widget.DragDrop         += FaultDragDrop;
                widget.DragDataReceived += FaultDragDataReceived;
                DND.DestSet(widget, false);
            }
            widgetFaults[win] = new Fault(owner, faultId, orientation, win);
        }
Beispiel #2
0
 public Placeholder()
 {
     undoId = WidgetUtils.GetUndoId();
     DND.DestSet(this, true);
     Events      |= Gdk.EventMask.ButtonPressMask;
     WidgetFlags |= WidgetFlags.AppPaintable;
 }
 protected override void OnDragBegin(Gdk.DragContext ctx)
 {
     Gtk.Widget ob = CreateItemWidget();
     if (ob != null)
     {
         DND.Drag(this, ctx, ob);
     }
 }
 public ActionPaletteGroup(string name, Wrapper.ActionGroup group) : base(name)
 {
     DND.DestSet(this, true);
     this.group           = group;
     group.ActionAdded   += OnActionGroupChanged;
     group.ActionRemoved += OnActionGroupChanged;
     group.ActionChanged += OnActionGroupChanged;
     group.ObjectChanged += OnActionGroupChanged;
     Fill();
 }
Beispiel #5
0
        static void FaultDragDrop(object obj, Gtk.DragDropArgs args)
        {
            Gtk.Widget            w       = DND.Drop(args.Context, (Gtk.Widget)obj, args.Time);
            Stetic.Wrapper.Widget dropped = Stetic.Wrapper.Widget.Lookup(w);
            if (dropped != null)
            {
                Gtk.Widget targetWidget = (Gtk.Widget)obj;
                int        px           = args.X + targetWidget.Allocation.X;
                int        py           = args.Y + targetWidget.Allocation.Y;

                FaultDrop(dropped, px, py, targetWidget);
                args.RetVal = true;
            }
        }
Beispiel #6
0
        static void ClearFaults(Gtk.Widget widget)
        {
            Hashtable widgetFaults = faultGroups[widget] as Hashtable;

            if (widgetFaults == null)
            {
                return;
            }
            faultGroups.Remove(widget);

            foreach (Gdk.Window win in widgetFaults.Keys)
            {
                win.Destroy();
            }
            widgetFaults.Clear();
            DND.DestUnset(widget);
        }
Beispiel #7
0
        protected override bool OnDragDrop(Gdk.DragContext context, int x, int y, uint time)
        {
            Wrapper.ActionPaletteItem dropped = DND.Drop(context, null, time) as Wrapper.ActionPaletteItem;
            if (dropped == null)
            {
                return(false);
            }

            if (dropped.Node.Action.ActionGroup != group)
            {
                using (dropped.Node.Action.UndoManager.AtomicChange) {
                    dropped.Node.Action.ActionGroup.Actions.Remove(dropped.Node.Action);
                    group.Actions.Add(dropped.Node.Action);
                }
            }

            return(base.OnDragDrop(context, x, y, time));
        }
Beispiel #8
0
        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);
            }
        }
Beispiel #9
0
        static void ClearFaults(Gtk.Widget widget)
        {
            Hashtable widgetFaults = faultGroups[widget] as Hashtable;

            if (widgetFaults == null)
            {
                return;
            }
            faultGroups.Remove(widget);
            widget.Destroyed        -= FaultWidgetDestroyed;
            widget.DragMotion       -= FaultDragMotion;
            widget.DragLeave        -= FaultDragLeave;
            widget.DragDrop         -= FaultDragDrop;
            widget.DragDataReceived -= FaultDragDataReceived;

            foreach (Gdk.Window win in widgetFaults.Keys)
            {
                win.Destroy();
            }
            widgetFaults.Clear();
            DND.DestUnset(widget);
        }
        public virtual void Initialize(string name, Gdk.Pixbuf icon)
        {
            DND.SourceSet(this);
            AboveChild = true;

            Gtk.HBox hbox = new HBox(false, 6);
            hbox.BorderWidth = 3;

            if (icon != null)
            {
                icon = icon.ScaleSimple(16, 16, Gdk.InterpType.Bilinear);
                hbox.PackStart(new Gtk.Image(icon), false, false, 0);
            }

            Gtk.Label label = new Gtk.Label("<small>" + name + "</small>");
            label.UseMarkup = true;
            label.Justify   = Justification.Left;
            label.Xalign    = 0;
            hbox.PackEnd(label, true, true, 0);

            Add(hbox);
        }
 public override void Initialize(string name, Gdk.Pixbuf icon)
 {
     base.Initialize(name, icon);
     DND.SourceUnset(this);
 }