Rectangle WindowPositionAndSize(Gdk.Window window) { int x,y,width,height; window.GetPosition(out x, out y); window.GetSize(out width, out height); return new Rectangle(x,y,width,height); }
void DrawFocus(Gdk.Window window, Color c) { int x, y, width, height; window.GetPosition(out x, out y); window.GetSize(out width, out height); System.Drawing.Rectangle r = new System.Drawing.Rectangle(x, y, width, height); using (Cairo.Context context = Gdk.CairoHelper.Create(window)) { uint b = mainBox.BorderWidth; // Top using (Cairo.Gradient gradient = createGradient(0.0, 0.0, 0, b, c)) { context.SetSource(gradient); context.MoveTo(0, 0); context.LineTo(r.Width, 0); context.LineTo(r.Width - b + 1, b); context.LineTo(b - 1, b); context.ClosePath(); context.Fill(); } // Left using (Cairo.Gradient gradient = createGradient(0.0, 0.0, b, 0, c)) { context.SetSource(gradient); context.MoveTo(0, 0); context.LineTo(b, b - 1); context.LineTo(b, r.Height - b + 1); context.LineTo(0, r.Height); context.ClosePath(); context.Fill(); } // Bottom using (Cairo.Gradient gradient = createGradient(0.0, r.Height, 0, r.Height - b, c)) { context.SetSource(gradient); context.MoveTo(0, r.Height); context.LineTo(b - 1, r.Height - b); context.LineTo(r.Width - b + 1, r.Height - b); context.LineTo(r.Width, r.Height); context.ClosePath(); context.Fill(); } // Right using (Cairo.Gradient gradient = createGradient(r.Width, 0, r.Width - b, 0, c)) { context.SetSource(gradient); context.MoveTo(r.Width, 0); context.LineTo(r.Width - b, b - 1); context.LineTo(r.Width - b, r.Height - b + 1); context.LineTo(r.Width, r.Height); context.ClosePath(); context.Fill(); } } }
private static Gdk.Rectangle GetRect(Gdk.Window window) { Gdk.Rectangle rect = Gdk.Rectangle.Zero; int vx, vy; window.GetPosition(out vx, out vy); rect.X = vx; rect.Y = vy; window.GetSize(out vx, out vy); rect.Width = vx; rect.Height = vy; return rect; }