[Monodevelop-patches-list] r2358 - in trunk/MonoDevelop/Core/src: MonoDevelop.Base MonoDevelop.Base/Gui/Workbench/Layouts MonoDevelop.Dock

John Luke <jluke@cfl.rr.com> jluke at mono-cvs.ximian.com
Tue Mar 15 19:35:59 EST 2005


Author: jluke
Date: 2005-03-15 19:35:59 -0500 (Tue, 15 Mar 2005)
New Revision: 2358

Modified:
   trunk/MonoDevelop/Core/src/MonoDevelop.Base/ChangeLog
   trunk/MonoDevelop/Core/src/MonoDevelop.Base/Gui/Workbench/Layouts/SdiWorkspaceLayout.cs
   trunk/MonoDevelop/Core/src/MonoDevelop.Dock/ChangeLog
   trunk/MonoDevelop/Core/src/MonoDevelop.Dock/DockItem.cs
   trunk/MonoDevelop/Core/src/MonoDevelop.Dock/DockItemBehavior.cs
   trunk/MonoDevelop/Core/src/MonoDevelop.Dock/DockItemGrip.cs
   trunk/MonoDevelop/Core/src/MonoDevelop.Dock/TODO
Log:
fix lock/unlock and showing the grip


Modified: trunk/MonoDevelop/Core/src/MonoDevelop.Base/ChangeLog
===================================================================
--- trunk/MonoDevelop/Core/src/MonoDevelop.Base/ChangeLog	2005-03-15 23:15:34 UTC (rev 2357)
+++ trunk/MonoDevelop/Core/src/MonoDevelop.Base/ChangeLog	2005-03-16 00:35:59 UTC (rev 2358)
@@ -1,3 +1,8 @@
+2005-03-15  John Luke  <john.luke at gmail.com>
+
+	* Gui/Workbench/Layout/SdiWorkspaceLayout.cs: add NoGrip flags
+	to the documents section to match new dock API
+
 2005-03-15  Lluis Sanchez Gual <lluis at novell.com>
 
 	* Pads/SolutionPad/TreeViewPad.cs: implemented ITreeBuilder.UpdateAll()

Modified: trunk/MonoDevelop/Core/src/MonoDevelop.Base/Gui/Workbench/Layouts/SdiWorkspaceLayout.cs
===================================================================
--- trunk/MonoDevelop/Core/src/MonoDevelop.Base/Gui/Workbench/Layouts/SdiWorkspaceLayout.cs	2005-03-15 23:15:34 UTC (rev 2357)
+++ trunk/MonoDevelop/Core/src/MonoDevelop.Base/Gui/Workbench/Layouts/SdiWorkspaceLayout.cs	2005-03-16 00:35:59 UTC (rev 2358)
@@ -96,7 +96,7 @@
 			tabControl.SwitchPage += new SwitchPageHandler (ActiveMdiChanged);
 			tabControl.TabsReordered += new TabsReorderedHandler (OnTabsReordered);
 			DockItem item = new DockItem ("Documents", "Documents",
-						      DockItemBehavior.Locked);
+						      DockItemBehavior.Locked | DockItemBehavior.NoGrip);
 			item.PreferredWidth = -2;
 			item.PreferredHeight = -2;
 			item.Add (tabControl);

Modified: trunk/MonoDevelop/Core/src/MonoDevelop.Dock/ChangeLog
===================================================================
--- trunk/MonoDevelop/Core/src/MonoDevelop.Dock/ChangeLog	2005-03-15 23:15:34 UTC (rev 2357)
+++ trunk/MonoDevelop/Core/src/MonoDevelop.Dock/ChangeLog	2005-03-16 00:35:59 UTC (rev 2358)
@@ -1,5 +1,12 @@
 2005-03-15  John Luke  <john.luke at gmail.com>
 
+	* DockItemBehavior.cs: add NoGrip flag
+	* DockItem.cs:
+	* DockItemGrip.cs: hide/show the DockItemGrip based
+	on NoGrip flag, not Locked status and update for that
+
+2005-03-15  John Luke  <john.luke at gmail.com>
+
 	* DockItem.cs: add comment about saving position
 	* DockPaned.cs: override OnChildPlacement
 

Modified: trunk/MonoDevelop/Core/src/MonoDevelop.Dock/DockItem.cs
===================================================================
--- trunk/MonoDevelop/Core/src/MonoDevelop.Dock/DockItem.cs	2005-03-15 23:15:34 UTC (rev 2357)
+++ trunk/MonoDevelop/Core/src/MonoDevelop.Dock/DockItem.cs	2005-03-16 00:35:59 UTC (rev 2358)
@@ -89,11 +89,11 @@
 		}
 		
 		public bool CantClose {
-			get { return ((Behavior & DockItemBehavior.CantClose) != 0); }
+			get { return ((Behavior & DockItemBehavior.CantClose) != 0) || Locked; }
 		}
 		
 		public bool CantIconify {
-			get { return ((Behavior & DockItemBehavior.CantIconify) != 0); }
+			get { return ((Behavior & DockItemBehavior.CantIconify) != 0) || Locked; }
 		}
 		
 		public new Widget Child {
@@ -122,11 +122,11 @@
 		}
 		
 		public bool GripShown {
-			get { return (HasGrip && !Locked && grip.Visible); }
+			get { return HasGrip; }
 		}
 		
 		public virtual bool HasGrip {
-			get { return true; }
+			get { return !NoGrip; }
 		}
 		
 		public bool Iconified {
@@ -165,6 +165,16 @@
 				}
 			}
 		}
