Author: danw
Date: 2005-03-24 14:37:03 -0500 (Thu, 24 Mar 2005)
New Revision: 42233

Modified:
   trunk/stetic/ChangeLog
   trunk/stetic/libstetic/DND.cs
   trunk/stetic/libstetic/WidgetSite.cs
   trunk/stetic/libstetic/wrapper/Box.cs
   trunk/stetic/libstetic/wrapper/Widget.cs
Log:
        * libstetic/DND.cs: move the drag-and-drop "fault" code from
        WidgetSite to here. Remove the DragBegin and DragEnd events since
        nothing needs them any more.

        * libstetic/WidgetSite.cs (AddFault, AddVFault, AddHFault,
        ClearFaults, ShowFaults, HideFaults, OnDragMotion, OnDragLeave,
        OnDragDrop): all moved into DND now.
        (Internal): gone; does nothing WidgetBox.Internal doesn't do now

        * libstetic/wrapper/Widget.cs (Drop): dummy virtual implementation
        that just destroys the dropped widget

        * libstetic/wrapper/Box.cs (Sync): s/site/DND/ for all the fault
        stuff
        (Drop): override to dtrt


Modified: trunk/stetic/ChangeLog
===================================================================
--- trunk/stetic/ChangeLog      2005-03-24 19:21:44 UTC (rev 42232)
+++ trunk/stetic/ChangeLog      2005-03-24 19:37:03 UTC (rev 42233)
@@ -1,5 +1,23 @@
 2005-03-24  Dan Winship  <[EMAIL PROTECTED]>
 
+       * libstetic/DND.cs: move the drag-and-drop "fault" code from
+       WidgetSite to here. Remove the DragBegin and DragEnd events since
+       nothing needs them any more.
+
+       * libstetic/WidgetSite.cs (AddFault, AddVFault, AddHFault,
+       ClearFaults, ShowFaults, HideFaults, OnDragMotion, OnDragLeave,
+       OnDragDrop): all moved into DND now.
+       (Internal): gone; does nothing WidgetBox.Internal doesn't do now
+
+       * libstetic/wrapper/Widget.cs (Drop): dummy virtual implementation
+       that just destroys the dropped widget
+
+       * libstetic/wrapper/Box.cs (Sync): s/site/DND/ for all the fault
+       stuff
+       (Drop): override to dtrt
+
+2005-03-24  Dan Winship  <[EMAIL PROTECTED]>
+
        More code migration out of WidgetSite
 
        * libstetic/DND.cs (DragWidget): public accessor for dragWidget

Modified: trunk/stetic/libstetic/DND.cs
===================================================================
--- trunk/stetic/libstetic/DND.cs       2005-03-24 19:21:44 UTC (rev 42232)
+++ trunk/stetic/libstetic/DND.cs       2005-03-24 19:37:03 UTC (rev 42233)
@@ -1,28 +1,29 @@
 using System;
