Пример #1
0
        public Rectangle GetCursorLocation()
        {
            Pango.Rectangle weak, strong;

            int index = PositionToIndex(CurrentPosition);

            layout.GetCursorPos(index, out strong, out weak);

            int x = Pango.Units.ToPixels(strong.X) + origin.X;
            int y = Pango.Units.ToPixels(strong.Y) + origin.Y;
            int w = Pango.Units.ToPixels(strong.Width);
            int h = Pango.Units.ToPixels(strong.Height);

            return(new Rectangle(x, y, w, h));
        }
Пример #2
0
        //TODO: Deprecate Cairo usage entirely
        public Gdk.Rectangle RenderLayoutText(Context cr, String text, int x, int y, int width, int textHeight,
                                              Constants.Color color, Pango.Alignment align, Pango.EllipsizeMode ellipse, int horisontalOffset = 0)
        {
            if (string.IsNullOrEmpty(text))
            {
                return(new Gdk.Rectangle());
            }

            if (layout != null)
            {
                layout.Context.Dispose();
                layout.FontDescription.Dispose();
                layout.Dispose();
            }

            layout = new Pango.Layout(ReferenceWidget.CreatePangoContext());
            layout.FontDescription = new Pango.FontDescription();
            layout.FontDescription.AbsoluteSize = Pango.Units.FromPixels(textHeight);

            layout.Width     = Pango.Units.FromPixels(width);
            layout.Ellipsize = ellipse;
            layout.Alignment = align;

            if (ellipse == Pango.EllipsizeMode.None)
            {
                layout.Wrap = Pango.WrapMode.WordChar;
            }

            text = string.Format("<span foreground=\"#{0}\">{1}</span>", color, text);
            layout.SetMarkup(text);

            cr.Rectangle(x, y, width, 155);
            cr.Clip();
            cr.MoveTo(x + horisontalOffset, y);
            Pango.CairoHelper.ShowLayout(cr, layout);
            Pango.Rectangle strong, weak;
            layout.GetCursorPos(layout.Lines [layout.LineCount - 1].StartIndex +
                                layout.Lines [layout.LineCount - 1].Length,
                                out strong, out weak);
            cr.ResetClip();

            return(new Gdk.Rectangle(Pango.Units.ToPixels(weak.X) + x,
                                     Pango.Units.ToPixels(weak.Y) + y,
                                     Pango.Units.ToPixels(weak.Width),
                                     Pango.Units.ToPixels(weak.Height)));
        }
Пример #3
0
 public void GetCursorPos(int index_, out Pango.Rectangle strong_pos, out Pango.Rectangle weak_pos)
 {
     layout.GetCursorPos(index_, out strong_pos, out weak_pos);
 }