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

commit-watcher at mono-cvs.ximian.com commit-watcher at mono-cvs.ximian.com
Tue Jun 8 01:12:24 EDT 2004


Author: tberman
Date: 2004-06-08 01:12:24 -0400 (Tue, 08 Jun 2004)
New Revision: 1707

Added:
   trunk/MonoDevelop/src/Libraries/Gdl/DockNotebook.cs
   trunk/MonoDevelop/src/Libraries/Gdl/DockPaned.cs
   trunk/MonoDevelop/src/Libraries/Gdl/DockPlaceholder.cs
Modified:
   trunk/MonoDevelop/src/Libraries/Gdl/DockItem.cs
   trunk/MonoDevelop/src/Libraries/Gdl/DockObject.cs
   trunk/MonoDevelop/src/Libraries/Gdl/Gdl.prjx
   trunk/MonoDevelop/src/Libraries/Gdl/Makefile.Gdl
Log:
lots more code


Modified: trunk/MonoDevelop/src/Libraries/Gdl/DockItem.cs
===================================================================
--- trunk/MonoDevelop/src/Libraries/Gdl/DockItem.cs	2004-06-08 04:51:04 UTC (rev 1706)
+++ trunk/MonoDevelop/src/Libraries/Gdl/DockItem.cs	2004-06-08 05:12:24 UTC (rev 1707)
@@ -61,6 +61,11 @@
 			this.StockId = stock_id;
 		}
 		
+		public Gtk.Widget TabLabel {
+			get { return this.tab_label; }
+			set { this.tab_label = value; }
+		}
+		
 		public virtual bool HasGrip {
 			get { return true; }
 		}
@@ -742,7 +747,7 @@
 			}
 		}
 		