+using System.Collections;
 
 namespace Stetic {
 
        public static class DND {
+               static Gtk.TargetEntry[] targets;
+               static Gtk.TargetList targetList;
+               static Gdk.Atom steticWidgetType;
+
                static DND ()
                {
-                       SteticWidgetType = Gdk.Atom.Intern 
("application/x-stetic-widget", false);
+                       steticWidgetType = Gdk.Atom.Intern 
("application/x-stetic-widget", false);
 
-                       Targets = new Gtk.TargetEntry[1];
-                       Targets[0] = new Gtk.TargetEntry 
("application/x-stetic-widget", 0, 0);
+                       targets = new Gtk.TargetEntry[1];
+                       targets[0] = new Gtk.TargetEntry 
("application/x-stetic-widget", 0, 0);
 
-                       TargetList = new Gtk.TargetList ();
-                       TargetList.Add (SteticWidgetType, 0, 0);
+                       targetList = new Gtk.TargetList ();
+                       targetList.Add (steticWidgetType, 0, 0);
                }
 
-               public static Gtk.TargetEntry[] Targets;
-               public static Gtk.TargetList TargetList;
-               public static Gdk.Atom SteticWidgetType;
-
                public static void SourceSet (Gtk.Widget source, bool automatic)
                {
                        if (automatic) {
                                Gtk.Drag.SourceSet (source, 
Gdk.ModifierType.Button1Mask,
-                                                   Targets, 
Gdk.DragAction.Move);
+                                                   targets, 
Gdk.DragAction.Move);
                        } else
                                source.ButtonPressEvent += SourceButtonPress;
                }
@@ -36,7 +37,7 @@
                public static void DestSet (Gtk.Widget dest, bool automatic)
                {
                        Gtk.Drag.DestSet (dest, automatic ? 
Gtk.DestDefaults.All : 0,
-                                         Targets, Gdk.DragAction.Move);
+                                         targets, Gdk.DragAction.Move);
                }
 
                public static void DestUnset (Gtk.Widget dest)
