Author: danw
Date: 2005-03-28 14:01:16 -0500 (Mon, 28 Mar 2005)
New Revision: 42313
Added:
trunk/stetic/libstetic/HandleWindow.cs
Modified:
trunk/stetic/ChangeLog
trunk/stetic/libstetic/IStetic.cs
trunk/stetic/libstetic/Makefile.am
trunk/stetic/libstetic/WidgetBox.cs
trunk/stetic/libstetic/wrapper/Container.cs
trunk/stetic/libstetic/wrapper/Notebook.cs
trunk/stetic/libstetic/wrapper/Table.cs
trunk/stetic/libstetic/wrapper/Widget.cs
trunk/stetic/libstetic/wrapper/Window.cs
trunk/stetic/stetic/Project.cs
trunk/stetic/stetic/ProjectView.cs
trunk/stetic/stetic/PropertyGrid.cs
Log:
* libstetic/HandleWindow.cs: new class to implement selection handles.
* libstetic/WidgetBox.cs: Remove all handle-related code
* libstetic/IStetic.cs (Select): new, to tell the main program to
select a widget (rather than having the it listen for an event on
all toplevel windows).
* libstetic/wrapper/Widget.cs (Select, UnSelect): tell the parent
container (if any) to select this widget
(CreateWidgetSite, CreatePlaceholder): remove these; anything that
is a container needs to be subclassing Container, not Widget.
* libstetic/wrapper/Container.cs (CreateWidgetSite,
CreatePlaceholder): catch ButtonPressEvents
(SiteButtonPress, PlaceholderButtonPress): handle
selection/context menus
(Select, UnSelect): update handles, call stetic.Select()
* libstetic/wrapper/Notebook.cs: FIXME out a few bits for now...
* libstetic/wrapper/Table.cs (OnButtonPressEvent): remove this
code, which has been commented-out forever.
* libstetic/wrapper/Window.cs (SetFocus, Select): gone; selection
is handled at the Container level now.
* stetic/Project.cs (WindowFocusChanged): gone
(IStetic.Select): handle selection here
(SelectedHandler): change the WidgetBox arg to a Wrapper.Widget
* stetic/ProjectView.cs (WidgetSelected):
* stetic/PropertyGrid.cs (Selected): update signature
Modified: trunk/stetic/ChangeLog
===================================================================
--- trunk/stetic/ChangeLog 2005-03-28 18:26:00 UTC (rev 42312)
+++ trunk/stetic/ChangeLog 2005-03-28 19:01:16 UTC (rev 42313)
@@ -1,3 +1,39 @@
+2005-03-28 Dan Winship <[EMAIL PROTECTED]>
+
+ * libstetic/HandleWindow.cs: new class to implement selection handles.
+
+ * libstetic/WidgetBox.cs: Remove all handle-related code
+
+ * libstetic/IStetic.cs (Select): new, to tell the main program to
+ select a widget (rather than having the it listen for an event on
+ all toplevel windows).
+
+ * libstetic/wrapper/Widget.cs (Select, UnSelect): tell the parent
+ container (if any) to select this widget
+ (CreateWidgetSite, CreatePlaceholder): remove these; anything that
+ is a container needs to be subclassing Container, not Widget.
+
+ * libstetic/wrapper/Container.cs (CreateWidgetSite,
+ CreatePlaceholder): catch ButtonPressEvents
+ (SiteButtonPress, PlaceholderButtonPress): handle
+ selection/context menus
+ (Select, UnSelect): update handles, call stetic.Select()
+
+ * libstetic/wrapper/Notebook.cs: FIXME out a few bits for now...
+
+ * libstetic/wrapper/Table.cs (OnButtonPressEvent): remove this
+ code, which has been commented-out forever.
+
+ * libstetic/wrapper/Window.cs (SetFocus, Select): gone; selection
+ is handled at the Container level now.
+
+ * stetic/Project.cs (WindowFocusChanged): gone
+ (IStetic.Select): handle selection here
+ (SelectedHandler): change the WidgetBox arg to a Wrapper.Widget
+
+ * stetic/ProjectView.cs (WidgetSelected):
+ * stetic/PropertyGrid.cs (Selected): update signature
+
2005-03-24 Dan Winship <[EMAIL PROTECTED]>
* libstetic/DND.cs: move the drag-and-drop "fault" code from
Added: trunk/stetic/libstetic/HandleWindow.cs
===================================================================
--- trunk/stetic/libstetic/HandleWindow.cs 2005-03-28 18:26:00 UTC (rev
42312)
+++ trunk/stetic/libstetic/HandleWindow.cs 2005-03-28 19:01:16 UTC (rev
42313)
@@ -0,0 +1,116 @@
+using System;
+
+namespace Stetic {
+
+ // This ought to be a subclass of Gdk.Window, but GdkWindow isn't
subclassable
+
+ public class HandleWindow : IDisposable {
+
+ static Gdk.Color black, white;
+
+ static HandleWindow ()
+ {
+ black = new Gdk.Color (0, 0, 0);
+ black.Pixel = 1;
+ white = new Gdk.Color (255, 255, 255);
+ white.Pixel = 0;
+ }
+
+ public HandleWindow (Gtk.Widget selection, bool showHandles)
+ {
+ if (selection.Parent is WidgetBox)
+ selection = selection.Parent;
+ this.selection = selection;
+ this.showHandles = showHandles;
+
+ selection.SizeAllocated += SelectionResized;
+
+ Gdk.WindowAttr attributes = new Gdk.WindowAttr ();
+ attributes.WindowType = Gdk.WindowType.Child;
+ attributes.Wclass = Gdk.WindowClass.InputOutput;
+ attributes.visual = selection.Visual;
+ attributes.colormap = selection.Colormap;
+ attributes.Mask = (Gdk.EventMask.ButtonPressMask |
+ Gdk.EventMask.ButtonMotionMask |
+ Gdk.EventMask.ButtonReleaseMask |
+ Gdk.EventMask.ExposureMask);
+ window = new Gdk.Window (selection.Toplevel.GdkWindow,
attributes,
+
Gdk.WindowAttributesType.Visual |
+
Gdk.WindowAttributesType.Colormap);
+ window.UserData = selection.Handle;
+ selection.Style.Attach (window);
+
+ Shape ();
+ }
+
+ public void Dispose ()
+ {
+ if (selection != null) {
+ selection.SizeAllocated -= SelectionResized;
+ selection = null;
+ }
+
+ if (window != null) {
+ window.Destroy ();
+ window = null;
+ }
+ }
+
+ Gtk.Widget selection;
+ bool showHandles;
+
+ Gdk.Window window;
+ public Gdk.Window Window {
+ get {
+ return window;
+ }
+ }
+
+ const int handleSize = 6;
+
+ public void Shape ()
+ {
+ Gdk.GC gc;
+ Gdk.Pixmap pixmap;
+ Gdk.Rectangle handleAllocation;
+ int tlx, tly;
+
+ selection.TranslateCoordinates (selection.Toplevel, 0,
0, out tlx, out tly);
+ handleAllocation.X = tlx - handleSize / 2;
+ handleAllocation.Y = tly - handleSize / 2;
+ handleAllocation.Width = selection.Allocation.Width +
handleSize;
+ handleAllocation.Height = selection.Allocation.Height +
handleSize;
+
+ int width = handleAllocation.Width, height =
handleAllocation.Height;
+
+ pixmap = new Gdk.Pixmap (window, width, height, 1);
+ gc = new Gdk.GC (pixmap);
+ gc.Background = white;
+ gc.Foreground = white;
+ pixmap.DrawRectangle (gc, true, 0, 0, width, height);
+
+ gc.Foreground = black;
+
+ // Draw border
+ pixmap.DrawRectangle (gc, false, handleSize / 2,
handleSize / 2,
+ width - handleSize, height -
handleSize);
+
+ if (showHandles) {
+ pixmap.DrawRectangle (gc, true, 0, 0,
handleSize, handleSize);
+ pixmap.DrawRectangle (gc, true, 0, height -
handleSize, handleSize, handleSize);
+ pixmap.DrawRectangle (gc, true, width -
handleSize, 0, handleSize, handleSize);
+ pixmap.DrawRectangle (gc, true, width -
handleSize, height - handleSize, handleSize, handleSize);
+ }
+
+ window.Hide ();
+ window.MoveResize (handleAllocation);
+ window.ShapeCombineMask (pixmap, 0, 0);
+ window.Show ();
+ }
+
+ void SelectionResized (object obj, Gtk.SizeAllocatedArgs args)
+ {
+ Shape ();
+ }
+ }
+}
Modified: trunk/stetic/libstetic/IStetic.cs
===================================================================
--- trunk/stetic/libstetic/IStetic.cs 2005-03-28 18:26:00 UTC (rev 42312)
+++ trunk/stetic/libstetic/IStetic.cs 2005-03-28 19:01:16 UTC (rev 42313)
@@ -7,6 +7,8 @@
WidgetSite CreateWidgetSite (Gtk.Widget w);
Placeholder CreatePlaceholder ();
+ void Select (Stetic.Wrapper.Widget wrapper);
+
Gtk.Widget LookupWidgetById (string id);
event ISteticDelegate GladeImportComplete;
Modified: trunk/stetic/libstetic/Makefile.am
===================================================================
--- trunk/stetic/libstetic/Makefile.am 2005-03-28 18:26:00 UTC (rev 42312)
+++ trunk/stetic/libstetic/Makefile.am 2005-03-28 19:01:16 UTC (rev 42313)
@@ -9,6 +9,7 @@
GladeException.cs \
GladePropertyAttribute.cs \
GladeUtils.cs \
+ HandleWindow.cs \
ItemDescriptor.cs \
ItemGroup.cs \
IStetic.cs \
Modified: trunk/stetic/libstetic/WidgetBox.cs
===================================================================
--- trunk/stetic/libstetic/WidgetBox.cs 2005-03-28 18:26:00 UTC (rev 42312)
+++ trunk/stetic/libstetic/WidgetBox.cs 2005-03-28 19:01:16 UTC (rev 42313)
@@ -7,52 +7,14 @@
public abstract class WidgetBox : Gtk.Bin {
- static Color black, white;
-
- static WidgetBox ()
- {
- black = new Color (0, 0, 0);
- black.Pixel = 1;
- white = new Color (255, 255, 255);
- white.Pixel = 0;
- }
-
public WidgetBox ()
{
- WidgetFlags |= WidgetFlags.CanFocus;
WidgetFlags &= ~WidgetFlags.NoWindow;
}
public abstract bool HExpandable { get; }
public abstract bool VExpandable { get; }
- public Gdk.Window HandleWindow;
- bool showHandles;
- protected bool ShowHandles {
- get { return showHandles; }
- set {
- if (value == showHandles)
- return;
- showHandles = value;
-
- if (showHandles) {
- if (IsRealized) {
- HandleWindow = NewWindow
(Toplevel.GdkWindow, Gdk.WindowClass.InputOutput);
- HandleWindow.Background = black;
- ShapeHandles ();
- }
- if (IsMapped)
- HandleWindow.Show ();
- } else {
- if (HandleWindow != null) {
- HandleWindow.Hide ();
- HandleWindow.Destroy ();
- HandleWindow = null;
- }
- }
- }
- }
-
bool isInternal;
public virtual bool Internal {
get { return isInternal; }
@@ -60,60 +22,17 @@
if (value == isInternal)
return;
isInternal = value;
-
- if (ShowHandles) {
- ShowHandles = false;
- ShowHandles = true;
- }
}
}
- protected override void OnAdded (Widget child)
- {
- child.ButtonPressEvent += InterceptButtonPress;
- base.OnAdded (child);
- }
-
- protected override void OnRemoved (Widget child)
- {
- child.ButtonPressEvent -= InterceptButtonPress;
- ShowHandles = false;
- base.OnRemoved (child);
- }
-
public event EventHandler PopupContextMenu;
- protected void EmitPopupContextMenu ()
+ public void EmitPopupContextMenu ()
{
if (PopupContextMenu != null)
PopupContextMenu (this, EventArgs.Empty);
}
- [ConnectBefore]
- void InterceptButtonPress (object obj, ButtonPressEventArgs
args)
- {
- if (args.Event.Type != EventType.ButtonPress)
- return;
-
- if (args.Event.Button == 1 && !ShowHandles) {
- GrabFocus ();
- args.RetVal = true;
- } else if (args.Event.Button == 3) {
- args.RetVal = true;
- EmitPopupContextMenu ();
- }
- }
-
- protected override bool OnButtonPressEvent (Gdk.EventButton evt)
- {
-
- if (evt.Button == 3 && evt.Type ==
EventType.ButtonPress)
- EmitPopupContextMenu ();
- else
- GrabFocus ();
- return true;
- }
-
protected override bool OnPopupMenu ()
{
EmitPopupContextMenu ();
@@ -134,8 +53,6 @@
if (GdkWindow != null && GdkWindow != ParentWindow)
GdkWindow.MoveResize (allocation);
- if (HandleWindow != null)
- ShapeHandles ();
if (Child != null) {
allocation.X = allocation.Y = 0;
@@ -187,95 +104,12 @@
GdkWindow = NewWindow (ParentWindow,
Gdk.WindowClass.InputOutput);
Style.SetBackground (GdkWindow, StateType.Normal);
-
- if (ShowHandles) {
- HandleWindow = NewWindow (Toplevel.GdkWindow,
Gdk.WindowClass.InputOutput);
- HandleWindow.Background = black;
- ShapeHandles ();
- }
}
- private const int handleSize = 6;
- void ShapeHandles ()
- {
- Gdk.GC gc;
- Gdk.Pixmap pixmap;
- Rectangle handleAllocation;
- int tlx, tly;
-
- TranslateCoordinates (Toplevel, 0, 0, out tlx, out tly);
- handleAllocation.X = tlx - handleSize / 2;
- handleAllocation.Y = tly - handleSize / 2;
- handleAllocation.Width = Allocation.Width + handleSize;
- handleAllocation.Height = Allocation.Height +
handleSize;
-
- int width = handleAllocation.Width, height =
handleAllocation.Height;
-
- pixmap = new Pixmap (HandleWindow, width, height, 1);
- gc = new Gdk.GC (pixmap);
- gc.Background = white;
- gc.Foreground = white;
- pixmap.DrawRectangle (gc, true, 0, 0, width, height);
-
- gc.Foreground = black;
-
- // Draw border
- pixmap.DrawRectangle (gc, false, handleSize / 2,
handleSize / 2,
- width - handleSize, height -
handleSize);
-
- if (!Internal) {
- // Draw corner handles
- pixmap.DrawRectangle (gc, true, 0, 0,
handleSize, handleSize);
- pixmap.DrawRectangle (gc, true, 0, height -
handleSize, handleSize, handleSize);
- pixmap.DrawRectangle (gc, true, width -
handleSize, 0, handleSize, handleSize);
- pixmap.DrawRectangle (gc, true, width -
handleSize, height - handleSize, handleSize, handleSize);
- }
-
- HandleWindow.MoveResize (handleAllocation);
- HandleWindow.ShapeCombineMask (pixmap, 0, 0);
- }
-
- protected override void OnMapped ()
- {
- base.OnMapped ();
- if (HandleWindow != null)
- HandleWindow.Show ();
- }
-
- protected override void OnUnmapped ()
- {
- if (HandleWindow != null)
- HandleWindow.Hide ();
- base.OnUnmapped ();
- }
-
- protected override void OnUnrealized ()
- {
- if (HandleWindow != null) {
- HandleWindow.Destroy ();
- HandleWindow = null;
- }
- base.OnUnrealized ();
- }
-
protected override void OnSetScrollAdjustments (Gtk.Adjustment
hadj, Gtk.Adjustment vadj)
{
if (Child != null)
Child.SetScrollAdjustments (hadj, vadj);
}
-
- public event EventHandler Selected;
-
- public void Focus ()
- {
- ShowHandles = true;
- if (Selected != null)
- Selected (this, EventArgs.Empty);
- }
-
- public void UnFocus ()
- {
- ShowHandles = false;
- }
}
}
Modified: trunk/stetic/libstetic/wrapper/Container.cs
===================================================================
--- trunk/stetic/libstetic/wrapper/Container.cs 2005-03-28 18:26:00 UTC (rev
42312)
+++ trunk/stetic/libstetic/wrapper/Container.cs 2005-03-28 19:01:16 UTC (rev
42313)
@@ -29,6 +29,19 @@
} while (type != typeof (Stetic.Wrapper.Container));
}
+ public override void Wrap (object obj, bool initialized)
+ {
+ base.Wrap (obj, initialized);
+ container.Removed += SiteRemoved;
+ container.SizeAllocated += SizeAllocated;
+ }
+
+ Gtk.Container container {
+ get {
+ return (Gtk.Container)Wrapped;
+ }
+ }
+
int freeze;
protected void Freeze ()
{
@@ -55,18 +68,6 @@
freeze = 0;
}
- Gtk.Container container {
- get {
- return (Gtk.Container)Wrapped;
- }
- }
-
- public override void Wrap (object obj, bool initialized)
- {
- base.Wrap (obj, initialized);
- container.Removed += SiteRemoved;
- }
-
public virtual Widget GladeImportChild (string className,
string id,
Hashtable props,
Hashtable childprops)
{
@@ -189,10 +190,13 @@
protected Set AutoSize = new Set ();
- protected override WidgetSite CreateWidgetSite (Gtk.Widget w)
+ protected virtual WidgetSite CreateWidgetSite (Gtk.Widget w)
{
- WidgetSite site = base.CreateWidgetSite (w);
+ WidgetSite site = stetic.CreateWidgetSite (w);
+ site.Show ();
site.MotionNotifyEvent += SiteMotionNotify;
+ site.ButtonPressEvent += SiteButtonPress;
+ w.ButtonPressEvent += SiteButtonPress;
DND.SourceSet (site, false);
Container childWrapper = Lookup (w);
@@ -202,16 +206,50 @@
return site;
}
+ [GLib.ConnectBefore]
+ void SiteButtonPress (object obj, Gtk.ButtonPressEventArgs args)
+ {
+ if (args.Event.Type != Gdk.EventType.ButtonPress)
+ return;
+
+ Gtk.Widget w;
+ WidgetSite site = obj as WidgetSite;
+ if (site == null) {
+ w = (Gtk.Widget)obj;
+ site = w.Parent as WidgetSite;
+ } else
+ w = site.Child;
+ Stetic.Wrapper.Widget wrapper =
Stetic.Wrapper.Widget.Lookup (w);
+ if (wrapper == null || site == null)
+ return;
+
+ if (args.Event.Button == 1) {
+ if (w == selection) {
+ if (args.Event.Window == handles.Window)
+ args.RetVal = true;
+ return;
+ }
+ wrapper.Select ();
+ args.RetVal = true;
+ } else if (args.Event.Button == 3) {
+ site.EmitPopupContextMenu ();
+ args.RetVal = true;
+ }
+ }
+
void SiteMotionNotify (object obj, Gtk.MotionNotifyEventArgs
args)
{
WidgetSite site = obj as WidgetSite;
- if (args.Event.Window != site.HandleWindow ||
+ if (handles == null ||
+ args.Event.Window != handles.Window ||
!DND.CanDrag (site, args.Event)) {
args.RetVal = true;
return;
}
+ Select ((Stetic.Wrapper.Widget)null);
+
Placeholder ph = CreatePlaceholder ();
ph.Mimic (site);
ReplaceChild (site, ph);
@@ -222,15 +260,33 @@
DND.Drag (ph, args.Event, dragWidget);
}
- protected override Placeholder CreatePlaceholder ()
+ protected virtual Placeholder CreatePlaceholder ()
{
- Placeholder ph = base.CreatePlaceholder ();
+ Placeholder ph = stetic.CreatePlaceholder ();
+ ph.Show ();
ph.Drop += PlaceholderDrop;
ph.DragEnd += PlaceholderDragEnd;
+ ph.ButtonPressEvent += PlaceholderButtonPress;
AutoSize[ph] = true;
return ph;
}
+ void PlaceholderButtonPress (object obj,
Gtk.ButtonPressEventArgs args)
+ {
+ if (args.Event.Type != Gdk.EventType.ButtonPress)
+ return;
+
+ Placeholder ph = obj as Placeholder;
+
+ if (args.Event.Button == 1) {
+ Select (ph);
+ args.RetVal = true;
+ } else if (args.Event.Button == 3) {
+ ph.EmitPopupContextMenu ();
+ args.RetVal = true;
+ }
+ }
+
void PlaceholderDrop (Placeholder ph, Gtk.Widget dropped)
{
WidgetSite site = CreateWidgetSite (dropped);
@@ -316,6 +372,51 @@
Sync ();
}
+ Gtk.Widget selection;
+ HandleWindow handles;
+
+ public void Select (Stetic.Wrapper.Widget wrapper)
+ {
+ if (wrapper == null)
+ Select ((Gtk.Widget)null);
+ else
+ Select (wrapper.Wrapped);
+ stetic.Select (wrapper);
+ }
+
+ public void UnSelect (Stetic.Wrapper.Widget wrapper)
+ {
+ if (selection == wrapper.Wrapped)
+ Select ((Gtk.Widget)null);
+ }
+
+ public void Select (Placeholder ph)
+ {
+ Select ((Gtk.Widget)ph);
+ stetic.Select (null);
+ }
+
+ void Select (Gtk.Widget widget)
+ {
+ if (widget == selection)
+ return;
+ selection = widget;
+
+ if (handles != null)
+ handles.Dispose ();
+
+ if (selection != null)
+ handles = new HandleWindow (selection, !(widget
is Placeholder));
+ else
+ handles = null;
+ }
+
+ void SizeAllocated (object obj, Gtk.SizeAllocatedArgs args)
+ {
+ if (handles != null)
+ handles.Shape ();
+ }
+
public class ContainerChild : Stetic.ObjectWrapper {
public static new Type WrappedType = typeof
(Gtk.Container.ContainerChild);
Modified: trunk/stetic/libstetic/wrapper/Notebook.cs
===================================================================
--- trunk/stetic/libstetic/wrapper/Notebook.cs 2005-03-28 18:26:00 UTC (rev
42312)
+++ trunk/stetic/libstetic/wrapper/Notebook.cs 2005-03-28 19:01:16 UTC (rev
42313)
@@ -47,7 +47,7 @@
if (childprops.Count == 1 &&
((string)childprops["type"]) == "tab") {
ObjectWrapper wrapper =
Stetic.ObjectWrapper.GladeImport (stetic, className, id, props);
WidgetSite site = CreateWidgetSite
((Gtk.Widget)wrapper.Wrapped);
- site.Selected += LabelSelected;
+// FIXME site.Selected += LabelSelected;
notebook.SetTabLabel (notebook.GetNthPage
(notebook.NPages - 1), site);
tabs.Add (site);
@@ -86,7 +86,7 @@
Stetic.Wrapper.Label label = new Stetic.Wrapper.Label
("page" + (notebook.NPages + 1).ToString ());
labelSite = CreateWidgetSite
((Gtk.Widget)label.Wrapped);
- labelSite.Selected += LabelSelected;
+// FIXME labelSite.Selected += LabelSelected;
tabs.Insert (position, labelSite);
return notebook.InsertPage (CreatePlaceholder (),
labelSite, position);
Modified: trunk/stetic/libstetic/wrapper/Table.cs
===================================================================
--- trunk/stetic/libstetic/wrapper/Table.cs 2005-03-28 18:26:00 UTC (rev
42312)
+++ trunk/stetic/libstetic/wrapper/Table.cs 2005-03-28 19:01:16 UTC (rev
42313)
@@ -364,72 +364,6 @@
base.ChildContentsChanged (child);
}
-#if NOT
- private const int delta = 4;
-
- protected override bool OnButtonPressEvent (Gdk.EventButton evt)
- {
- int diff, closest;
- Where where = Where.None;
- Rectangle alloc;
-
- if (evt.Type != EventType.TwoButtonPress)
- return false;
-
- if (FocusChild == null)
- return false;
-
- alloc = FocusChild.Allocation;
-
- closest = delta;
- diff = (int)evt.X;
- if (diff < closest) {
- closest = diff;
- where = Where.Left;
- }
- diff = alloc.Width - (int)evt.X;
- if (diff < closest) {
- closest = diff;
- where = Where.Right;
- }
- diff = (int)evt.Y;
- if (diff < closest) {
- closest = diff;
- where = Where.Above;
- }
- diff = alloc.Height - (int)evt.Y;
- if (diff < closest) {
- closest = diff;
- where = Where.Below;
- }
-
- Gtk.Table.TableChild tc = table[FocusChild] as
Gtk.Table.TableChild;
-
- switch (where) {
- case Where.None:
- return false;
-
- case Where.Left:
- AddColumn (tc.LeftAttach);
- break;
-
- case Where.Right:
- AddColumn (tc.RightAttach);
- break;
-
- case Where.Above:
- AddRow (tc.TopAttach);
- break;
-
- case Where.Below:
- AddRow (tc.BottomAttach);
- break;
- }
-
- return true;
- }
-#endif
-
public class TableChild : Container.ContainerChild {
public static new Type WrappedType = typeof
(Gtk.Table.TableChild);
Modified: trunk/stetic/libstetic/wrapper/Widget.cs
===================================================================
--- trunk/stetic/libstetic/wrapper/Widget.cs 2005-03-28 18:26:00 UTC (rev
42312)
+++ trunk/stetic/libstetic/wrapper/Widget.cs 2005-03-28 19:01:16 UTC (rev
42313)
@@ -47,6 +47,31 @@
}
}
+ public Stetic.Wrapper.Container ParentWrapper {
+ get {
+ Gtk.Widget p = Wrapped.Parent;
+ while (p != null && (p is WidgetSite))
+ p = p.Parent;
+ return Stetic.Wrapper.Container.Lookup (p);
+ }
+ }
+
+ public void Select ()
+ {
+ if (ParentWrapper != null)
+ ParentWrapper.Select (this);
+ else if (this is Stetic.Wrapper.Container)
+ ((Container)this).Select (this);
+ }
+
+ public void UnSelect ()
+ {
+ if (ParentWrapper != null)
+ ParentWrapper.UnSelect (this);
+ else if (this is Stetic.Wrapper.Container)
+ ((Container)this).UnSelect (this);
+ }
+
protected virtual void GladeImport (string className, string
id, Hashtable props)
{
GladeUtils.ImportWidget (stetic, this, className, id,
props);
@@ -63,29 +88,6 @@
return Stetic.ObjectWrapper.Lookup (obj) as
Stetic.Wrapper.Widget;
}
- protected virtual WidgetSite CreateWidgetSite (Gtk.Widget w)
- {
- WidgetSite site = stetic.CreateWidgetSite (w);
- site.Show ();
- return site;
- }
-
- protected virtual Placeholder CreatePlaceholder ()
- {
- Placeholder ph = stetic.CreatePlaceholder ();
- ph.Show ();
- return ph;
- }
-
- public Stetic.Wrapper.Container ParentWrapper {
- get {
- Gtk.Widget p = Wrapped.Parent;
- while (p != null && (p is WidgetSite))
- p = p.Parent;
- return Stetic.Wrapper.Container.Lookup (p);
- }
- }
-
string internalChildId;
public string InternalChildId {
get {
@@ -102,14 +104,6 @@
}
}
- public virtual void Select ()
- {
- Gtk.Widget w = Wrapped;
- if (!w.CanFocus && w.Parent is WidgetSite)
- w = w.Parent;
- w.GrabFocus ();
- }
-
public virtual void Drop (Gtk.Widget widget, object faultId)
{
widget.Destroy ();
Modified: trunk/stetic/libstetic/wrapper/Window.cs
===================================================================
--- trunk/stetic/libstetic/wrapper/Window.cs 2005-03-28 18:26:00 UTC (rev
42312)
+++ trunk/stetic/libstetic/wrapper/Window.cs 2005-03-28 19:01:16 UTC (rev
42313)
@@ -52,53 +52,15 @@
}
window.DeleteEvent += DeleteEvent;
- window.SetFocus += SetFocus;
}
- public delegate void FocusChangedHandler (Stetic.Wrapper.Window
wrapper, WidgetBox focus);
- public event FocusChangedHandler FocusChanged;
-
- [ConnectBefore] // otherwise contents.Focus will be the new
focus, not the old
- void SetFocus (object obj, Gtk.SetFocusArgs args)
- {
- Gtk.Widget w;
-
- w = ((Gtk.Window)Wrapped).Focus;
- while (w != null && !(w is WidgetBox))
- w = w.Parent;
- WidgetBox oldf = (WidgetBox)w;
-
- w = args.Focus;
- while (w != null && !(w is WidgetBox))
- w = w.Parent;
- WidgetBox newf = (WidgetBox)w;
-
- if (oldf == newf)
- return;
-
- if (oldf != null)
- oldf.UnFocus ();
- if (newf != null)
- newf.Focus ();
-
- if (FocusChanged != null)
- FocusChanged (this, newf);
- }
-
- public override void Select ()
- {
- Wrapped.Show ();
- ((Gtk.Window)Wrapped).Focus = null;
- }
-
[ConnectBefore]
void DeleteEvent (object obj, Gtk.DeleteEventArgs args)
{
Wrapped.Hide ();
args.RetVal = true;
- if (FocusChanged != null)
- FocusChanged (this, null);
+ Select (this);
}
public override bool HExpandable { get { return true; } }
Modified: trunk/stetic/stetic/Project.cs
===================================================================
--- trunk/stetic/stetic/Project.cs 2005-03-28 18:26:00 UTC (rev 42312)
+++ trunk/stetic/stetic/Project.cs 2005-03-28 19:01:16 UTC (rev 42313)
@@ -21,11 +21,9 @@
public void AddWindow (Stetic.Wrapper.Window window, bool
select)
{
- window.FocusChanged += WindowFocusChanged;
AddWidget (window.Wrapped, null, -1);
-
if (select)
- WindowFocusChanged (window, null);
+ Select (window);
}
void AddWidget (Widget widget, ProjectNode parent)
@@ -155,20 +153,27 @@
store = new NodeStore (typeof (ProjectNode));
}
- public delegate void SelectedHandler (WidgetBox box,
ProjectNode node);
+ public delegate void SelectedHandler (Stetic.Wrapper.Widget
focus, ProjectNode node);
public event SelectedHandler Selected;
- void WindowFocusChanged (Stetic.Wrapper.Window window,
WidgetBox focus)
+ Stetic.Wrapper.Widget selection;
+
+ public void Select (Stetic.Wrapper.Widget selection)
{
+ if (this.selection == selection)
+ return;
+
+ if (this.selection != null)
+ this.selection.UnSelect ();
+ this.selection = selection;
+
if (Selected == null)
return;
- if (focus == null)
+ if (selection == null)
Selected (null, null);
- else if (focus.Child == null)
- Selected (focus, null);
else
- Selected (focus, nodes[focus.Child] as
ProjectNode);
+ Selected (selection, nodes[selection.Wrapped]
as ProjectNode);
}
// IStetic
Modified: trunk/stetic/stetic/ProjectView.cs
===================================================================
--- trunk/stetic/stetic/ProjectView.cs 2005-03-28 18:26:00 UTC (rev 42312)
+++ trunk/stetic/stetic/ProjectView.cs 2005-03-28 19:01:16 UTC (rev 42313)
@@ -52,7 +52,7 @@
}
}
- void WidgetSelected (WidgetBox box, ProjectNode node)
+ void WidgetSelected (Stetic.Wrapper.Widget selection,
ProjectNode node)
{
if (!syncing) {
syncing = true;
Modified: trunk/stetic/stetic/PropertyGrid.cs
===================================================================
--- trunk/stetic/stetic/PropertyGrid.cs 2005-03-28 18:26:00 UTC (rev 42312)
+++ trunk/stetic/stetic/PropertyGrid.cs 2005-03-28 19:01:16 UTC (rev 42313)
@@ -93,19 +93,16 @@
}
}
- void Selected (WidgetBox box, ProjectNode node)
+ void Selected (Stetic.Wrapper.Widget selection, ProjectNode
node)
{
Clear ();
- WidgetSite site = box as WidgetSite;
- if (site == null) {
+ this.selection = selection;
+ if (selection == null) {
AppendLabel ("<i>No selection</i>");
return;
}
- selection = Stetic.Wrapper.Widget.Lookup (site.Child);
- if (selection == null)
- return;
selection.Notify += Notified;
AppendProperty (new PropertyDescriptor (typeof
(Stetic.Wrapper.Widget), typeof (Gtk.Widget), "Name"), selection);
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches