protected override void OnRealized() { base.OnRealized(); MonoDevelop.Components.HslColor c = Style.Background(Gtk.StateType.Normal); c.L -= 0.1; headerBox.ModifyBg(Gtk.StateType.Normal, c); }
public static string ColorMarkupBackground (string textMarkup, int startIndex, int endIndex, HslColor searchColor) { var markupBuilder = new StringBuilder(); bool inMarkup = false, inEntity = false, closed = false, opened = false; int i = 0; for (int j = 0; j < textMarkup.Length; j++) { var ch = textMarkup [j]; if (inEntity) { if (ch == ';') { inEntity = false; i++; } markupBuilder.Append (ch); continue; } if (inMarkup) { if (ch == '>') { inMarkup = false; markupBuilder.Append (ch); if (i > startIndex && markupBuilder.ToString ().EndsWith("</span>")) { if (opened && !closed) { markupBuilder.Append ("</span>"); opened = false; } markupBuilder.Append (textMarkup.Substring(j + 1)); return ColorMarkupBackground (markupBuilder.ToString (), i, endIndex, searchColor); } continue; } markupBuilder.Append (ch); continue; } if (i == endIndex) { if (opened) { markupBuilder.Append ("</span>"); opened = false; } markupBuilder.Append (textMarkup.Substring (j)); closed = true; break; } if (ch == '<') { inMarkup = true; markupBuilder.Append (ch); continue; } if (i == startIndex) { opened = true; markupBuilder.Append ("<span background=\"" + ColorToPangoMarkup (searchColor) + "\">"); } if (ch == '&') { inEntity = true; markupBuilder.Append (ch); continue; } markupBuilder.Append (ch); i++; } if (!closed && opened) markupBuilder.Append ("</span>"); return markupBuilder.ToString (); }
public OptionsDialog (Gtk.Window parentWindow, object dataObject, string extensionPath, bool removeEmptySections) { buttonCancel = new Gtk.Button (Gtk.Stock.Cancel); AddActionWidget (this.buttonCancel, ResponseType.Cancel); buttonOk = new Gtk.Button (Gtk.Stock.Ok); this.ActionArea.PackStart (buttonOk); buttonOk.Clicked += OnButtonOkClicked; mainHBox = new HBox (); tree = new TreeView (); var sw = new ScrolledWindow (); sw.Add (tree); sw.HscrollbarPolicy = PolicyType.Never; sw.VscrollbarPolicy = PolicyType.Automatic; sw.ShadowType = ShadowType.None; var fboxTree = new HeaderBox (); fboxTree.SetMargins (0, 1, 0, 1); fboxTree.SetPadding (0, 0, 0, 0); fboxTree.BackgroundColor = new Gdk.Color (255, 255, 255); fboxTree.Add (sw); mainHBox.PackStart (fboxTree, false, false, 0); Realized += delegate { fboxTree.BackgroundColor = tree.Style.Base (Gtk.StateType.Normal); }; var vbox = new VBox (); mainHBox.PackStart (vbox, true, true, 0); var headerBox = new HBox (false, 6); image = new Image (); // headerBox.PackStart (image, false, false, 0); labelTitle = new Label (); labelTitle.Xalign = 0; headerBox.PackStart (labelTitle, true, true, 0); headerBox.BorderWidth = 12; var fboxHeader = new HeaderBox (); fboxHeader.SetMargins (0, 1, 0, 0); fboxHeader.Add (headerBox); // fbox.GradientBackround = true; // fbox.BackgroundColor = new Gdk.Color (255, 255, 255); Realized += delegate { var c = new HslColor (Style.Background (Gtk.StateType.Normal)); c.L += 0.09; fboxHeader.BackgroundColor = c; }; vbox.PackStart (fboxHeader, false, false, 0); pageFrame = new HBox (); var fbox = new HeaderBox (); fbox.SetMargins (0, 1, 0, 0); fbox.ShowTopShadow = true; fbox.Add (pageFrame); vbox.PackStart (fbox, true, true, 0); this.VBox.PackStart (mainHBox, true, true, 0); this.removeEmptySections = removeEmptySections; extensionContext = AddinManager.CreateExtensionContext (); this.mainDataObject = dataObject; this.extensionPath = extensionPath; if (parentWindow != null) TransientFor = parentWindow; ImageService.EnsureStockIconIsLoaded (emptyCategoryIcon, treeIconSize); ImageService.EnsureStockIconIsLoaded (emptyCategoryIcon, headerIconSize); store = new TreeStore (typeof(OptionsDialogSection)); tree.Model = store; tree.HeadersVisible = false; // Column 0 is used to add some padding at the left of the expander TreeViewColumn col0 = new TreeViewColumn (); col0.MinWidth = 6; tree.AppendColumn (col0); TreeViewColumn col = new TreeViewColumn (); var crp = new CellRendererPixbuf (); col.PackStart (crp, false); col.SetCellDataFunc (crp, PixbufCellDataFunc); var crt = new CellRendererText (); col.PackStart (crt, true); col.SetCellDataFunc (crt, TextCellDataFunc); tree.AppendColumn (col); tree.ExpanderColumn = col; tree.Selection.Changed += OnSelectionChanged; Child.ShowAll (); InitializeContext (extensionContext); FillTree (); ExpandCategories (); this.DefaultResponse = Gtk.ResponseType.Ok; DefaultWidth = 722; DefaultHeight = 502; }
public ChunkStyle () { Foreground = Background = new HslColor (0, 0, 0, 0); FontWeight = Xwt.Drawing.FontWeight.Normal; FontStyle = Xwt.Drawing.FontStyle.Normal; }
HslColor AlphaBlend (HslColor color, HslColor color2, double alpha) { return (HslColor)AlphaBlend ((Gdk.Color)color, (Gdk.Color)color2, alpha); }
protected override void OnRealized () { base.OnRealized (); var c = new HslColor (Style.Base (StateType.Normal)); c.L *= 0.8; commitBox.ModifyBg (StateType.Normal, c); var tcol = new Gdk.Color (255, 251, 242); textviewDetails.ModifyBase (StateType.Normal, tcol); scrolledwindow1.ModifyBase (StateType.Normal, tcol); }
internal static Cairo.Color IncreaseLight (Cairo.Color color, double factor) { var c = new HslColor (color); c.L += (1 - c.L) * factor; return c; }
public static double Brightness(HslColor c) { return(Brightness((Cairo.Color)c)); }
public static List<HslColor> GenerateHighlightColors (HslColor backGround, HslColor foreGround, int n) { double bgH = (backGround.H == 0 && backGround.S == 0) ? 2 / 3.0 : backGround.H; var result = new List<HslColor> (); for (int i = 0; i < n; i++) { double h = bgH + (i + 1.0) / (double)n; // for monochromatic backround the h value doesn't matter if (i + 1 == n && !(backGround.H == 0 && backGround.S == 0)) h = bgH + 0.5; if (h > 1.0) h -= 1.0; double s = 0.85; double l = 0.5; if (backGround.H == 0 && backGround.S == 0 && backGround.L < 0.5) l = 0.8; result.Add (HslColor.FromHsl (h, s, l)); } return result; }
public static Gdk.Color GetColor (this Counter c) { Gdk.Color cachedColor; if (colors.TryGetValue (c, out cachedColor)) return cachedColor; Random r = new Random (c.Name.GetHashCode ()); HslColor col = new HslColor (); int nc = c.Name.GetHashCode (); if (nc < 0) nc = -nc; col.H = r.NextDouble (); col.S = r.NextDouble (); col.L = 0.3 + (r.NextDouble () * 0.3); Gdk.Color gc = col; colors [c] = gc; return gc; }
public static double Brightness (HslColor c) { return Brightness ((Cairo.Color)c); }
protected override bool OnExposeEvent (Gdk.EventExpose evnt) { if (isActive || hilight) { double x = Allocation.Left, y = Allocation.Top; int w = Allocation.Width, h = Allocation.Height; using (Cairo.Context ctx = Gdk.CairoHelper.Create (GdkWindow)) { HslColor c1 = new HslColor (Style.Background (Gtk.StateType.Normal)); HslColor c2 = c1; if (isActive) c2.L *= 0.8; else c2.L *= 0.9; Cairo.Gradient pat; pat = new Cairo.LinearGradient (x, y, x+w-2, y); pat.AddColorStop (0, c2); pat.AddColorStop (1, c1); ctx.Pattern = pat; ctx.NewPath (); ctx.Rectangle (x, y, w, h); ctx.Fill (); } } // Gtk.Style.PaintBox (Style, GdkWindow, StateType.Normal, ShadowType.Out, evnt.Area, this, isWindows? "button" : "", // Allocation.Left, Allocation.Top, Allocation.Width, Allocation.Height); bool res = base.OnExposeEvent (evnt); 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 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); }
public static string ColorToMarkup (HslColor color) { return color.ToMarkup (); }
internal static Cairo.Color ReduceLight (Cairo.Color color, double factor) { var c = new HslColor (color); c.L *= factor; return c; }
internal static HslColor AlphaBlend (HslColor fore, HslColor back, double alpha) { var fc = (Cairo.Color)fore; var bc = (Cairo.Color)back; return new HslColor ( (1.0 - alpha) * bc.R + alpha * fc.R, (1.0 - alpha) * bc.G + alpha * fc.G, (1.0 - alpha) * bc.B + alpha * fc.B); }
/// <summary> /// Makes a color lighter or darker /// </summary> /// <param name='lightAmount'> /// Amount of lightness to add. If the value is positive, the color will be lighter, /// if negative it will be darker. Value must be between 0 and 1. /// </param> public static HslColor AddLight(this HslColor color, double lightAmount) { color.L += lightAmount; return(color); }