-		public void SetDefaultPosition (DockObject reference)
+		public virtual void SetDefaultPosition (DockObject reference)
 		{
 			this.ph = null;
 			

Added: trunk/MonoDevelop/src/Libraries/Gdl/DockNotebook.cs
===================================================================
--- trunk/MonoDevelop/src/Libraries/Gdl/DockNotebook.cs	2004-06-08 04:51:04 UTC (rev 1706)
+++ trunk/MonoDevelop/src/Libraries/Gdl/DockNotebook.cs	2004-06-08 05:12:24 UTC (rev 1707)
@@ -0,0 +1,182 @@
+// created on 07/06/2004 at 5:44 P
+
+using System;
+using Gtk;
+
+namespace Gdl
+{
+	public class DockNotebook : DockItem
+	{
+		
+		static DockNotebook ()
+		{
+			Gtk.Rc.ParseString ("style \"gdl-dock-notebook-default\" {\n" +
+			                    "xthickness = 2\n" +
+			                    "ythickness = 2\n" +
+			                    "}\n" +
+			                    "widget_class \"*.GtkNotebook.Gdl_DockItem\" " +
+			                    "style : gtk \"gdl-dock-notebook-default\"\n");
+		}
+		
+		public DockNotebook ()
+		{
+			this.Child = new Gtk.Notebook ();
+			this.Child.Parent = this;
+			((Gtk.Notebook)this.Child).TabPos = Gtk.PositionType.Bottom;
+			((Gtk.Notebook)this.Child).SwitchPage += new Gtk.SwitchPageHandler (SwitchPageCb);
+			((Gtk.Notebook)this.Child).ButtonPressEvent += new Gtk.ButtonPressEvent (ButtonPressCb);
+			((Gtk.Notebook)this.Child).ButtonReleaseEvent += new Gtk.ButtonReleaseEvent (ButtonReleaseCb);
+			((Gtk.Notebook)this.Child).Scrollable = true;
+			this.Child.Show ();
+			this.DockObjectFlags &= DockObjectFlags.Automatic;
+		}
+		
+		protected void SwitchPageHandler (object o, SwitchPageArgs e)
+		{
+			//Does this code need to be ported at all?
+		}
+		
+		protected override void OnAdded (Gtk.Widget widget)
+		{
+			if (widget == null || !(widget is DockItem))
+				return;
+			this.Dock ((DockObject)widget, DockPlacement.Center, null);
+		}
+		
+		private CallbackInvoker stored_invoker;
+		protected override void ForAll (bool include_internals, CallbackInvoker invoker)
+		{
+			if (include_internals) {
+				base.ForAll (include_internals, invoker);
+			} else {
+				if (this.Child != null) {
+					Console.WriteLine ("Missing a foreach here we prolly need");
+					stored_invoker = invoker;
+					lock (stored_invoker) {
+						((Gtk.Notebook)this.Child).Foreach (new Gtk.Callback (childForall));
+					}
+				}
+			}
+		}
+		
+		private void childForAll (Gtk.Widget widget)
+		{
+			stored_invoker.Invoke (widget);
+		}
+		
+		protected struct DockInfo
+		{
+			public DockPlacement position;
+			public object other_data;
+			
+			public DockInfo (DockPlacement pos, object data)
+			{
+				position = pos;
+				other_data = data;
+			}
+		}
+		
+		private void dock_child (Widget w)
+		{
+			this.Dock (w, stored_info.position, stored_info.other_data);
+		}
+		
+		private DockInfo stored_info;
+		protected override void Dock (DockObject requestor, DockPlacement position, object extra_data)
+		{
+			if (position == DockPlacement.Center) {
+				if (requestor.IsCompound) {
+					requestor.Freeze ();
+					stored_info = new DockInfo (position, extra_data);
+					lock (stored_info) {
+						requestor.Foreach (new Gtk.Callback (dock_child));
+					}
+					requestor.Thaw ();
+				} else {
+					DockItem requestor_item = requestor as DockItem;
+					if (requestor_item == null)
+						return;
+					Gtk.Widget label = requestor_item.TabLabel;
+					if (label == null) {
+						label = new Gtk.Label (requestor_item.LongName);
+						requestor_item.TabLabel = label;
+					}
+					int position = -1;
+					if (extra_data is Int32)
+						position = Convert.ToInt32 (extra_data);
+					((Gtk.Notebook)this.Child).InsertPage (requestor, label, position);
+					requestor.DockObjectFlags |= DockObjectFlags.Attached;
+				}
+			} else
+				base.Dock (requestor, position, extra_data);
+		}
+		
+		public override SetOrientation (Gtk.Orientation orientation)
+		{
+			if (this.Child != null && this.Child is Gtk.Notebook) {
+				if (orientation == Gtk.Orientation.Horizontal)
+					((Gtk.Notebook)this.Child).TabPos = Gtk.PositionType.Top;
+				else
+					((Gtk.Notebook)this.Child).TabPos = Gtk.PositionType.Left;
+			}
+			base.SetOrientation (orientation);
+		}
+		
+		public override bool ChildPlacement (DockObject child, ref DockPlacement position)
+		{
+			DockPlacement pos = DockPlacement.None;
+			if (this.Child != null) {
+				foreach (Gtk.Widget widget in ((Gtk.Notebook)this.Child).Children) {
+					if (widget == child) {
+						pos = DockPlacement.Center;
+						break;
+					}
+				}
+			}
+			if (pos != DockPlacement.None) {
+				position = pos;
+				return true;
+			}
+			return false;
+		}
+		
+		public override void Present (DockObject child)
+		{
+			int i = ((Gtk.Notebook)this.Child).PageNum (child);
+			if (i >= 0) {
+				((Gtk.Notebook)this.Child).CurrentPage = i;
+			}
+			base.Present (child);
+		}
+		
+		public bool Reorder (DockObject requestor, DockPlacement new_position, object other_data)
+		{
+			bool handled = false;
+			int current_position, new_pos = -1;
+			
+			if (this.Child != null && new_position == DockPlacement.Center) {
+				current_position = ((Gtk.Notebook)this.Child).PageNum (requestor);
+				if (current_position >= 0) {
+					handled = true;
+					if (other_data is Int32)
+						new_pos = Convert.ToInt32 (other_data);
+					((Gtk.Notebook)this.Child).ReorderChild (requestor, new_pos);
+				}
+			}
+			return handled;
+		}
+		
+		public override bool IsCompound {
+			get { return false; }
+		}
+		
+		public int Page {
+			get { return ((Gtk.Notebook)this.Child).CurrentPage; }
+			set { ((Gtk.Notebook)this.Child).CurrentPage = value; }
+		}
+		
+		public override bool HasGrip {
+			get { return false; }
+		}
+	}
+}
\ No newline at end of file

Modified: trunk/MonoDevelop/src/Libraries/Gdl/DockObject.cs
===================================================================
--- trunk/MonoDevelop/src/Libraries/Gdl/DockObject.cs	2004-06-08 04:51:04 UTC (rev 1706)
+++ trunk/MonoDevelop/src/Libraries/Gdl/DockObject.cs	2004-06-08 05:12:24 UTC (rev 1707)
@@ -156,7 +156,7 @@
 			this.Show ();
 		}
 		
