private void SetDataType(Type type) { dataType = type; alignment = Pango.Alignment.Right; format = String.Empty; switch (dataType.ToString()) { case "System.DateTime": format = "yyyy/MM/dd HH:mm:ss:fff"; columnSize = 25; alignment = Pango.Alignment.Left; break; case "System.Boolean": columnSize = 5; break; case "System.Byte": case "System.SByte": columnSize = 3; break; case "System.Single": columnSize = 12; break; case "System.Double": columnSize = 21; break; case "System.Int16": case "System.Unt16": columnSize = 5; break; case "System.Int32": case "System.UInt32": columnSize = 10; break; case "System.Int64": case "System.UInt64": columnSize = 20; break; case "System.Decimal": columnSize = 29; break; default: columnSize = -1; alignment = Pango.Alignment.Left; break; } }
//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))); }
public static TextAlignment ToEto(this Pango.Alignment alignment) { switch (alignment) { case Pango.Alignment.Left: return(TextAlignment.Left); case Pango.Alignment.Center: return(TextAlignment.Center); case Pango.Alignment.Right: return(TextAlignment.Right); default: throw new NotSupportedException(); } }
public TreeViewColumn CreateColumn(int columnNum, string columnName, Pango.Alignment alignment) { TreeViewColumn treeViewCol = new TreeViewColumn(); CellRendererText renderer = new CellRendererText(); renderer.Family = "courier new"; //renderer.Alignment = alignment; // only available in gtk# 2.10+ treeViewCol.Title = columnName; treeViewCol.PackStart(renderer, true); treeViewCol.AddAttribute(renderer, "text", columnNum); DataGridColumn gridCol = (DataGridColumn)gridColumns[columnNum]; gridCol.TreeViewColumn = treeViewCol; return(treeViewCol); }
private LayoutHelper(String text, Pango.Alignment alignment) { Text = text; Alignment = alignment; }
private void SetDataType (Type type) { dataType = type; alignment = Pango.Alignment.Right; format = String.Empty; switch (dataType.ToString ()) { case "System.DateTime": format = "yyyy/MM/dd HH:mm:ss:fff"; columnSize = 25; alignment = Pango.Alignment.Left; break; case "System.Boolean": columnSize = 5; break; case "System.Byte": case "System.SByte": columnSize = 3; break; case "System.Single": columnSize = 12; break; case "System.Double": columnSize = 21; break; case "System.Int16": case "System.Unt16": columnSize = 5; break; case "System.Int32": case "System.UInt32": columnSize = 10; break; case "System.Int64": case "System.UInt64": columnSize = 20; break; case "System.Decimal": columnSize = 29; break; default: columnSize = -1; alignment = Pango.Alignment.Left; break; } }