Browse Source

Implemented text selection and temporarily worked around text scaling

pull/66/head
Nelson Carrillo 11 years ago
parent
commit
1d4cca886d
  1. 8
      Cairo/Perspex.Cairo/Media/DrawingContext.cs
  2. 19
      Cairo/Perspex.Cairo/Media/FormattedTextImpl.cs

8
Cairo/Perspex.Cairo/Media/DrawingContext.cs

@ -51,7 +51,7 @@ namespace Perspex.Cairo.Media
this.Drawable = drawable;
this.context = Gdk.CairoHelper.Create(drawable);
this.CurrentTransform = Matrix.Identity;
}
}
public Matrix CurrentTransform
{
@ -175,7 +175,7 @@ namespace Perspex.Cairo.Media
/// </summary>
/// <param name="pen">The pen.</param>
/// <param name="rect">The rectangle bounds.</param>
public void DrawRectange(Pen pen, Rect rect)
public void DrawRectange(Pen pen, Rect rect, float cornerRadius)
{
this.SetPen(pen);
this.context.Rectangle(rect.ToCairo());
@ -192,7 +192,7 @@ namespace Perspex.Cairo.Media
{
var layout = ((FormattedTextImpl)text.PlatformImpl).Layout;
this.SetBrush(foreground);
this.context.MoveTo(origin.X, origin.Y);
Pango.CairoHelper.ShowLayout(this.context, layout);
}
@ -202,7 +202,7 @@ namespace Perspex.Cairo.Media
/// </summary>
/// <param name="brush">The brush.</param>
/// <param name="rect">The rectangle bounds.</param>
public void FillRectange(Perspex.Media.Brush brush, Rect rect)
public void FillRectange(Perspex.Media.Brush brush, Rect rect, float cornerRadius)
{
this.SetBrush(brush);
this.context.Rectangle(rect.ToCairo());

19
Cairo/Perspex.Cairo/Media/FormattedTextImpl.cs

@ -29,11 +29,11 @@ namespace Perspex.Cairo.Media
this.Layout.FontDescription = new Pango.FontDescription
{
Family = fontFamily,
Size = Pango.Units.FromDouble(fontSize),
Size = Pango.Units.FromDouble(fontSize * 0.73),
Style = (Pango.Style)fontStyle,
Weight = fontWeight.ToCairo()
};
this.Layout.Alignment = textAlignment.ToCairo();
}
@ -92,8 +92,14 @@ namespace Perspex.Cairo.Media
public IEnumerable<Rect> HitTestTextRange(int index, int length, Point origin)
{
// TODO: Implement.
return new Rect[0];
var ranges = new List<Rect>();
for (var i = 0; i < length; i++)
{
ranges.Add(this.HitTestTextPosition(index+i));
}
return ranges;
}
public Size Measure()
@ -102,11 +108,6 @@ namespace Perspex.Cairo.Media
int height;
this.Layout.GetPixelSize(out width, out height);
if (this.Layout.Alignment == Pango.Alignment.Right)
{
return new Size(width, height);
}
return new Size(width, height);
}

Loading…
Cancel
Save