本文整理汇总了C#中Gtk.CreatePangoLayout方法的典型用法代码示例。如果您正苦于以下问题:C# Gtk.CreatePangoLayout方法的具体用法?C# Gtk.CreatePangoLayout怎么用?C# Gtk.CreatePangoLayout使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Gtk
的用法示例。
在下文中一共展示了Gtk.CreatePangoLayout方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DrawComment
private static void DrawComment(Gtk.PrintContext context, double x, double y, double h, string comment, bool rotated)
{
if (string.IsNullOrEmpty(comment))
return;
Context cr = context.CairoContext;
cr.Save ();
Pango.Layout layout = context.CreatePangoLayout ();
Pango.FontDescription desc = Pango.FontDescription.FromString ("sans 14");
layout.FontDescription = desc;
layout.SetText (comment);
int lay_w, lay_h;
layout.GetPixelSize (out lay_w, out lay_h);
double scale = h/lay_h;
if (rotated) {
cr.Translate (x - h, y + lay_w * scale);
cr.Rotate (- Math.PI / 2);
}
else
cr.Translate (x - lay_w * scale, y - h);
cr.Scale (scale, scale);
Pango.CairoHelper.ShowLayout (context.CairoContext, layout);
cr.Restore ();
}
示例2: GetLayout
Pango.Layout GetLayout(Gtk.Widget widget)
{
return widget.CreatePangoLayout (string.Empty);
}
示例3: Draw
public void Draw(Gtk.PrintContext context)
{
Cairo.Context con = context.CairoContext;
Pango.Layout layout = context.CreatePangoLayout();
layout.SetText(this.textValue);
layout.FontDescription = Pango.FontDescription.FromString(this.FontDescription);
int pixelSizeWidth, pixelSizeHeight;
layout.GetPixelSize(out pixelSizeWidth, out pixelSizeHeight);
Console.WriteLine(" Text value: " + this.textValue);
Console.WriteLine(" Pixel size width: " + pixelSizeWidth);
Console.WriteLine(" Pixel size height: " + pixelSizeHeight);
Console.WriteLine(" Text X position: " + this.x);
Console.WriteLine(" Text Y position: " + this.y);
double x_offset = pixelSizeWidth*0; // Disabled
double y_offset = pixelSizeHeight * 0.83;
Console.WriteLine("width: " + x_offset);
Console.WriteLine("height: " + y_offset);
/// Alignment
/// If text.Alignment == "center", then x coordinate is indicating
/// the center, not the left side. That's way we add pixelSizeWidth/2
/// to x_offset
if (this.alignment.Equals("center")) {
layout.Alignment = Pango.Alignment.Center;
x_offset += pixelSizeWidth/2;
}
con.MoveTo(this.x - x_offset, this.y - y_offset);
Pango.CairoHelper.ShowLayout(con, layout);
// con.MoveTo(text.X, text.Y - y_offset);
// con.LineTo(text.X + 100, text.Y - y_offset);
// con.Stroke();
//
// con.MoveTo(text.X, 38.4376957919563);
// con.LineTo(text.X + 100, 38.4376957919563);
// con.Stroke();
}
示例4: CreateTimestampLayout
private Pango.Layout CreateTimestampLayout (Gtk.PrintContext context)
{
Pango.Layout layout = context.CreatePangoLayout ();
layout.FontDescription = Window.Editor.Style.FontDesc;
layout.Width = Pango.Units.FromPixels ((int) context.Width);
layout.FontDescription.Style = Pango.Style.Normal;
layout.FontDescription.Weight = Pango.Weight.Light;
string footer_right = DateTime.Now.ToString (
/* Translators: Explanation of the date and time format specifications can be found here:
* http://msdn.microsoft.com/en-us/library/system.globalization.datetimeformatinfo.aspx */
Catalog.GetString ("dddd MM/dd/yyyy, hh:mm:ss tt"));
layout.Alignment = Pango.Alignment.Right;
layout.SetText (footer_right);
return layout;
}
示例5: CreatePagenumbersLayout
private Pango.Layout CreatePagenumbersLayout (Gtk.PrintContext context,
int page_number, int total_pages)
{
Pango.Layout layout = context.CreatePangoLayout ();
layout.FontDescription = Window.Editor.Style.FontDesc;
layout.Width = Pango.Units.FromPixels ((int) context.Width);
layout.FontDescription.Style = Pango.Style.Normal;
layout.FontDescription.Weight = Pango.Weight.Light;
string footer_left = string.Format (Catalog.GetString ("Page {0} of {1}"),
page_number, total_pages);
layout.Alignment = Pango.Alignment.Left;
layout.SetText (footer_left);
return layout;
}
示例6: CreateParagraphLayout
private Pango.Layout CreateParagraphLayout (Gtk.PrintContext context,
Gtk.TextIter p_start,
Gtk.TextIter p_end,
out int indentation)
{
Pango.Layout layout = context.CreatePangoLayout ();
layout.FontDescription = Window.Editor.Style.FontDesc;
int start_index = p_start.LineIndex;
indentation = 0;
double dpiX = context.DpiX;
using (Pango.AttrList attr_list = new Pango.AttrList ()) {
Gtk.TextIter segm_start = p_start;
Gtk.TextIter segm_end;
while (segm_start.Compare (p_end) < 0) {
segm_end = segm_start;
IEnumerable<Pango.Attribute> attrs =
GetParagraphAttributes (
layout, dpiX, out indentation,
ref segm_end, p_end);
uint si = (uint) (segm_start.LineIndex - start_index);
uint ei = (uint) (segm_end.LineIndex - start_index);
foreach (Pango.Attribute a in attrs) {
a.StartIndex = si;
a.EndIndex = ei;
attr_list.Insert (a);
}
segm_start = segm_end;
}
layout.Attributes = attr_list;
}
DepthNoteTag depth = Buffer.FindDepthTag (p_start);
if (depth != null)
indentation += ((int) (dpiX / 3)) * depth.Depth;
layout.Width = Pango.Units.FromPixels ((int)context.Width -
margin_left - margin_right - indentation);
layout.Wrap = Pango.WrapMode.WordChar;
layout.SetText (Buffer.GetSlice (p_start, p_end, false));
return layout;
}
示例7: Draw
public void Draw(Gtk.PrintContext context,
Dictionary<string, string> data,
Dictionary<string, DataTable> dataTables,
double maxYToDraw,
bool reallyDraw)
{
foreach (IShape aShape in this.shapesInSection) {
if (aShape is Text) {
Text aText = (Text)aShape;
Console.WriteLine(aText.TextValue);
if (data.ContainsKey(aText.Id))
aText.TextValue = data[aText.Id];
}
else if (aShape is Table) {
Table aTable = (Table)aShape;
/* If the table has no data, don't draw it */
if (!dataTables.ContainsKey(aTable.Id))
continue;
// DataTable corresponding to the Table object
DataTable dataTable = dataTables[aTable.Id];
if (this.datarowsToDraw == null) {
this.datarowsToDraw = new List<DataRow>();
// Add all DataRows
foreach (DataRow dr in dataTable.Rows)
this.datarowsToDraw.Add(dr);
this.originalNumberOfDataRows = this.datarowsToDraw.Count;
}
Console.WriteLine("Procesando un DataTable...");
Text textTemp = null;
List<Text> textRow = new List<Text>(aTable.NumberOfColumns);
List<DataRow> datarowsDrawn = new List<DataRow>();
foreach (DataRow dataRow in this.datarowsToDraw) {
foreach (Text aText in aTable.LastRowAdded) {
Console.WriteLine(" Text: " + aText.TextValue);
textTemp = (Text)aText.Clone();
textTemp.TextValue =
dataRow[textTemp.Id].ToString();
textTemp.Y = textTemp.Y +
Utils.GetPixelHeightSize(textTemp,
context.CreatePangoLayout());
textRow.Add(textTemp);
}
/* We stop drawing rows if we have reached the end
* of the section (the start of the next one) */
double heightOfLastText =
textTemp.Y + Utils.GetPixelHeightSize(textTemp,
context.CreatePangoLayout());
if (heightOfLastText > maxYToDraw)
break;
aTable.AddRow(textRow);
textRow.Clear();
/* I add the DataRow to remove it later.
* This is for multipage reports, where there is a lot
* of data. Next call to this function we will draw
* remaning shapes */
datarowsDrawn.Add(dataRow);
}
// Remove already drawn datarows
foreach (DataRow dr in datarowsDrawn)
this.datarowsToDraw.Remove(dr);
}
// Draw the Shape
if (reallyDraw)
aShape.Draw(context);
// Let's reset all tables for next iteration
if (aShape is Table) (aShape as Table).Reset();
}
}