@@ -74,7 +75,7 @@
                {
                        Gdk.DragContext ctx;
 
-                       ctx = Gtk.Drag.Begin (source, TargetList, 
Gdk.DragAction.Move,
+                       ctx = Gtk.Drag.Begin (source, targetList, 
Gdk.DragAction.Move,
                                              1 /* button */, evt);
                        Drag (source, ctx, dragWidget);
                }
@@ -85,9 +86,7 @@
                        Gtk.Window dragWin;
                        Gtk.Requisition req;
 
-                       if (DragBegin != null)
-                               DragBegin ();
-
+                       ShowFaults ();
                        DND.dragWidget = dragWidget;
 
                        dragWin = new Gtk.Window (Gtk.WindowType.Popup);
@@ -110,7 +109,8 @@
                        dragWin.Show ();
                        Gtk.Drag.SetIconWidget (ctx, dragWin, 0, 0);
 
-                       source.DragEnd += DragEnded;
+                       if (source != null)
+                               source.DragEnd += DragEnded;
                }
 
                public static Gtk.Widget DragWidget {
@@ -145,13 +145,308 @@
                static void DragEnded (object obj, Gtk.DragEndArgs args)
                {
                        dragWidget = null;
-                       if (DragEnd != null)
-                               DragEnd ();
+                       HideFaults ();
+
+                       ((Gtk.Widget)obj).DragEnd -= DragEnded;
                }
 
-               public delegate void DNDDelegate ();
+               class Fault {
+                       public Stetic.Wrapper.Widget Owner;
+                       public object Id;
+                       public Gtk.Orientation Orientation;
+                       public Gdk.Window Window;
 
-               public static event DNDDelegate DragBegin;
-               public static event DNDDelegate DragEnd;
+                       public Fault (Stetic.Wrapper.Widget owner, object id,
+                                     Gtk.Orientation orientation, Gdk.Window 
window)
+                       {
+                               Owner = owner;
+                               Id = id;
+                               Orientation = orientation;
+                               Window = window;
+                       }
+               }
+
+               static Hashtable faultGroups = new Hashtable ();
+               const int FaultOverlap = 3;
+
+               public static void AddFault (Stetic.Wrapper.Widget owner, 
object faultId,
+                                            Gtk.Orientation orientation, 
Gdk.Rectangle fault)
+               {
+                       AddFault (owner, faultId, orientation,
+                                 fault.X, fault.Y, fault.Width, fault.Height);
+               }
+
+               public static void AddFault (Stetic.Wrapper.Widget owner, 
object faultId,
+                                            Gtk.Orientation orientation,
+                                            int x, int y, int width, int 
height)
+               {
+                       WidgetSite site = owner.Wrapped.Parent as WidgetSite;
+                       if (site == null || !site.IsRealized)
+                               return;
+
+                       Gdk.Window win = NewWindow (site, 
Gdk.WindowClass.InputOnly);
+                       win.MoveResize (x, y, width, height);
+
+                       Hashtable siteFaults = faultGroups[site] as Hashtable;
+                       if (siteFaults == null) {
+                               faultGroups[site] = siteFaults = new Hashtable 
();
+                               site.Destroyed += SiteDestroyed;
+                               site.DragMotion += FaultDragMotion;
+                               site.DragLeave += FaultDragLeave;
+                               site.DragDrop += FaultDragDrop;
+                               DND.DestSet (site, false);
+                       }
+                       siteFaults[win] = new Fault (owner, faultId, 
orientation, win);
+               }
+
+               public static void AddHFault (Stetic.Wrapper.Widget owner, 
object faultId,
+                                             Gtk.Widget above, Gtk.Widget 
below)
+               {
+                       WidgetSite site = owner.Wrapped.Parent as WidgetSite;
+                       if (site == null || !site.IsRealized)
+                               return;
+
+                       Gdk.Rectangle aboveAlloc, belowAlloc;
+                       int x1, y1, x2, y2;
+
+                       if (above != null && below != null) {
+                               aboveAlloc = above.Allocation;
+                               belowAlloc = below.Allocation;
+
+                               x1 = Math.Min (aboveAlloc.X, belowAlloc.X);
+                               x2 = Math.Max (aboveAlloc.X + aboveAlloc.Width, 
belowAlloc.X + belowAlloc.Width);
+                               y1 = aboveAlloc.Y + aboveAlloc.Height;
+                               y2 = belowAlloc.Y;
+
+                               while (y2 - y1 < FaultOverlap * 2) {
+                                       y1--;
+                                       y2++;
+                               }
+                       } else if (above == null) {
+                               belowAlloc = below.Allocation;
+
+                               x1 = belowAlloc.X;
+                               x2 = belowAlloc.X + belowAlloc.Width;
+                               y1 = 0;
+                               y2 = Math.Max (belowAlloc.Y, FaultOverlap);
+                       } else {
+                               aboveAlloc = above.Allocation;
+
+                               x1 = aboveAlloc.X;
+                               x2 = aboveAlloc.X + aboveAlloc.Width;
+                               y1 = Math.Min (aboveAlloc.Y + 
aboveAlloc.Height, site.Allocation.Height - FaultOverlap);
+                               y2 = site.Allocation.Height;
+                       }
+
+                       AddFault (owner, faultId, Gtk.Orientation.Horizontal,
+                                 x1, y1, x2 - x1, y2 - y1);
+               }
+
+               public static void AddVFault (Stetic.Wrapper.Widget owner, 
object faultId,
+                                             Gtk.Widget left, Gtk.Widget right)
+               {
+                       WidgetSite site = owner.Wrapped.Parent as WidgetSite;
+                       if (site == null || !site.IsRealized)
+                               return;
+
+                       Gdk.Rectangle leftAlloc, rightAlloc;
+                       int x1, y1, x2, y2;
+
+                       if (left != null && right != null) {
+                               leftAlloc = left.Allocation;
+                               rightAlloc = right.Allocation;
+
+                               x1 = leftAlloc.X + leftAlloc.Width;
+                               x2 = rightAlloc.X;
+
+                               y1 = Math.Min (leftAlloc.Y, rightAlloc.Y);
+                               y2 = Math.Max (leftAlloc.Y + leftAlloc.Height, 
rightAlloc.Y + rightAlloc.Height);
+
+                               while (x2 - x1 < FaultOverlap * 2) {
+                                       x1--;
+                                       x2++;
+                               }
+                       } else if (left == null) {
+                               rightAlloc = right.Allocation;
+
+                               x1 = 0;
+                               x2 = Math.Max (rightAlloc.X, FaultOverlap);
+
+                               y1 = rightAlloc.Y;
+                               y2 = rightAlloc.Y + rightAlloc.Height;
+                       } else {
+                               leftAlloc = left.Allocation;
+
+                               x1 = Math.Min (leftAlloc.X + leftAlloc.Width, 
site.Allocation.Width - FaultOverlap);
+                               x2 = site.Allocation.Width;
+
+                               y1 = leftAlloc.Y;
+                               y2 = leftAlloc.Y + leftAlloc.Height;
+                       }
+
+                       AddFault (owner, faultId, Gtk.Orientation.Vertical,
+                                 x1, y1, x2 - x1, y2 - y1);
+               }
+
+               static void SiteDestroyed (object site, EventArgs args)
+               {
+                       ClearFaults ((WidgetSite)site);
+               }
+
+               public static void ClearFaults (Stetic.Wrapper.Widget owner)
+               {
+                       WidgetSite site = owner.Wrapped.Parent as WidgetSite;
+                       if (site != null)
+                               ClearFaults (site);
+               }
+
+               static void ClearFaults (WidgetSite site)
+               {
+                       Hashtable siteFaults = faultGroups[site] as Hashtable;
+                       if (siteFaults == null)
+                               return;
+                       faultGroups.Remove (site);
+
+                       foreach (Gdk.Window win in siteFaults.Keys)
+                               win.Destroy ();
+                       siteFaults.Clear ();
+                       DND.DestUnset (site);
+               }
+
+               static void ShowFaults ()
+               {
+                       foreach (Hashtable siteFaults in faultGroups.Values) {
+                               foreach (Gdk.Window win in siteFaults.Keys)
+                                       win.Show ();
+                       }
+               }
+
+               static void HideFaults ()
+               {
+                       foreach (Hashtable siteFaults in faultGroups.Values) {
+                               foreach (Gdk.Window win in siteFaults.Keys)
+                                       win.Hide ();
+                       }
+                       DestroySplitter ();
+                       dragFault = null;
+               }
+
+               static Fault dragFault;
+               static Gdk.Window splitter;
+
+               static void DestroySplitter ()
+               {
+                       if (splitter != null) {
+                               splitter.Hide ();
+                               splitter.Destroy ();
+                               splitter = null;
+                       }
+               }
+
+               static void FindFault (int x, int y, out Fault fault)
+               {
+                       int wx, wy, width, height, depth;
+
+                       fault = null;
+
+                       foreach (Hashtable siteFaults in faultGroups.Values) {
+                               foreach (Fault f in siteFaults.Values) {
+                                       f.Window.GetGeometry (out wx, out wy, 
out width, out height, out depth);
+                                       if (x >= wx && y >= wy && x <= wx + 
width && y <= wy + height) {
+                                               fault = f;
+                                               return;
+                                       }
+                               }
+                       }
+               }
+
+               static void FaultDragMotion (object obj, Gtk.DragMotionArgs 
args)
+               {
+                       int wx, wy, width, height, depth;
+                       Fault fault;
+
+                       FindFault (args.X, args.Y, out fault);
+
+                       // If there's a splitter visible, and we're not 
currently dragging
+                       // in the fault that owns that splitter, hide it
+                       if (splitter != null && dragFault != fault)
+                               DestroySplitter ();
+
+                       if (dragFault != fault) {
+                               dragFault = fault;
+                               if (dragFault == null)
+                                       return;
+
+                               splitter = NewWindow (fault.Owner.Wrapped, 
Gdk.WindowClass.InputOutput);
+                               fault.Window.GetGeometry (out wx, out wy, out 
width, out height, out depth);
+                               if (fault.Orientation == 
Gtk.Orientation.Horizontal) {
+                                       splitter.MoveResize (wx, wy + height / 
2 - FaultOverlap,
+                                                            width, 2 * 
FaultOverlap);
+                               } else {
+                                       splitter.MoveResize (wx + width / 2 - 
FaultOverlap, wy,
+                                                            2 * FaultOverlap, 
height);
+                               }
+                               splitter.ShowUnraised ();
+                               fault.Window.Parent.Lower ();
+                       } else if (dragFault == null)
+                               return;
+
+                       Gdk.Drag.Status (args.Context, Gdk.DragAction.Move, 
args.Time);
+                       args.RetVal = true;
+               }
+
+               static void FaultDragLeave (object obj, Gtk.DragLeaveArgs args)
+               {
+                       DestroySplitter ();
+                       dragFault = null;
+               }
+
+               static void FaultDragDrop (object obj, Gtk.DragDropArgs args)
+               {
+                       Gtk.Widget dragged = DND.Drop (args.Context, args.Time);
+                       if (dragged == null)
+                               return;
+
+                       Fault fault;
+                       FindFault (args.X, args.Y, out fault);
+                       fault.Owner.Drop (dragged, fault.Id);
+
+                       Stetic.Wrapper.Widget wrapper = 
Stetic.Wrapper.Widget.Lookup (dragged);
+                       if (wrapper != null)
+                               wrapper.Select ();
+
+                       args.RetVal = true;
+               }
+
+               static Gdk.Window NewWindow (Gtk.Widget parent, Gdk.WindowClass 
wclass)
+               {
+                       Gdk.WindowAttr attributes;
+                       Gdk.WindowAttributesType attributesMask;
+                       Gdk.Window win;
+
+                       attributes = new Gdk.WindowAttr ();
+                       attributes.WindowType = Gdk.WindowType.Child;
+                       attributes.Wclass = wclass ;
+                       attributes.visual = parent.Visual;
+                       attributes.colormap = parent.Colormap;
+                       attributes.Mask = (Gdk.EventMask.ButtonPressMask |
+                                          Gdk.EventMask.ButtonMotionMask |
+                                          Gdk.EventMask.ButtonReleaseMask |
+                                          Gdk.EventMask.ExposureMask |
+                                          Gdk.EventMask.EnterNotifyMask |
+                                          Gdk.EventMask.LeaveNotifyMask);
+
+                       attributesMask =
+                               Gdk.WindowAttributesType.Visual |
+                               Gdk.WindowAttributesType.Colormap;
+
+                       win = new Gdk.Window (parent.GdkWindow, attributes, 
attributesMask);
+                       win.UserData = parent.Handle;
+
+                       if (wclass == Gdk.WindowClass.InputOutput)
+                               parent.Style.Attach (win);
+
+                       return win;
+               }
        }
 }

