void HandleLabelExposeEvent(object o, Gtk.ExposeEventArgs args) { using (var ctx = Gdk.CairoHelper.Create(Label.GdkWindow)) { ctx.Rectangle(Label.Allocation.X, Label.Allocation.Y, Label.Allocation.Width, Label.Allocation.Height); ctx.Color = Util.ToCairoColor(backColor); ctx.Fill(); } }
protected override bool OnExposeEvent(Gdk.EventExpose evnt) { Gdk.Rectangle rect; if (DrawBackground) { GdkWindow.DrawRectangle(Style.BackgroundGC(Gtk.StateType.Normal), true, Allocation.X, Allocation.Y, Allocation.Width - 1, Allocation.Height - 1); } if (GradientBackround) { rect = new Gdk.Rectangle(Allocation.X, Allocation.Y, Allocation.Width, Allocation.Height); Color gcol = Util.ToXwtColor(Style.Background(Gtk.StateType.Normal)); using (Cairo.Context cr = Gdk.CairoHelper.Create(GdkWindow)) { cr.NewPath(); cr.MoveTo(rect.X, rect.Y); cr.RelLineTo(rect.Width, 0); cr.RelLineTo(0, rect.Height); cr.RelLineTo(-rect.Width, 0); cr.RelLineTo(0, -rect.Height); cr.ClosePath(); Cairo.Gradient pat = new Cairo.LinearGradient(rect.X, rect.Y, rect.X, rect.Bottom); Cairo.Color color1 = Util.ToCairoColor(gcol); pat.AddColorStop(0, color1); gcol.Light -= 0.1; pat.AddColorStop(1, Util.ToCairoColor(gcol)); cr.Pattern = pat; cr.FillPreserve(); } } bool res = base.OnExposeEvent(evnt); Gdk.GC borderColor; if (color != null) { borderColor = new Gdk.GC(GdkWindow); borderColor.RgbFgColor = Util.ToGdkColor(color.Value); } else { borderColor = Style.DarkGC(Gtk.StateType.Normal); } rect = Allocation; for (int n = 0; n < topMargin; n++) { GdkWindow.DrawLine(borderColor, rect.X, rect.Y + n, rect.Right, rect.Y + n); } for (int n = 0; n < bottomMargin; n++) { GdkWindow.DrawLine(borderColor, rect.X, rect.Bottom - n, rect.Right, rect.Bottom - n); } for (int n = 0; n < leftMargin; n++) { GdkWindow.DrawLine(borderColor, rect.X + n, rect.Y, rect.X + n, rect.Bottom); } for (int n = 0; n < rightMargin; n++) { GdkWindow.DrawLine(borderColor, rect.Right - n, rect.Y, rect.Right - n, rect.Bottom); } if (color != null) { borderColor.Dispose(); } return(res); }