+
+		public bool NoGrip {
+			get { return ((behavior & DockItemBehavior.NoGrip) != 0); }
+			set {
+				if (value)
+					behavior |= DockItemBehavior.NoGrip;
+				else
+					behavior &= ~(DockItemBehavior.NoGrip);
+			}
+		}
 		
 		[Export]
 		public Orientation Orientation {
@@ -442,7 +452,7 @@
 		
 		protected override bool OnButtonPressEvent (Gdk.EventButton evnt)
 		{
-			if (!EventInGripWindow (evnt) || Locked)
+			if (!EventInGripWindow (evnt))
 				return false;
 			
 			bool eventHandled = false;
@@ -463,7 +473,7 @@
 			}
 			
 			/* Left mousebutton click on dockitem. */
-			if (evnt.Button == 1 && evnt.Type == Gdk.EventType.ButtonPress) {
+			if (!Locked && evnt.Button == 1 && evnt.Type == Gdk.EventType.ButtonPress) {
 				/* Set in_drag flag, grab pointer and call begin drag operation. */
 				if (inHandle) {
 					startX = (int)evnt.X;
@@ -473,7 +483,7 @@
 					grip.TitleWindow.Cursor = cursor;
 					eventHandled = true;
 				}
-			} else if (evnt.Type == Gdk.EventType.ButtonRelease && evnt.Button == 1) {
+			} else if (!Locked && evnt.Type == Gdk.EventType.ButtonRelease && evnt.Button == 1) {
 				if (InDrag) {
 					/* User dropped widget somewhere. */
 					EndDrag (false);
@@ -726,14 +736,15 @@
 				mitem.Activated += new EventHandler (ItemHideCb);
 				menu.Append (mitem);
 
-				// Lock menuitem -- need to be able to unlock
-				//mitem = new MenuItem ("Lock");
-				//mitem.Activated += new EventHandler (ItemLockCb);
-				//menu.Append (mitem);
+				// Lock menuitem
+				CheckMenuItem citem = new CheckMenuItem ("Lock");
+				citem.Active = this.Locked;
+				citem.Toggled += ItemLockCb;
+				menu.Append (citem);
 			}
+
 			menu.ShowAll ();
 			menu.Popup (null, null, null, IntPtr.Zero, button, time);
-			
 		}
 		
 		private void ItemHideCb (object o, EventArgs e)
@@ -741,9 +752,9 @@
 			HideItem ();
 		}
 
-		private void ItemLockCb (object o, EventArgs e)
+		private void ItemLockCb (object sender, EventArgs a)
 		{
-			this.Locked = true;
+			this.Locked = ((CheckMenuItem)sender).Active;
 		}
 		
 		private void StartDrag ()
@@ -780,7 +791,17 @@
 		
 		private void ShowHideGrip ()
 		{
+			DetachMenu (this, null);
+
 			if (grip != null) {
+				Gdk.Cursor cursor = null;
+
+				if (GripShown && !Locked)
+					cursor = new Gdk.Cursor (Display, Gdk.CursorType.Hand2);
+
+				if (grip.TitleWindow != null)
+					grip.TitleWindow.Cursor = cursor;
+
 				if (GripShown)
 					grip.Show ();
 				else

Modified: trunk/MonoDevelop/Core/src/MonoDevelop.Dock/DockItemBehavior.cs
===================================================================
--- trunk/MonoDevelop/Core/src/MonoDevelop.Dock/DockItemBehavior.cs	2005-03-15 23:15:34 UTC (rev 2357)
+++ trunk/MonoDevelop/Core/src/MonoDevelop.Dock/DockItemBehavior.cs	2005-03-16 00:35:59 UTC (rev 2358)
@@ -17,5 +17,6 @@
 		CantDockCenter = 1 << 8,
 		CantClose = 1 << 9,
 		CantIconify = 1 << 10,
+		NoGrip = 1 << 11,
 	}
 }

Modified: trunk/MonoDevelop/Core/src/MonoDevelop.Dock/DockItemGrip.cs
===================================================================
--- trunk/MonoDevelop/Core/src/MonoDevelop.Dock/DockItemGrip.cs	2005-03-15 23:15:34 UTC (rev 2357)
+++ trunk/MonoDevelop/Core/src/MonoDevelop.Dock/DockItemGrip.cs	2005-03-16 00:35:59 UTC (rev 2358)
@@ -141,13 +141,14 @@
 				
 				Layout.GetPixelSize (out width, out height);
 				
+				height = Math.Max (height, closeButton.Allocation.Height);
+				height = Math.Max (height, iconifyButton.Allocation.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;
 				}
 				
@@ -181,15 +182,27 @@
 				Title = item.LongName;
 				break;
 			case "Behavior":
-				if (!item.CantClose)
+				bool cursor = false;
+
+				if (item.CantClose) {
+					closeButton.Hide ();
+				}
+				else {
 					closeButton.Show ();
-				else
-					closeButton.Hide ();
+					cursor = true;
+				}
 
-				if (!item.CantIconify)
+				if (item.CantIconify) {
+					iconifyButton.Hide ();
+				}
+				else {
 					iconifyButton.Show ();
-				else
-					iconifyButton.Hide ();
+					cursor = true;
+				}
+
+				if (!cursor && titleWindow != null)
+					titleWindow.Cursor = null;
+
 				break;
 			default:
 				break;
@@ -297,7 +310,11 @@
 					Gdk.WindowAttributesType.Noredir));
 
 				titleWindow.UserData = Handle;