Modified: trunk/stetic/libstetic/WidgetSite.cs
===================================================================
--- trunk/stetic/libstetic/WidgetSite.cs        2005-03-24 19:21:44 UTC (rev 
42232)
+++ trunk/stetic/libstetic/WidgetSite.cs        2005-03-24 19:37:03 UTC (rev 
42233)
@@ -12,19 +12,6 @@
                        Add (child);
                }
 
-               public override bool Internal {
-                       get {
-                               return base.Internal;
-                       }
-                       set {
-                               if (!base.Internal && value)
-                                       DND.SourceUnset (this);
-                               else if (base.Internal && !value)
-                                       DND.SourceSet (this, false);
-                               base.Internal = value;
-                       }
-               }
-
                public override bool HExpandable {
                        get {
                                Stetic.Wrapper.Widget child = 
Stetic.Wrapper.Widget.Lookup (Child);
@@ -39,248 +26,6 @@
                        }
                }
 
-               Hashtable faults;
-               Set hfaults;
-               const int FaultOverlap = 3;
-
-               public void AddFault (object id, Gtk.Orientation orientation, 
Rectangle fault)
-               {
-                       AddFault (id, orientation, fault.X, fault.Y, 
fault.Width, fault.Height);
-               }
-
-               public void AddFault (object id, Gtk.Orientation orientation,
-                                     int x, int y, int width, int height)
-               {
-                       if (!IsRealized)
-                               return;
-
-                       Gdk.Window win = NewWindow (GdkWindow, 
Gdk.WindowClass.InputOnly);
-                       win.MoveResize (x, y, width, height);
-
-                       if (faults == null || faults.Count == 0) {
-                               if (faults == null) {
-                                       faults = new Hashtable ();
-                                       hfaults = new Set ();
-                                       DND.DragBegin += ShowFaults;
-                                       DND.DragEnd += HideFaults;
-                               }
-                               DND.DestSet (this, false);
-                       }
-
-                       faults[id] = win;
-                       hfaults[id] = (orientation == 
Gtk.Orientation.Horizontal);
-               }
-
-               public void AddHFault (object id, WidgetSite above, WidgetSite 
below)
-               {
-                       if (!IsRealized)
-                               return;
-
-                       Gdk.Rectangle aboveAlloc, belowAlloc;
-                       int x1, y1, x2, y2;
-
-                       if (above != null && below != null) {
-                               aboveAlloc = above.Allocation;
-                               belowAlloc = below.Allocation;
-
-                               x1 = Math.Min (aboveAlloc.X, belowAlloc.X);
-                               x2 = Math.Max (aboveAlloc.X + aboveAlloc.Width, 
belowAlloc.X + belowAlloc.Width);
-                               y1 = aboveAlloc.Y + aboveAlloc.Height;
-                               y2 = belowAlloc.Y;
-
-                               while (y2 - y1 < FaultOverlap * 2) {
-                                       y1--;
-                                       y2++;
-                               }
-                       } else if (above == null) {
-                               belowAlloc = below.Allocation;
-
-                               x1 = belowAlloc.X;
-                               x2 = belowAlloc.X + belowAlloc.Width;
-                               y1 = 0;
-                               y2 = Math.Max (belowAlloc.Y, FaultOverlap);
-                       } else {
-                               aboveAlloc = above.Allocation;
-
-                               x1 = aboveAlloc.X;
-                               x2 = aboveAlloc.X + aboveAlloc.Width;
-                               y1 = Math.Min (aboveAlloc.Y + 
aboveAlloc.Height, Allocation.Height - FaultOverlap);
-                               y2 = Allocation.Height;
-                       }
-
-                       AddFault (id, Gtk.Orientation.Horizontal, x1, y1, x2 - 
x1, y2 - y1);
-               }
-
-               public void AddVFault (object id, WidgetSite left, WidgetSite 
right)
-               {
-                       if (!IsRealized)
-                               return;
-
-                       Gdk.Rectangle leftAlloc, rightAlloc;
-                       int x1, y1, x2, y2;
-
-                       if (left != null && right != null) {
-                               leftAlloc = left.Allocation;
-                               rightAlloc = right.Allocation;
-
-                               x1 = leftAlloc.X + leftAlloc.Width;
-                               x2 = rightAlloc.X;
-
-                               y1 = Math.Min (leftAlloc.Y, rightAlloc.Y);
-                               y2 = Math.Max (leftAlloc.Y + leftAlloc.Height, 
rightAlloc.Y + rightAlloc.Height);
-
-                               while (x2 - x1 < FaultOverlap * 2) {
-                                       x1--;
-                                       x2++;
-                               }
-                       } else if (left == null) {
-                               rightAlloc = right.Allocation;
-
-                               x1 = 0;
-                               x2 = Math.Max (rightAlloc.X, FaultOverlap);
-
-                               y1 = rightAlloc.Y;
-                               y2 = rightAlloc.Y + rightAlloc.Height;
-                       } else {
-                               leftAlloc = left.Allocation;
-
-                               x1 = Math.Min (leftAlloc.X + leftAlloc.Width, 
Allocation.Width - FaultOverlap);
-                               x2 = Allocation.Width;
-
-                               y1 = leftAlloc.Y;
-                               y2 = leftAlloc.Y + leftAlloc.Height;
-                       }
-
-                       AddFault (id, Gtk.Orientation.Vertical, x1, y1, x2 - 
x1, y2 - y1);
-               }
-
-               public void ClearFaults ()
-               {
-                       if (faults != null) {
-                               foreach (Gdk.Window win in faults.Values)
-                                       win.Destroy ();
-                               faults.Clear ();
-                               hfaults.Clear ();
-                       }
-                       DND.DestUnset (this);
-               }
-
-               void ShowFaults ()
-               {
-                       foreach (Gdk.Window win in faults.Values)
-                               win.Show ();
-               }
-
-               void HideFaults ()
-               {
-                       foreach (Gdk.Window win in faults.Values)
-                               win.Hide ();
-                       OnDragLeave (null, 0);
-               }
-
-               object dragFault;
-               Gdk.Window splitter;
-
-               void FindFault (int x, int y, out object fault, out Gdk.Window 
win)
-               {
-                       int wx, wy, width, height, depth;
-
-                       fault = null;
-                       win = null;
-                       wx = wy = width = height = 0;
-
-                       foreach (object id in faults.Keys) {
-                               win = faults[id] as Gdk.Window;
-                               win.GetGeometry (out wx, out wy, out width, out 
height, out depth);
-                               if (x >= wx && y >= wy && x <= wx + width && y 
<= wy + height) {
-                                       fault = id;
-                                       return;
-                               }
-                       }
-               }
-
-               // This is only called when dragging in fault mode, not in
-               // placeholder mode.
-               protected override bool OnDragMotion (Gdk.DragContext ctx, int 
x, int y, uint time)
-               {
-                       if (faults == null || faults.Count == 0)
-                               return false;
-
-                       int wx, wy, width, height, depth;
-                       object match;
-                       Gdk.Window matchWin;
-                       
-                       FindFault (x, y, out match, out matchWin);
-
-                       // If there's a splitter visible, and we're not 
currently dragging
-                       // in the fault that owns that splitter, hide it
-                       if (splitter != null && dragFault != match) {
-                               splitter.Hide ();
-                               splitter.Destroy ();
-                               splitter = null;
-                       }
-
-                       if (dragFault != match) {
-                               dragFault = match;
-                               if (dragFault == null)
-                                       return false;
-
-                               splitter = NewWindow (GdkWindow, 
Gdk.WindowClass.InputOutput);
-                               matchWin.GetGeometry (out wx, out wy, out 
width, out height, out depth);
-                               if (hfaults[dragFault]) {
-                                       splitter.MoveResize (wx, wy + height / 
2 - FaultOverlap,
-                                                            width, 2 * 
FaultOverlap);
-                               } else {
-                                       splitter.MoveResize (wx + width / 2 - 
FaultOverlap, wy,
-                                                            2 * FaultOverlap, 
height);
-                               }
-                               splitter.ShowUnraised ();
-                               GdkWindow.Lower ();
-                       } else if (dragFault == null)
-                               return false;
-
-                       Gdk.Drag.Status (ctx, Gdk.DragAction.Move, time);
-                       return true;
-               }
-
-               protected override void OnDragLeave (Gdk.DragContext ctx, uint 
time)
-               {
-                       if (splitter != null) {
-                               splitter.Hide ();
-                               splitter.Destroy ();
-                               splitter = null;
-                               dragFault = null;
-                       }
-               }
-
-               public delegate void DropOnHandler (Widget w, object faultId);
-               public event DropOnHandler DropOn;
-
-               protected virtual void Drop (Widget w, int x, int y)
-               {
-                       if (faults != null && DropOn != null) {
-                               object faultId = null;
-                               Gdk.Window win;
-                               FindFault (x, y, out faultId, out win);
-                               DropOn (w, faultId);
-                       } else
-                               Add (w);
-
-                       Stetic.Wrapper.Widget wrapper = 
Stetic.Wrapper.Widget.Lookup (w);
-                       if (wrapper != null)
-                               wrapper.Select ();
-               }
-
-               protected override bool OnDragDrop (DragContext ctx, int x, int 
y, uint time)
-               {
-                       Widget dragged = DND.Drop (ctx, time);
-                       if (dragged == null)
-                               return false;
-
-                       Drop (dragged, x, y);
-                       return true;
-               }
-
                public override string ToString ()
                {
                        if (Child.Name == null)

Modified: trunk/stetic/libstetic/wrapper/Box.cs
===================================================================
--- trunk/stetic/libstetic/wrapper/Box.cs       2005-03-24 19:21:44 UTC (rev 
42232)
+++ trunk/stetic/libstetic/wrapper/Box.cs       2005-03-24 19:37:03 UTC (rev 
42233)
@@ -43,7 +43,7 @@
                        if (site == null)
                                return;
 
-                       site.ClearFaults ();
+                       DND.ClearFaults (this);
 
                        Gtk.Widget[] children = box.Children;
                        if (children.Length == 0)
@@ -72,22 +72,22 @@
 
                        if (this is HBox || this is HButtonBox) {
                                if (sorted[0] != null)
-                                       site.AddVFault (0, null, sorted[0]);
+                                       DND.AddVFault (this, 0, null, 
sorted[0]);
                                if (sorted[sorted.Length - 1] != null)
-                                       site.AddVFault (sorted.Length, 
sorted[sorted.Length - 1], null);
+                                       DND.AddVFault (this, sorted.Length, 
sorted[sorted.Length - 1], null);
                        } else {
                                if (sorted[0] != null)
-                                       site.AddHFault (0, null, sorted[0]);
+                                       DND.AddHFault (this, 0, null, 
sorted[0]);
                                if (sorted[sorted.Length - 1] != null)
-                                       site.AddHFault (sorted.Length, 
sorted[sorted.Length - 1], null);
+                                       DND.AddHFault (this, sorted.Length, 
sorted[sorted.Length - 1], null);
                        }
 
                        for (int i = 1; i < sorted.Length; i++) {
                                if (sorted[i - 1] != null && sorted[i] != null) 
{
                                        if (this is HBox || this is HButtonBox)
-                                               site.AddVFault (i, sorted[i - 
1], sorted[i]);
+                                               DND.AddVFault (this, i, 
sorted[i - 1], sorted[i]);
                                        else
-                                               site.AddHFault (i, sorted[i - 
1], sorted[i]);
+                                               DND.AddHFault (this, i, 
sorted[i - 1], sorted[i]);
                                }
                        }
                }
@@ -149,8 +149,6 @@
                        WidgetSite site = box.Parent as WidgetSite;
                        if (site == null)
                                return;
-
-                       site.DropOn += DropOn;
                }
 
                void box_SizeAllocated (object obj, Gtk.SizeAllocatedArgs args)
@@ -158,7 +156,7 @@
                        Sync ();
                }
 
-               void DropOn (Gtk.Widget w, object faultId)
+               public override void Drop (Gtk.Widget w, object faultId)
                {
                        WidgetSite site = CreateWidgetSite (w);
                        AutoSize[site] = true;

Modified: trunk/stetic/libstetic/wrapper/Widget.cs
===================================================================
--- trunk/stetic/libstetic/wrapper/Widget.cs    2005-03-24 19:21:44 UTC (rev 
42232)
+++ trunk/stetic/libstetic/wrapper/Widget.cs    2005-03-24 19:37:03 UTC (rev 
42233)
@@ -110,6 +110,11 @@
                        w.GrabFocus ();
                }
 
+               public virtual void Drop (Gtk.Widget widget, object faultId)
+               {
+                       widget.Destroy ();
+               }
+
                public virtual bool HExpandable { get { return false; } }
                public virtual bool VExpandable { get { return false; } }
 

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to