[Monodevelop-patches-list] r1753 - trunk/MonoDevelop/src/Libraries/Gdl

commit-watcher at mono-cvs.ximian.com commit-watcher at mono-cvs.ximian.com
Sun Jun 13 06:18:53 EDT 2004


Author: jzwart
Date: 2004-06-13 06:18:53 -0400 (Sun, 13 Jun 2004)
New Revision: 1753

Modified:
   trunk/MonoDevelop/src/Libraries/Gdl/DockItem.cs
   trunk/MonoDevelop/src/Libraries/Gdl/DockItemGrip.cs
   trunk/MonoDevelop/src/Libraries/Gdl/DockMaster.cs
   trunk/MonoDevelop/src/Libraries/Gdl/DockObject.cs
   trunk/MonoDevelop/src/Libraries/Gdl/GdlDockTest.cs
Log:
Add some more events and hook them up. Make the DockItemBehavior flags actually
work in the DockItemGrip. Remove some C'isms in the DockItemGrip code.


Modified: trunk/MonoDevelop/src/Libraries/Gdl/DockItem.cs
===================================================================
--- trunk/MonoDevelop/src/Libraries/Gdl/DockItem.cs	2004-06-12 23:37:47 UTC (rev 1752)
+++ trunk/MonoDevelop/src/Libraries/Gdl/DockItem.cs	2004-06-13 10:18:53 UTC (rev 1753)
@@ -74,14 +74,10 @@
 				DockItemBehavior oldBehavior = behavior;
 				behavior = value;
 				if (((oldBehavior ^ behavior) & DockItemBehavior.Locked) != 0) {
-					/* PORT THIS:
-					                if (GDL_DOCK_OBJECT_GET_MASTER (item))
-                    g_signal_emit_by_name (GDL_DOCK_OBJECT_GET_MASTER (item),
-                                           "layout_changed");
-                g_object_notify (g_object, "locked");
-                gdl_dock_item_showhide_grip (item);
-                */
-                		}
+					if (Master != null)
+						Master.EmitLayoutChangedEvent ();
+				}
+				EmitPropertyEvent ("Behavior");
 			}
 		}
 		
@@ -165,17 +161,16 @@
 				return ((behavior & DockItemBehavior.Locked) != 0);
 			}
 			set {
-				DockItemBehavior old_beh = behavior;
+				DockItemBehavior oldBehavior = behavior;
 				if (value)
 					behavior |= DockItemBehavior.Locked;
 				else
 					behavior &= ~(DockItemBehavior.Locked);
-				if ((old_beh ^ behavior) != 0) {
-					//PORT THIS:
-					//gdl_dock_item_showhide_grip (item /*this*/);
-					//g_object_notify (g_object, "behavior");
-					//if (GDL_DOCK_OBJECT_GET_MASTER (item))
-					//    g_signal_emit_by_name (GDL_DOCK_OBJECT_GET_MASTER (item)), "layout_changed");
+
+				if ((oldBehavior ^ behavior) != 0) {
+					if (Master != null)
+						Master.EmitLayoutChangedEvent ();
+					EmitPropertyEvent ("Locked");
 				}
 			}
 		}
@@ -186,6 +181,7 @@
 			}
 			set {
 				SetOrientation (value);
+				EmitPropertyEvent ("Orientation");
 			}
 		}
 		
@@ -214,6 +210,7 @@
 			set {
 				resize = value;
 				QueueResize ();
+				EmitPropertyEvent ("Resize");
 			}
 		}
 		

Modified: trunk/MonoDevelop/src/Libraries/Gdl/DockItemGrip.cs
===================================================================
--- trunk/MonoDevelop/src/Libraries/Gdl/DockItemGrip.cs	2004-06-12 23:37:47 UTC (rev 1752)
+++ trunk/MonoDevelop/src/Libraries/Gdl/DockItemGrip.cs	2004-06-13 10:18:53 UTC (rev 1753)
@@ -3,141 +3,197 @@
 using System;
 using Gtk;
 
