本文整理汇总了C#中Pango.IndexToPos方法的典型用法代码示例。如果您正苦于以下问题:C# Pango.IndexToPos方法的具体用法?C# Pango.IndexToPos怎么用?C# Pango.IndexToPos使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Pango
的用法示例。
在下文中一共展示了Pango.IndexToPos方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Draw
public override void Draw (TextEditor editor, Cairo.Context cr, Pango.Layout layout, bool selected, int startOffset, int endOffset, double y, double startXPos, double endXPos)
{
int markerStart = LineSegment.Offset + System.Math.Max (StartCol - 1, 0);
int markerEnd = LineSegment.Offset + (EndCol < 1 ? LineSegment.EditableLength : EndCol - 1);
if (markerEnd < startOffset || markerStart > endOffset)
return;
double @from;
double to;
if (markerStart < startOffset && endOffset < markerEnd) {
@from = startXPos;
to = endXPos;
} else {
int start = startOffset < markerStart ? markerStart : startOffset;
int end = endOffset < markerEnd ? endOffset : markerEnd;
int /*lineNr,*/ x_pos;
x_pos = layout.IndexToPos (start - startOffset).X;
@from = startXPos + (int)(x_pos / Pango.Scale.PangoScale);
x_pos = layout.IndexToPos (end - startOffset).X;
to = startXPos + (int)(x_pos / Pango.Scale.PangoScale);
}
@from = System.Math.Max (@from, editor.TextViewMargin.XOffset);
to = System.Math.Max (to, editor.TextViewMargin.XOffset);
if (@from >= to) {
return;
}
double height = editor.LineHeight / 5;
cr.Color = ColorName == null ? Color : editor.ColorStyle.GetColorFromDefinition (ColorName);
Pango.CairoHelper.ShowErrorUnderline (cr, @from, y + editor.LineHeight - height, to - @from, height);
}
示例2: Draw
public override void Draw (TextEditor editor, Cairo.Context cr, Pango.Layout layout, bool selected, int startOffset, int endOffset, double y, double startXPos, double endXPos)
{
int markerStart = LineSegment.Offset + System.Math.Max (StartCol - 1, 0);
int markerEnd = LineSegment.Offset + (EndCol < 1 ? LineSegment.Length : EndCol - 1);
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) {
drawFrom = startXPos;
drawTo = endXPos;
} else {
int start = startOffset < markerStart ? markerStart : startOffset;
int end = endOffset < markerEnd ? endOffset : markerEnd;
int /*lineNr,*/ 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.Color = ColorName == null ? Color : editor.ColorStyle.GetColorFromDefinition (ColorName);
if (drawOverlay) {
cr.Rectangle (drawFrom, y, drawTo - drawFrom, editor.LineHeight);
var color = editor.ColorStyle.Default.CairoBackgroundColor;
color.A = 0.6;
cr.Color = color;
cr.Fill ();
} else if (Wave) {
Pango.CairoHelper.ShowErrorUnderline (cr, drawFrom, y + editor.LineHeight - height, drawTo - drawFrom, height);
} else {
cr.MoveTo (drawFrom, y + editor.LineHeight - 1);
cr.LineTo (drawTo, y + editor.LineHeight - 1);
cr.Stroke ();
}
}
示例3: InternalDraw
void InternalDraw (int markerStart, int markerEnd, TextEditor editor, Cairo.Context cr, Pango.Layout layout, bool selected, int startOffset, int endOffset, double y, double startXPos, double endXPos)
{
if (markerStart >= markerEnd)
return;
double @from;
double to;
if (markerStart < startOffset && endOffset < markerEnd) {
@from = startXPos;
to = endXPos;
} else {
int start = startOffset < markerStart ? markerStart : startOffset;
int end = endOffset < markerEnd ? endOffset : markerEnd;
int /*lineNr,*/ x_pos;
x_pos = layout.IndexToPos (start - startOffset).X;
@from = startXPos + (int)(x_pos / Pango.Scale.PangoScale);
x_pos = layout.IndexToPos (end - startOffset).X;
to = startXPos + (int)(x_pos / Pango.Scale.PangoScale);
}
@from = System.Math.Max (@from, editor.TextViewMargin.XOffset);
to = System.Math.Max (to, editor.TextViewMargin.XOffset);
if (@from >= to) {
return;
}
double height = editor.LineHeight / 5;
if (selected) {
cr.Color = editor.ColorStyle.SelectedText.Foreground;
} else {
cr.Color = ColorName == null ? Color : editor.ColorStyle.GetChunkStyle (ColorName).Foreground;
}
if (Wave) {
Pango.CairoHelper.ShowErrorUnderline (cr, @from, y + editor.LineHeight - height, to - @from, height);
} else {
cr.LineWidth = 1;
cr.MoveTo (@from, y + editor.LineHeight - 1.5);
cr.LineTo (to, y + editor.LineHeight - 1.5);
cr.Stroke ();
}
}
示例4: Draw
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 ();
}
}
示例5: Draw
public override void Draw (TextEditor editor, Gdk.Drawable win, Pango.Layout layout, bool selected, int startOffset, int endOffset, int y, int startXPos, int endXPos)
{
int markerStart = LineSegment.Offset + System.Math.Max (StartCol, 0);
int markerEnd = LineSegment.Offset + (EndCol < 0 ? LineSegment.Length : EndCol);
if (markerEnd < startOffset || markerStart > endOffset)
return;
int @from;
int to;
if (markerStart < startOffset && endOffset < markerEnd) {
@from = startXPos;
to = endXPos;
} else {
int start = startOffset < markerStart ? markerStart : startOffset;
int end = endOffset < markerEnd ? endOffset : markerEnd;
int /*lineNr,*/ x_pos;
x_pos = layout.IndexToPos (start - startOffset).X;
@from = startXPos + (int)(x_pos / Pango.Scale.PangoScale);
x_pos = layout.IndexToPos (end - startOffset).X;
to = startXPos + (int)(x_pos / Pango.Scale.PangoScale);
}
@from = System.Math.Max (@from, editor.TextViewMargin.XOffset);
to = System.Math.Max (to, editor.TextViewMargin.XOffset);
if (@from >= to) {
return;
}
using (Cairo.Context cr = Gdk.CairoHelper.Create (win)) {
int height = editor.LineHeight / 5;
cr.Color = Mono.TextEditor.Highlighting.Style.ToCairoColor (ColorName == null ? Color : editor.ColorStyle.GetColorFromDefinition (ColorName));
Pango.CairoHelper.ShowErrorUnderline (cr, @from, y + editor.LineHeight - height, to - @from, height);
}
/*
using (Gdk.GC gc = new Gdk.GC(win)) {
gc.RgbFgColor = ;
const int length = 6;
const int height = 2;
if (Wave) {
startXPos = System.Math.Max (startXPos, editor.TextViewMargin.XOffset);
for (int height = @from; height < to; height += length) {
win.DrawLine (gc, height, drawY, height + length / 2, drawY - height);
win.DrawLine (gc, height + length / 2, drawY - height, height + length, drawY);
}
} else {
win.DrawLine (gc, @from, drawY, to, drawY);
}
} */
}
示例6: InternalDraw
private void InternalDraw(int markerStart, int markerEnd, TextEditor editor, Cairo.Context cr, Pango.Layout layout, bool selected, int startOffset, int endOffset, double y, double startXPos, double endXPos)
{
// we get called twice, the second time has a different set of params because we are the same offset
// on the next line as well
//Debug.WriteLine("draw marker {0}, {1}", startXPos, y);
if (markerStart >= markerEnd)
return;
double @from;
double to;
if (markerStart < startOffset && endOffset < markerEnd)
{
@from = startXPos;
to = endXPos;
} else
{
int start = startOffset < markerStart ? markerStart : startOffset;
int end = endOffset < markerEnd ? endOffset : markerEnd;
int /*lineNr,*/ x_pos;
x_pos = layout.IndexToPos (start - startOffset).X;
@from = startXPos + (int)(x_pos / Pango.Scale.PangoScale);
x_pos = layout.IndexToPos (end - startOffset).X;
to = startXPos + (int)(x_pos / Pango.Scale.PangoScale);
}
var charWidth = editor.TextViewMargin.CharWidth;
@from = System.Math.Max (@from, editor.TextViewMargin.XOffset) - charWidth / 2;
to = System.Math.Max (to, editor.TextViewMargin.XOffset) - charWidth / 2;
if (@from >= to)
{
//return;
// BUG: fake it for now, but doesn't draw correctly
// to += editor.TextViewMargin.CharWidth;
}
to = @from + editor.TextViewMargin.CharWidth;
double height = editor.LineHeight / 2;
if (selected)
{
cr.Color = editor.ColorStyle.SelectedText.Foreground;
}
else
{
cr.Color = ColorName == null ? Color : editor.ColorStyle.GetChunkStyle (ColorName).Foreground;
}
cr.LineWidth = 1;
cr.MoveTo (@from, y + editor.LineHeight - 1.5);
cr.LineTo (to, y + editor.LineHeight - 1.5);
cr.LineTo (@from + (@to - @from) / 2, y + editor.LineHeight - 5);
cr.LineTo (@from, y + editor.LineHeight - 1.5);
cr.Fill();
}