public void RefreshColors() { if (refreshing) { return; } refreshing = true; int mc = (int)GtkColorClass.Foreground; int ms = (int)StateType.Insensitive; if (gtk_colors == null) { gtk_colors = new Cairo.Color [(mc + 1) * (ms + 1)]; } for (int c = (int)GtkColorClass.Light; c <= mc; c++) { for (int s = (int)StateType.Normal; s <= ms; s++) { Gdk.Color color = Gdk.Color.Zero; if (widget != null && widget.IsRealized) { switch ((GtkColorClass)c) { case GtkColorClass.Light: color = widget.Style.LightColors [s]; break; case GtkColorClass.Mid: color = widget.Style.MidColors [s]; break; case GtkColorClass.Dark: color = widget.Style.DarkColors [s]; break; case GtkColorClass.Base: color = widget.Style.BaseColors [s]; break; case GtkColorClass.Background: color = widget.Style.Backgrounds [s]; break; case GtkColorClass.Foreground: color = widget.Style.Foregrounds [s]; break; } } else { color = new Gdk.Color(0, 0, 0); } gtk_colors [c * mc + s] = color.ToCairoColor(); } } selection_fill = GetWidgetColor(GtkColorClass.Dark, StateType.Active); selection_stroke = GetWidgetColor(GtkColorClass.Background, StateType.Selected); view_fill = GetWidgetColor(GtkColorClass.Base, StateType.Normal); view_fill_transparent = view_fill; view_fill_transparent.A = 0; border_color = GetWidgetColor(GtkColorClass.Dark, StateType.Active); refreshing = false; }
public static Color ToCairoColor(this Gdk.Color color, double alpha = 1.0) { return(new Color( (color.Red >> 8) / 255.0, (color.Green >> 8) / 255.0, (color.Blue >> 8) / 255.0, alpha)); }
public static Color FromString(string color_str) { Gdk.Color gdk_color = new Gdk.Color (0, 0, 0); bool success = Gdk.Color.Parse (color_str, ref gdk_color); if (!success) throw new ApplicationException ("color_str"); return FromGdkColor (gdk_color); }