-//FIXME: Hook up the event notifyin stuff here.
-
 namespace Gdl
 {
 	public class DockItemGrip : Container
 	{
 		private DockItem item;
-		private Gdk.Window title_window;
-		private Button close_button;
-		private Button iconify_button;
+		private Gdk.Window titleWindow;
+		private Button closeButton;
+		private Button iconifyButton;
 		private Tooltips tooltips;
-		private bool icon_pixbuf_valid = false;
-		private Gdk.Pixbuf icon_pixbuf = null;
+		private Gdk.Pixbuf icon = null;
 		private string title;
-		private Pango.Layout title_layout = null;
+		private Pango.Layout layout = null;
 
 		protected DockItemGrip (IntPtr raw) : base (raw) { }
 		
-		public DockItemGrip ()
+		protected DockItemGrip ()
 		{
 			Flags |= (int)WidgetFlags.NoWindow;
 			
 			Widget.PushCompositeChild ();
-			close_button = new Button ();
+			closeButton = new Button ();
 			Widget.PopCompositeChild ();
 			
-			close_button.Flags &= ~(int)WidgetFlags.CanFocus;
-			close_button.Parent = this;
-			close_button.Relief = ReliefStyle.None;
-			close_button.Show ();
+			closeButton.Flags &= ~(int)WidgetFlags.CanFocus;
+			closeButton.Parent = this;
+			closeButton.Relief = ReliefStyle.None;
+			closeButton.Show ();
 			
 			Image image = new Image (Gdl.Stock.Close, IconSize.Menu);
-			close_button.Add (image);
+			closeButton.Add (image);
 			image.Show ();
 			
-			close_button.Clicked += new EventHandler (CloseClicked);
+			closeButton.Clicked += new EventHandler (CloseClicked);
 			
 			Widget.PushCompositeChild ();
-			iconify_button = new Button ();
+			iconifyButton = new Button ();
 			Widget.PopCompositeChild ();
 			
-			iconify_button.Flags &= ~(int)(WidgetFlags.CanFocus);
-			iconify_button.Parent = this;
-			iconify_button.Relief = ReliefStyle.None;
-			iconify_button.Show ();
+			iconifyButton.Flags &= ~(int)(WidgetFlags.CanFocus);
+			iconifyButton.Parent = this;
+			iconifyButton.Relief = ReliefStyle.None;
+			iconifyButton.Show ();
 			
 			image = new Image (Gdl.Stock.MenuLeft, IconSize.Menu);
-			iconify_button.Add (image);
+			iconifyButton.Add (image);
 			image.Show ();
 			
-			iconify_button.Clicked += new EventHandler (IconifyClicked);
+			iconifyButton.Clicked += new EventHandler (IconifyClicked);
 			
 			tooltips = new Tooltips ();
-			tooltips.SetTip (iconify_button, "Iconify", "Iconify this dock");
-			tooltips.SetTip (close_button, "Close", "Close this dock");
+			tooltips.SetTip (iconifyButton, "Iconify", "Iconify this dock");
+			tooltips.SetTip (closeButton, "Close", "Close this dock");
 		}
 		
 		public DockItemGrip (DockItem item) : this ()
 		{
+			if (item == null)
+				throw new ArgumentNullException ("A valid DockItem must be given");
 			Item = item;
 		}
 		
+		private Gdk.Pixbuf Icon {
+			get {
+				if (icon == null && item.StockId != null)
+					icon = RenderIcon (item.StockId, IconSize.Menu, "");
+				return icon;
+			}
+		}
+		
 		public DockItem Item {
-			get { return item; }
+			get {
+				return item;
+			}
 			set {
-				//hookup notify stuff here
 				item = value;
-				if (!(item.CantClose) && close_button != null)
-					close_button.Show ();
-				if (!(item.CantIconify) && iconify_button != null)
-					iconify_button.Show ();
+				item.PropertyChanged += OnPropertyChanged;
+				
+				if (!item.CantClose)
+					closeButton.Show ();
+				else
+					closeButton.Hide ();
+
+				if (!item.CantIconify)
+					iconifyButton.Show ();
+				else
+					iconifyButton.Hide ();
+
+				icon = null;
+				layout = null;
+				title = null;
 			}
 		}
 		
-		public Gdk.Window TitleWindow {
-			get { return title_window; }
-			set { title_window = value; }
+		private Pango.Layout Layout {
+			get {
+				if (layout == null) {
+					layout = CreatePangoLayout (Title);
+					layout.SingleParagraphMode = true;
+				}
+				return layout;
+			}
 		}
 		
-		public Gdk.Rectangle GetTitleArea ()
-		{
-			Gdk.Rectangle area;
-			int border = (int)BorderWidth;
-			int alloc_height, alloc_width;
-			
-			area.Width = (Allocation.Width - 2 * border);
-			
-			title_layout.GetPixelSize (out alloc_width, out alloc_height);
-			
-			if (close_button.Visible) {
-				alloc_height = Math.Max (alloc_height, close_button.Allocation.Height);
-				area.Width -= close_button.Allocation.Width;
+		private string Title {
+			get {
+				if (title == null) {
+					if (item.LongName != null)
+						title = item.LongName;
+					else
+						title = "";
+				}
+				return title;
 			}
-			if (iconify_button.Visible) {
-				alloc_height = Math.Max (alloc_height, iconify_button.Allocation.Height);
-				area.Width -= close_button.Allocation.Width;
+			set {
+				title = value;
+				if (layout != null)
+					layout.SetText (Title);
 			}
-			
-			area.X = Allocation.X + border;
-			area.Y = Allocation.Y + border;
-			area.Height = alloc_height;
-			
-			if (Direction == TextDirection.Rtl)
-				area.X += (Allocation.Width - 2 * border) - area.Width;
+		}
+		
+		private Gdk.Rectangle TitleArea {
+			get {
+				Gdk.Rectangle area;
+				int bw = (int)BorderWidth;
+				int height, width;
 				
-			return area;
+				area.Width = Allocation.Width - 2 * bw;
+				
+				Layout.GetPixelSize (out width, out height);
+				
+				if (closeButton.Visible) {
+					height = Math.Max (height, closeButton.Allocation.Height);
+					area.Width -= closeButton.Allocation.Width;
+				}
+				
+				if (iconifyButton.Visible) {
+					height = Math.Max (height, iconifyButton.Allocation.Height);
+					area.Width -= iconifyButton.Allocation.Width;
+				}
+				
+				area.X = Allocation.X + bw;
+				area.Y = Allocation.Y + bw;
+				area.Height = height;
+				
+				if (Direction == TextDirection.Rtl)
+					area.X += (Allocation.Width - 2 * bw) - area.Width;
+					
+				return area;
+			}
 		}
 		
-		private void EnsureTitleAndIconPixbuf ()
-		{
-			if (title == null) {
-				title = item.LongName;
-				if (title == null)
-					title = "";
+		public Gdk.Window TitleWindow {
+			get {
+				return titleWindow;
 			}
-			
-			if (!icon_pixbuf_valid) {
-				if (item.StockId != null) {
-					icon_pixbuf = RenderIcon (item.StockId, IconSize.Menu, "");
-				}
-				icon_pixbuf_valid = true;
+			set {
+				titleWindow = value;
 			}
-			
-			if (title_layout == null) {
-				title_layout = CreatePangoLayout (title);
-				title_layout.SingleParagraphMode = true;
+		}
+		
+		private void OnPropertyChanged (object o, string name)
+		{
+			switch (name) {
+			case "StockId":
+				icon = RenderIcon (item.StockId, IconSize.Menu, "");
+				break;
+			case "LongName":
+				Title = item.LongName;
+				break;
+			case "Behavior":
+				if (!item.CantClose)
+					closeButton.Show ();
+				else
+					closeButton.Hide ();
+
+				if (!item.CantIconify)
+					iconifyButton.Show ();
+				else
+					iconifyButton.Hide ();
+				break;
+			default:
+				break;
 			}
 		}
 
 		/*protected override void OnDestroyed ()
 		{
-			if (title_layout != null)
-				title_layout = null;
-			if (icon_pixbuf != null)
-				icon_pixbuf = null;
+			if (layout != null)
+				layout = null;
+			if (icon != null)
+				icon = null;
 			if (tooltips != null)
 				tooltips = null;
 			if (item != null) {
@@ -149,38 +205,47 @@
 	
 		protected override bool OnExposeEvent (Gdk.EventExpose evnt)
 		{
-			Gdk.Rectangle title_area = GetTitleArea ();
-			Gdk.Rectangle expose_area;
+			Gdk.Rectangle titleArea = TitleArea;
+			Gdk.Rectangle exposeArea;
 			
-			if (icon_pixbuf != null) {
-				Gdk.Rectangle pixbuf_rect;
-				pixbuf_rect.Width = icon_pixbuf.Width;
-				pixbuf_rect.Height = icon_pixbuf.Height;
+			if (Icon != null) {
+				Gdk.Rectangle pixbufRect;
+				pixbufRect.Width = icon.Width;
+				pixbufRect.Height = icon.Height;
 				
 				if (Direction == TextDirection.Rtl) {
-					pixbuf_rect.X = title_area.X + title_area.Width - pixbuf_rect.Width;
+					pixbufRect.X = titleArea.X + titleArea.Width - pixbufRect.Width;
 				} else {
-					pixbuf_rect.X = title_area.X;
-					title_area.X += pixbuf_rect.Width + 1;
+					pixbufRect.X = titleArea.X;
+					titleArea.X += pixbufRect.Width + 1;
 				}
 				
-				title_area.Width -= pixbuf_rect.Width - 1;
-				pixbuf_rect.Y = title_area.Y + (title_area.Height - pixbuf_rect.Height) / 2;
-				if (evnt.Area.Intersect (pixbuf_rect, out expose_area)) {
+				titleArea.Width -= pixbufRect.Width - 1;
+				pixbufRect.Y = titleArea.Y + (titleArea.Height - pixbufRect.Height) / 2;
+
+				if (evnt.Area.Intersect (pixbufRect, out exposeArea)) {
 					Gdk.GC gc = Style.BackgroundGC (State);
-					GdkWindow.DrawPixbuf (gc, icon_pixbuf, 0, 0, pixbuf_rect.X, pixbuf_rect.Y, pixbuf_rect.Width, pixbuf_rect.Height, Gdk.RgbDither.None, 0, 0);
+					GdkWindow.DrawPixbuf (gc, icon, 0, 0, pixbufRect.X,
+							      pixbufRect.Y, pixbufRect.Width,
+							      pixbufRect.Height, Gdk.RgbDither.None,
+							      0, 0);
 				}
 			}
 
-			if (title_area.Intersect (evnt.Area, out expose_area)) {
-				int layout_width, layout_height, text_x, text_y;
-				title_layout.GetPixelSize (out layout_width, out layout_height);
+			if (titleArea.Intersect (evnt.Area, out exposeArea)) {
+				int width, height, textX, textY;
+				Layout.GetPixelSize (out width, out height);
+				
 				if (Direction == TextDirection.Rtl)
-					text_x = title_area.X + title_area.Width - layout_width;
+					textX = titleArea.X + titleArea.Width - width;
 				else
-					text_x = title_area.X;
-				text_y = title_area.Y + (title_area.Height - layout_height) / 2;
-				Style.PaintLayout (Style, GdkWindow, State, true, expose_area, this, null, text_x, text_y, title_layout);
+					textX = titleArea.X;
+
+				textY = titleArea.Y + (titleArea.Height - height) / 2;
+	
+				Style.PaintLayout (Style, GdkWindow, State, true,
+						   exposeArea, this, null, textX,
+						   textY, layout);
 			}
 			
 			return base.OnExposeEvent (evnt);
@@ -194,20 +259,18 @@
 		private void IconifyClicked (object o, EventArgs e)
 		{
 			item.IconifyItem ();
-			iconify_button.InButton = false;
-			iconify_button.Leave ();
+			iconifyButton.InButton = false;
+			iconifyButton.Leave ();
 		}
 		
 		protected override void OnRealized ()
 		{
 			base.OnRealized ();
-			if (title_window == null) {
+
+			if (titleWindow == null) {
 				Gdk.WindowAttr attributes = new Gdk.WindowAttr ();
+				Gdk.Rectangle area = TitleArea;
 				
-				EnsureTitleAndIconPixbuf ();
-				
-				Gdk.Rectangle area = GetTitleArea ();
-				
 				attributes.X = area.X;
 				attributes.Y = area.Y;
 				attributes.Width = area.Width;
@@ -215,36 +278,45 @@
 				attributes.WindowType = Gdk.WindowType.Temp;
 				attributes.Wclass = Gdk.WindowClass.InputOnly;
 				attributes.OverrideRedirect = true;
-				attributes.EventMask = (int) (Events | Gdk.EventMask.ButtonPressMask | Gdk.EventMask.ButtonReleaseMask | Gdk.EventMask.ButtonMotionMask);
-				title_window = new Gdk.Window (ParentWindow, attributes, (int) (Gdk.WindowAttributesType.X | Gdk.WindowAttributesType.Y | Gdk.WindowAttributesType.Noredir));
-				title_window.UserData = Handle;
-				title_window.Cursor = new Gdk.Cursor (Display, Gdk.CursorType.Hand2);
+				attributes.EventMask = (int) (Events |
+					Gdk.EventMask.ButtonPressMask |
+					Gdk.EventMask.ButtonReleaseMask |
+					Gdk.EventMask.ButtonMotionMask);
+	
+				titleWindow = new Gdk.Window (ParentWindow, attributes,
+					(int) (Gdk.WindowAttributesType.X |
+					Gdk.WindowAttributesType.Y |
+					Gdk.WindowAttributesType.Noredir));
+
+				titleWindow.UserData = Handle;
+				titleWindow.Cursor = new Gdk.Cursor (Display, Gdk.CursorType.Hand2);
 			}
 		}
 		
 		protected override void OnUnrealized ()
 		{
-			if (title_window != null) {
-				title_window.UserData = IntPtr.Zero;
-				title_window.Destroy ();
-				title_window = null;
+			if (titleWindow != null) {
+				titleWindow.UserData = IntPtr.Zero;
+				titleWindow.Destroy ();
+				titleWindow = null;
 			}
+
 			base.OnUnrealized ();
 		}
 		
 		protected override void OnMapped ()
 		{
 			base.OnMapped ();
-			if (title_window != null) {
-				title_window.Show ();
-			}
+
+			if (titleWindow != null)
+				titleWindow.Show ();
 		}
 		
 		protected override void OnUnmapped ()
 		{
-			if (title_window != null) {
-				title_window.Hide ();
-			}
+			if (titleWindow != null)
+				titleWindow.Hide ();
+
 			base.OnUnmapped ();
 		}
 		
@@ -253,103 +325,104 @@
 			requisition.Width = (int)BorderWidth * 2;
 			requisition.Height = (int)BorderWidth * 2;
 
-			EnsureTitleAndIconPixbuf ();
-			
-			if (close_button.Visible) {
-				Requisition childReq = close_button.SizeRequest ();
+			if (closeButton.Visible) {
+				Requisition childReq = closeButton.SizeRequest ();
 				requisition.Width += childReq.Width;
 				requisition.Height = Math.Max (requisition.Height,
 							       childReq.Height);
 			}
 			
-			if (iconify_button.Visible) {
-				Requisition childReq = iconify_button.SizeRequest ();
+			if (iconifyButton.Visible) {
+				Requisition childReq = iconifyButton.SizeRequest ();
 				requisition.Width += childReq.Width;
 				requisition.Height = Math.Max (requisition.Height,
 							       childReq.Height);
 			}
 			
-			if (icon_pixbuf != null) {
-				requisition.Width += icon_pixbuf.Width + 1;
+			if (Icon != null) {
+				requisition.Width += icon.Width + 1;
 				requisition.Height = Math.Max (requisition.Height,
-							       icon_pixbuf.Height);
+							       icon.Height);
 			}
 		}
 		
 		private void EllipsizeLayout (int width)
 		{
 			if (width <= 0) {
-				title_layout.SetText ("");
+				layout.SetText ("");
 				return;
 			}
 			
 			int w, h, ell_w, ell_h, x, empty;
-			title_layout.GetPixelSize (out w, out h);
+			layout.GetPixelSize (out w, out h);
 			if (w <= width) return;
 			
-			Pango.Layout ell = title_layout.Copy ();
+			Pango.Layout ell = layout.Copy ();
 			ell.SetText ("...");
 			ell.GetPixelSize (out ell_w, out ell_h);
 			if (width < ell_w) {
-				title_layout.SetText ("");
+				layout.SetText ("");
 				return;
 			}
 			
 			width -= ell_w;
-			Pango.LayoutLine line = title_layout.GetLine (0);
-			string text = title_layout.Text;
+			Pango.LayoutLine line = layout.GetLine (0);
+			string text = layout.Text;
 			if (line.XToIndex (width * 1024, out x, out empty)) {
-				title_layout.SetText (text.Substring (0, x) + "...");
+				layout.SetText (text.Substring (0, x) + "...");
 			}
 		}
 		
 		protected override void OnSizeAllocated (Gdk.Rectangle allocation)
 		{
 			base.OnSizeAllocated (allocation);
-			Gdk.Rectangle child_allocation;
+
+			Gdk.Rectangle childAlloc;
+			int bw = (int)BorderWidth;
 			
 			if (Direction == TextDirection.Rtl)
-				child_allocation.X = allocation.X + (int)BorderWidth;
+				childAlloc.X = allocation.X + bw;
 			else
-				child_allocation.X = allocation.X + allocation.Width - (int)BorderWidth;
-			child_allocation.Y = allocation.Y + (int)BorderWidth;
+				childAlloc.X = allocation.X + allocation.Width - bw;
+			childAlloc.Y = allocation.Y + bw;
 			
-			if (close_button.Visible) {
-				Requisition button_requisition = close_button.SizeRequest ();
+			if (closeButton.Visible) {
+				Requisition buttonReq = closeButton.SizeRequest ();
+
 				if (Direction != TextDirection.Rtl) 
-					child_allocation.X -= button_requisition.Width;
+					childAlloc.X -= buttonReq.Width;
+				childAlloc.Width = buttonReq.Width;
+				childAlloc.Height = buttonReq.Height;
 				
-				child_allocation.Width = button_requisition.Width;
-				child_allocation.Height = button_requisition.Height;
+				closeButton.SizeAllocate (childAlloc);
 				
-				close_button.SizeAllocate (child_allocation);
-				
 				if (Direction == TextDirection.Rtl)
-					child_allocation.X += button_requisition.Width;
+					childAlloc.X += buttonReq.Width;
 			}
 			
-			if (iconify_button.Visible) {
-				Requisition button_requisition = iconify_button.SizeRequest ();
+			if (iconifyButton.Visible) {
+				Requisition buttonReq = iconifyButton.SizeRequest ();
+				
 				if (Direction != TextDirection.Rtl)
-					child_allocation.X -= button_requisition.Width;
+					childAlloc.X -= buttonReq.Width;
+				childAlloc.Width = buttonReq.Width;
+				childAlloc.Height = buttonReq.Height;
 				
-				child_allocation.Width = button_requisition.Width;
-				child_allocation.Height = button_requisition.Height;
+				iconifyButton.SizeAllocate (childAlloc);
 				
-				iconify_button.SizeAllocate (child_allocation);
-				
 				if (Direction == TextDirection.Rtl)
-					child_allocation.X += button_requisition.Width;
+					childAlloc.X += buttonReq.Width;
 			}
 			
-			if (title_window != null) {
-				EnsureTitleAndIconPixbuf ();
-				title_layout.SetText (title);
-				Gdk.Rectangle area = GetTitleArea ();
-				title_window.MoveResize (area.X, area.Y, area.Width, area.Height);
-				if (icon_pixbuf != null) {
-					area.Width -= icon_pixbuf.Width + 1;
-				}
+			if (TitleWindow != null) {
+				layout.SetText (title);
+
+				Gdk.Rectangle area = TitleArea;
+				titleWindow.MoveResize (area.X, area.Y,area.Width, area.Height);
+				
+				if (Icon != null)
+					area.Width -= icon.Width + 1;
+				
 				EllipsizeLayout (area.Width);
 			}
 		}
@@ -367,8 +440,8 @@
 		protected override void ForAll (bool include_internals, CallbackInvoker invoker)
 		{
 			if (include_internals) {
-				invoker.Invoke (close_button);
-				invoker.Invoke (iconify_button);
+				invoker.Invoke (closeButton);
+				invoker.Invoke (iconifyButton);
 			}
 		}
 	}

Modified: trunk/MonoDevelop/src/Libraries/Gdl/DockMaster.cs
===================================================================
--- trunk/MonoDevelop/src/Libraries/Gdl/DockMaster.cs	2004-06-12 23:37:47 UTC (rev 1752)
+++ trunk/MonoDevelop/src/Libraries/Gdl/DockMaster.cs	2004-06-13 10:18:53 UTC (rev 1753)
@@ -377,5 +377,10 @@
 				}
 			}
 		}
+		
+		internal void EmitLayoutChangedEvent ()
+		{
+			// FIXME: emit the LayoutChanged event here.
+		}
 	}
 }

Modified: trunk/MonoDevelop/src/Libraries/Gdl/DockObject.cs
===================================================================
--- trunk/MonoDevelop/src/Libraries/Gdl/DockObject.cs	2004-06-12 23:37:47 UTC (rev 1752)
+++ trunk/MonoDevelop/src/Libraries/Gdl/DockObject.cs	2004-06-13 10:18:53 UTC (rev 1753)
@@ -4,6 +4,8 @@
 
 namespace Gdl
 {
+	public delegate void PropertyChangedHandler (object o, string name);
+
 	public class DockObject : Container
 	{	
 		private DockObjectFlags flags = DockObjectFlags.Automatic;
@@ -16,6 +18,7 @@
 		
 		public event DetachedHandler Detached;
 		public event DockedHandler Docked;
+		public event PropertyChangedHandler PropertyChanged;
 
 		protected DockObject (IntPtr raw) : base (raw) { }
 		protected DockObject () : base () { }
@@ -26,6 +29,7 @@
 			}
 			set {
 				flags = value;
+				EmitPropertyEvent ("DockObjectFlags");
 			}
 		}
 		
@@ -77,6 +81,7 @@
 			}
 			set {
 				longName = value;
+				EmitPropertyEvent ("LongName");
 			}
 		}
 		
@@ -89,6 +94,7 @@
 					Bind (master);
 				else
 					Unbind ();
+				EmitPropertyEvent ("Master");
 			}
 		}
 		
@@ -98,6 +104,7 @@
 			}
 			set {
 				name = value;
+				EmitPropertyEvent ("Name");
 			}
 		}
 		
@@ -110,12 +117,14 @@
 				return parent != null ? (DockObject)parent : null;
 			}
 		}
+
 		public string StockId {
 			get {
 				return stockid;
 			}
 			set {
 				stockid = value;
+				EmitPropertyEvent ("StockId");
 			}
 		}
 
@@ -297,9 +306,10 @@
 			/* notify interested parties that an object has been docked. */
 			if (position != DockPlacement.None) {
 				OnDocked (requestor, position, data);
-				if (Docked != null) {
+				DockedHandler handler = Docked;
+				if (handler != null) {
 					DockedArgs args = new DockedArgs (requestor, position);
-					Docked (this, args);
+					handler (this, args);
 				}
 			}
 			
@@ -378,5 +388,15 @@
 				//g_object_notify (G_OBJECT (object) /*this*/, "master");
 			}
 		}
+		
+		protected void EmitPropertyEvent (string name)
+		{
+			// Make a local assignment of the handler here to prevent
+			// any race conditions if the PropertyChanged value changes
+			// to null after the != null check.
+			PropertyChangedHandler handler = PropertyChanged;
+			if (handler != null)
+				handler (this, name);
+		}
 	}
 }

Modified: trunk/MonoDevelop/src/Libraries/Gdl/GdlDockTest.cs
===================================================================
--- trunk/MonoDevelop/src/Libraries/Gdl/GdlDockTest.cs	2004-06-12 23:37:47 UTC (rev 1752)
+++ trunk/MonoDevelop/src/Libraries/Gdl/GdlDockTest.cs	2004-06-13 10:18:53 UTC (rev 1753)
@@ -16,9 +16,19 @@
 		app.SetDefaultSize (400, 400);
 		app.DeleteEvent += new DeleteEventHandler (OnAppDelete);
 		
-		Dock dock = new Dock ();
+		Box table = new VBox (false, 5);
+		table.BorderWidth = 10;
+		app.Add (table);
+		
+		Dock dock = new Dock ();		
 		//DockLayout layout = new DockLayout (dock);
+		//DockBar dockbar = new DockBar (dock);
 		
+		Box box = new HBox (false, 5);
+		//box.PackStart (dockbar, false, false, 0);
+		box.PackEnd (dock, true, true, 0);
+		table.PackStart (box, true, true, 0);
+
 		DockItem di = new DockItem ("item1", "Item #1", DockItemBehavior.Locked);
 		di.Add (CreateTextView ());
 		dock.AddItem (di, DockPlacement.Top);
@@ -31,13 +41,9 @@
 		DockItem di3 = new DockItem ("item3", "Item #3 has accented characters",/* (áéíóúñ)",*/
 					     Gtk.Stock.Convert, DockItemBehavior.Normal |
 					     DockItemBehavior.CantClose);
-		di3.Add (CreateTextView ());
+		di3.Add (new Button ("Button 3"));
 		dock.AddItem (di3, DockPlacement.Bottom);
 
-		DockItem di4 = new DockItem ("itemfloat", "Floating Item", Gtk.Stock.Convert, DockItemBehavior.Normal);
-		di4.Add (new Label ("Floating dockitem"));
-		dock.AddFloatingItem (di4, 10, 10, 200, 200);
-		
 		DockItem[] items = new DockItem[4];
 		items[0] = new DockItem ("item4", "Item #4", Gtk.Stock.JustifyFill,
 					 DockItemBehavior.Normal | DockItemBehavior.CantIconify);
@@ -57,8 +63,23 @@
 		di3.DockTo (di, DockPlacement.Top);
 		di2.DockTo (di3, DockPlacement.Right);
 		di2.DockTo (di3, DockPlacement.Left);
+		di2.DockTo (null, DockPlacement.Floating);
 
-		app.Add (dock);
+		box = new HBox (true, 5);
+		table.PackEnd (box, false, false, 0);
+		
+		Button button = new Button (Gtk.Stock.Save);
+		button.Clicked += OnSaveLayout;
+		box.PackEnd (button, false, true, 0);
+		
+		button = new Button ("Layout Manager");
+		button.Clicked += OnRunLayoutManager;
+		box.PackEnd (button, false, true, 0);
+
+		button = new Button ("Dump XML");
+		button.Clicked += OnDumpXML;
+		box.PackEnd (button, false, true, 0);
+
 		app.ShowAll ();
 		Application.Run ();
 	}
@@ -76,6 +97,18 @@
 		return sw;
 	}
 	
+	private void OnSaveLayout (object o, EventArgs args)
+	{
+	}
+	
+	private void OnRunLayoutManager (object o, EventArgs args)
+	{
+	}
+	
+	private void OnDumpXML (object o, EventArgs args)
+	{
+	}
+	
 	private void OnAppDelete (object o, DeleteEventArgs args)
 	{
 		Application.Quit ();




More information about the Monodevelop-patches-list mailing list