Esempio n. 1
0
		public bool GetDockTarget (DockItem item, int px, int py, Gdk.Rectangle rect, out DockDelegate dockDelegate, out Gdk.Rectangle outrect)
		{
			outrect = Gdk.Rectangle.Zero;
			dockDelegate = null;
			
			if (item != this.item && this.item.Visible && rect.Contains (px, py)) {

				// Check if the item is allowed to be docked here
				var s = Frame.GetRegionStyleForObject (this);

				int xdockMargin = (int) ((double)rect.Width * (1.0 - DockFrame.ItemDockCenterArea)) / 2;
				int ydockMargin = (int) ((double)rect.Height * (1.0 - DockFrame.ItemDockCenterArea)) / 2;
				DockPosition pos;
				
/*				if (ParentGroup.Type == DockGroupType.Tabbed) {
					rect = new Gdk.Rectangle (rect.X + xdockMargin, rect.Y + ydockMargin, rect.Width - xdockMargin*2, rect.Height - ydockMargin*2);
					pos = DockPosition.CenterAfter;
				}*/				
				if (px <= rect.X + xdockMargin && ParentGroup.Type != DockGroupType.Horizontal) {
					if (s.SingleColumnMode.Value)
						return false;
					outrect = new Gdk.Rectangle (rect.X, rect.Y, xdockMargin, rect.Height);
					pos = DockPosition.Left;
				}
				else if (px >= rect.Right - xdockMargin && ParentGroup.Type != DockGroupType.Horizontal) {
					if (s.SingleColumnMode.Value)
						return false;
					outrect = new Gdk.Rectangle (rect.Right - xdockMargin, rect.Y, xdockMargin, rect.Height);
					pos = DockPosition.Right;
				}
				else if (py <= rect.Y + ydockMargin && ParentGroup.Type != DockGroupType.Vertical) {
					if (s.SingleRowMode.Value)
						return false;
					outrect = new Gdk.Rectangle (rect.X, rect.Y, rect.Width, ydockMargin);
					pos = DockPosition.Top;
				}
				else if (py >= rect.Bottom - ydockMargin && ParentGroup.Type != DockGroupType.Vertical) {
					if (s.SingleRowMode.Value)
						return false;
					outrect = new Gdk.Rectangle (rect.X, rect.Bottom - ydockMargin, rect.Width, ydockMargin);
					pos = DockPosition.Bottom;
				}
				else {
					outrect = new Gdk.Rectangle (rect.X + xdockMargin, rect.Y + ydockMargin, rect.Width - xdockMargin*2, rect.Height - ydockMargin*2);
					pos = DockPosition.Center;
				}
				
				dockDelegate = delegate (DockItem dit) {
					DockGroupItem it = ParentGroup.AddObject (dit, pos, Id);
					it.SetVisible (true);
					ParentGroup.FocusItem (it);
				};
				return true;
			}
			return false;
		}
		public void DrawCaret (Gdk.Drawable win, Gdk.Rectangle area)
		{
			if (Settings.Default.CursorBlink && !caretBlink || HexEditorData.IsSomethingSelected) 
				return;
			if (caretGc == null) {
				caretGc = new Gdk.GC (win);
				caretGc.RgbFgColor = new Color (255, 255, 255);
				caretGc.Function = Gdk.Function.Xor;
			}
			long caretY = HexEditorData.Caret.Line * LineHeight - (long)HexEditorData.VAdjustment.Value;
			int caretX;
			if (HexEditorData.Caret.InTextEditor) {
				caretX = textEditorMargin.CalculateCaretXPos ();
			} else {
				caretX = hexEditorMargin.CalculateCaretXPos ();
			}
			
			if (!area.Contains (caretX, (int)caretY))
				return;
			
			if (HexEditorData.Caret.IsInsertMode) {
				win.DrawRectangle (caretGc, true, new Gdk.Rectangle (caretX, (int)caretY, 2, LineHeight));
			} else {
				win.DrawRectangle (caretGc, true, new Gdk.Rectangle (caretX, (int)caretY, textEditorMargin.charWidth, LineHeight));
			}
		}