本文整理汇总了C#中Gtk.TextView.GetIterLocation方法的典型用法代码示例。如果您正苦于以下问题:C# TextView.GetIterLocation方法的具体用法?C# TextView.GetIterLocation怎么用?C# TextView.GetIterLocation使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Gtk.TextView
的用法示例。
在下文中一共展示了TextView.GetIterLocation方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DrawLineEndAtIter
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 ();
}
示例2: GetCharCountDrawInfo
private void GetCharCountDrawInfo (TextView textView, out int[,] info) {
if (textView.Buffer.LineCount == 0) {
info = null;
return; //shouldn't happen, but just to make sure
}
/* Get visible coordinates */
int minVisibleY = textView.VisibleRect.Top;
int maxVisibleY = textView.VisibleRect.Bottom;
/* Get visible start and end iters */
TextIter startIter, endIter;
int lineTop;
textView.GetLineAtY(out startIter, minVisibleY, out lineTop);
textView.GetLineAtY(out endIter, maxVisibleY, out lineTop);
int lineCount = endIter.Line - startIter.Line + 1;
int startLine = startIter.Line;
int endLine = endIter.Line;
/* Initializations */
info = new int[lineCount, 2];
/* Process start iter */
int startLineCharCount = startIter.CharsInLine - (lineCount > 1 ? 1 : 0); //subtract 1 for newline if there are >1 lines
info[0, 0] = startLineCharCount; //Char Count
Gdk.Rectangle startIterLocation = textView.GetIterLocation(startIter);
info[0, 1] = startIterLocation.Bottom - (startIterLocation.Height/2) - minVisibleY; //Y
/* If only 1 line, return */
if (lineCount == 1) {
return;
}
/* Process middle iters */
for (int i = 1, line = startLine + 1 ; line < endLine ; i++, line++) {
TextIter iter = textView.Buffer.GetIterAtLine(line);
int charCount = iter.CharsInLine - 1; //subtract 1 for newline
info[i, 0] = charCount;
Gdk.Rectangle iterLocation = textView.GetIterLocation(iter);
info[i, 1] = iterLocation.Bottom - (iterLocation.Height/2) - minVisibleY; //Y
}
/* Process end iter */
int endLineCharCount = endIter.CharsInLine - (endLine == textView.Buffer.LineCount - 1 ? 0 : 1); //subtract newline if this isn't the last line in the buffer
info[lineCount-1, 0] = endLineCharCount;
Gdk.Rectangle endIterLocation = textView.GetIterLocation(endIter);
info[lineCount-1, 1] = endIterLocation.Bottom - (endIterLocation.Height/2) - minVisibleY; //Y
}
示例3: DrawSpaceAtIter
static void DrawSpaceAtIter (Cairo.Context cntx, TextView view, TextIter iter)
{
Gdk.Rectangle rect = view.GetIterLocation (iter);
int x, y;
view.BufferToWindowCoords (TextWindowType.Text,
rect.X + rect.Width / 2,
rect.Y + rect.Height / 2,
out x, out y);
cntx.Save ();
cntx.Color = GetDrawingColorForIter (view, iter);
//no overlap on the circle, even if context is set to LineCap.Square
cntx.LineCap = Cairo.LineCap.Butt;
cntx.MoveTo (x, y);
cntx.Arc (x, y, 0.5, 0, 2 * Math.PI);
cntx.Stroke ();
cntx.Restore ();
}