-		public abstract bool ChildPlacement (DockObject child, DockPlacement placement);
+		public abstract bool ChildPlacement (DockObject child, ref DockPlacement placement);
 		
 		public virtual bool IsCompound {
 			get {
@@ -186,6 +186,12 @@
 			}
 		}
 		
+		public bool InReflow {
+			get {
+				return ((this.flags & Gdl.DockObjectFlags.InReflow) != 0);
+			}
+		}
+		
 		public void Freeze ()
 		{
 			freeze_count++;

Added: trunk/MonoDevelop/src/Libraries/Gdl/DockPaned.cs
===================================================================
--- trunk/MonoDevelop/src/Libraries/Gdl/DockPaned.cs	2004-06-08 04:51:04 UTC (rev 1706)
+++ trunk/MonoDevelop/src/Libraries/Gdl/DockPaned.cs	2004-06-08 05:12:24 UTC (rev 1707)
@@ -0,0 +1 @@
+// created on 07/06/2004 at 5:43 P
\ No newline at end of file

Added: trunk/MonoDevelop/src/Libraries/Gdl/DockPlaceholder.cs
===================================================================
--- trunk/MonoDevelop/src/Libraries/Gdl/DockPlaceholder.cs	2004-06-08 04:51:04 UTC (rev 1706)
+++ trunk/MonoDevelop/src/Libraries/Gdl/DockPlaceholder.cs	2004-06-08 05:12:24 UTC (rev 1707)
@@ -0,0 +1,155 @@
+// created on 07/06/2004 at 5:43 P
+
+using System;
+using System.Collections;
+using Gtk;
+
+namespace Gdl
+{
+	public class DockPlaceholder : DockObject
+	{
+		private DockObject host;
+		private bool sticky;
+		private ArrayList placement_stack;
+		private int host_detach_handler;
+		private int host_dock_handler;
+		
+		public DockPlaceholder ()
+		{
+			this.Flags |= Gtk.WidgetFlags.NoWindow;
+			this.Flags &= ~(Gtk.WidgetFlags.CanFocus);
+		}
+		
+		public DockPlaceholder (string name, DockObject objekt, DockPlacement position, bool sticky) : this ()
+		{
+			this.Sticky = sticky;
+			this.Name = name;
+			if (objekt != null) {
+				this.Attach (objekt);
+				if (positition == DockPlacement.None) {
+					position = DockPlacement.Center;
+				}
+				NextPlacement = position;
+				if (objekt is Dock) {
+					NextPlacement = DockPlacement.Center;
+				}
+				DoExcursion ();
+			}
+		}
+		
+		public bool Sticky {
+			get { return sticky; }
+			set { sticky = value; }
+		}
+		
+		public DockObject Host {
+			get { return host; }
+			set { this.Attach (value) }
+		}
+		
+		public DockPlacement NextPlacement {
+			get {
+				if (this.placement_stack != null && this.placement_stack.Count != 0)
+					return (DockPlacement)this.placement_stack[0];
+				return DockPlacement.Center;
+			}
+			set { this.placement_stack.Insert (0, value); }
+		}
+		
+		protected override void OnAdded (Gtk.Widget widget)
+		{
+			if (!(widget is DockItem))
+				return;
+			this.Dock (widget, this.NextPlacement, null);
+		}
+		
+		public override void Detach (bool recursive)
+		{
+			this.DisconnectHost ();
+			this.placement_stack = null;
+			this.DockObjectFlags &= ~(DockObjectFlags.Attached);
+		}
+		
+		public override void Reduce ()
+		{
+		}
+		
+		public override void Dock (DockObject requestor, DockPlacement position, object other_data)
+		{
+			if (this.host != null) {
+				this.host.Dock (requestor, position, other_data);
+			} else {
+				if (!this.IsBound) {
+					Console.WriteLine ("Attempt to dock a dock object to an unbound placeholder");
+					return;
+				}
+				this.Master.Controller.Dock (requestor, DockPlacement.Floating, null);
+			}
+		}
+		
+		public override void Present (DockObject child)
+		{
+		}
+		
+		public void DoExcursion ()
+		{
+			if (this.host != null && !this.Sticky && this.placement_stack != null && this.host.IsCompound) {
+				DockPlacement pos;
+				DockPlacement stack_pos = this.NextPlacement;
+				foreach (Gtk.Widget child = this.host.Children) {
+					DockObject item = child as DockObject;
+					if (item == null)
+						continue;
+					pos = stack_pos;
+					
+					this.host.ChildPlacement (item, ref pos);
+					if (pos == stack_pos) {
+						this.placement_stack.RemoveAt (0);
+						DisconnectHost ();
+						ConnectHost (item);
+						
+						if (!item.InReflow)
+							DoExcursion ();
+						break;
+					}
+				}
+			}
+		}
+		
+		private void DisconnectHost ()
+		{
+			//Disconnect from host detach and dock events here.
+			this.host = null;
+		}
+		
+		private void ConnectHost (DockObject new_host)
+		{
+			if (this.host != null)
+				DisconnectHost ();
+			this.host = new_host;
+			//Connect to host detach and dock events here.
+		}
+		
+		public void Attach (DockObject objekt)
+		{
+			if (objekt == null)
+				return;
+			
+			if (!this.IsBound)
+				this.Bind(objekt.Master);
+			
+			if (objekt.Master != this.Master)
+				return;
+			
+			this.Freeze ();
+			
+			if (this.host != null)
+				this.Detach (false);
+			
+			ConnectHost (objekt);
+			
+			this.DockObjectFlags |= DockObjectFlags.Attached;
+			this.Thaw ();
+		}
+	}
+}
\ No newline at end of file

Modified: trunk/MonoDevelop/src/Libraries/Gdl/Gdl.prjx
===================================================================
--- trunk/MonoDevelop/src/Libraries/Gdl/Gdl.prjx	2004-06-08 04:51:04 UTC (rev 1706)
+++ trunk/MonoDevelop/src/Libraries/Gdl/Gdl.prjx	2004-06-08 05:12:24 UTC (rev 1707)
@@ -12,6 +12,9 @@
     <File name="./Dock.cs" subtype="Code" buildaction="Compile" dependson="" data="" />
     <File name="./DockItem.cs" subtype="Code" buildaction="Compile" dependson="" data="" />
     <File name="./DockItemGrip.cs" subtype="Code" buildaction="Compile" dependson="" data="" />
+    <File name="./DockPlaceholder.cs" subtype="Code" buildaction="Compile" dependson="" data="" />
+    <File name="./DockPaned.cs" subtype="Code" buildaction="Compile" dependson="" data="" />
+    <File name="./DockNotebook.cs" subtype="Code" buildaction="Compile" dependson="" data="" />
   </Contents>
   <References>
     <Reference type="Gac" refto="gtk-sharp, Version=1.0.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f" localcopy="True" />

Modified: trunk/MonoDevelop/src/Libraries/Gdl/Makefile.Gdl
===================================================================
--- trunk/MonoDevelop/src/Libraries/Gdl/Makefile.Gdl	2004-06-08 04:51:04 UTC (rev 1706)
+++ trunk/MonoDevelop/src/Libraries/Gdl/Makefile.Gdl	2004-06-08 05:12:24 UTC (rev 1707)
@@ -13,7 +13,10 @@
 ./DockMaster.cs \
 ./Dock.cs \
 ./DockItem.cs \
-./DockItemGrip.cs
+./DockItemGrip.cs \
+./DockPlaceholder.cs \
+./DockPaned.cs \
+./DockNotebook.cs
 
 PKG_REFERENCES = \
 gtk-sharp




More information about the Monodevelop-patches-list mailing list