protected override bool OnLeaveNotifyEvent(Gdk.EventCrossing evnt) { isInBorder = false; if (!isSizing) { sizingSide = SizingSide.SizingSideType.E_NONE; SelectCursor(); } return(base.OnLeaveNotifyEvent(evnt)); }
protected override bool OnMotionNotifyEvent(Gdk.EventMotion evnt) { if (!evnt.Window.Equals(base.GdkWindow) && !evnt.Window.Equals(this.evntboxTitleBar.GdkWindow)) return base.OnMotionNotifyEvent (evnt); if (base.Decorated || base.GdkWindow.State == Gdk.WindowState.Maximized || !base.Resizable) return base.OnMotionNotifyEvent (evnt); if (!isSizing) { sizingSide = SizingSide.SizingSideType.E_NONE; if (evnt.X < Allocation.X + frameBorderWidth) sizingSide |= SizingSide.SizingSideType.E_LEFT_SIDE; else if (evnt.X >= Allocation.X + Allocation.Width - frameBorderWidth) sizingSide |= SizingSide.SizingSideType.E_RIGHT_SIDE; if (evnt.Y < Allocation.Y + frameBorderWidth) sizingSide |= SizingSide.SizingSideType.E_TOP_SIDE; else if (evnt.Y >= Allocation.Y + Allocation.Height - frameBorderWidth) sizingSide |= SizingSide.SizingSideType.E_BOTTOM_SIDE; } else { Gdk.Point windowPos = Gdk.Point.Zero; GdkWindow.GetPosition (out windowPos.X, out windowPos.Y); Gdk.Rectangle windowRect = Gdk.Rectangle.Zero; windowRect.X = windowPos.X; windowRect.Y = windowPos.Y; windowRect.Width = lastWindowSize.Width; windowRect.Height = lastWindowSize.Height; Gdk.Point curMousePos = Gdk.Point.Zero; curMousePos.X = (int) evnt.XRoot; curMousePos.Y = (int) evnt.YRoot; Gdk.Size minSize = Gdk.Size.Empty; minSize.Width = base.SizeRequest().Width; minSize.Height = base.SizeRequest().Height; switch (sizingSide) { case SizingSide.SizingSideType.E_LEFT_SIDE: windowRect.Width -= curMousePos.X - lastMousePos.X; windowRect.Width = Math.Max(windowRect.Width, minSize.Width); windowRect.X = lastMousePos.X + lastWindowSize.Width - windowRect.Width; break; case SizingSide.SizingSideType.E_RIGHT_SIDE: windowRect.Width += curMousePos.X - lastMousePos.X; windowRect.Width = Math.Max(windowRect.Width, minSize.Width); break; case SizingSide.SizingSideType.E_TOP_SIDE: windowRect.Height -= curMousePos.Y - lastMousePos.Y; windowRect.Height = Math.Max(windowRect.Height, minSize.Height); windowRect.Y = lastMousePos.Y + lastWindowSize.Height - windowRect.Height; break; case SizingSide.SizingSideType.E_TOP_LEFT_CONER: windowRect.Width -= curMousePos.X - lastMousePos.X; windowRect.Width = Math.Max(windowRect.Width, minSize.Width); windowRect.X = lastMousePos.X + lastWindowSize.Width - windowRect.Width; windowRect.Height -= curMousePos.Y - lastMousePos.Y; windowRect.Height = Math.Max(windowRect.Height, minSize.Height); windowRect.Y = lastMousePos.Y + lastWindowSize.Height - windowRect.Height; break; case SizingSide.SizingSideType.E_TOP_RIGHT_CONER: windowRect.Width += curMousePos.X - lastMousePos.X; windowRect.Width = Math.Max(windowRect.Width, minSize.Width); windowRect.Height -= curMousePos.Y - lastMousePos.Y; windowRect.Height = Math.Max(windowRect.Height, minSize.Height); windowRect.Y = lastMousePos.Y + lastWindowSize.Height - windowRect.Height; break; case SizingSide.SizingSideType.E_BOTTOM_SIDE: windowRect.Height += curMousePos.Y - lastMousePos.Y; windowRect.Height = Math.Max(windowRect.Height, minSize.Height); break; case SizingSide.SizingSideType.E_BOTTOM_LEFT_CONER: windowRect.Width -= curMousePos.X - lastMousePos.X; windowRect.Width = Math.Max(windowRect.Width, minSize.Width); windowRect.X = lastMousePos.X + lastWindowSize.Width - windowRect.Width; windowRect.Height += curMousePos.Y - lastMousePos.Y; windowRect.Height = Math.Max(windowRect.Height, minSize.Height); break; case SizingSide.SizingSideType.E_BOTTOM_RIGHT_CONER: windowRect.Width += curMousePos.X - lastMousePos.X; windowRect.Width = Math.Max(windowRect.Width, minSize.Width); windowRect.Height += curMousePos.Y - lastMousePos.Y; windowRect.Height = Math.Max(windowRect.Height, minSize.Height); break; default: break; } base.GdkWindow.FreezeUpdates(); base.GdkWindow.MoveResize(windowRect); base.GdkWindow.ThawUpdates(); } SelectCursor (); return base.OnMotionNotifyEvent (evnt); }
protected override bool OnLeaveNotifyEvent(Gdk.EventCrossing evnt) { isInBorder = false; if (!isSizing) { sizingSide = SizingSide.SizingSideType.E_NONE; SelectCursor(); } return base.OnLeaveNotifyEvent(evnt); }
protected override bool OnMotionNotifyEvent(Gdk.EventMotion evnt) { if (!evnt.Window.Equals(base.GdkWindow) && !evnt.Window.Equals(this.evntboxTitleBar.GdkWindow)) { return(base.OnMotionNotifyEvent(evnt)); } if (base.Decorated || base.GdkWindow.State == Gdk.WindowState.Maximized || !base.Resizable) { return(base.OnMotionNotifyEvent(evnt)); } if (!isSizing && isInBorder) { sizingSide = SizingSide.SizingSideType.E_NONE; if (evnt.X < Allocation.X + frameBorderWidth + frameBorderMargin) { sizingSide |= SizingSide.SizingSideType.E_LEFT_SIDE; } else if (evnt.X >= Allocation.X + Allocation.Width - frameBorderWidth - frameBorderMargin) { sizingSide |= SizingSide.SizingSideType.E_RIGHT_SIDE; } int cornerMargin = (sizingSide == SizingSide.SizingSideType.E_NONE ? 0 : frameBorderWidth * 2); if (evnt.Y < Allocation.Y + frameBorderWidth + frameBorderMargin + cornerMargin) { sizingSide |= SizingSide.SizingSideType.E_TOP_SIDE; } else if (evnt.Y >= Allocation.Y + Allocation.Height - frameBorderWidth - frameBorderMargin - cornerMargin) { sizingSide |= SizingSide.SizingSideType.E_BOTTOM_SIDE; } cornerMargin = (sizingSide == SizingSide.SizingSideType.E_NONE ? 0 : frameBorderWidth * 2); if (evnt.X < Allocation.X + frameBorderWidth + frameBorderMargin + cornerMargin) { sizingSide |= SizingSide.SizingSideType.E_LEFT_SIDE; } else if (evnt.X >= Allocation.X + Allocation.Width - frameBorderWidth - frameBorderMargin - cornerMargin) { sizingSide |= SizingSide.SizingSideType.E_RIGHT_SIDE; } } if (isSizing) { Gdk.Point windowPos = Gdk.Point.Zero; GdkWindow.GetPosition(out windowPos.X, out windowPos.Y); Gdk.Rectangle windowRect = Gdk.Rectangle.Zero; windowRect.X = windowPos.X; windowRect.Y = windowPos.Y; windowRect.Width = lastWindowSize.Width; windowRect.Height = lastWindowSize.Height; Gdk.Point curMousePos = Gdk.Point.Zero; curMousePos.X = (int)evnt.XRoot; curMousePos.Y = (int)evnt.YRoot; Gdk.Size minSize = Gdk.Size.Empty; minSize.Width = base.SizeRequest().Width; minSize.Height = base.SizeRequest().Height; switch (sizingSide) { case SizingSide.SizingSideType.E_LEFT_SIDE: windowRect.Width -= curMousePos.X - lastMousePos.X; windowRect.Width = Math.Max(windowRect.Width, minSize.Width); windowRect.X = lastWindowPos.X + lastWindowSize.Width - windowRect.Width; break; case SizingSide.SizingSideType.E_RIGHT_SIDE: windowRect.Width += curMousePos.X - lastMousePos.X; windowRect.Width = Math.Max(windowRect.Width, minSize.Width); break; case SizingSide.SizingSideType.E_TOP_SIDE: windowRect.Height -= curMousePos.Y - lastMousePos.Y; windowRect.Height = Math.Max(windowRect.Height, minSize.Height); windowRect.Y = lastWindowPos.Y + lastWindowSize.Height - windowRect.Height; break; case SizingSide.SizingSideType.E_TOP_LEFT_CONER: windowRect.Width -= curMousePos.X - lastMousePos.X; windowRect.Width = Math.Max(windowRect.Width, minSize.Width); windowRect.X = lastWindowPos.X + lastWindowSize.Width - windowRect.Width; windowRect.Height -= curMousePos.Y - lastMousePos.Y; windowRect.Height = Math.Max(windowRect.Height, minSize.Height); windowRect.Y = lastWindowPos.Y + lastWindowSize.Height - windowRect.Height; break; case SizingSide.SizingSideType.E_TOP_RIGHT_CONER: windowRect.Width += curMousePos.X - lastMousePos.X; windowRect.Width = Math.Max(windowRect.Width, minSize.Width); windowRect.Height -= curMousePos.Y - lastMousePos.Y; windowRect.Height = Math.Max(windowRect.Height, minSize.Height); windowRect.Y = lastWindowPos.Y + lastWindowSize.Height - windowRect.Height; break; case SizingSide.SizingSideType.E_BOTTOM_SIDE: windowRect.Height += curMousePos.Y - lastMousePos.Y; windowRect.Height = Math.Max(windowRect.Height, minSize.Height); break; case SizingSide.SizingSideType.E_BOTTOM_LEFT_CONER: windowRect.Width -= curMousePos.X - lastMousePos.X; windowRect.Width = Math.Max(windowRect.Width, minSize.Width); windowRect.X = lastWindowPos.X + lastWindowSize.Width - windowRect.Width; windowRect.Height += curMousePos.Y - lastMousePos.Y; windowRect.Height = Math.Max(windowRect.Height, minSize.Height); break; case SizingSide.SizingSideType.E_BOTTOM_RIGHT_CONER: windowRect.Width += curMousePos.X - lastMousePos.X; windowRect.Width = Math.Max(windowRect.Width, minSize.Width); windowRect.Height += curMousePos.Y - lastMousePos.Y; windowRect.Height = Math.Max(windowRect.Height, minSize.Height); break; default: break; } base.GdkWindow.MoveResize(windowRect); } SelectCursor(); return(base.OnMotionNotifyEvent(evnt)); }