本文整理汇总了C#中Pango.GetPixelSize方法的典型用法代码示例。如果您正苦于以下问题:C# Pango.GetPixelSize方法的具体用法?C# Pango.GetPixelSize怎么用?C# Pango.GetPixelSize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Pango
的用法示例。
在下文中一共展示了Pango.GetPixelSize方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Ellipsize
public static string Ellipsize(Pango.Layout layout, string newtext, int bound, int ellipsis_width, int en_width)
{
int width, tmp;
layout.SetText (newtext);
layout.GetPixelSize (out width, out tmp);
if (width < bound)
return newtext;
if (bound <= ellipsis_width)
return ellipsis;
string ellipsized = "";
int i = 0;
i = (bound - ellipsis_width) / (en_width);
if (i >= newtext.Length)
i = 0;
ellipsized = newtext.Substring (0, i);
while (true)
{
ellipsized = ellipsized + newtext[i];
layout.SetText (ellipsized);
layout.GetPixelSize (out width, out tmp);
if (i == newtext.Length - 1) {
ellipsized = "";
i = 0;
continue;
}
if (width > bound - ellipsis_width)
break;
i++;
}
ellipsized = ellipsized.Remove (ellipsized.Length - 1, 1);
ellipsized += ellipsis;
return ellipsized;
}
示例2: DrawHorizontalSectionIndicator
protected void DrawHorizontalSectionIndicator(string text, Cairo.Context cr, Pango.Layout layout, double x, double y, double w, out double h)
{
cr.MoveTo(x,y);
cr.LineTo(x,y+SectionSerifeWidth*2);
cr.MoveTo(x,y+SectionSerifeWidth);
cr.LineTo(x+w,y+SectionSerifeWidth);
cr.MoveTo(x+w,y);
cr.LineTo(x+w,y+SectionSerifeWidth*2);
cr.Color = new Cairo.Color(0, 0, 0);
cr.LineWidth = 1;
cr.Stroke();
layout.Width = (int)(w*Pango.Scale.PangoScale);
layout.Alignment = Pango.Alignment.Center;
layout.SetText (text);
layout.Ellipsize = EllipsizeMode.Middle;
layout.Justify = true;
cr.Color = new Cairo.Color(0, 0, 0);
cr.MoveTo(x,y+SectionSerifeWidth*2);
Pango.CairoHelper.ShowLayout (cr, layout);
int lw,lh;
layout.GetPixelSize(out lw, out lh);
h=(double)lh+SectionSerifeWidth*2;
}
示例3: Ellipsize
public static string Ellipsize (Pango.Layout layout, string newtext, int bound, int ellipsis_width, int en_width)
{
int width, tmp;
layout.SetText (newtext);
layout.GetPixelSize (out width, out tmp);
if (width < bound)
return newtext;
if (bound <= ellipsis_width)
return ellipsis;
string ellipsized = "";
int i = 0;
//make a guess of where to start
i = (bound - ellipsis_width) / (en_width);
if (i >= newtext.Length)
i = 0;
ellipsized = newtext.Substring (0, i);
//add chars one by one to determine how many are allowed
while (true)
{
ellipsized = ellipsized + newtext[i];
layout.SetText (ellipsized);
layout.GetPixelSize (out width, out tmp);
if (i == newtext.Length - 1) {
//bad guess, start from the beginning
ellipsized = "";
i = 0;
continue;
}
if (width > bound - ellipsis_width)
break;
i++;
}
ellipsized = ellipsized.Remove (ellipsized.Length - 1, 1);
ellipsized += ellipsis;
return ellipsized;
}
示例4: UpdateText
public void UpdateText(Pango.Layout layout, double cellWidth, string text)
{
if (String.IsNullOrEmpty (text)) {
return;
}
layout.Width = (int)((cellWidth - Padding.X) * Pango.Scale.PangoScale);
layout.FontDescription.Weight = font_weight;
layout.Ellipsize = EllipsizeMode;
layout.Alignment = alignment;
layout.SingleParagraphMode = SingleParagraphMode;
UpdateLayout (layout, text);
layout.GetPixelSize (out text_width, out text_height);
is_ellipsized = layout.IsEllipsized;
}
示例5: GetWidthRange
public void GetWidthRange(Pango.Layout layout, out int min, out int max)
{
int height;
min = max = -1;
if (!String.IsNullOrEmpty (MinString)) {
UpdateLayout (layout, MinString);
layout.GetPixelSize (out min, out height);
min += (int)Padding.X;
//Console.WriteLine ("for {0} got min {1} for {2}", this, min, MinString);
}
if (!String.IsNullOrEmpty (MaxString)) {
UpdateLayout (layout, MaxString);
layout.GetPixelSize (out max, out height);
max += (int)Padding.X;
//Console.WriteLine ("for {0} got max {1} for {2}", this, max, MaxString);
}
}
示例6: CalculateSize
void CalculateSize(Pango.Layout layout, out int x, out int y,
out int width, out int height)
{
int w, h;
layout.GetPixelSize (out w, out h);
x = 0;
y = 0;
width = w + ((int) Xpad) * 2;
height = h + ((int) Ypad) * 2;
}
示例7: GetLayoutSize
Size GetLayoutSize (Pango.Layout layout)
{
int width;
int height;
layout.GetPixelSize (out width, out height);
return new Size (width, height);
}
示例8: DrawVerticalSectionIndicator
protected void DrawVerticalSectionIndicator(string text, Cairo.Context cr, Pango.Layout layout, double x, double y, out double w, double h)
{
cr.MoveTo(x,y);
cr.LineTo(x+SectionSerifeWidth*2,y);
cr.MoveTo(x+SectionSerifeWidth,y);
cr.LineTo(x+SectionSerifeWidth,y+h);
cr.MoveTo(x,y+h);
cr.LineTo(x+SectionSerifeWidth*2,y+h);
cr.Color = new Cairo.Color(0, 0, 0);
cr.LineWidth = 1;
layout.Alignment = Pango.Alignment.Left;
layout.SetText (text);
layout.Ellipsize = EllipsizeMode.Middle;
layout.Justify = true;
int lh,lw;
layout.GetPixelSize(out lw, out lh);
w=(double)lw+SectionSerifeWidth*2;
cr.Color = new Cairo.Color(0, 0, 0);
cr.MoveTo(x+SectionSerifeWidth*2,y+(h-lh)/2);
Pango.CairoHelper.ShowLayout (cr, layout);
}
示例9: DrawGroup
/// <summary>Draws a group.</summary>
internal void DrawGroup (Context cr, Rectangle r, double roundSize, double lineWidth, double space, Pango.Layout l, Gtk.Widget expandButton, RibbonGroup w)
{
double lineWidth05 = lineWidth/2, lineWidth15 = 3*lineWidth05;
LinearGradient linGrad;
double x0 = r.X + roundSize, x1 = r.X + r.Width - roundSize;
double y0 = r.Y + roundSize, y1 = r.Y + r.Height - roundSize;
cr.Arc (x1, y1, roundSize - lineWidth05, 0, Math.PI/2);
cr.Arc (x0 + lineWidth, y1, roundSize - lineWidth05, Math.PI/2, Math.PI);
cr.Arc (x0, y0, roundSize - lineWidth15, Math.PI, 3*Math.PI/2);
cr.Arc (x1, y0 + lineWidth, roundSize - lineWidth05, 3*Math.PI/2, 0);
cr.LineTo (x1 + roundSize - lineWidth05, y1);
cr.LineWidth = lineWidth;
cr.Color = colorScheme.Bright;
cr.Stroke ();
if(l != null)
{
int lblWidth, lblHeight;
Pango.CairoHelper.UpdateLayout (cr, l);
l.GetPixelSize(out lblWidth, out lblHeight);
double bandHeight = lblHeight + 2*space;
cr.Arc (x1, y1, roundSize - lineWidth15, 0, Math.PI/2);
cr.Arc (x0, y1 - lineWidth, roundSize - lineWidth05, Math.PI/2, Math.PI);
double bandY = y1 + roundSize - 2*lineWidth - bandHeight;
cr.LineTo (x0 - roundSize + lineWidth05, bandY);
cr.LineTo (x1 + roundSize - lineWidth15, bandY);
linGrad = new LinearGradient (0, bandY, 0, bandY + bandHeight);
linGrad.AddColorStop (0.0, colorScheme.Dark);
linGrad.AddColorStop (1.0, colorScheme.PrettyDark);
cr.Pattern = linGrad;
cr.Fill ();
double frameSize = 2*lineWidth + space;
double availableHorizontalSpace = r.Width - 2 * frameSize;
if(expandButton.Visible) availableHorizontalSpace -= expandButton.WidthRequest + space;
cr.Save ();
cr.Rectangle (r.X + frameSize, bandY, availableHorizontalSpace, bandHeight);
cr.Clip ();
cr.Color = new Color(1, 1, 1);
Pango.CairoHelper.UpdateLayout (cr, l);
cr.MoveTo (r.X + frameSize + Math.Max(0, (availableHorizontalSpace - lblWidth) / 2), bandY + space);
Pango.CairoHelper.ShowLayout (cr, l);
cr.Restore();
}
cr.MoveTo (x1 + roundSize - lineWidth15, y1);
cr.Arc (x1, y1, roundSize - lineWidth15, 0, Math.PI/2);
cr.Arc (x0, y1 - lineWidth, roundSize - lineWidth05, Math.PI/2, Math.PI);
cr.Arc (x0, y0, roundSize - lineWidth05, Math.PI, 3*Math.PI/2);
cr.Arc (x1 - lineWidth, y0, roundSize - lineWidth05, 3*Math.PI/2, 0);
cr.LineTo (x1 + roundSize - lineWidth15, y1);
cr.LineWidth = lineWidth;
linGrad = new LinearGradient (0, r.Y, 0, r.Y + r.Height - lineWidth);
linGrad.AddColorStop (0.0, ColorScheme.GetColorRelative (colorScheme.PrettyDark, 0.1));
linGrad.AddColorStop (1.0, colorScheme.PrettyDark);
cr.Pattern = linGrad;
cr.Stroke ();
}
示例10: DrawKeyTip
internal void DrawKeyTip(Context cr, Point reference, double horizontal_align, double vertical_align, Pango.Layout layout)
{
Pango.Layout min_layout = Pango.CairoHelper.CreateLayout (cr);
min_layout.SetText ("O");
Pango.CairoHelper.UpdateLayout (cr, min_layout);
int minWidth, minHeight;
min_layout.GetPixelSize (out minWidth, out minHeight);
/*layout.SetText (label);
Pango.CairoHelper.UpdateLayout (cr, layout);*/
int lblWidth, lblHeight;
layout.GetPixelSize (out lblWidth, out lblHeight);
int width = Math.Max (minWidth, lblWidth);
int height = Math.Max (minHeight, lblHeight);
double x0 = reference.X - (width * horizontal_align), x1 = x0 + width;
double y0 = reference.Y - (height * vertical_align), y1 = y0 + height;
cr.LineWidth = 1.0;
cr.MoveTo (x0 + 1.5, y0 + 0.5);
cr.LineTo (x1 - 1.5, y0 + 0.5);
cr.LineTo (x1 - 0.5, y0 + 1.5);
cr.LineTo (x1 - 0.5, y1 - 1.5);
cr.LineTo (x1 - 1.5, y1 - 0.5);
cr.LineTo (x0 + 1.5, y1 - 0.5);
cr.LineTo (x0 + 0.5, y1 - 1.5);
cr.LineTo (x0 + 0.5, y0 + 1.5);
cr.LineTo (x0 + 0.5, y0 + 0.5);
cr.Color = new Color (0, 0, 0);
cr.StrokePreserve ();
LinearGradient grad = new LinearGradient (0, y0, 0, y1);
grad.AddColorStop (0, colorScheme.LightBright);
grad.AddColorStop (1, colorScheme.LightDark);
cr.Pattern = grad;
cr.Fill ();
grad.Destroy ();
Pango.CairoHelper.UpdateLayout (cr, layout);
cr.MoveTo (x0 + 1, y0 +1);
cr.Color = new Color (0, 0, 0);
Pango.CairoHelper.ShowLayout (cr, layout);
}
示例11: DrawGroup
/// <summary>Draws a group.</summary>
internal void DrawGroup(Context cr, Rectangle r, double roundSize, double lineWidth, double space, Pango.Layout l, Gtk.Widget expandButton, RibbonGroup w)
{
double lineWidth05 = lineWidth/2, lineWidth15 = 3*lineWidth05;
LinearGradient linGrad;
double x0 = r.X + roundSize, x1 = r.X + r.Width - roundSize;
double y0 = r.Y + roundSize, y1 = r.Y + r.Height - roundSize;
cr.Arc (x1, y1, roundSize - lineWidth05, 0, Math.PI/2);
cr.Arc (x0 + lineWidth, y1, roundSize - lineWidth05, Math.PI/2, Math.PI);
cr.Arc (x0, y0, roundSize - lineWidth15, Math.PI, 3*Math.PI/2);
cr.Arc (x1, y0 + lineWidth, roundSize - lineWidth05, 3*Math.PI/2, 0);
cr.LineTo (x1 + roundSize - lineWidth05, y1);
cr.LineWidth = lineWidth;
cr.Color = colorScheme.Bright;
cr.Stroke ();
if(l != null)
{
int lblWidth, lblHeight;
Pango.CairoHelper.UpdateLayout (cr, l);
l.GetPixelSize(out lblWidth, out lblHeight);
if(w.LabelPosition == Position.Top || w.LabelPosition == Position.Bottom)
{
double labelY;
double bandHeight = lblHeight + 2*space;
if(w.LabelPosition == Position.Top)
{
cr.Arc (x0, y0, roundSize - lineWidth05, Math.PI, 3*Math.PI/2);
cr.Arc (x1, y0, roundSize - lineWidth05, 3*Math.PI/2, 0);
double bandY = y0 - roundSize + 2*lineWidth + bandHeight;
cr.LineTo (x1 + roundSize - lineWidth15, bandY);
cr.LineTo (x0 - roundSize + lineWidth05, bandY);
linGrad = new LinearGradient (0, bandY - bandHeight, 0, bandY);
linGrad.AddColorStop (0.0, colorScheme.Dark);
linGrad.AddColorStop (1.0, colorScheme.PrettyDark);
cr.Pattern = linGrad;
cr.Fill ();
linGrad.Destroy ();
labelY = bandY - bandHeight - space;
}
else
{
cr.Arc (x1, y1, roundSize - lineWidth15, 0, Math.PI/2);
cr.Arc (x0, y1 - lineWidth, roundSize - lineWidth05, Math.PI/2, Math.PI);
double bandY = y1 + roundSize - 2*lineWidth - bandHeight;
cr.LineTo (x0 - roundSize + lineWidth05, bandY);
cr.LineTo (x1 + roundSize - lineWidth15, bandY);
linGrad = new LinearGradient (0, bandY, 0, bandY + bandHeight);
linGrad.AddColorStop (0.0, colorScheme.Dark);
linGrad.AddColorStop (1.0, colorScheme.PrettyDark);
cr.Pattern = linGrad;
cr.Fill ();
linGrad.Destroy ();
labelY = bandY;
}
double frameSize = 2*lineWidth + space;
double availableHorizontalSpace = r.Width - 2 * frameSize;
if(expandButton.Visible) availableHorizontalSpace -= expandButton.WidthRequest + space;
cr.Save ();
cr.Rectangle (r.X + frameSize, labelY, availableHorizontalSpace, bandHeight);
cr.Clip ();
cr.Color = new Color(1, 1, 1);
Pango.CairoHelper.UpdateLayout (cr, l);
cr.MoveTo (r.X + frameSize + Math.Max(0, (availableHorizontalSpace - lblWidth) / 2), labelY + space);
Pango.CairoHelper.ShowLayout (cr, l);
cr.Restore();
}
else // label at right or left
{
double labelX;
double bandWidth = lblHeight + 2*space;
if(w.LabelPosition == Position.Left)
{
cr.Arc (x0, y1, roundSize - lineWidth05, Math.PI/2, Math.PI);
cr.Arc (x0, y0, roundSize - lineWidth05, Math.PI, 3*Math.PI/2);
double bandX = x0 - roundSize + 2*lineWidth + bandWidth;
cr.LineTo (bandX, y0 - roundSize + lineWidth05);
cr.LineTo (bandX, y1 + roundSize - lineWidth15);
linGrad = new LinearGradient (bandX - bandWidth, 0, bandX, 0);
linGrad.AddColorStop (0.0, colorScheme.Dark);
linGrad.AddColorStop (1.0, colorScheme.PrettyDark);
cr.Pattern = linGrad;
cr.Fill ();
linGrad.Destroy ();
labelX = bandX - bandWidth - space;
}
else
{
cr.Arc (x1, y0 - lineWidth05, roundSize - lineWidth15, 3*Math.PI/2, 0);
//.........这里部分代码省略.........
示例12: GetPixelHeightSize
public static int GetPixelHeightSize(Text aText, Pango.Layout layout)
{
layout.SetText(aText.TextValue);
layout.FontDescription = Pango.FontDescription.FromString(aText.FontDescription);
int pixelSizeWidth, pixelSizeHeight;
layout.GetPixelSize(out pixelSizeWidth, out pixelSizeHeight);
return pixelSizeHeight;
}