protected override bool OnExposeEvent(Gdk.EventExpose evt) { if (!IsDrawable) { return(false); } int width, height; GdkWindow.GetSize(out width, out height); Gdk.Rectangle a = new Gdk.Rectangle(0, 0, width, height); byte b2 = 210; int ssLT = 12; int ssRB = 7; double grey = 0.6; double greyb1 = 0.9; double greyb2 = 0.6; Gdk.Rectangle rect = a; Cairo.Color back1 = new Cairo.Color(greyb1, greyb1, greyb1); Cairo.Color back2 = new Cairo.Color(greyb2, greyb2, greyb2); Cairo.Color cdark = new Cairo.Color(grey, grey, grey, 1); Cairo.Color clight = new Cairo.Color(grey, grey, grey, 0); using (Cairo.Context cr = Gdk.CairoHelper.Create(evt.Window)) { DrawGradient(cr, rect, 0, 0, 1, 1, back1, back2); rect.X = a.X; rect.Y = a.Y; rect.Height = ssLT; rect.Width = a.Width; DrawGradient(cr, rect, 0, 0, 0, 1, cdark, clight); rect.Y = a.Bottom - ssRB; rect.Height = ssRB; DrawGradient(cr, rect, 0, 0, 0, 1, clight, cdark); rect.X = a.X; rect.Y = a.Y; rect.Width = ssLT; rect.Height = a.Height; DrawGradient(cr, rect, 0, 0, 1, 0, cdark, clight); rect.X = a.Right - ssRB; rect.Width = ssRB; DrawGradient(cr, rect, 0, 0, 1, 0, clight, cdark); Gdk.GC gc = new Gdk.GC(GdkWindow); gc.RgbBgColor = new Gdk.Color(b2, b2, b2); gc.RgbFgColor = new Gdk.Color(b2, b2, b2); GdkWindow.DrawRectangle(gc, false, a.X, a.Y, a.Width, a.Height); gc.Dispose(); } return(base.OnExposeEvent(evt)); }
protected override bool OnExposeEvent(Gdk.EventExpose e) { Gdk.GC gc = new Gdk.GC(e.Window); int count = 0; foreach (Hunk h in hunks) { IncPos(h, ref count); } int start = 0; foreach (Hunk h in hunks) { int size = 0; IncPos(h, ref size); if (h.Same) { gc.RgbFgColor = widget.ColorDefault; } else if (h.Original().Count == 0) { gc.RgbFgColor = widget.ColorAdded; } else if (h.ChangedLists == 1 && h.Changes(0).Count == 0) { gc.RgbFgColor = widget.ColorRemoved; } else { gc.RgbFgColor = widget.ColorChanged; } GdkWindow.DrawRectangle(gc, true, 0, Allocation.Height * start / count, Allocation.Width, Allocation.Height * size / count); start += size; } gc.RgbFgColor = widget.ColorGrey; e.Window.DrawRectangle(gc, false, 1, (int)(Allocation.Height * scroller.Vadjustment.Value / scroller.Vadjustment.Upper) + 1, Allocation.Width - 3, (int)(Allocation.Height * ((double)scroller.Allocation.Height / scroller.Vadjustment.Upper)) - 2); gc.RgbFgColor = widget.ColorBlack; e.Window.DrawRectangle(gc, false, 0, (int)(Allocation.Height * scroller.Vadjustment.Value / scroller.Vadjustment.Upper), Allocation.Width - 1, (int)(Allocation.Height * ((double)scroller.Allocation.Height / scroller.Vadjustment.Upper))); gc.Dispose(); return(true); }
private void RefreshGC() { if (text_gc == null) { return; } text_gc.Dispose(); text_gc = null; }
protected override bool OnExposeEvent(Gdk.EventExpose evnt) { if (VisualStyle.TabStyle == DockTabStyle.Normal) { Gdk.GC gc = new Gdk.GC(GdkWindow); gc.RgbFgColor = VisualStyle.PadBackgroundColor.Value; evnt.Window.DrawRectangle(gc, true, Allocation); gc.Dispose(); } return(base.OnExposeEvent(evnt)); }
protected override bool OnExposeEvent (Gdk.EventExpose evnt) { base.OnExposeEvent (evnt); if (Child1 != null && Child1.Visible && Child2 != null && Child2.Visible) { var gc = new Gdk.GC (evnt.Window); gc.RgbFgColor = (HslColor) Styles.ThinSplitterColor; var x = Child1.Allocation.X + Child1.Allocation.Width; evnt.Window.DrawLine (gc, x, Allocation.Y, x, Allocation.Y + Allocation.Height); gc.Dispose (); } return true; }
protected override void OnDestroyed() { if (layout != null) { layout.Dispose(); layout = null; } if (text_gc != null) { text_gc.Dispose(); text_gc = null; } base.OnDestroyed(); }
protected override bool OnExposeEvent(Gdk.EventExpose evnt) { base.OnExposeEvent(evnt); if (Child1 != null && Child1.Visible && Child2 != null && Child2.Visible) { var gc = new Gdk.GC(evnt.Window); gc.RgbFgColor = Styles.ThinSplitterColor.ToGdkColor(); var x = Child1.Allocation.X + Child1.Allocation.Width; evnt.Window.DrawLine(gc, x, Allocation.Y, x, Allocation.Y + Allocation.Height); gc.Dispose(); } return(true); }
void DrawAsBrowser(Gdk.EventExpose evnt) { var alloc = Allocation; Gdk.GC bgc = new Gdk.GC(GdkWindow); var c = VisualStyle.PadBackgroundColor.Value; c.Light *= 0.7; bgc.RgbFgColor = c.ToGdkColor(); bool first = true; bool last = true; TabStrip tabStrip = null; if (Parent is TabStrip.TabStripBox) { var tsb = (TabStrip.TabStripBox)Parent; var cts = tsb.Children; first = cts[0] == this; last = cts[cts.Length - 1] == this; tabStrip = tsb.TabStrip; } if (Active || (first && last)) { Gdk.GC gc = new Gdk.GC(GdkWindow); gc.RgbFgColor = VisualStyle.PadBackgroundColor.Value.ToGdkColor(); evnt.Window.DrawRectangle(gc, true, alloc); if (!first) { evnt.Window.DrawLine(bgc, alloc.X, alloc.Y, alloc.X, alloc.Y + alloc.Height - 1); } if (!(last && first) && !(tabStrip != null && tabStrip.VisualStyle.ExpandedTabs.Value && last)) { evnt.Window.DrawLine(bgc, alloc.X + alloc.Width - 1, alloc.Y, alloc.X + alloc.Width - 1, alloc.Y + alloc.Height - 1); } gc.Dispose(); } else { Gdk.GC gc = new Gdk.GC(GdkWindow); gc.RgbFgColor = tabStrip != null?tabStrip.VisualStyle.InactivePadBackgroundColor.Value.ToGdkColor() : frame.DefaultVisualStyle.InactivePadBackgroundColor.Value.ToGdkColor(); evnt.Window.DrawRectangle(gc, true, alloc); gc.Dispose(); evnt.Window.DrawLine(bgc, alloc.X, alloc.Y + alloc.Height - 1, alloc.X + alloc.Width - 1, alloc.Y + alloc.Height - 1); } bgc.Dispose(); }
protected override bool OnExposeEvent(Gdk.EventExpose evnt) { if (VisualStyle.TabStyle == DockTabStyle.Normal) { Gdk.GC gc = new Gdk.GC(GdkWindow); gc.RgbFgColor = VisualStyle.PadBackgroundColor.Value; evnt.Window.DrawRectangle(gc, true, Allocation); gc.Dispose(); } bool result = base.OnExposeEvent(evnt); Gdk.Color?col = VisualStyle.PadBackgroundColor; if (col.HasValue) { DrawFocus(evnt.Window, Color.FromArgb(255, col.Value.Red / 256, col.Value.Green / 256, col.Value.Blue / 256)); } return(result); }
void drawHVBox(Gdk.EventExpose evnt, Gdk.Window GdkWindow, Gdk.Rectangle alloc) { if (VisualStyle.TabStyle == DockTabStyle.Normal) { Gdk.GC gc = new Gdk.GC(GdkWindow); gc.RgbFgColor = VisualStyle.InactivePadBackgroundColor.Value; evnt.Window.DrawRectangle(gc, true, alloc); gc.Dispose(); Gdk.GC bgc = new Gdk.GC(GdkWindow); var c = new HslColor(VisualStyle.PadBackgroundColor.Value); c.L *= 0.7; bgc.RgbFgColor = c; evnt.Window.DrawLine(bgc, alloc.X, alloc.Y + alloc.Height - 1, alloc.X + alloc.Width - 1, alloc.Y + alloc.Height - 1); bgc.Dispose(); } }
protected override bool OnExposeEvent(Gdk.EventExpose evnt) { if (TabStrip.VisualStyle.TabStyle == DockTabStyle.Normal) { var alloc = Allocation; Gdk.GC gc = new Gdk.GC(GdkWindow); gc.RgbFgColor = TabStrip.VisualStyle.InactivePadBackgroundColor.Value.ToGdkColor(); evnt.Window.DrawRectangle(gc, true, alloc); gc.Dispose(); Gdk.GC bgc = new Gdk.GC(GdkWindow); var c = TabStrip.VisualStyle.PadBackgroundColor.Value; c.Light *= 0.7; bgc.RgbFgColor = c.ToGdkColor(); evnt.Window.DrawLine(bgc, alloc.X, alloc.Y + alloc.Height - 1, alloc.X + alloc.Width - 1, alloc.Y + alloc.Height - 1); bgc.Dispose(); } return(base.OnExposeEvent(evnt)); }
void DrawAsBrowser(Gdk.EventExpose evnt) { var alloc = Allocation; Gdk.GC bgc = new Gdk.GC(GdkWindow); var baseColor = Style.Background(StateType.Normal); var c = new HslColor(baseColor); c.L *= 0.7; bgc.RgbFgColor = c; var cts = ((SquaredTabStrip.TabStripBox)Parent).Children; var first = cts[0] == this; var last = cts[cts.Length - 1] == this; if (Active || (first && last)) { Gdk.GC gc = new Gdk.GC(GdkWindow); gc.RgbFgColor = baseColor; evnt.Window.DrawRectangle(gc, true, alloc); if (!first) { evnt.Window.DrawLine(bgc, alloc.X, alloc.Y, alloc.X, alloc.Y + alloc.Height - 1); } if (!last || !first) { evnt.Window.DrawLine(bgc, alloc.X + alloc.Width - 1, alloc.Y, alloc.X + alloc.Width - 1, alloc.Y + alloc.Height - 1); } gc.Dispose(); } else { c = new HslColor(baseColor); c.L *= 0.9; Gdk.GC gc = new Gdk.GC(GdkWindow); gc.RgbFgColor = c; evnt.Window.DrawRectangle(gc, true, alloc); gc.Dispose(); evnt.Window.DrawLine(bgc, alloc.X, alloc.Y + alloc.Height - 1, alloc.X + alloc.Width - 1, alloc.Y + alloc.Height - 1); } bgc.Dispose(); }
protected override bool OnExposeEvent(Gdk.EventExpose evnt) { var alloc = Allocation; var baseColor = Style.Background(StateType.Normal); var c = new HslColor(baseColor); c.L *= 0.9; Gdk.GC gc = new Gdk.GC(GdkWindow); gc.RgbFgColor = c; evnt.Window.DrawRectangle(gc, true, alloc); gc.Dispose(); Gdk.GC bgc = new Gdk.GC(GdkWindow); c = new HslColor(baseColor); c.L *= 0.7; bgc.RgbFgColor = c; evnt.Window.DrawLine(bgc, alloc.X, alloc.Y + alloc.Height - 1, alloc.X + alloc.Width - 1, alloc.Y + alloc.Height - 1); bgc.Dispose(); return(base.OnExposeEvent(evnt)); }
void HandleWidgetExposeEvent(object o, Gtk.ExposeEventArgs args) { // The Entry's GdkWindow is the top level window onto which // the frame is drawn; the actual text entry is drawn into a // separate window, so we can ensure that for themes that don't // respect HasFrame, we never ever allow the base frame drawing // to happen if (args.Event.Window == Widget.GdkWindow) { return; } if (Widget.Text.Length > 0) { return; } if (layout == null) { layout = new Pango.Layout(Widget.PangoContext); layout.FontDescription = Widget.PangoContext.FontDescription.Copy(); } int wh, ww; args.Event.Window.GetSize(out ww, out wh); int width, height; layout.SetText(placeHolderText); layout.GetPixelSize(out width, out height); Gdk.GC gc = new Gdk.GC(args.Event.Window); gc.Copy(Widget.Style.TextGC(Gtk.StateType.Normal)); Color color_a = Util.ToXwtColor(Widget.Style.Base(Gtk.StateType.Normal)); Color color_b = Util.ToXwtColor(Widget.Style.Text(Gtk.StateType.Normal)); gc.RgbFgColor = Util.ToGdkColor(color_b.BlendWith(color_a, 0.5)); args.Event.Window.DrawLayout(gc, 2, (wh - height) / 2 + 1, layout); gc.Dispose(); }
void DisposeGCs() { if (foldDashedLineGC != null) { foldDashedLineGC.Dispose(); foldDashedLineGC = null; } if (foldDashedLineGC2 != null) { foldDashedLineGC2.Dispose(); foldDashedLineGC2 = null; } if (bgGC != null) { bgGC.Dispose(); bgGC = null; } if (bgGC2 != null) { bgGC2.Dispose(); bgGC2 = null; } }
protected void UpdatePreview() { thumb_image.Clear(); FileIsGood = false; int size = 200, margins = 30; if (System.IO.File.Exists(mFilename)) // Selected item is a file { origsize_label.Markup = ""; GLib.Timeout.Add(100, new GLib.TimeoutHandler(delegate { Gdk.Pixmap pm = null; Gdk.GC gc = null; Gdk.Pixbuf pb = null; try { pm = new Gdk.Pixmap(thumb_image.GdkWindow, size + margins, size + margins, -1); gc = new Gdk.GC(thumb_image.GdkWindow); pm.DrawRectangle(gc, true, new Gdk.Rectangle(0, 0, size + margins, size + margins)); RawDescriptionLoader rdl = RawDescriptionLoader.FromFile(mFilename); string idtext = ""; try { idtext += "Shot has been taken\n" + " on <b>" + rdl.TimeStamp.ToString("MMMM, d, yyyy") + "</b> at <b>" + rdl.TimeStamp.ToString("h:mm:ss tt") + "</b>,\n"; idtext += " with <b>" + rdl.CameraMaker + " " + rdl.CameraModel + "</b>\n\n"; idtext += "ISO speed: <b>" + rdl.ISOSpeed.ToString("0") + "</b>\n"; if (rdl.Shutter > 1) { idtext += "Shutter: <b>" + rdl.Shutter.ToString("0.0") + "</b> sec\n"; } else { idtext += "Shutter: <b>1/" + (1.0 / (rdl.Shutter + 0.000001)).ToString("0") + "</b> sec\n"; } idtext += "Aperture: <b>" + rdl.Aperture.ToString("0.0") + "</b>\n" + "Focal length: <b>" + rdl.FocalLength.ToString("0") + "</b> mm\n"; if (rdl.Artist != "") { idtext += "Artist: <b>" + rdl.Artist + "</b>\n"; } if (rdl.Description != "") { idtext += "Description: <b>" + rdl.Description + "</b>\n"; } Console.WriteLine(rdl.Flip); // Creating the thumbnail pixbuf pb = new Gdk.Pixbuf(rdl.ThumbnailData); } catch (Exception ex) { Console.WriteLine("Can't load the thumbnail: " + ex.Message); idtext += "\n<i>Can't load the thumbnail.</i>"; } identification_label.Markup = idtext; if (pb != null) { // Scaling the thumbnail Gdk.Pixbuf pbold = pb; int imgw = pb.Width, imgh = pb.Height; if (pb.Width > pb.Height) { pb = pb.ScaleSimple(size, (int)((double)pb.Height / pb.Width * size), Gdk.InterpType.Bilinear); } else { pb = pb.ScaleSimple((int)((double)pb.Width / pb.Height * size), size, Gdk.InterpType.Bilinear); } pbold.Dispose(); // Rotating the thumbnail if (rdl.Flip != RawDescriptionLoader.FlipValues.None) { pbold = pb; if (rdl.Flip == RawDescriptionLoader.FlipValues.UpsideDown) { pb = pb.RotateSimple(Gdk.PixbufRotation.Upsidedown); } else if (rdl.Flip == RawDescriptionLoader.FlipValues.Clockwise) { int t = imgw; imgw = imgh; imgh = t; pb = pb.RotateSimple(Gdk.PixbufRotation.Clockwise); } else if (rdl.Flip == RawDescriptionLoader.FlipValues.Counterclockwise) { int t = imgw; imgw = imgh; imgh = t; pb = pb.RotateSimple(Gdk.PixbufRotation.Counterclockwise); } pbold.Dispose(); } origsize_label.Markup = "Image size: <b>" + imgw + "</b> x <b>" + imgh + "</b>"; pm.DrawPixbuf(gc, pb, 0, 0, (size + margins) / 2 - pb.Width / 2, (size + margins) / 2 - pb.Height / 2, pb.Width, pb.Height, Gdk.RgbDither.Max, 0, 0); thumb_image.SetFromPixmap(pm, null); pb.Dispose(); } FileIsGood = true; } catch (Exception #if DEBUG ex #endif ) { #if DEBUG Console.WriteLine("Exception occured during the thumbnail loading process: " + ex.Message); #endif identification_label.Wrap = true; identification_label.Markup = "<i>Cannot decode the selected file. " + "Maybe it's corrupted or the user hasn't enough access rights to open it.</i>"; FileIsGood = false; } finally { if (gc != null) { gc.Dispose(); } if (pm != null) { pm.Dispose(); } } return(false); })); } }
protected override bool OnExposeEvent (Gdk.EventExpose evnt) { var alloc = Allocation; var baseColor = Style.Background (StateType.Normal); var c = new HslColor (baseColor); c.L *= 0.9; Gdk.GC gc = new Gdk.GC (GdkWindow); gc.RgbFgColor = c; evnt.Window.DrawRectangle (gc, true, alloc); gc.Dispose (); Gdk.GC bgc = new Gdk.GC (GdkWindow); c = new HslColor (baseColor); c.L *= 0.7; bgc.RgbFgColor = c; evnt.Window.DrawLine (bgc, alloc.X, alloc.Y + alloc.Height - 1, alloc.X + alloc.Width - 1, alloc.Y + alloc.Height - 1); bgc.Dispose (); return base.OnExposeEvent (evnt); }
protected override bool OnExposeEvent (Gdk.EventExpose args) { using (var g = Gdk.CairoHelper.Create (args.Window)) { g.Translate (Allocation.X, Allocation.Y); g.LineWidth = 1; Gdk.GC gc = new Gdk.GC (args.Window); layout.SetMarkup (TitleText); int width, height; layout.GetPixelSize (out width, out height); width += xBorder * 2; FoldingScreenbackgroundRenderer.DrawRoundRectangle (g, true, false, 0.5, 0.5, height + yBorder * 2 + 1.5, width, height + yBorder * 2); g.SetSourceColor (Styles.TableLayoutModeTitleBackgroundColor.ToCairoColor ()); g.FillPreserve (); g.SetSourceColor (Styles.TableLayoutModeBorderColor.ToCairoColor ()); g.Stroke (); g.Save (); g.SetSourceColor (Styles.TableLayoutModeTextColor.ToCairoColor ()); g.Translate (xBorder, yBorder); g.ShowLayout (layout); g.Restore (); FoldingScreenbackgroundRenderer.DrawRoundRectangle (g, false, true, 0.5, height * 2 + yBorder * 2 + 0.5, height, Allocation.Width - 1, Allocation.Height - height * 2 - yBorder * 2 - 1); g.SetSourceColor (Styles.TableLayoutModeBackgroundColor.ToCairoColor ()); g.FillPreserve (); g.SetSourceColor (Styles.TableLayoutModeBorderColor.ToCairoColor ()); g.Stroke (); g.MoveTo (xSpacer + 0.5, height * 2 + yBorder * 2); g.LineTo (xSpacer + 0.5, Allocation.Height - 1); g.SetSourceColor (Styles.TableLayoutModeGridColor.ToCairoColor ()); g.Stroke (); int y = height + yBorder * 2; for (int i = 0; i < Items.Count; i++) { KeyValuePair<string, string> pair = Items[i]; layout.SetMarkup (pair.Key); layout.GetPixelSize (out width, out height); if (i == 0) { FoldingScreenbackgroundRenderer.DrawRoundRectangle (g, false, true, false, false, 0, y + 0.5, height + 1.5, Allocation.Width, height); g.SetSourceColor (Styles.TableLayoutModeCategoryBackgroundColor.ToCairoColor ()); g.FillPreserve (); g.SetSourceColor (Styles.TableLayoutModeBorderColor.ToCairoColor ()); g.Stroke (); g.MoveTo (xSpacer + 0.5, height + yBorder * 2 + 1); g.LineTo (xSpacer + 0.5, height * 2 + yBorder * 2 + 1); g.SetSourceColor (Styles.TableLayoutModeGridColor.ToCairoColor ()); g.Stroke (); } gc.RgbFgColor = (HslColor)(i == 0 ? Styles.TableLayoutModeBackgroundColor : Styles.TableLayoutModeTextColor).ToCairoColor (); g.Save (); g.SetSourceColor (Styles.TableLayoutModeTextColor.ToCairoColor ()); g.Translate (xBorder, y); g.ShowLayout (layout); g.Restore (); g.Save (); g.SetSourceColor (Styles.TableLayoutModeTextColor.ToCairoColor ()); g.Translate (xSpacer + xBorder, y); layout.SetMarkup (pair.Value); g.ShowLayout (layout); g.Restore (); // draw top line if (i > 0) { g.MoveTo (1, y + 0.5); g.LineTo (Allocation.Width - 1, y + 0.5); g.SetSourceColor (Styles.TableLayoutModeGridColor.ToCairoColor ()); g.Stroke (); } y += height; } gc.Dispose (); } return base.OnExposeEvent (args); }
protected override bool OnExposeEvent(Gdk.EventExpose evnt) { Gdk.Rectangle rect; if (GradientBackround) { rect = new Gdk.Rectangle(Allocation.X, Allocation.Y, Allocation.Width, Allocation.Height); HslColor gcol = 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(); using (Cairo.Gradient pat = new Cairo.LinearGradient(rect.X, rect.Y, rect.X, rect.Bottom)) { Cairo.Color color1 = gcol; pat.AddColorStop(0, color1); gcol.L -= 0.1; if (gcol.L < 0) { gcol.L = 0; } pat.AddColorStop(1, gcol); cr.SetSource(pat); cr.FillPreserve(); } } } else if (BackgroundColor != null) { using (Cairo.Context cr = Gdk.CairoHelper.Create(GdkWindow)) { cr.Rectangle(Allocation.X, Allocation.Y, Allocation.Width, Allocation.Height); cr.SetSourceColor(BackgroundColor.Value.ToCairoColor()); cr.Fill(); } } else if (useChildBackgroundColor && Child != null) { using (Cairo.Context cr = Gdk.CairoHelper.Create(GdkWindow)) { cr.Rectangle(Allocation.X, Allocation.Y, Allocation.Width, Allocation.Height); cr.SetSourceColor(Child.Style.Base(StateType.Normal).ToCairoColor()); cr.Fill(); } } bool res = base.OnExposeEvent(evnt); var borderColor = new Gdk.GC(GdkWindow); borderColor.RgbFgColor = BorderColor != null ? BorderColor.Value : Style.Dark(Gtk.StateType.Normal); rect = Allocation; for (int n = 0; n < topMargin; n++) { GdkWindow.DrawLine(borderColor, rect.X, rect.Y + n, rect.Right - 1, 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 (showTopShadow) { using (Cairo.Context cr = Gdk.CairoHelper.Create(GdkWindow)) { cr.Rectangle(Allocation.X, Allocation.Y, Allocation.Width, shadowSize); using (Cairo.Gradient pat = new Cairo.LinearGradient(rect.X, rect.Y, rect.X, rect.Y + shadowSize)) { pat.AddColorStop(0, new Cairo.Color(0, 0, 0, shadowStrengh)); pat.AddColorStop(1, new Cairo.Color(0, 0, 0, 0)); cr.SetSource(pat); cr.Fill(); } } } borderColor.Dispose(); return(res); }
protected override bool OnExposeEvent(Gdk.EventExpose evnt) { if (VisualStyle.TabStyle == DockTabStyle.Normal) { Gdk.GC gc = new Gdk.GC (GdkWindow); gc.RgbFgColor = VisualStyle.PadBackgroundColor.Value; evnt.Window.DrawRectangle (gc, true, Allocation); gc.Dispose (); } return base.OnExposeEvent (evnt); }
protected override bool OnExposeEvent (Gdk.EventExpose args) { using (var g = Gdk.CairoHelper.Create (args.Window)) { g.SetSourceRGBA (1, 1, 1, 0); g.Operator = Cairo.Operator.Source; g.Paint (); } Cairo.Color bgColor = new Cairo.Color (1, 1, 1); Cairo.Color titleBgColor = new Cairo.Color (0.88, 0.88, 0.98); Cairo.Color categoryBgColor = new Cairo.Color (0.58, 0.58, 0.98); Cairo.Color borderColor = new Cairo.Color (0.4, 0.4, 0.6); Cairo.Color textColor = new Cairo.Color (0.3, 0.3, 1); Cairo.Color gridColor = new Cairo.Color (0.8, 0.8, 0.8); using (var g = Gdk.CairoHelper.Create (args.Window)) { g.LineWidth = 1; Gdk.GC gc = new Gdk.GC (args.Window); layout.SetMarkup (TitleText); int width, height; layout.GetPixelSize (out width, out height); width += xBorder * 2; FoldingScreenbackgroundRenderer.DrawRoundRectangle (g, true, false, 0.5, 0.5, height + yBorder * 2 + 1.5, width, height + yBorder * 2); g.Color = titleBgColor; g.FillPreserve (); g.Color = borderColor; g.Stroke (); gc.RgbFgColor = (HslColor)textColor; args.Window.DrawLayout (gc, xBorder, yBorder, layout); FoldingScreenbackgroundRenderer.DrawRoundRectangle (g, false, true, 0.5, height * 2 + yBorder * 2 + 0.5, height, Allocation.Width - 1, Allocation.Height - height * 2 - yBorder * 2 - 1); g.Color = bgColor; g.FillPreserve (); g.Color = borderColor; g.Stroke (); g.MoveTo (xSpacer + 0.5, height * 2 + yBorder * 2); g.LineTo (xSpacer + 0.5, Allocation.Height - 1); g.Color = gridColor; g.Stroke (); int y = height + yBorder * 2; for (int i = 0; i < Items.Count; i++) { KeyValuePair<string, string> pair = Items[i]; layout.SetMarkup (pair.Key); layout.GetPixelSize (out width, out height); if (i == 0) { FoldingScreenbackgroundRenderer.DrawRoundRectangle (g, false, true, false, false, 0, y + 0.5, height + 1.5, Allocation.Width, height); g.Color = categoryBgColor; g.FillPreserve (); g.Color = borderColor; g.Stroke (); g.MoveTo (xSpacer + 0.5, height + yBorder * 2 + 1); g.LineTo (xSpacer + 0.5, height * 2 + yBorder * 2 + 1); g.Color = gridColor; g.Stroke (); } gc.RgbFgColor = (HslColor)(i == 0 ? bgColor : textColor); args.Window.DrawLayout (gc, xBorder, y, layout); layout.SetMarkup (pair.Value); args.Window.DrawLayout (gc, xSpacer + xBorder, y, layout); // draw top line if (i > 0) { g.MoveTo (1, y + 0.5); g.LineTo (Allocation.Width - 1, y + 0.5); g.Color = gridColor; g.Stroke (); } y += height; } gc.Dispose (); } return false; }
protected override bool OnExposeEvent(Gdk.EventExpose evnt) { if (VisualStyle.TabStyle == DockTabStyle.Normal) { Gdk.GC gc = new Gdk.GC (GdkWindow); gc.RgbFgColor = VisualStyle.PadBackgroundColor.Value; evnt.Window.DrawRectangle (gc, true, Allocation); gc.Dispose (); } bool result = base.OnExposeEvent(evnt); Gdk.Color? col = VisualStyle.PadBackgroundColor; if (col.HasValue) { DrawFocus(evnt.Window, Color.FromArgb(255, col.Value.Red / 256, col.Value.Green / 256, col.Value.Blue / 256)); } return result; }
protected override bool OnExposeEvent (Gdk.EventExpose evnt) { if (TabStrip.VisualStyle.TabStyle == DockTabStyle.Normal) { var alloc = Allocation; Gdk.GC gc = new Gdk.GC (GdkWindow); gc.RgbFgColor = TabStrip.VisualStyle.InactivePadBackgroundColor.Value.ToGdkColor (); evnt.Window.DrawRectangle (gc, true, alloc); gc.Dispose (); Gdk.GC bgc = new Gdk.GC (GdkWindow); var c = TabStrip.VisualStyle.PadBackgroundColor.Value; c.Light *= 0.7; bgc.RgbFgColor = c.ToGdkColor (); evnt.Window.DrawLine (bgc, alloc.X, alloc.Y + alloc.Height - 1, alloc.X + alloc.Width - 1, alloc.Y + alloc.Height - 1); bgc.Dispose (); } return base.OnExposeEvent (evnt); }
protected void UpdatePreview() { thumb_image.Clear(); FileIsGood = false; int size = 200, margins = 30; if (System.IO.File.Exists(mFilename)) // Selected item is a file { origsize_label.Markup = ""; GLib.Timeout.Add(100, new GLib.TimeoutHandler(delegate { Gdk.Pixmap pm = null; Gdk.GC gc = null; Gdk.Pixbuf pb = null; try { pm = new Gdk.Pixmap(thumb_image.GdkWindow, size + margins, size + margins, -1); gc = new Gdk.GC(thumb_image.GdkWindow); pm.DrawRectangle(gc, true, new Gdk.Rectangle(0, 0, size + margins, size + margins)); RawDescriptionLoader rdl = RawDescriptionLoader.FromFile(mFilename); string idtext = ""; try { idtext += "Shot has been taken\n" + " on <b>" + rdl.TimeStamp.ToString("MMMM, d, yyyy") + "</b> at <b>" + rdl.TimeStamp.ToString("h:mm:ss tt") + "</b>,\n"; idtext += " with <b>" + rdl.CameraMaker + " " + rdl.CameraModel + "</b>\n\n"; idtext += "ISO speed: <b>" + rdl.ISOSpeed.ToString("0") + "</b>\n"; if (rdl.Shutter > 1) idtext += "Shutter: <b>" + rdl.Shutter.ToString("0.0") + "</b> sec\n"; else idtext += "Shutter: <b>1/" + (1.0 / (rdl.Shutter + 0.000001)).ToString("0") + "</b> sec\n"; idtext += "Aperture: <b>" + rdl.Aperture.ToString("0.0") + "</b>\n" + "Focal length: <b>" + rdl.FocalLength.ToString("0") + "</b> mm\n"; if (rdl.Artist != "") idtext += "Artist: <b>" + rdl.Artist + "</b>\n"; if (rdl.Description != "") idtext += "Description: <b>" + rdl.Description + "</b>\n"; Console.WriteLine(rdl.Flip); // Creating the thumbnail pixbuf pb = new Gdk.Pixbuf(rdl.ThumbnailData); } catch (Exception ex) { Console.WriteLine("Can't load the thumbnail: " + ex.Message); idtext += "\n<i>Can't load the thumbnail.</i>"; } identification_label.Markup = idtext; if (pb != null) { // Scaling the thumbnail Gdk.Pixbuf pbold = pb; int imgw = pb.Width, imgh = pb.Height; if (pb.Width > pb.Height) pb = pb.ScaleSimple(size, (int)((double)pb.Height / pb.Width * size), Gdk.InterpType.Bilinear); else pb = pb.ScaleSimple((int)((double)pb.Width / pb.Height * size), size, Gdk.InterpType.Bilinear); pbold.Dispose(); // Rotating the thumbnail if (rdl.Flip != RawDescriptionLoader.FlipValues.None) { pbold = pb; if (rdl.Flip == RawDescriptionLoader.FlipValues.UpsideDown) pb = pb.RotateSimple(Gdk.PixbufRotation.Upsidedown); else if (rdl.Flip == RawDescriptionLoader.FlipValues.Clockwise) { int t = imgw; imgw = imgh; imgh = t; pb = pb.RotateSimple(Gdk.PixbufRotation.Clockwise); } else if (rdl.Flip == RawDescriptionLoader.FlipValues.Counterclockwise) { int t = imgw; imgw = imgh; imgh = t; pb = pb.RotateSimple(Gdk.PixbufRotation.Counterclockwise); } pbold.Dispose(); } origsize_label.Markup = "Image size: <b>" + imgw + "</b> x <b>" + imgh + "</b>"; pm.DrawPixbuf(gc, pb, 0, 0, (size + margins) / 2 - pb.Width / 2, (size + margins) / 2 - pb.Height / 2, pb.Width, pb.Height, Gdk.RgbDither.Max, 0, 0); thumb_image.SetFromPixmap(pm, null); pb.Dispose(); } FileIsGood = true; } catch (Exception #if DEBUG ex #endif ) { #if DEBUG Console.WriteLine("Exception occured during the thumbnail loading process: " + ex.Message); #endif identification_label.Wrap = true; identification_label.Markup = "<i>Cannot decode the selected file. "+ "Maybe it's corrupted or the user hasn't enough access rights to open it.</i>"; FileIsGood = false; } finally { if (gc != null) gc.Dispose(); if (pm != null) pm.Dispose(); } return false; })); } }
protected override bool OnExposeEvent (Gdk.EventExpose evt) { if (!IsDrawable) return false; int width, height; GdkWindow.GetSize (out width, out height); Gdk.Rectangle a = new Gdk.Rectangle (0,0,width,height); byte b2 = 210; int ssLT = 12; int ssRB = 7; double grey = 0.6; double greyb1 = 0.9; double greyb2 = 0.6; Gdk.Rectangle rect = a; Cairo.Color back1 = new Cairo.Color (greyb1, greyb1, greyb1); Cairo.Color back2 = new Cairo.Color (greyb2, greyb2, greyb2); Cairo.Color cdark = new Cairo.Color (grey, grey, grey, 1); Cairo.Color clight = new Cairo.Color (grey, grey, grey, 0); using (Cairo.Context cr = Gdk.CairoHelper.Create (evt.Window)) { DrawGradient (cr, rect, 0, 0, 1, 1, back1, back2); rect.X = a.X; rect.Y = a.Y; rect.Height = ssLT; rect.Width = a.Width; DrawGradient (cr, rect, 0, 0, 0, 1, cdark, clight); rect.Y = a.Bottom - ssRB; rect.Height = ssRB; DrawGradient (cr, rect, 0, 0, 0, 1, clight, cdark); rect.X = a.X; rect.Y = a.Y; rect.Width = ssLT; rect.Height = a.Height; DrawGradient (cr, rect, 0, 0, 1, 0, cdark, clight); rect.X = a.Right - ssRB; rect.Width = ssRB; DrawGradient (cr, rect, 0, 0, 1, 0, clight, cdark); Gdk.GC gc = new Gdk.GC (GdkWindow); gc.RgbBgColor = new Gdk.Color (b2,b2,b2); gc.RgbFgColor = new Gdk.Color (b2,b2,b2); GdkWindow.DrawRectangle (gc, false, a.X, a.Y, a.Width, a.Height); gc.Dispose (); } return base.OnExposeEvent (evt); }
protected override bool OnExposeEvent(Gdk.EventExpose args) { using (var g = Gdk.CairoHelper.Create(args.Window)) { g.SetSourceRGBA(1, 1, 1, 0); g.Operator = Cairo.Operator.Source; g.Paint(); } Cairo.Color bgColor = new Cairo.Color(1, 1, 1); Cairo.Color titleBgColor = new Cairo.Color(0.88, 0.88, 0.98); Cairo.Color categoryBgColor = new Cairo.Color(0.58, 0.58, 0.98); Cairo.Color borderColor = new Cairo.Color(0.4, 0.4, 0.6); Cairo.Color textColor = new Cairo.Color(0.3, 0.3, 1); Cairo.Color gridColor = new Cairo.Color(0.8, 0.8, 0.8); using (var g = Gdk.CairoHelper.Create(args.Window)) { g.LineWidth = 1; Gdk.GC gc = new Gdk.GC(args.Window); layout.SetMarkup(TitleText); int width, height; layout.GetPixelSize(out width, out height); width += xBorder * 2; FoldingScreenbackgroundRenderer.DrawRoundRectangle(g, true, false, 0.5, 0.5, height + yBorder * 2 + 1.5, width, height + yBorder * 2); g.Color = titleBgColor; g.FillPreserve(); g.Color = borderColor; g.Stroke(); gc.RgbFgColor = (HslColor)textColor; args.Window.DrawLayout(gc, xBorder, yBorder, layout); FoldingScreenbackgroundRenderer.DrawRoundRectangle(g, false, true, 0.5, height * 2 + yBorder * 2 + 0.5, height, Allocation.Width - 1, Allocation.Height - height * 2 - yBorder * 2 - 1); g.Color = bgColor; g.FillPreserve(); g.Color = borderColor; g.Stroke(); g.MoveTo(xSpacer + 0.5, height * 2 + yBorder * 2); g.LineTo(xSpacer + 0.5, Allocation.Height - 1); g.Color = gridColor; g.Stroke(); int y = height + yBorder * 2; for (int i = 0; i < Items.Count; i++) { KeyValuePair <string, string> pair = Items[i]; layout.SetMarkup(pair.Key); layout.GetPixelSize(out width, out height); if (i == 0) { FoldingScreenbackgroundRenderer.DrawRoundRectangle(g, false, true, false, false, 0, y + 0.5, height + 1.5, Allocation.Width, height); g.Color = categoryBgColor; g.FillPreserve(); g.Color = borderColor; g.Stroke(); g.MoveTo(xSpacer + 0.5, height + yBorder * 2 + 1); g.LineTo(xSpacer + 0.5, height * 2 + yBorder * 2 + 1); g.Color = gridColor; g.Stroke(); } gc.RgbFgColor = (HslColor)(i == 0 ? bgColor : textColor); args.Window.DrawLayout(gc, xBorder, y, layout); layout.SetMarkup(pair.Value); args.Window.DrawLayout(gc, xSpacer + xBorder, y, layout); // draw top line if (i > 0) { g.MoveTo(1, y + 0.5); g.LineTo(Allocation.Width - 1, y + 0.5); g.Color = gridColor; g.Stroke(); } y += height; } gc.Dispose(); } GtkWorkarounds.UpdateNativeShadow(this); return(false); }
void DrawAsBrowser (Gdk.EventExpose evnt) { var alloc = Allocation; Gdk.GC bgc = new Gdk.GC (GdkWindow); var c = new HslColor (VisualStyle.PadBackgroundColor.Value); c.L *= 0.7; bgc.RgbFgColor = c; bool first = true; bool last = true; TabStrip tabStrip = null; if (Parent is TabStrip.TabStripBox) { var tsb = (TabStrip.TabStripBox) Parent; var cts = tsb.Children; first = cts[0] == this; last = cts[cts.Length - 1] == this; tabStrip = tsb.TabStrip; } if (Active || (first && last)) { Gdk.GC gc = new Gdk.GC (GdkWindow); gc.RgbFgColor = VisualStyle.PadBackgroundColor.Value; evnt.Window.DrawRectangle (gc, true, alloc); if (!first) evnt.Window.DrawLine (bgc, alloc.X, alloc.Y, alloc.X, alloc.Y + alloc.Height - 1); if (!(last && first) && !(tabStrip != null && tabStrip.VisualStyle.ExpandedTabs.Value && last)) evnt.Window.DrawLine (bgc, alloc.X + alloc.Width - 1, alloc.Y, alloc.X + alloc.Width - 1, alloc.Y + alloc.Height - 1); gc.Dispose (); } else { Gdk.GC gc = new Gdk.GC (GdkWindow); gc.RgbFgColor = tabStrip != null ? tabStrip.VisualStyle.InactivePadBackgroundColor.Value : frame.DefaultVisualStyle.InactivePadBackgroundColor.Value; evnt.Window.DrawRectangle (gc, true, alloc); gc.Dispose (); evnt.Window.DrawLine (bgc, alloc.X, alloc.Y + alloc.Height - 1, alloc.X + alloc.Width - 1, alloc.Y + alloc.Height - 1); } bgc.Dispose (); }
protected override bool OnExposeEvent(Gdk.EventExpose evnt) { Gdk.Rectangle rect = Allocation; //Gdk.Rectangle.Right and Bottom are inconsistent int right = rect.X + rect.Width, bottom = rect.Y + rect.Height; var bcolor = backgroundColorSet ? BackgroundColor : Style.Background(Gtk.StateType.Normal); using (Cairo.Context cr = Gdk.CairoHelper.Create(evnt.Window)) { if (GradientBackround) { 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(); using (Cairo.Gradient pat = new Cairo.LinearGradient(rect.X, rect.Y, rect.X, bottom)) { pat.AddColorStop(0, bcolor.ToCairoColor()); HslColor gcol = bcolor; gcol.L -= 0.1; if (gcol.L < 0) { gcol.L = 0; } pat.AddColorStop(1, gcol); cr.SetSource(pat); cr.Fill(); } } else { if (backgroundColorSet) { Gdk.GC gc = new Gdk.GC(GdkWindow); gc.RgbFgColor = bcolor; evnt.Window.DrawRectangle(gc, true, rect.X, rect.Y, rect.Width, rect.Height); gc.Dispose(); } } cr.Dispose(); } // using base.OnExposeEvent(evnt); using (Cairo.Context cr = Gdk.CairoHelper.Create(evnt.Window)) { cr.SetSourceColor((HslColor)Style.Dark(Gtk.StateType.Normal)); double y = rect.Y + topMargin / 2d; cr.LineWidth = topMargin; cr.Line(rect.X, y, right, y); cr.Stroke(); y = bottom - bottomMargin / 2d; cr.LineWidth = bottomMargin; cr.Line(rect.X, y, right, y); cr.Stroke(); double x = rect.X + leftMargin / 2d; cr.LineWidth = leftMargin; cr.Line(x, rect.Y, x, bottom); cr.Stroke(); x = right - rightMargin / 2d; cr.LineWidth = rightMargin; cr.Line(x, rect.Y, x, bottom); cr.Stroke(); cr.Dispose(); return(false); } }
protected override bool OnExposeEvent (Gdk.EventExpose e) { Gdk.GC gc = new Gdk.GC (e.Window); int count = 0; foreach (Hunk h in hunks) { IncPos(h, ref count); } int start = 0; foreach (Hunk h in hunks) { int size = 0; IncPos(h, ref size); if (h.Same) gc.RgbFgColor = widget.ColorDefault; else if (h.Original().Count == 0) gc.RgbFgColor = widget.ColorAdded; else if (h.ChangedLists == 1 && h.Changes(0).Count == 0) gc.RgbFgColor = widget.ColorRemoved; else gc.RgbFgColor = widget.ColorChanged; GdkWindow.DrawRectangle(gc, true, 0, Allocation.Height*start/count, Allocation.Width, Allocation.Height*size/count); start += size; } gc.RgbFgColor = widget.ColorGrey; e.Window.DrawRectangle(gc, false, 1, (int)(Allocation.Height*scroller.Vadjustment.Value/scroller.Vadjustment.Upper) + 1, Allocation.Width-3, (int)(Allocation.Height*((double)scroller.Allocation.Height/scroller.Vadjustment.Upper))-2); gc.RgbFgColor = widget.ColorBlack; e.Window.DrawRectangle(gc, false, 0, (int)(Allocation.Height*scroller.Vadjustment.Value/scroller.Vadjustment.Upper), Allocation.Width-1, (int)(Allocation.Height*((double)scroller.Allocation.Height/scroller.Vadjustment.Upper))); gc.Dispose (); return true; }
protected override bool OnExposeEvent(Gdk.EventExpose evnt) { Gdk.Rectangle rect = Allocation; //Gdk.Rectangle.Right and Bottom are inconsistent int right = rect.X + rect.Width, bottom = rect.Y + rect.Height; var bcolor = backgroundColorSet ? BackgroundColor : Style.Background (Gtk.StateType.Normal); using (Cairo.Context cr = Gdk.CairoHelper.Create (evnt.Window)) { if (GradientBackround) { 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 (); using (Cairo.Gradient pat = new Cairo.LinearGradient (rect.X, rect.Y, rect.X, bottom)) { pat.AddColorStop (0, bcolor.ToCairoColor ()); Xwt.Drawing.Color gcol = bcolor.ToXwtColor (); gcol.Light -= 0.1; if (gcol.Light < 0) gcol.Light = 0; pat.AddColorStop (1, gcol.ToCairoColor ()); cr.SetSource (pat); cr.Fill (); } } else { if (backgroundColorSet) { Gdk.GC gc = new Gdk.GC (GdkWindow); gc.RgbFgColor = bcolor; evnt.Window.DrawRectangle (gc, true, rect.X, rect.Y, rect.Width, rect.Height); gc.Dispose (); } } } base.OnExposeEvent (evnt); using (Cairo.Context cr = Gdk.CairoHelper.Create (evnt.Window)) { cr.SetSourceColor (Style.Dark (Gtk.StateType.Normal).ToCairoColor ()); double y = rect.Y + topMargin / 2d; cr.LineWidth = topMargin; cr.Line (rect.X, y, right, y); cr.Stroke (); y = bottom - bottomMargin / 2d; cr.LineWidth = bottomMargin; cr.Line (rect.X, y, right, y); cr.Stroke (); double x = rect.X + leftMargin / 2d; cr.LineWidth = leftMargin; cr.Line (x, rect.Y, x, bottom); cr.Stroke (); x = right - rightMargin / 2d; cr.LineWidth = rightMargin; cr.Line (x, rect.Y, x, bottom); cr.Stroke (); return false; } }
void HandleWidgetExposeEvent(object o, Gtk.ExposeEventArgs args) { // The Entry's GdkWindow is the top level window onto which // the frame is drawn; the actual text entry is drawn into a // separate window, so we can ensure that for themes that don't // respect HasFrame, we never ever allow the base frame drawing // to happen if (args.Event.Window == Widget.GdkWindow) return; if (Widget.Text.Length > 0) return; if (layout == null) { layout = new Pango.Layout (Widget.PangoContext); layout.FontDescription = Widget.PangoContext.FontDescription.Copy (); } int wh, ww; args.Event.Window.GetSize (out ww, out wh); int width, height; layout.SetText (placeHolderText); layout.GetPixelSize (out width, out height); Gdk.GC gc = new Gdk.GC (args.Event.Window); gc.Copy (Widget.Style.TextGC (Gtk.StateType.Normal)); Color color_a = Util.ToXwtColor (Widget.Style.Base (Gtk.StateType.Normal)); Color color_b = Util.ToXwtColor (Widget.Style.Text (Gtk.StateType.Normal)); gc.RgbFgColor = Util.ToGdkColor (color_b.BlendWith (color_a, 0.5)); args.Event.Window.DrawLayout (gc, 2, (wh - height) / 2 + 1, layout); gc.Dispose (); }
protected override bool OnExposeEvent (Gdk.EventExpose evnt) { Gdk.Rectangle rect; if (GradientBackround) { rect = new Gdk.Rectangle (Allocation.X, Allocation.Y, Allocation.Width, Allocation.Height); HslColor gcol = 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 = gcol; pat.AddColorStop (0, color1); gcol.L -= 0.1; if (gcol.L < 0) gcol.L = 0; pat.AddColorStop (1, gcol); cr.Pattern = pat; cr.FillPreserve (); } } else if (BackgroundColor != null) { using (Cairo.Context cr = Gdk.CairoHelper.Create (GdkWindow)) { cr.Rectangle (Allocation.X, Allocation.Y, Allocation.Width, Allocation.Height); cr.Color = BackgroundColor.Value.ToCairoColor (); cr.Fill (); } } else if (useChildBackgroundColor && Child != null) { using (Cairo.Context cr = Gdk.CairoHelper.Create (GdkWindow)) { cr.Rectangle (Allocation.X, Allocation.Y, Allocation.Width, Allocation.Height); cr.Color = Child.Style.Base (StateType.Normal).ToCairoColor (); cr.Fill (); } } bool res = base.OnExposeEvent (evnt); var borderColor = new Gdk.GC (GdkWindow); borderColor.RgbFgColor = BorderColor != null ? BorderColor.Value : Style.Dark (Gtk.StateType.Normal); rect = Allocation; for (int n=0; n<topMargin; n++) GdkWindow.DrawLine (borderColor, rect.X, rect.Y + n, rect.Right - 1, 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 (showTopShadow) { using (Cairo.Context cr = Gdk.CairoHelper.Create (GdkWindow)) { cr.Rectangle (Allocation.X, Allocation.Y, Allocation.Width, shadowSize); Cairo.Gradient pat = new Cairo.LinearGradient (rect.X, rect.Y, rect.X, rect.Y + shadowSize); pat.AddColorStop (0, new Cairo.Color (0, 0, 0, shadowStrengh)); pat.AddColorStop (1, new Cairo.Color (0, 0, 0, 0)); cr.Pattern = pat; cr.Fill (); } } borderColor.Dispose (); return res; }
void DrawAsBrowser (Gdk.EventExpose evnt) { var alloc = Allocation; Gdk.GC bgc = new Gdk.GC (GdkWindow); var baseColor = Style.Background (StateType.Normal); var c = new HslColor (baseColor); c.L *= 0.7; bgc.RgbFgColor = c; var cts = ((SquaredTabStrip.TabStripBox)Parent).Children; var first = cts[0] == this; var last = cts[cts.Length - 1] == this; if (Active || (first && last)) { Gdk.GC gc = new Gdk.GC (GdkWindow); gc.RgbFgColor = baseColor; evnt.Window.DrawRectangle (gc, true, alloc); if (!first) evnt.Window.DrawLine (bgc, alloc.X, alloc.Y, alloc.X, alloc.Y + alloc.Height - 1); if (!last || !first) evnt.Window.DrawLine (bgc, alloc.X + alloc.Width - 1, alloc.Y, alloc.X + alloc.Width - 1, alloc.Y + alloc.Height - 1); gc.Dispose (); } else { c = new HslColor (baseColor); c.L *= 0.9; Gdk.GC gc = new Gdk.GC (GdkWindow); gc.RgbFgColor = c; evnt.Window.DrawRectangle (gc, true, alloc); gc.Dispose (); evnt.Window.DrawLine (bgc, alloc.X, alloc.Y + alloc.Height - 1, alloc.X + alloc.Width - 1, alloc.Y + alloc.Height - 1); } bgc.Dispose (); }
protected override bool OnExposeEvent(Gdk.EventExpose args) { using (var g = Gdk.CairoHelper.Create(args.Window)) { g.Translate(Allocation.X, Allocation.Y); g.LineWidth = 1; Gdk.GC gc = new Gdk.GC(args.Window); layout.SetMarkup(TitleText); int width, height; layout.GetPixelSize(out width, out height); width += xBorder * 2; FoldingScreenbackgroundRenderer.DrawRoundRectangle(g, true, false, 0.5, 0.5, height + yBorder * 2 + 1.5, width, height + yBorder * 2); g.SetSourceColor(Styles.TableLayoutModeTitleBackgroundColor.ToCairoColor()); g.FillPreserve(); g.SetSourceColor(Styles.TableLayoutModeBorderColor.ToCairoColor()); g.Stroke(); g.Save(); g.SetSourceColor(Styles.TableLayoutModeTextColor.ToCairoColor()); g.Translate(xBorder, yBorder); g.ShowLayout(layout); g.Restore(); FoldingScreenbackgroundRenderer.DrawRoundRectangle(g, false, true, 0.5, height * 2 + yBorder * 2 + 0.5, height, Allocation.Width - 1, Allocation.Height - height * 2 - yBorder * 2 - 1); g.SetSourceColor(Styles.TableLayoutModeBackgroundColor.ToCairoColor()); g.FillPreserve(); g.SetSourceColor(Styles.TableLayoutModeBorderColor.ToCairoColor()); g.Stroke(); g.MoveTo(xSpacer + 0.5, height * 2 + yBorder * 2); g.LineTo(xSpacer + 0.5, Allocation.Height - 1); g.SetSourceColor(Styles.TableLayoutModeGridColor.ToCairoColor()); g.Stroke(); int y = height + yBorder * 2; for (int i = 0; i < Items.Count; i++) { KeyValuePair <string, string> pair = Items[i]; layout.SetMarkup(pair.Key); layout.GetPixelSize(out width, out height); if (i == 0) { FoldingScreenbackgroundRenderer.DrawRoundRectangle(g, false, true, false, false, 0, y + 0.5, height + 1.5, Allocation.Width, height); g.SetSourceColor(Styles.TableLayoutModeCategoryBackgroundColor.ToCairoColor()); g.FillPreserve(); g.SetSourceColor(Styles.TableLayoutModeBorderColor.ToCairoColor()); g.Stroke(); g.MoveTo(xSpacer + 0.5, height + yBorder * 2 + 1); g.LineTo(xSpacer + 0.5, height * 2 + yBorder * 2 + 1); g.SetSourceColor(Styles.TableLayoutModeGridColor.ToCairoColor()); g.Stroke(); } gc.RgbFgColor = (HslColor)(i == 0 ? Styles.TableLayoutModeBackgroundColor : Styles.TableLayoutModeTextColor).ToCairoColor(); g.Save(); g.SetSourceColor(Styles.TableLayoutModeTextColor.ToCairoColor()); g.Translate(xBorder, y); g.ShowLayout(layout); g.Restore(); g.Save(); g.SetSourceColor(Styles.TableLayoutModeTextColor.ToCairoColor()); g.Translate(xSpacer + xBorder, y); layout.SetMarkup(pair.Value); g.ShowLayout(layout); g.Restore(); // draw top line if (i > 0) { g.MoveTo(1, y + 0.5); g.LineTo(Allocation.Width - 1, y + 0.5); g.SetSourceColor(Styles.TableLayoutModeGridColor.ToCairoColor()); g.Stroke(); } y += height; } gc.Dispose(); } return(base.OnExposeEvent(args)); }
private void RefreshGC() { text_gc?.Dispose(); text_gc = null; }