static void draw (Cairo.Context gr, int width, int height) { gr.Scale (width, height); gr.LineWidth = 0.04; gr.MoveTo ( new PointD (0.5, 0.1) ); gr.LineTo ( new PointD (0.9, 0.9) ); gr.RelLineTo ( new Distance (-0.4, 0.0) ); gr.CurveTo ( new PointD (0.2, 0.9), new PointD ( 0.2, 0.5), new PointD (0.5, 0.5) ); gr.ClosePath (); gr.MoveTo ( new PointD (0.25, 0.1) ); gr.RelLineTo ( new Distance (0.2, 0.2) ); gr.RelLineTo ( new Distance ( -0.2, 0.2) ); gr.RelLineTo ( new Distance (-0.2, -0.2) ); gr.ClosePath (); gr.Color = new Color (0, 0, 1, 1); gr.FillPreserve (); gr.Color = new Color ( 0, 0, 0, 1); gr.Stroke (); }
public static void DrawRoundRectangle (Cairo.Context cr, double x, double y, double r, double w, double h) { const double ARC_TO_BEZIER = 0.55228475; double radius_x = r; double radius_y = r / 4; if (radius_x > w - radius_x) radius_x = w / 2; if (radius_y > h - radius_y) radius_y = h / 2; double c1 = ARC_TO_BEZIER * radius_x; double c2 = ARC_TO_BEZIER * radius_y; cr.NewPath (); cr.MoveTo (x + radius_x, y); cr.RelLineTo (w - 2 * radius_x, 0.0); cr.RelCurveTo (c1, 0.0, radius_x, c2, radius_x, radius_y); cr.RelLineTo (0, h - 2 * radius_y); cr.RelCurveTo (0.0, c2, c1 - radius_x, radius_y, -radius_x, radius_y); cr.RelLineTo (-w + 2 * radius_x, 0); cr.RelCurveTo (-c1, 0, -radius_x, -c2, -radius_x, -radius_y); cr.RelLineTo (0, -h + 2 * radius_y); cr.RelCurveTo (0.0, -c2, radius_x - c1, -radius_y, radius_x, -radius_y); cr.ClosePath (); }
public void Draw (Cairo.Context cr, Cairo.Rectangle rectangle) { if (IsSeparator) { cr.NewPath (); double x = Math.Ceiling (rectangle.X + rectangle.Width / 2) + 0.5; cr.MoveTo (x, rectangle.Y + 0.5 + 2); cr.RelLineTo (0, rectangle.Height - 1 - 4); cr.ClosePath (); cr.Color = (HslColor)parent.Style.Dark (StateType.Normal); cr.LineWidth = 1; cr.Stroke (); return; } if (Active || HoverPosition.X >= 0) { if (Active) { cr.Rectangle (rectangle.X, rectangle.Y, rectangle.Width, rectangle.Height); using (var gr = new LinearGradient (rectangle.X, rectangle.Y, rectangle.X, rectangle.Y + rectangle.Height)) { gr.AddColorStop (0, Tabstrip.ActiveGradientStart); gr.AddColorStop (1, Tabstrip.ActiveGradientEnd); cr.Pattern = gr; } cr.Fill (); cr.Rectangle (rectangle.X + 0.5, rectangle.Y + 0.5, rectangle.Width - 1, rectangle.Height - 1); cr.Color = new Cairo.Color (1, 1, 1, 0.05); cr.LineWidth = 1; cr.Stroke (); } else if (HoverPosition.X >= 0) { cr.Rectangle (rectangle.X, rectangle.Y, rectangle.Width, rectangle.Height); using (var gr = new LinearGradient (rectangle.X, rectangle.Y, rectangle.X, rectangle.Y + rectangle.Height)) { var c1 = Tabstrip.ActiveGradientStart; var c2 = Tabstrip.ActiveGradientEnd; c1.A = 0.2; c2.A = 0.2; gr.AddColorStop (0, c1); gr.AddColorStop (1, c2); cr.Pattern = gr; } cr.Fill (); } } if (Active) cr.Color = new Cairo.Color (1, 1, 1); else cr.Color = parent.Style.Text (StateType.Normal).ToCairoColor (); cr.MoveTo (rectangle.X + (rectangle.Width - w) / 2, (rectangle.Height - h) / 2); Pango.CairoHelper.ShowLayout (cr, layout); }
void DrawErrorMarkers (TextEditor editor, Cairo.Context g, TextViewMargin.LayoutWrapper layout2, double x, double y) { uint curIndex = 0, byteIndex = 0; foreach (var task in errors.Select (t => t.Task)) { int index = (int)layout2.TranslateToUTF8Index ((uint)(task.Column - 1), ref curIndex, ref byteIndex); var pos = layout2.Layout.IndexToPos (index); g.Color = MarkerColor.Color; g.MoveTo ( x + editor.TextViewMargin.TextStartPosition + pos.X / Pango.Scale.PangoScale, y + editor.LineHeight - 4 ); g.RelLineTo (3, 3); g.RelLineTo (-6, 0); g.ClosePath (); g.Fill (); } }
void DrawErrorMarkers (MonoTextEditor editor, Cairo.Context g, LineMetrics metrics, double y) { uint curIndex = 0, byteIndex = 0; var o = metrics.LineSegment.Offset; foreach (var task in errors.Select (t => t.Task)) { var column = (uint)(Math.Min (Math.Max (0, task.Column - 1), metrics.Layout.LineChars.Length)); var line = editor.GetLine (task.Line); // skip possible white space locations while (column < line.Length && char.IsWhiteSpace (editor.GetCharAt (line.Offset + (int)column))) { column++; } if (column >= line.Length) continue; int index = (int)metrics.Layout.TranslateToUTF8Index (column, ref curIndex, ref byteIndex); var pos = metrics.Layout.Layout.IndexToPos (index); var co = o + task.Column - 1; g.SetSourceColor (GetMarkerColor (false, metrics.SelectionStart <= co && co < metrics.SelectionEnd)); g.MoveTo ( metrics.TextRenderStartPosition + editor.TextViewMargin.TextStartPosition + pos.X / Pango.Scale.PangoScale, y + editor.LineHeight - 3 ); g.RelLineTo (3, 3); g.RelLineTo (-6, 0); g.ClosePath (); g.Fill (); } }
void DrawMarkedPositions(Cairo.Context cr) { if (MarkedPositionsToDisplay) { SetColor (cr, ref ColorMarkedPos); if (markedPositions.Length == PosSize) { // all positions are marked Rectangle (cr, ref totalRect); cr.Fill (); } else { foreach (int i in markedPositions) { cr.MoveTo (WorldToPhysicalX (i), 0); cr.RelLineTo (0, height); } // single call is much faster cr.Stroke (); } } }
protected virtual void DrawHoverBackground(Cairo.Context ctx) { if (BorderPadding <= 0) { ctx.Rectangle (Allocation.X, Allocation.Y, Allocation.Width, Allocation.Height); ctx.SetSourceColor (CairoExtensions.ParseColor (HoverBackgroundColor)); ctx.Fill (); ctx.MoveTo (Allocation.X, Allocation.Y + 0.5); ctx.RelLineTo (Allocation.Width, 0); ctx.MoveTo (Allocation.X, Allocation.Y + Allocation.Height - 0.5); ctx.RelLineTo (Allocation.Width, 0); if (DrawRightBorder) { ctx.MoveTo (Allocation.Right + 0.5, Allocation.Y + 0.5); ctx.LineTo (Allocation.Right + 0.5, Allocation.Bottom - 0.5); } if (DrawLeftBorder) { ctx.MoveTo (Allocation.Left + 0.5, Allocation.Y + 0.5); ctx.LineTo (Allocation.Left + 0.5, Allocation.Bottom - 0.5); } ctx.LineWidth = 1; ctx.SetSourceColor (CairoExtensions.ParseColor (HoverBorderColor)); ctx.Stroke (); } else { Gdk.Rectangle region = Allocation; region.Inflate (-BorderPadding, -BorderPadding); ctx.RoundedRectangle (region.X + 0.5, region.Y + 0.5, region.Width - 1, region.Height - 1, 3); ctx.SetSourceColor (CairoExtensions.ParseColor (HoverBackgroundColor)); ctx.FillPreserve (); ctx.LineWidth = 1; ctx.SetSourceColor (CairoExtensions.ParseColor (HoverBorderColor)); ctx.Stroke (); } }
void DrawErrorMarkers (TextEditor editor, Cairo.Context g, LineMetrics metrics, double y) { uint curIndex = 0, byteIndex = 0; var o = metrics.LineSegment.Offset; foreach (var task in errors.Select (t => t.Task)) { var column = (uint)(Math.Min (Math.Max (0, task.Column - 1), metrics.Layout.LineChars.Length)); int index = (int)metrics.Layout.TranslateToUTF8Index (column, ref curIndex, ref byteIndex); var pos = metrics.Layout.Layout.IndexToPos (index); var co = o + task.Column - 1; g.SetSourceColor (GetMarkerColor (false, metrics.SelectionStart <= co && co < metrics.SelectionEnd)); g.MoveTo ( metrics.TextRenderStartPosition + editor.TextViewMargin.TextStartPosition + pos.X / Pango.Scale.PangoScale, y + editor.LineHeight - 3 ); g.RelLineTo (3, 3); g.RelLineTo (-6, 0); g.ClosePath (); g.Fill (); } }
public override void Draw (MonoTextEditor editor, Cairo.Context cr, LineMetrics layout, int startOffset, int endOffset) { if (DebuggingService.IsDebugging) return; int markerStart = Segment.Offset; int markerEnd = Segment.EndOffset; if (markerEnd < startOffset || markerStart > endOffset) return; double drawFrom; double drawTo; double y = layout.LineYRenderStartPosition; double startXPos = layout.TextRenderStartPosition; double endXPos = layout.TextRenderEndPosition; if (markerStart < startOffset && endOffset < markerEnd) { drawTo = endXPos; var line = editor.GetLineByOffset (startOffset); int offset = line.GetIndentation (editor.Document).Length; drawFrom = startXPos + (layout.Layout.Layout.IndexToPos (offset).X / Pango.Scale.PangoScale); } else { int start; if (startOffset < markerStart) { start = markerStart; } else { var line = editor.GetLineByOffset (startOffset); int offset = line.GetIndentation (editor.Document).Length; start = startOffset + offset; } int end = endOffset < markerEnd ? endOffset : markerEnd; int x_pos; x_pos = layout.Layout.Layout.IndexToPos (start - startOffset).X; drawFrom = startXPos + (int)(x_pos / Pango.Scale.PangoScale); x_pos = layout.Layout.Layout.IndexToPos (end - startOffset).X; drawTo = startXPos + (int)(x_pos / Pango.Scale.PangoScale); } drawFrom = Math.Max (drawFrom, editor.TextViewMargin.XOffset); drawTo = Math.Max (drawTo, editor.TextViewMargin.XOffset); if (drawFrom >= drawTo) return; double height = editor.LineHeight / 5; cr.SetSourceColor (color); if (effect == MonoDevelop.Ide.Editor.TextSegmentMarkerEffect.WavedLine) { Pango.CairoHelper.ShowErrorUnderline (cr, drawFrom, y + editor.LineHeight - height, drawTo - drawFrom, height); } else if (effect == MonoDevelop.Ide.Editor.TextSegmentMarkerEffect.DottedLine) { cr.Save (); cr.LineWidth = 1; cr.MoveTo (drawFrom + 1, y + editor.LineHeight - 1 + 0.5); cr.RelLineTo (Math.Min (drawTo - drawFrom, 4 * 3), 0); cr.SetDash (new double[] { 2, 2 }, 0); cr.Stroke (); cr.Restore (); } else { cr.MoveTo (drawFrom, y + editor.LineHeight - 1); cr.LineTo (drawTo, y + editor.LineHeight - 1); cr.Stroke (); } }
void DrawButtonTabs (Cairo.Context cr, Cairo.Rectangle rectangle) { if (IsSeparator) { cr.NewPath (); double x = Math.Ceiling (rectangle.X + rectangle.Width / 2) + 0.5; cr.MoveTo (x, rectangle.Y + 0.5 + 2); cr.RelLineTo (0, rectangle.Height - 1 - 4); cr.ClosePath (); cr.Color = (HslColor)parent.Style.Dark (StateType.Normal); cr.LineWidth = 1; cr.Stroke (); return; } int topPadding = 2; if (Active || HoverPosition.X >= 0) { cr.Rectangle (rectangle.X + 1, rectangle.Y + 1 + topPadding, rectangle.Width - 1, rectangle.Height - topPadding); if (Active) { cr.Color = (HslColor)parent.Style.Background (StateType.Prelight); } else if (HoverPosition.X >= 0) { double rx = rectangle.X + HoverPosition.X; double ry = rectangle.Y + HoverPosition.Y; Cairo.RadialGradient gradient = new Cairo.RadialGradient (rx, ry, rectangle.Height * 1.5, rx, ry, 2); var color = (HslColor)parent.Style.Dark (StateType.Normal); color.L *= 1.1; gradient.AddColorStop (0, color); color.L *= 1.1; gradient.AddColorStop (1, color); cr.Pattern = gradient; } cr.Fill (); if (Active) { cr.Rectangle (rectangle.X + 0.5, rectangle.Y + 0.5 + topPadding, rectangle.Width - 1, rectangle.Height - topPadding); cr.Color = (HslColor)parent.Style.Dark (StateType.Normal); cr.LineWidth = 1; cr.Stroke (); } } cr.Save (); cr.Translate (rectangle.X + (rectangle.Width - w) / 2, (rectangle.Height - h) / 2 + topPadding); cr.Color = (HslColor)parent.Style.Text (StateType.Normal); cr.ShowLayout (layout); cr.Restore (); }
public void Draw (Cairo.Context cr, Cairo.Rectangle rectangle) { if (IsSeparator) { cr.NewPath (); double x = Math.Ceiling (rectangle.X + rectangle.Width / 2) + 0.5; cr.MoveTo (x, rectangle.Y + 0.5 + 2); cr.RelLineTo (0, rectangle.Height - 1 - 4); cr.ClosePath (); cr.SetSourceColor (Styles.SubTabBarSeparatorColor.ToCairoColor ()); cr.LineWidth = 1; cr.Stroke (); return; } if (Active || HoverPosition.X >= 0) { if (Active) { cr.Rectangle (rectangle.X, rectangle.Y, rectangle.Width, rectangle.Height); cr.SetSourceColor (Styles.SubTabBarActiveBackgroundColor.ToCairoColor ()); cr.Fill (); } else if (HoverPosition.X >= 0) { cr.Rectangle (rectangle.X, rectangle.Y, rectangle.Width, rectangle.Height); cr.SetSourceColor (Styles.SubTabBarHoverBackgroundColor.ToCairoColor ()); cr.Fill (); } } if (Active) { cr.SetSourceColor (Styles.SubTabBarActiveTextColor.ToCairoColor ()); layout.FontDescription = FontService.SansFont.CopyModified (Styles.FontScale11, Pango.Weight.Bold); } else { cr.SetSourceColor (Styles.SubTabBarTextColor.ToCairoColor ()); layout.FontDescription = FontService.SansFont.CopyModified (Styles.FontScale11); } layout.Width = (int)rectangle.Width; cr.MoveTo (rectangle.X + (int)(rectangle.Width / 2), (rectangle.Height - h) / 2 - 1); Pango.CairoHelper.ShowLayout (cr, layout); }
public new void Draw (Cairo.Context cr) { Gdk.Rectangle rect; if (GradientBackround) { rect = new Gdk.Rectangle (Allocation.X, Allocation.Y, Allocation.Width, Allocation.Height); HslColor gcol = useCustomColor ? customColor : Parent.Style.Background (Gtk.StateType.Normal); 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.Y + rect.Height - 1)) { 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 (); } } base.Draw (cr); //FIXME: Get this drawing properly again! // Gdk.Color colour = Parent.Style.Dark (Gtk.StateType.Normal); // cr.SetSourceRGB (colour.Red, colour.Green, colour.Blue); // // rect = Allocation; // for (int n=0; n<topMargin; n++) // GdkWindow.DrawLine (borderColor, rect.X, rect.Y + n, rect.Left + rect.Width - 1, rect.Y + n); // // for (int n=0; n<bottomMargin; n++) // GdkWindow.DrawLine (borderColor, rect.X, rect.Top + rect.Height - 1 - n, rect.Left + rect.Width - 1, rect.Top + rect.Height - 1 - n); // // for (int n=0; n<leftMargin; n++) // GdkWindow.DrawLine (borderColor, rect.X + n, rect.Y, rect.X + n, rect.Top + rect.Height - 1); // // for (int n=0; n<rightMargin; n++) // GdkWindow.DrawLine (borderColor, rect.Left + rect.Width - 1 - n, rect.Y, rect.Left + rect.Width - 1 - n, rect.Top + rect.Height - 1); }
protected override void OnDrawn (Cairo.Context cr, Gdk.Rectangle rect) { if (BackgroundColor.HasValue) { cr.Rectangle (rect.X, rect.Y, rect.Width, rect.Height); cr.SetSourceColor (BackgroundColor.Value.ToCairoColor ()); cr.Fill (); } if (GradientBackround) { Color gcol = Style.Background (Gtk.StateType.Normal).ToXwtValue (); 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 (var pat = new Cairo.LinearGradient (rect.X, rect.Y, rect.X, rect.Bottom)) { Cairo.Color color1 = gcol.ToCairoColor (); pat.AddColorStop (0, color1); gcol.Light -= 0.1; pat.AddColorStop (1, gcol.ToCairoColor ()); cr.SetSource (pat); cr.FillPreserve (); } } cr.SetSourceColor (color.HasValue ? color.Value.ToCairoColor () : Style.Dark (Gtk.StateType.Normal).ToXwtValue ().ToCairoColor ()); cr.Rectangle (rect.X, rect.Y, rect.Width, topMargin); cr.Rectangle (rect.X, rect.Y + rect.Height - bottomMargin, rect.Width, bottomMargin); cr.Rectangle (rect.X, rect.Y, leftMargin, rect.Height); cr.Rectangle (rect.X + rect.Width - rightMargin, rect.Y, rightMargin, rect.Height); cr.Fill (); }
private void DrawOutputndicator(Cairo.Context context) { context.Save(); RelativeLocator locator = new RelativeLocator(-0.04, 1.2); PointD point = locator.Locate(this); context.MoveTo(point); context.LineCap = LineCap.Round; context.Color = s_ioIndicatorColor; double l = 4; //arm lenght of indicator icon double s = 0.4; //spacing between arms in the indicator icon //draw << //up context.RelLineTo (new Distance (-s, -l)); context.RelMoveTo (new Distance (s, l)); //back //right context.RelLineTo (new Distance (l, s)); context.RelMoveTo (new Distance (-l, -s)); //back context.RelMoveTo (new Distance (3, -3)); //repeat above for second arrow context.RelLineTo (new Distance (-s, -l)); context.RelMoveTo (new Distance (s, l)); //back context.RelLineTo (new Distance (l, s)); context.RelMoveTo (new Distance (-l, -s)); //back context.Stroke(); context.Restore(); }
static void DrawLineEndAtIter (Cairo.Context cntx, TextView view, TextIter iter) { Gdk.Rectangle rect = view.GetIterLocation (iter); int x, y; view.BufferToWindowCoords (TextWindowType.Text, rect.X, rect.Y + rect.Height / 2, out x, out y); cntx.Save (); cntx.Color = GetDrawingColorForIter (view, iter); double arrowSize = 3; cntx.MoveTo (x + 10, y); cntx.RelLineTo (new Cairo.Distance (0, -arrowSize)); cntx.RelMoveTo (new Cairo.Distance (0, arrowSize)); cntx.RelLineTo (new Cairo.Distance (-8, 0)); cntx.RelLineTo (new Cairo.Distance (arrowSize, arrowSize)); cntx.RelMoveTo (new Cairo.Distance (-arrowSize, -arrowSize)); cntx.RelLineTo (new Cairo.Distance (arrowSize, -arrowSize)); cntx.Stroke (); cntx.Restore (); }
void DrawMarker(Cairo.Context cr, ref Cairo.Color color, int sampleIndex) { SetColor (cr, ref color); cr.MoveTo (WorldToPhysicalX (sampleIndex), 0); cr.RelLineTo (0, height); cr.Stroke (); }
void DrawChangeSymbol (Cairo.Context ctx, double x, int width, BlockInfo block) { if (!IsChangeBlock (block.Type)) return; Gdk.Color color = block.Type == BlockType.Added ? baseAddColor : baseRemoveColor; int ssize = 8; int barSize = 3; if (ssize - 2 > lineHeight) ssize = lineHeight - 2; if (ssize <= 0) return; double inSize = (ssize / 2) - (barSize / 2); double py = block.YStart + ((block.YEnd - block.YStart) / 2 - ssize / 2) + 0.5; double px = x + (LeftPaddingBlock/2) - (ssize / 2) + 0.5; if (block.Type == BlockType.Added) { ctx.MoveTo (px + inSize, py); ctx.RelLineTo (barSize, 0); ctx.RelLineTo (0, inSize); ctx.RelLineTo (inSize, 0); ctx.RelLineTo (0, barSize); ctx.RelLineTo (-inSize, 0); ctx.RelLineTo (0, inSize); ctx.RelLineTo (-barSize, 0); ctx.RelLineTo (0, -inSize); ctx.RelLineTo (-inSize, 0); ctx.RelLineTo (0, -barSize); ctx.RelLineTo (inSize, 0); ctx.RelLineTo (0, -inSize); ctx.ClosePath (); } else { ctx.MoveTo (px, py + inSize); ctx.RelLineTo (ssize, 0); ctx.RelLineTo (0, barSize); ctx.RelLineTo (-ssize, 0); ctx.RelLineTo (0, -barSize); ctx.ClosePath (); } ctx.Color = color.ToCairoColor (); ctx.FillPreserve (); ctx.Color = color.AddLight (-0.2).ToCairoColor ();; ctx.LineWidth = 1; ctx.Stroke (); }
public override void Draw (TextEditor editor, Cairo.Context cr, Pango.Layout layout, bool selected, int startOffset, int endOffset, double y, double startXPos, double endXPos) { if (Debugger.DebuggingService.IsDebugging) return; int markerStart = Segment.Offset; int markerEnd = Segment.EndOffset; if (markerEnd < startOffset || markerStart > endOffset) return; bool drawOverlay = result.InspectionMark == IssueMarker.GrayOut; if (drawOverlay && editor.IsSomethingSelected) { var selectionRange = editor.SelectionRange; if (selectionRange.Contains (markerStart) && selectionRange.Contains (markerEnd)) return; if (selectionRange.Contains (markerEnd)) markerEnd = selectionRange.Offset; if (selectionRange.Contains (markerStart)) markerStart = selectionRange.EndOffset; if (markerEnd <= markerStart) return; } double drawFrom; double drawTo; if (markerStart < startOffset && endOffset < markerEnd) { drawTo = endXPos; var line = editor.GetLineByOffset (startOffset); int offset = line.GetIndentation (editor.Document).Length; drawFrom = startXPos + (layout.IndexToPos (offset).X / Pango.Scale.PangoScale); } else { int start; if (startOffset < markerStart) { start = markerStart; } else { var line = editor.GetLineByOffset (startOffset); int offset = line.GetIndentation (editor.Document).Length; start = startOffset + offset; } int end = endOffset < markerEnd ? endOffset : markerEnd; int x_pos; x_pos = layout.IndexToPos (start - startOffset).X; drawFrom = startXPos + (int)(x_pos / Pango.Scale.PangoScale); x_pos = layout.IndexToPos (end - startOffset).X; drawTo = startXPos + (int)(x_pos / Pango.Scale.PangoScale); } drawFrom = System.Math.Max (drawFrom, editor.TextViewMargin.XOffset); drawTo = System.Math.Max (drawTo, editor.TextViewMargin.XOffset); if (drawFrom >= drawTo) return; double height = editor.LineHeight / 5; cr.SetSourceColor (GetColor (editor, Result)); if (drawOverlay) { cr.Rectangle (drawFrom, y, drawTo - drawFrom, editor.LineHeight); var color = editor.ColorStyle.PlainText.Background; color.A = 0.6; cr.SetSourceColor (color); cr.Fill (); } else if (result.InspectionMark == IssueMarker.WavedLine) { Pango.CairoHelper.ShowErrorUnderline (cr, drawFrom, y + editor.LineHeight - height, drawTo - drawFrom, height); } else if (result.InspectionMark == IssueMarker.DottedLine) { cr.Save (); cr.LineWidth = 1; cr.MoveTo (drawFrom + 1, y + editor.LineHeight - 1 + 0.5); cr.RelLineTo (System.Math.Min (drawTo - drawFrom, 4 * 3), 0); cr.SetDash (new double[] { 2, 2 }, 0); cr.Stroke (); cr.Restore (); } else { cr.MoveTo (drawFrom, y + editor.LineHeight - 1); cr.LineTo (drawTo, y + editor.LineHeight - 1); cr.Stroke (); } }
void DrawExpander (Cairo.Context ctx, double ex, double ey, bool expanded, bool hilight) { ctx.NewPath (); ctx.LineWidth = 1; ctx.Rectangle (ex, ey, ExpanderSize, ExpanderSize); if (hilight) ctx.SetSourceColor (Style.Background (Gtk.StateType.Normal).ToCairoColor ()); else ctx.SetSourceColor (Style.White.ToCairoColor ()); ctx.FillPreserve (); ctx.SetSourceColor (Style.Foreground (Gtk.StateType.Normal).ToCairoColor ()); ctx.Stroke (); ctx.NewPath (); ctx.MoveTo (ex + 2, ey + (ExpanderSize/2)); ctx.RelLineTo (ExpanderSize - 4, 0); if (!expanded) { ctx.MoveTo (ex + (ExpanderSize/2), ey + 2); ctx.RelLineTo (0, ExpanderSize - 4); } ctx.Stroke (); }
void DrawGradient (Cairo.Context cr, Gdk.Rectangle rect, int fx, int fy, int fw, int fh, Cairo.Color c1, Cairo.Color c2) { 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 (); // FIXME: VV: Remove gradient features using (var pat = new Cairo.LinearGradient (rect.X + rect.Width*fx, rect.Y + rect.Height*fy, rect.X + rect.Width*fw, rect.Y + rect.Height*fh)) { pat.AddColorStop (0, c1); pat.AddColorStop (1, c2); cr.Source = pat; cr.FillPreserve (); } }
protected void DrawArrow (Cairo.Context cr, double x, double y, double size) { y += 2.5; x += 2.5; size -= 4; double awidth = 0.5; double aheight = 0.4; double pich = (size - (size * aheight)) / 2; cr.NewPath (); cr.MoveTo (x + size * awidth, y); cr.LineTo (x + size, y + size / 2); cr.LineTo (x + size * awidth, y + size); cr.RelLineTo (0, -pich); cr.RelLineTo (-size * awidth, 0); cr.RelLineTo (0, -size * aheight); cr.RelLineTo (size * awidth, 0); cr.RelLineTo (0, -pich); cr.ClosePath (); }
void DrawGradient (Cairo.Context cr, Gdk.Rectangle rect, int fx, int fy, int fw, int fh, Cairo.Color c1, Cairo.Color c2) { 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.LinearGradient pat = new Cairo.LinearGradient (rect.X + rect.Width*fx, rect.Y + rect.Height*fy, rect.X + rect.Width*fw, rect.Y + rect.Height*fh); pat.AddColorStop (0, c1); pat.AddColorStop (1, c2); cr.Pattern = pat; cr.FillPreserve (); }
private void RenderBarcode(IBarcode bc, Cairo.Context cr, double x, double y, double width, double height) { // throws an exception if no stop was added double barWidth = width/(double)bc.BarcodeWidth; cr.Save(); cr.LineWidth = barWidth; cr.Color = new Cairo.Color(0, 0, 0); x += bc.Silence*barWidth; foreach(bool b in bc.Bars){ if(b){ cr.MoveTo(x,y); cr.RelLineTo(0,height); } x+=barWidth; } cr.Stroke(); cr.Restore(); }
public void Draw (Cairo.Context cr, Cairo.Rectangle rectangle) { if (IsSeparator) { cr.NewPath (); double x = Math.Ceiling (rectangle.X + rectangle.Width / 2) + 0.5; cr.MoveTo (x, rectangle.Y + 0.5 + 2); cr.RelLineTo (0, rectangle.Height - 1 - 4); cr.ClosePath (); cr.SetSourceColor (parent.Style.Dark (StateType.Normal).ToCairoColor ()); cr.LineWidth = 1; cr.Stroke (); return; } if (Active || HoverPosition.X >= 0) { if (Active) { cr.Rectangle (rectangle.X, rectangle.Y, rectangle.Width, rectangle.Height); using (var gr = new LinearGradient (rectangle.X, rectangle.Y, rectangle.X, rectangle.Y + rectangle.Height)) { gr.AddColorStop (0, Tabstrip.ActiveGradientStart); gr.AddColorStop (1, Tabstrip.ActiveGradientEnd); cr.SetSource (gr); } cr.Fill (); cr.Rectangle (rectangle.X + 0.5, rectangle.Y + 0.5, rectangle.Width - 1, rectangle.Height - 1); cr.SetSourceRGBA (1, 1, 1, 0.05); cr.LineWidth = 1; cr.Stroke (); } else if (HoverPosition.X >= 0) { cr.Rectangle (rectangle.X, rectangle.Y, rectangle.Width, rectangle.Height); using (var gr = new LinearGradient (rectangle.X, rectangle.Y, rectangle.X, rectangle.Y + rectangle.Height)) { var c1 = Tabstrip.ActiveGradientStart; var c2 = Tabstrip.ActiveGradientEnd; c1.A = 0.2; c2.A = 0.2; gr.AddColorStop (0, c1); gr.AddColorStop (1, c2); cr.SetSource (gr); } cr.Fill (); } } if (Active) cr.SetSourceRGB (1, 1, 1); else cr.SetSourceColor (parent.Style.Text (StateType.Normal).ToCairoColor ()); if (layout.Width != (int)rectangle.Width) layout.Width = (int)rectangle.Width; #if MAC /* On Cocoa, Pango doesn't render text correctly using layout width/height computation. * For instance here we need to balance some kind of internal padding by two pixels which * only happens on Mac. */ const int verticalOffset = -2; #else const int verticalOffset = 0; #endif cr.MoveTo (rectangle.X + (int)(rectangle.Width / 2), (rectangle.Height - h) / 2 + verticalOffset); Pango.CairoHelper.ShowLayout (cr, layout); }