public override void AddColorStop(object backend, double position, Xwt.Drawing.Color color) { GradientInfo gr = (GradientInfo)backend; gr.Colors.Add(color.ToCGColor()); gr.Stops.Add((float)position); }
public static void LoadStyles() { if (IdeApp.Preferences.UserInterfaceTheme == Theme.Light) { CellBackgroundColor = Ide.Gui.Styles.PadBackground; } else { CellBackgroundColor = Xwt.Drawing.Color.FromName("#3c3c3c"); } // Shared BackgroundColor = Ide.Gui.Styles.PrimaryBackgroundColor; CellTextColor = Ide.Gui.Styles.BaseForegroundColor; CellStrongSelectionColor = Ide.Gui.Styles.BaseSelectionBackgroundColor; CellSelectionColor = Ide.Gui.Styles.BaseSelectionBackgroundColor; CellTextSelectionColor = Ide.Gui.Styles.BaseSelectionTextColor; PackageInfoBackgroundColor = Ide.Gui.Styles.SecondaryBackgroundLighterColor; PackageSourceErrorTextColor = Ide.Gui.Styles.ErrorForegroundColor; PackageSourceUrlTextColor = Ide.Gui.Styles.DimTextColor; PackageSourceErrorSelectedTextColor = PackageSourceErrorTextColor; // Blue selection text color only on Mac PackageSourceUrlSelectedTextColor = Platform.IsMac ? Xwt.Drawing.Color.FromName("#ffffff") : Ide.Gui.Styles.DimTextColor; LineBorderColor = Ide.Gui.Styles.SeparatorColor; ErrorBackgroundColor = Ide.Gui.Styles.StatusWarningBackgroundColor; ErrorForegroundColor = Ide.Gui.Styles.StatusWarningTextColor; }
protected override void OnSetBackgroundColor(Xwt.Drawing.Color color) { base.OnSetBackgroundColor(color); Widget.SetBackgroundColor(color); Widget.SetChildBackgroundColor(color); EventsRootWidget.SetBackgroundColor(color); }
public static void SetChildBackgroundColor(this Gtk.Container container, Xwt.Drawing.Color color) { foreach (var widget in container.Children) { widget.SetBackgroundColor(Gtk.StateFlags.Normal, color); } }
public static void InvertColorOfPixel(this BitmapImage img, int x, int y) { var color = img.GetPixel(x, y); var invertedColor = Color.FromBytes((byte)(255 * (1.0 - color.Red)), (byte)(255 * (1.0 - color.Green)), (byte)(255 * (1.0 - color.Blue))); img.SetPixel(x, y, invertedColor); }
static void RenderPlaceholderText_internal(Gtk.Widget widget, Gtk.ExposeEventArgs args, string placeHolderText, ref Pango.Layout layout, float xalign, float yalign, int xpad, int ypad) { 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); int x = xpad + (int)((ww - width) * xalign); int y = ypad + (int)((wh - height) * yalign); using (var gc = new Gdk.GC(args.Event.Window)) { gc.Copy(widget.Style.TextGC(Gtk.StateType.Normal)); Xwt.Drawing.Color color_a = widget.Style.Base(Gtk.StateType.Normal).ToXwtValue(); Xwt.Drawing.Color color_b = widget.Style.Text(Gtk.StateType.Normal).ToXwtValue(); gc.RgbFgColor = color_b.BlendWith(color_a, 0.5).ToGtkValue(); args.Event.Window.DrawLayout(gc, x, y, layout); } }
public static void SetChildBackgroundColor(this Gtk.Container container, Xwt.Drawing.Color color) { foreach (var widget in container.Children) { widget.ModifyBg(Gtk.StateType.Normal, color.ToGtkValue()); } }
public static void LoadStyles () { if (IdeApp.Preferences.UserInterfaceSkin == Skin.Light) { CellBackgroundColor = Ide.Gui.Styles.PadBackground; } else { CellBackgroundColor = Xwt.Drawing.Color.FromName ("#3c3c3c"); } // Shared BackgroundColor = Ide.Gui.Styles.PrimaryBackgroundColor; CellTextColor = Ide.Gui.Styles.BaseForegroundColor; CellStrongSelectionColor = Ide.Gui.Styles.BaseSelectionBackgroundColor; CellSelectionColor = Ide.Gui.Styles.BaseSelectionBackgroundColor; CellTextSelectionColor = Ide.Gui.Styles.BaseSelectionTextColor; PackageSourceUrlSelectedTextColor = PackageSourceUrlTextColor; PackageSourceErrorSelectedTextColor = PackageSourceErrorTextColor; PackageInfoBackgroundColor = Ide.Gui.Styles.SecondaryBackgroundLighterColor; PackageSourceErrorTextColor = Ide.Gui.Styles.ErrorForegroundColor; PackageSourceUrlTextColor = Ide.Gui.Styles.DimTextColor; LineBorderColor = Ide.Gui.Styles.SeparatorColor; ErrorBackgroundColor = Ide.Gui.Styles.StatusWarningBackgroundColor; ErrorForegroundColor = Ide.Gui.Styles.StatusWarningTextColor; }
protected override void OnSetBackgroundColor(Xwt.Drawing.Color color) { if (EventsRootWidget != null) { EventsRootWidget.SetBackgroundColor(color); } base.OnSetBackgroundColor(color); }
protected override void OnSetBackgroundColor(Xwt.Drawing.Color color) { // Gtk3 workaround (by rpc-scandinavia, see https://github.com/mono/xwt/pull/411) var selectedColor = Widget.GetBackgroundColor(StateType.Selected); Widget.SetBackgroundColor(StateType.Normal, Xwt.Drawing.Colors.Transparent); Widget.SetBackgroundColor(StateType.Selected, selectedColor); base.OnSetBackgroundColor(color); }
public static Xwt.Drawing.Color SystemColorToXwtColor(System.Drawing.Color theColor) { double a = Convert.ToDouble(theColor.A); double b = Convert.ToDouble(theColor.B); double g = Convert.ToDouble(theColor.G); double r = Convert.ToDouble(theColor.R); Xwt.Drawing.Color ec = new Xwt.Drawing.Color(r, g, b, a); return ec; }
public static Xwt.Drawing.Color SystemColorToXwtColor(System.Drawing.Color theColor) { double a = Convert.ToDouble(theColor.A); double b = Convert.ToDouble(theColor.B); double g = Convert.ToDouble(theColor.G); double r = Convert.ToDouble(theColor.R); Xwt.Drawing.Color ec = new Xwt.Drawing.Color(r, g, b, a); return(ec); }
protected virtual void SetWidgetColor(Color value) { if ((Widget is Control)) { ((Control)Widget).Background = ResPool.GetSolidBrush(value); } if ((Widget is System.Windows.Controls.Panel)) { ((SWC.Panel)Widget).Background = ResPool.GetSolidBrush(value); } }
private void ProcessPage(Xwt.Drawing.Context g, IEnumerable p) { foreach (PageItem pi in p) { if (pi is PageTextHtml) { // PageTextHtml is actually a composite object (just like a page) ProcessHtml(pi as PageTextHtml, g); continue; } if (pi is PageLine) { PageLine pl = pi as PageLine; Xwt.Drawing.Color bcolorleft = XwtColor.SystemColorToXwtColor(pl.SI.BColorLeft); DrawLine(bcolorleft, pl.SI.BStyleLeft, pl.SI.BWidthLeft, g, PixelsX(pl.X), PixelsY(pl.Y), PixelsX(pl.X2), PixelsY(pl.Y2) ); continue; } Xwt.Rectangle rect = new Xwt.Rectangle(PixelsX(pi.X), PixelsY(pi.Y), PixelsX(pi.W), PixelsY(pi.H)); if (pi.SI.BackgroundImage != null) { // put out any background image PageImage i = pi.SI.BackgroundImage; DrawImage(i, g, rect); continue; } if (pi is PageText) { PageText pt = pi as PageText; DrawString(pt, g, rect); } if (pi is PageImage) { PageImage i = pi as PageImage; DrawImage(i, g, rect); } if (pi is PageRectangle) { //DrawBackground(g, rect, pi.SI); } DrawBorder(pi, g, rect); } }
public override void SetPixel(object handle, int x, int y, Xwt.Drawing.Color color) { var pix = (Gdk.Pixbuf)handle; unsafe { byte *p = (byte *)pix.Pixels; p += y * pix.Rowstride + x * pix.NChannels; p[0] = (byte)(color.Red * 255); p[1] = (byte)(color.Green * 255); p[2] = (byte)(color.Blue * 255); p[3] = (byte)(color.Alpha * 255); } }
void IRenderOwner.render(IRenderFrame destination, long time, Rectangle r) { // var state = this.Renderer.StartRender(destination, r); var c = (test++ % 25) / 25f; var cc = new Xwt.Drawing.Color(c, c, c, 255); GL.ClearColor((float)cc.Red, (float)cc.Green, (float)cc.Blue, (float)cc.Alpha); GL.Clear(ClearBufferMask.ColorBufferBit /*ClearBufferMask.DepthBufferBit | ClearBufferMask.StencilBufferBit*/); // We're not using stencil buffer so why bother with clearing? this.vertices.Apply(this.shader); GL.DrawArrays(BeginMode.Triangles, 0, 3); // Starting from vertex 0; 3 vertices total -> 1 triangle GL.DisableVertexAttribArray(0); // this.Renderer.EndRender(state); this.Renderer.Present(destination, r, IntPtr.Zero); }
private void DrawLine(Xwt.Drawing.Color c, BorderStyleEnum bs, float w, Xwt.Drawing.Context g, double x, double y, double x2, double y2) { if (bs == BorderStyleEnum.None || //|| c.IsEmpty w <= 0) // nothing to draw { return; } g.Save(); // Pen p = null; // p = new Pen(c, w); g.SetColor(c); g.SetLineWidth(w); switch (bs) { case BorderStyleEnum.Dashed: // p.DashStyle = DashStyle.Dash; g.SetLineDash(0.0, new double[] { 2, 1 }); break; case BorderStyleEnum.Dotted: // p.DashStyle = DashStyle.Dot; g.SetLineDash(0.0, new double[] { 1 }); break; case BorderStyleEnum.Double: case BorderStyleEnum.Groove: case BorderStyleEnum.Inset: case BorderStyleEnum.Solid: case BorderStyleEnum.Outset: case BorderStyleEnum.Ridge: case BorderStyleEnum.WindowInset: default: g.SetLineDash(0.0, new double[] { }); break; } g.MoveTo(x, y); g.LineTo(x2, y2); g.Stroke(); g.Restore(); }
private void DrawBorder(PageItem pi, Xwt.Drawing.Context g, Xwt.Rectangle r) { if (r.Height <= 0 || r.Width <= 0) // no bounding box to use { return; } double right = r.X + r.Width; double bottom = r.Y + r.Height; StyleInfo si = pi.SI; Xwt.Drawing.Color ec = XwtColor.SystemColorToXwtColor(si.BackgroundGradientEndColor); DrawLine(XwtColor.SystemColorToXwtColor(si.BColorTop), si.BStyleTop, si.BWidthTop, g, r.X, r.Y, right, r.Y); DrawLine(XwtColor.SystemColorToXwtColor(si.BColorRight), si.BStyleRight, si.BWidthRight, g, right, r.Y, right, bottom); DrawLine(XwtColor.SystemColorToXwtColor(si.BColorLeft), si.BStyleLeft, si.BWidthLeft, g, r.X, r.Y, r.X, bottom); DrawLine(XwtColor.SystemColorToXwtColor(si.BColorBottom), si.BStyleBottom, si.BWidthBottom, g, r.X, bottom, right, bottom); }
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()); int nc = c.Name.GetHashCode(); if (nc < 0) { nc = -nc; } Xwt.Drawing.Color col = Xwt.Drawing.Color.FromHsl(r.NextDouble(), r.NextDouble(), 0.3 + (r.NextDouble() * 0.3)); Gdk.Color gc = col.ToGdkColor(); colors [c] = gc; return(gc); }
public static void SetBackgroundColor(this Gtk.Widget widget, Gtk.StateType state, Xwt.Drawing.Color color) { widget.SetBackgroundColor(state.ToGtk3StateFlags(), color); }
public void Initialize(IPopoverEventSink sink) { this.sink = sink; this.BackgroundColor = Xwt.Drawing.Color.FromBytes(0xee, 0xee, 0xee, 0xf9); this.popover = new PopoverWindow(); }
public static SolidColorBrush GetSolidBrush(Xwt.Drawing.Color color) { return(GetSolidBrush(DataConverter.ToWpfColor(color))); }
private void DrawBackground(Xwt.Drawing.Context g, Xwt.Rectangle rect, StyleInfo si) { // LinearGradientBrush linGrBrush = null; // SolidBrush sb = null; if (si.BackgroundColor.IsEmpty) { return; } g.Save(); Xwt.Drawing.Color c = XwtColor.SystemColorToXwtColor(si.BackgroundColor); Xwt.Drawing.Gradient gradient = null; if (si.BackgroundGradientType != BackgroundGradientTypeEnum.None && !si.BackgroundGradientEndColor.IsEmpty) { Xwt.Drawing.Color ec = XwtColor.SystemColorToXwtColor(si.BackgroundGradientEndColor); switch (si.BackgroundGradientType) { case BackgroundGradientTypeEnum.LeftRight: // linGrBrush = new LinearGradientBrush(rect, c, ec, LinearGradientMode.Horizontal); gradient = new Xwt.Drawing.LinearGradient(rect.X, rect.Y, rect.X + rect.Width, rect.Y); break; case BackgroundGradientTypeEnum.TopBottom: // linGrBrush = new LinearGradientBrush(rect, c, ec, LinearGradientMode.Vertical); gradient = new Xwt.Drawing.LinearGradient(rect.X, rect.Y, rect.X, rect.Y + rect.Height); break; case BackgroundGradientTypeEnum.Center: // linGrBrush = new LinearGradientBrush(rect, c, ec, LinearGradientMode.Horizontal); throw new NotSupportedException(); // break; case BackgroundGradientTypeEnum.DiagonalLeft: // linGrBrush = new LinearGradientBrush(rect, c, ec, LinearGradientMode.ForwardDiagonal); gradient = new Xwt.Drawing.LinearGradient(rect.X, rect.Y, rect.X + rect.Width, rect.Y + rect.Height); break; case BackgroundGradientTypeEnum.DiagonalRight: // linGrBrush = new LinearGradientBrush(rect, c, ec, LinearGradientMode.BackwardDiagonal); gradient = new Xwt.Drawing.LinearGradient(rect.X + rect.Width, rect.Y + rect.Height, rect.X, rect.Y); break; case BackgroundGradientTypeEnum.HorizontalCenter: // linGrBrush = new LinearGradientBrush(rect, c, ec, LinearGradientMode.Horizontal); throw new NotSupportedException(); // break; case BackgroundGradientTypeEnum.VerticalCenter: // linGrBrush = new LinearGradientBrush(rect, c, ec, LinearGradientMode.Vertical); throw new NotSupportedException(); // break; default: break; } gradient.AddColorStop(0, c); gradient.AddColorStop(1, ec); } if (gradient != null) { // TODO: Fix //g.FillRectangle(rect, gradient); } else if (!si.BackgroundColor.IsEmpty) { // TODO: Fix //g.FillRectangle(rect, c); } g.Restore(); }
private void DrawString(PageText pt, Xwt.Drawing.Context g, Xwt.Rectangle r) { StyleInfo si = pt.SI; string s = pt.Text; g.Save(); layout = new Xwt.Drawing.TextLayout(g); layout.Font = g.Font; float fontsize = (si.FontSize * 72 / 96); layout.Font.WithFamily(si.GetFontFamily().Name); layout.Font.WithPixelSize(fontsize * PixelsX(1)); if (si.FontStyle == FontStyleEnum.Italic) { layout.Font.WithStyle(Xwt.Drawing.FontStyle.Italic); } switch (si.FontWeight) { case FontWeightEnum.Bold: case FontWeightEnum.Bolder: case FontWeightEnum.W500: case FontWeightEnum.W600: case FontWeightEnum.W700: case FontWeightEnum.W800: case FontWeightEnum.W900: layout.Font.WithWeight(Xwt.Drawing.FontWeight.Bold); break; } // TODO: Fix Alignment //switch (si.TextAlign) //{ // case TextAlignEnum.Right: // layout.Alignment = Pango.Alignment.Right; // break; // case TextAlignEnum.Center: // layout.Alignment = Pango.Alignment.Center; // break; // case TextAlignEnum.Left: // default: // layout.Alignment = Pango.Alignment.Left; // break; //} // TODO: Fix with //layout.Width = Pango.Units.FromPixels((int)(r.Width - si.PaddingLeft - si.PaddingRight - 2)); layout.Text = s; //Xwt.Rectangle logical; // Xwt.Rectangle ink; // TODO: Fix //layout.GetExtents(out ink, out logical); double height = 12; // logical.Height / Pango.Scale.PangoScale; double y = 0; switch (si.VerticalAlign) { case VerticalAlignEnum.Top: y = r.Y + si.PaddingTop; break; case VerticalAlignEnum.Middle: y = r.Y + (r.Height - height) / 2; break; case VerticalAlignEnum.Bottom: y = r.Y + (r.Height - height) - si.PaddingBottom; break; } // draw the background DrawBackground(g, r, si); Xwt.Rectangle box = new Xwt.Rectangle( r.X + si.PaddingLeft + 1, y, r.Width, r.Height); Xwt.Drawing.Color sicolor = XwtColor.SystemColorToXwtColor(si.Color); g.SetColor(sicolor); g.MoveTo(box.X, box.Y); g.DrawTextLayout(layout, box.X, box.Y); g.Restore(); }
protected override void OnSetBackgroundColor(Xwt.Drawing.Color color) { Widget.SetBackgroundColor(color); Widget.SetChildBackgroundColor(color); }
/// <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 Xwt.Drawing.Color AddLight(this Xwt.Drawing.Color color, double lightAmount) { color.Light += lightAmount; return(color); }
public override void AddColorStop(object backend, double position, Xwt.Drawing.Color color) { }
public static void SetBackgroundColor(this Gtk.Widget widget, Xwt.Drawing.Color color) { widget.SetBackgroundColor(Gtk.StateFlags.Normal, color); }
public void AddColorStop(object backend, double position, Color color) { ((GradientBase)backend).ColorStops.Add (new Tuple<double, Color> (position, color)); }
void SetWidgetColor(Color value) { if ((Widget is Control)) ((Control)Widget).Background = ResPool.GetSolidBrush (value); if ((Widget is System.Windows.Controls.Panel)) ((SWC.Panel)Widget).Background = ResPool.GetSolidBrush (value); }
public override void AddColorStop(object backend, double position, Color color) { ((GradientBrush)backend).GradientStops.Add (new GradientStop (color.ToWpfColor (), position)); }
public static void SetBackgroundColor(this Gtk.Widget widget, Gtk.StateFlags state, Xwt.Drawing.Color color) { widget.OverrideBackgroundColor(state, color.ToGtkRgbaValue()); }
public static Gdk.Color ToGdkColor(this Xwt.Drawing.Color color) { return(new Gdk.Color((byte)(color.Red * 255d), (byte)(color.Green * 255d), (byte)(color.Blue * 255d))); }
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); } }
public void Initialize (IPopoverEventSink sink) { this.sink = sink; this.BackgroundColor = Xwt.Drawing.Color.FromBytes (0xee, 0xee, 0xee, 0xf9); this.popover = new PopoverWindow (); }
public static Cairo.Color ToCairoColor(this Xwt.Drawing.Color color) { return(new Cairo.Color(color.Red, color.Green, color.Blue, color.Alpha)); }