-				titleWindow.Cursor = new Gdk.Cursor (Display, Gdk.CursorType.Hand2);
+
+				if (item.CantClose || item.CantIconify)
+					titleWindow.Cursor = null;
+				else
+					titleWindow.Cursor = new Gdk.Cursor (Display, Gdk.CursorType.Hand2);
 			}
 		}
 		
@@ -333,19 +350,13 @@
 			requisition.Width = (int)BorderWidth * 2;
 			requisition.Height = (int)BorderWidth * 2;
 
-			if (closeButton.Visible) {
-				Requisition childReq = closeButton.SizeRequest ();
-				requisition.Width += childReq.Width;
-				requisition.Height = Math.Max (requisition.Height,
-							       childReq.Height);
-			}
+			Requisition childReq = closeButton.SizeRequest ();
+			requisition.Width += childReq.Width;
+			requisition.Height = Math.Max (requisition.Height, childReq.Height);
 			
-			if (iconifyButton.Visible) {
-				Requisition childReq = iconifyButton.SizeRequest ();
-				requisition.Width += childReq.Width;
-				requisition.Height = Math.Max (requisition.Height,
-							       childReq.Height);
-			}
+			childReq = iconifyButton.SizeRequest ();
+			requisition.Width += childReq.Width;
+			requisition.Height = Math.Max (requisition.Height, childReq.Height);
 			
 			if (Icon != null) {
 				requisition.Width += icon.Width + 1;
@@ -404,33 +415,29 @@
 				childAlloc.X = allocation.X + allocation.Width - bw;
 			childAlloc.Y = allocation.Y + bw;
 			
-			if (closeButton.Visible) {
-				Requisition buttonReq = closeButton.SizeRequest ();
+			Requisition buttonReq = closeButton.SizeRequest ();
 
-				if (Direction != TextDirection.Rtl) 
-					childAlloc.X -= buttonReq.Width;
-				childAlloc.Width = buttonReq.Width;
-				childAlloc.Height = buttonReq.Height;
+			if (Direction != TextDirection.Rtl) 
+				childAlloc.X -= buttonReq.Width;
+			childAlloc.Width = buttonReq.Width;
+			childAlloc.Height = buttonReq.Height;
 				
-				closeButton.SizeAllocate (childAlloc);
+			closeButton.SizeAllocate (childAlloc);
 				
-				if (Direction == TextDirection.Rtl)
-					childAlloc.X += buttonReq.Width;
-			}
+			if (Direction == TextDirection.Rtl)
+				childAlloc.X += buttonReq.Width;
 			
-			if (iconifyButton.Visible) {
-				Requisition buttonReq = iconifyButton.SizeRequest ();
+			buttonReq = iconifyButton.SizeRequest ();
 				
-				if (Direction != TextDirection.Rtl)
-					childAlloc.X -= buttonReq.Width;
-				childAlloc.Width = buttonReq.Width;
-				childAlloc.Height = buttonReq.Height;
+			if (Direction != TextDirection.Rtl)
+				childAlloc.X -= buttonReq.Width;
+			childAlloc.Width = buttonReq.Width;
+			childAlloc.Height = buttonReq.Height;
 				
-				iconifyButton.SizeAllocate (childAlloc);
+			iconifyButton.SizeAllocate (childAlloc);
 				
-				if (Direction == TextDirection.Rtl)
-					childAlloc.X += buttonReq.Width;
-			}
+			if (Direction == TextDirection.Rtl)
+				childAlloc.X += buttonReq.Width;
 			
 			if (TitleWindow != null) {
 				layout.SetMarkup (title);

Modified: trunk/MonoDevelop/Core/src/MonoDevelop.Dock/TODO
===================================================================
--- trunk/MonoDevelop/Core/src/MonoDevelop.Dock/TODO	2005-03-15 23:15:34 UTC (rev 2357)
+++ trunk/MonoDevelop/Core/src/MonoDevelop.Dock/TODO	2005-03-16 00:35:59 UTC (rev 2358)
@@ -5,7 +5,6 @@
  - when we can use pango 1.6, use the built-in ellipsizing
  - audit event emitting frequency
  - use less ArrayLists
- - fix lock/unlock menuitems
 
 potential new features
  - restore size/position on de-iconify?




More information about the Monodevelop-patches-list mailing list