本文整理汇总了C#中Pango.Layout.GetPixelSize方法的典型用法代码示例。如果您正苦于以下问题:C# Pango.Layout.GetPixelSize方法的具体用法?C# Pango.Layout.GetPixelSize怎么用?C# Pango.Layout.GetPixelSize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Pango.Layout
的用法示例。
在下文中一共展示了Pango.Layout.GetPixelSize方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnDrawn
protected override bool OnDrawn(Cairo.Context cr)
{
double step_width = Allocation.Width / (double)steps;
double step_height = Allocation.Height / (double)steps;
double h = 1.0;
double s = 0.0;
for (int xi = 0, i = 0; xi < steps; xi++) {
for (int yi = 0; yi < steps; yi++, i++) {
double bg_b = (double)(i / 255.0);
double fg_b = 1.0 - bg_b;
double x = xi * step_width;
double y = yi * step_height;
cr.Rectangle (x, y, step_width, step_height);
cr.Color = CairoExtensions.ColorFromHsb (h, s, bg_b);
cr.Fill ();
int tw, th;
Pango.Layout layout = new Pango.Layout (PangoContext);
layout.SetText (((int)(bg_b * 255.0)).ToString ());
layout.GetPixelSize (out tw, out th);
cr.Translate (0.5, 0.5);
cr.MoveTo (x + (step_width - tw) / 2.0, y + (step_height - th) / 2.0);
cr.Color = CairoExtensions.ColorFromHsb (h, s, fg_b);
PangoCairoHelper.ShowLayout (cr, layout);
cr.Translate (-0.5, -0.5);
}
}
return true;
}
示例2: InitCell
public void InitCell (Widget container, bool diffMode, string[] lines, TreePath path)
{
if (isDisposed)
return;
this.lines = lines;
this.diffMode = diffMode;
this.path = path;
if (diffMode) {
if (lines != null && lines.Length > 0) {
int maxlen = -1;
int maxlin = -1;
for (int n=0; n<lines.Length; n++) {
if (lines [n].Length > maxlen) {
maxlen = lines [n].Length;
maxlin = n;
}
}
DisposeLayout ();
layout = CreateLayout (container, lines [maxlin]);
layout.GetPixelSize (out width, out lineHeight);
height = lineHeight * lines.Length;
}
else
width = height = 0;
}
else {
DisposeLayout ();
layout = CreateLayout (container, string.Join (Environment.NewLine, lines));
layout.GetPixelSize (out width, out height);
}
}
示例3: Render
public override void Render(Drawable window,
Widget widget,
Rectangle cell_area,
Rectangle expose_area,
StateType cell_state,
IPhoto photo)
{
string text = GetRenderText (photo);
var layout = new Pango.Layout (widget.PangoContext);
layout.SetText (text);
Rectangle layout_bounds;
layout.GetPixelSize (out layout_bounds.Width, out layout_bounds.Height);
layout_bounds.Y = cell_area.Y;
layout_bounds.X = cell_area.X + (cell_area.Width - layout_bounds.Width) / 2;
if (layout_bounds.IntersectsWith (expose_area)) {
Style.PaintLayout (widget.Style, window, cell_state,
true, expose_area, widget, "IconView",
layout_bounds.X, layout_bounds.Y,
layout);
}
}
示例4: ComputeRowHeight
public int ComputeRowHeight(Widget widget)
{
int w_width, row_height;
using (var layout = new Pango.Layout (widget.PangoContext)) {
layout.SetText ("W");
layout.GetPixelSize (out w_width, out row_height);
return row_height + 8;
}
}
示例5: ComputeRowHeight
public int ComputeRowHeight(Widget widget)
{
int lw, lh;
Pango.Layout layout = new Pango.Layout (widget.PangoContext);
layout.SetMarkup ("<big>W</big>");
layout.GetPixelSize (out lw, out lh);
layout.Dispose ();
return lh + 8;
}
示例6: OptionsChanged
internal protected override void OptionsChanged ()
{
Pango.Layout layout = new Pango.Layout (Editor.PangoContext);
layout.FontDescription = Editor.Options.Font;
layout.SetText (string.Format ("0{0:X}", Data.Length) + "_");
int height;
layout.GetPixelSize (out this.width, out height);
layout.Dispose ();
}
示例7: Measure
public override Gdk.Size Measure(Widget widget)
{
using (var layout = new Pango.Layout (widget.PangoContext)) {
int lw, lh;
layout.SetMarkup ("<b>W</b>\n<small><i>W</i></small>");
layout.GetPixelSize (out lw, out lh);
return new Gdk.Size (0, lh + 8);
}
}
示例8: BigList
public BigList (IListModel provider)
{
this.provider = provider;
//Accessibility
RefAccessible ().Role = Atk.Role.List;
adjustment = new Gtk.Adjustment (0, 0, provider.Rows, 1, 1, 1);
adjustment.ValueChanged += new EventHandler (ValueChangedHandler);
layout = new Pango.Layout (PangoContext);
ExposeEvent += new ExposeEventHandler (ExposeHandler);
ButtonPressEvent += new ButtonPressEventHandler (ButtonPressEventHandler);
ButtonReleaseEvent += new ButtonReleaseEventHandler (ButtonReleaseEventHandler);
KeyPressEvent += new KeyPressEventHandler (KeyHandler);
Realized += new EventHandler (RealizeHandler);
Unrealized += new EventHandler (UnrealizeHandler);
ScrollEvent += new ScrollEventHandler (ScrollHandler);
SizeAllocated += new SizeAllocatedHandler (SizeAllocatedHandler);
MotionNotifyEvent += new MotionNotifyEventHandler (MotionNotifyEventHandler);
AddEvents ((int) EventMask.ButtonPressMask | (int) EventMask.ButtonReleaseMask | (int) EventMask.KeyPressMask | (int) EventMask.PointerMotionMask);
CanFocus = true;
style_widget = new EventBox ();
style_widget.StyleSet += new StyleSetHandler (StyleHandler);
//
// Compute the height and ellipsis width of the font,
// and the en_width for our ellipsizing algorithm
//
layout.SetMarkup (ellipsis);
layout.GetPixelSize (out ellipsis_width, out line_height);
layout.SetMarkup ("n");
layout.GetPixelSize (out en_width, out line_height);
layout.SetMarkup ("W");
layout.GetPixelSize (out en_width, out line_height);
old_width = Allocation.Width;
}
示例9: OptionsChanged
internal protected override void OptionsChanged ()
{
Pango.Layout layout = new Pango.Layout (Editor.PangoContext);
layout.FontDescription = Editor.Options.Font;
layout.SetText (".");
int height;
layout.GetPixelSize (out charWidth, out height);
layout.Dispose ();
bgGC = GetGC (Style.HexDigitBg);
fgGC = GetGC (Style.HexDigit);
}
示例10: OptionsChanged
internal protected override void OptionsChanged ()
{
Pango.Layout layout = new Pango.Layout (Editor.PangoContext);
layout.FontDescription = Editor.Options.Font;
string groupString = new string ('0', Editor.Options.GroupBytes * 2);
layout.SetText (groupString + " ");
int lineHeight;
layout.GetPixelSize (out groupWidth, out lineHeight);
Data.LineHeight = lineHeight;
layout.SetText ("00");
layout.GetPixelSize (out byteWidth, out lineHeight);
layout.Dispose ();
tabArray = new Pango.TabArray (1, true);
tabArray.SetTab (0, Pango.TabAlign.Left, groupWidth);
bgGC = GetGC (Style.HexDigitBg);
fgGC = GetGC (Style.HexDigit);
}
示例11: OptionsChanged
internal protected override void OptionsChanged ()
{
backgroundGC = GetGC (Style.IconBarBg);
separatorGC = GetGC (Style.IconBarSeperator);
Pango.Layout layout = new Pango.Layout (Editor.PangoContext);
layout.FontDescription = Editor.Options.Font;
layout.SetText ("!");
int tmp;
layout.GetPixelSize (out tmp, out this.marginWidth);
marginWidth *= 12;
marginWidth /= 10;
layout.Dispose ();
}
示例12: OnExposeEvent
protected override bool OnExposeEvent (Gdk.EventExpose evt)
{
if (bitmap != null) {
Gdk.GC gc = Style.LightGC (StateType.Normal);
GdkWindow.DrawPixbuf (gc, bitmap, 0, 0, 0, 0, bitmap.Width, bitmap.Height, Gdk.RgbDither.None, 0, 0);
using (Pango.Layout pl = new Pango.Layout (PangoContext)) {
Pango.FontDescription des = this.Style.FontDescription.Copy();
pl.FontDescription = des;
//pl.SetMarkup("<b><span foreground='#cccccc'>" + BuildVariables.PackageVersionLabel + "</span></b>");
int w,h;
pl.GetPixelSize (out w, out h);
GdkWindow.DrawLayout (gc, bitmap.Width - w - 75, 90, pl);
des.Dispose ();
}
}
return base.OnExposeEvent (evt);
}
示例13: OnExposeEvent
protected override bool OnExposeEvent (Gdk.EventExpose evnt)
{
Pango.Layout la = new Pango.Layout (PangoContext);
int w, h;
if (UseMarkup)
la.SetMarkup (Text);
else
la.SetText (Text);
la.GetPixelSize (out w, out h);
int tx = Allocation.X + (int) Xpad + (int) ((float)(Allocation.Width - (int)(Xpad*2) - w) * Xalign);
int ty = Allocation.Y + (int) Ypad + (int) ((float)(Allocation.Height - (int)(Ypad*2) - h) * Yalign);
using (var ctx = CairoHelper.Create (evnt.Window)) {
ctx.SetSourceColor (Style.Text (State).ToCairoColor ());
ctx.MoveTo (tx, ty);
// In order to get the same result as in MonoDevelop.Components.DockNotebook.TabStrip.DrawTab()
// (document tabs) we need to draw using a LinearGradient (because of issues below),
// but we don't want to mask the actual text here, like in the doc tabs.
// Therefore we use a LinearGradient and mask only the last vertical pixel line
// of the label with 0.99 alpha, which forces Cairo to render the whole layout
// in the desired way.
// Semi-transparent gradient disables sub-pixel rendering of the label (reverting to grayscale antialiasing).
// As Mac sub-pixel font rendering looks stronger than grayscale rendering, the label used in pad tabs
// looked different. We need to simulate same gradient treatment as we have in document tabs.
using (var lg = new LinearGradient (tx + w - 1, 0, tx + w, 0)) {
var color = Style.Text (State).ToCairoColor ();
lg.AddColorStop (0, color);
color.A = 0.99;
lg.AddColorStop (1, color);
ctx.SetSource (lg);
Pango.CairoHelper.ShowLayout (ctx, la);
}
}
la.Dispose ();
return true;
}
示例14: InitCell
public void InitCell (Widget container, bool diffMode, string[] lines, TreePath path)
{
if (isDisposed)
return;
if (lines == null)
throw new ArgumentNullException ("lines");
this.lines = lines;
this.diffMode = diffMode;
this.path = path;
if (diffMode) {
if (lines != null && lines.Length > 0) {
int maxlen = -1;
int maxlin = -1;
for (int n=0; n<lines.Length; n++) {
string line = ProcessLine (lines [n]);
if (line == null)
throw new Exception ("Line " + n + " from diff was null.");
if (line.Length > maxlen) {
maxlen = lines [n].Length;
maxlin = n;
}
}
DisposeLayout ();
layout = CreateLayout (container, lines [maxlin]);
layout.GetPixelSize (out width, out lineHeight);
height = lineHeight * lines.Length;
width += LeftPaddingBlock + RightPadding;
}
else
width = height = 0;
}
else {
DisposeLayout ();
layout = CreateLayout (container, string.Join (Environment.NewLine, lines));
layout.GetPixelSize (out width, out height);
}
FontService.RegisterFontChangedCallback ("Editor", OnDiffFontChanged);
IdeApp.Preferences.CustomOutputPadFont.Changed += OnTextFontChanged;
}
示例15: OnExposeEvent
protected override bool OnExposeEvent (Gdk.EventExpose evnt)
{
if (!dropShadowVisible)
return base.OnExposeEvent (evnt);
Pango.Layout la = new Pango.Layout (PangoContext);
int w, h;
if (UseMarkup)
la.SetMarkup (Text);
else
la.SetText (Text);
la.GetPixelSize (out w, out h);
int tx = Allocation.X + (int) Xpad + (int) ((float)(Allocation.Width - (int)(Xpad*2) - w) * Xalign);
int ty = Allocation.Y + (int) Ypad + (int) ((float)(Allocation.Height - (int)(Ypad*2) - h) * Yalign);
GdkWindow.DrawLayout (Style.TextGC (State), tx, ty, la);
la.Dispose ();
return true;
}