本文整理汇总了C#中Gdk.DrawLayout方法的典型用法代码示例。如果您正苦于以下问题:C# Gdk.DrawLayout方法的具体用法?C# Gdk.DrawLayout怎么用?C# Gdk.DrawLayout使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Gdk
的用法示例。
在下文中一共展示了Gdk.DrawLayout方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Render
protected override void Render (Gdk.Drawable window, Widget widget, Gdk.Rectangle background_area, Gdk.Rectangle cell_area, Gdk.Rectangle expose_area, CellRendererState flags)
{
base.Render (window, widget, background_area, cell_area, expose_area, flags);
if (PackageSourceViewModel == null)
return;
using (var layout = new Pango.Layout (widget.PangoContext)) {
layout.Alignment = Pango.Alignment.Left;
layout.SetMarkup (GetPackageSourceNameMarkup ());
int packageSourceNameWidth = GetLayoutWidth (layout);
StateType state = GetState (widget, flags);
layout.SetMarkup (GetPackageSourceDescriptionMarkup ());
window.DrawLayout (widget.Style.TextGC (state), cell_area.X + textSpacing, cell_area.Y + textTopSpacing, layout);
if (!PackageSourceViewModel.IsValid) {
using (var ctx = Gdk.CairoHelper.Create (window)) {
ctx.DrawImage (widget, warningImage, cell_area.X + textSpacing + packageSourceNameWidth + imageSpacing, cell_area.Y + textTopSpacing);
}
layout.SetMarkup (GetPackageSourceErrorMarkup ());
int packageSourceErrorTextX = cell_area.X + textSpacing + packageSourceNameWidth + (int)warningImage.Width + (2 * imageSpacing);
window.DrawLayout (widget.Style.TextGC (state), packageSourceErrorTextX, cell_area.Y + textTopSpacing, layout);
}
}
}
示例2: Draw
internal protected override void Draw (Gdk.Drawable drawable, Gdk.Rectangle area, long line, int x, int y)
{
drawable.DrawRectangle (GetGC (Style.HexOffsetBg), true, x, y, Width, Editor.LineHeight);
LayoutWrapper layout = GetLayout (line);
int w, h;
layout.Layout.GetPixelSize (out w, out h);
drawable.DrawLayout (GetGC (line != Caret.Line ? Style.HexOffset : Style.HexOffsetHighlighted), x + Width - w - 4, y, layout.Layout);
if (layout.IsUncached)
layout.Dispose ();
}
示例3: Render
protected override void Render(Gdk.Drawable window, Widget widget, Gdk.Rectangle background_area, Gdk.Rectangle cell_area, Gdk.Rectangle expose_area, CellRendererState flags)
{
base.Render (window, widget, background_area, cell_area, expose_area, flags);
int xPos = cell_area.X;
if(this.Pixbuf != null){
window.DrawPixbuf(widget.Style.MidGC( StateType.Normal), this.Pixbuf, 0, 0, xPos + 1, cell_area.Y + 1, 16, 16, Gdk.RgbDither.Normal, 0, 0);
xPos += 20;
}
using (var layout = new Pango.Layout(widget.PangoContext)) {
layout.Alignment = Pango.Alignment.Left;
layout.SetText(this.Text ?? "");
StateType state = flags.HasFlag(CellRendererState.Selected) ?
widget.IsFocus ? StateType.Selected : StateType.Active : StateType.Normal;
window.DrawLayout(widget.Style.TextGC(state), xPos, cell_area.Y + 2, layout);
}
}
示例4: Draw
/// <summary>
/// Render an annotation on each line
/// </summary>
protected override void Draw (Gdk.Drawable drawable, Gdk.Rectangle area, int line, int x, int y, int lineHeight)
{
string ann = (line < annotations.Count)? annotations[line]: string.Empty;
Gdk.Rectangle drawArea = new Gdk.Rectangle (x, y, Width, lineHeight);
drawable.DrawRectangle (locallyModified.Equals (ann, StringComparison.Ordinal)? locallyModifiedGC: lineNumberBgGC, true, drawArea);
if (!locallyModified.Equals (ann, StringComparison.Ordinal) &&
(line < annotations.Count)) {
layout.SetText (annotations[line]);
drawable.DrawLayout ((editor.Caret.Line == line)? lineNumberHighlightGC: lineNumberGC, x + 1, y, layout);
}
}
示例5: DrawText
void DrawText(Gdk.Window window, Cairo.Context cr, string text)
{
bool theme;
Gdk.GC light;
const int marginx = 10;
int winWidth, winHeight, w, h;
window.GetSize (out winWidth, out winHeight);
if (project != null && project.Details.Theme != null) {
theme = true;
}
else
theme = false;
if (theme == true) {
if (winWidth > project.Details.Width)
winWidth = project.Details.Width;
if (winHeight > project.Details.Height)
winHeight = project.Details.Height;
}
Pango.Layout layout = new Pango.Layout (this.PangoContext);
layout.Width = winWidth * (int) Pango.Scale.PangoScale;
layout.SetMarkup (text);
layout.GetPixelSize (out w, out h);
if (theme) {
// TODO: We should force the ink colour too
cr.Color = new Cairo.Color (0, 0, 0, 0.7);
cr.Rectangle (((winWidth - w) /2) - marginx, (winHeight / 2), w + marginx * 2, h * 2);
cr.Fill ();
cr.Stroke ();
light = Style.LightGC (StateType.Normal);
}
light = Style.DarkGC (StateType.Normal);
window.DrawLayout (light, (winWidth - w) /2, (winHeight / 2) + 4, layout);
layout.Dispose ();
}
示例6: DrawCodeSegmentBorder
void DrawCodeSegmentBorder (Gdk.GC gc, Cairo.Context ctx, double x, int width, BlockInfo firstBlock, BlockInfo lastBlock, string[] lines, Gtk.Widget widget, Gdk.Drawable window)
{
int shadowSize = 2;
int spacing = 4;
int bottomSpacing = (lineHeight - spacing) / 2;
ctx.Rectangle (x + shadowSize + 0.5, firstBlock.YStart + bottomSpacing + spacing - shadowSize + 0.5, width - shadowSize*2, shadowSize);
ctx.Color = new Cairo.Color (0.9, 0.9, 0.9);
ctx.LineWidth = 1;
ctx.Fill ();
ctx.Rectangle (x + shadowSize + 0.5, lastBlock.YEnd + bottomSpacing + 0.5, width - shadowSize*2, shadowSize);
ctx.Color = new Cairo.Color (0.9, 0.9, 0.9);
ctx.Fill ();
ctx.Rectangle (x + 0.5, firstBlock.YStart + bottomSpacing + spacing + 0.5, width, lastBlock.YEnd - firstBlock.YStart - spacing);
ctx.Color = new Cairo.Color (0.7,0.7,0.7);
ctx.Stroke ();
string text = lines[firstBlock.FirstLine].Replace ("@","").Replace ("-","");
text = "<span size='x-small'>" + text.Replace ("+","</span><span size='small'>➜</span><span size='x-small'> ") + "</span>";
layout.SetText ("");
layout.SetMarkup (text);
int tw,th;
layout.GetPixelSize (out tw, out th);
th--;
int dy = (lineHeight - th) / 2;
ctx.Rectangle (x + 2 + LeftPaddingBlock - 1 + 0.5, firstBlock.YStart + dy - 1 + 0.5, tw + 2, th + 2);
ctx.LineWidth = 1;
ctx.Color = widget.Style.Base (Gtk.StateType.Normal).ToCairoColor ();
ctx.FillPreserve ();
ctx.Color = new Cairo.Color (0.7, 0.7, 0.7);
ctx.Stroke ();
window.DrawLayout (gc, (int)(x + 2 + LeftPaddingBlock), firstBlock.YStart + dy, layout);
}
示例7: DrawString
float DrawString(Gdk.Drawable g, Gdk.GC gc, Pango.FontDescription font, float x, float y, string s)
{
Pango.Layout ly = _layout;
ly.FontDescription = font;
ly.SetText(s);
g.DrawLayout(gc, (int) Math.Round(x), (int) Math.Round(y), ly);
int size = (int)Math.Round(ly.Size.Width/1024.0f);
return size;
}
示例8: DrawEolMarker
void DrawEolMarker (Gdk.Drawable win, LineSegment line, bool selected, int x, int y)
{
switch (line.DelimiterLength) {
case 1:
if (Document.GetCharAt (line.Offset + line.EditableLength) == '\n') {
markerLayout.SetText ("\\n");
} else {
markerLayout.SetText ("\\r");
}
break;
case 2:
markerLayout.SetText ("\\r\\n");
break;
case 4:
markerLayout.SetText ("<EOL>");
break;
}
win.DrawLayout (GetGC (selected ? SelectionColor.Color : ColorStyle.WhitespaceMarker), x, y, markerLayout);
}
示例9: Render
//.........这里部分代码省略.........
view.Theme.DrawArrow (view.Cr, r, source.Expanded ? Math.PI/2.0 : 0.0);
}
if (!np_etc) {
x += (int) exp_w;
x += 2; // a little spacing after the expander
expander_right_x = x;
}
// Draw icon
Pixbuf icon = SourceIconResolver.ResolveIcon (source, RowHeight);
bool dispose_icon = false;
if (state == StateType.Insensitive) {
// Code ported from gtk_cell_renderer_pixbuf_render()
var icon_source = new IconSource () {
Pixbuf = icon,
Size = IconSize.SmallToolbar,
SizeWildcarded = false
};
icon = widget.Style.RenderIcon (icon_source, widget.Direction, state,
(IconSize)(-1), widget, "SourceRowRenderer");
dispose_icon = true;
icon_source.Dispose ();
}
if (icon != null) {
x += expander_icon_spacing;
drawable.DrawPixbuf (main_gc, icon, 0, 0,
x, Middle (cell_area, icon.Height),
icon.Width, icon.Height, RgbDither.None, 0, 0);
x += icon.Width;
if (dispose_icon) {
icon.Dispose ();
}
}
// Setup font info for the title/count, and see if we should show the count
bool hide_count = source.EnabledCount <= 0 || source.Properties.Get<bool> ("SourceView.HideCount");
FontDescription fd = widget.PangoContext.FontDescription.Copy ();
fd.Weight = (ISource)ServiceManager.PlaybackController.NextSource == (ISource)source
? Pango.Weight.Bold
: Pango.Weight.Normal;
if (view != null && source == view.NewPlaylistSource) {
fd.Style = Pango.Style.Italic;
hide_count = true;
}
Pango.Layout title_layout = new Pango.Layout (widget.PangoContext);
Pango.Layout count_layout = null;
// If we have a count to draw, setup its fonts and see how wide it is to see if we have room
if (!hide_count) {
count_layout = new Pango.Layout (widget.PangoContext);
count_layout.FontDescription = fd;
count_layout.SetMarkup (String.Format ("<span size=\"small\">{0}</span>", source.EnabledCount));
count_layout.GetPixelSize (out count_layout_width, out count_layout_height);
}
// Hide the count if the title has no space
max_title_layout_width = cell_area.Width - x - count_layout_width;//(icon == null ? 0 : icon.Width) - count_layout_width - 10;
if (!hide_count && max_title_layout_width <= 0) {
hide_count = true;
}
// Draw the source Name
title_layout.FontDescription = fd;
title_layout.Width = (int)(max_title_layout_width * Pango.Scale.PangoScale);
title_layout.Ellipsize = EllipsizeMode.End;
title_layout.SetText (source.Name);
title_layout.GetPixelSize (out title_layout_width, out title_layout_height);
x += img_padding;
drawable.DrawLayout (main_gc, x, Middle (cell_area, title_layout_height), title_layout);
title_layout.Dispose ();
// Draw the count
if (!hide_count) {
if (view != null && view.Cr != null) {
view.Cr.Color = state == StateType.Normal || (view != null && state == StateType.Prelight)
? view.Theme.TextMidColor
: view.Theme.Colors.GetWidgetColor (GtkColorClass.Text, state);
view.Cr.MoveTo (
cell_area.X + cell_area.Width - count_layout_width - 2,
cell_area.Y + 0.5 + (double)(cell_area.Height - count_layout_height) / 2.0);
PangoCairoHelper.ShowLayout (view.Cr, count_layout);
}
count_layout.Dispose ();
}
fd.Dispose ();
}
示例10: draw
public void draw(Gdk.Window win, Gdk.Color terr, Gdk.Color textcolor, Pango.Context pango_context)
{
Gdk.GC textcoloring = new Gdk.GC(win);
textcoloring.RgbFgColor = textcolor;
int carriedUnits = 0;
string extraLabel = "";
GraphicsStorage store = GraphicsStorage.GetInstance();
int cenTerrX = MapTerritory.centerX;
int cenTerrY = MapTerritory.centerY;
/* Show flag */
Gdk.Pixbuf flag = store.AppropriateFlag(owner.CountryID);
if (flag != null && owner.Active)
win.DrawPixbuf(textcoloring, flag, 0, 0, cenTerrX, cenTerrY, flag.Width, flag.Height, RgbDither.Normal, 1, 1);
/* Draw the map */
MapTerritory.draw(win, terr, textcolor);
/* Show radiation if destroyed */
if (destroyed)
win.DrawPixbuf(textcoloring, store.Radiation, 0, 0, cenTerrX, cenTerrY, store.Radiation.Width, store.Radiation.Height, RgbDither.Normal, 1, 1);
/* Determine personnel carrier status */
foreach(TacticalUnit joe in units)
carriedUnits += joe.UnitsAboardCount;
if (carriedUnits > 0)
extraLabel = "(" + carriedUnits + ")";
/* Draw the first N units staggered, then use a label to show further #'s */
for (int offset=0; offset < units.Count && offset < 3; offset++)
{
((TacticalUnit)units[offset]).draw(win, offset*5);
}
/* Label */
if (units.Count > 1 || carriedUnits > 0)
{
Pango.Layout label = new Pango.Layout (pango_context);
label.Wrap = Pango.WrapMode.Word;
label.FontDescription = FontDescription.FromString ("Tahoma 8");
label.SetMarkup ( units.Count.ToString() + extraLabel );
int szX, szY;
label.GetPixelSize(out szX, out szY);
/*Redraw*/
// win.InvalidateRect(new Gdk.Rectangle(MapTerritory.centerX, MapTerritory.centerY, szX, szY), true);
win.DrawLayout (textcoloring, MapTerritory.centerX, MapTerritory.centerY, label);
}
}
示例11: Draw
public void Draw (TextEditor editor, Gdk.Drawable win, int lineNr, Gdk.Rectangle lineArea)
{
EnsureLayoutCreated (editor);
int lineNumber = editor.Document.OffsetToLineNumber (lineSegment.Offset);
int errorNumber = lineNr - lineNumber;
int x = editor.TextViewMargin.XOffset;
int y = lineArea.Y;
int right = editor.Allocation.Width;
int errorCounterWidth = 0;
int ew = 0, eh = 0;
if (errors.Count > 1 && errorCountLayout != null) {
errorCountLayout.GetPixelSize (out ew, out eh);
errorCounterWidth = ew + 10;
}
int x2 = System.Math.Max (right - LayoutWidth - border - (ShowIconsInBubble ? errorPixbuf.Width : 0) - errorCounterWidth, fitsInSameLine ? editor.TextViewMargin.XOffset + editor.LineHeight / 2 : editor.TextViewMargin.XOffset);
// bool isEolSelected = editor.IsSomethingSelected && editor.SelectionMode != SelectionMode.Block ? editor.SelectionRange.Contains (lineSegment.Offset + lineSegment.EditableLength) : false;
int active = editor.Document.GetTextAt (lineSegment) == initialText ? 0 : 1;
bool isCaretInLine = lineSegment.Offset <= editor.Caret.Offset && editor.Caret.Offset <= lineSegment.EndOffset;
int highlighted = active == 0 && isCaretInLine ? 1 : 0;
int selected = 0;
LayoutDescriptor layout = layouts[errorNumber];
x2 = right - LayoutWidth - border - (ShowIconsInBubble ? errorPixbuf.Width : 0);
x2 -= errorCounterWidth;
x2 = System.Math.Max (x2, fitsInSameLine ? editor.TextViewMargin.XOffset + editor.LineHeight / 2 : editor.TextViewMargin.XOffset);
using (var g = Gdk.CairoHelper.Create (win)) {
g.LineWidth = Math.Max (1.0, editor.Options.Zoom);
g.MoveTo (new Cairo.PointD (x2 + 0.5, y));
g.LineTo (new Cairo.PointD (x2 + 0.5, y + editor.LineHeight));
g.LineTo (new Cairo.PointD (right, y + editor.LineHeight));
g.LineTo (new Cairo.PointD (right, y));
g.ClosePath ();
g.Color = colorMatrix[active, BOTTOM, LIGHT, highlighted, selected];
g.Fill ();
g.Color = colorMatrix[active, BOTTOM, LINE, highlighted, selected];
g.MoveTo (new Cairo.PointD (x2 + 0.5, y));
g.LineTo (new Cairo.PointD (x2 + 0.5, y + editor.LineHeight));
if (errorNumber == errors.Count - 1)
g.LineTo (new Cairo.PointD (lineArea.Right, y + editor.LineHeight));
g.Stroke ();
if (editor.Options.ShowRuler) {
int divider = Math.Max (editor.TextViewMargin.XOffset, x + editor.TextViewMargin.RulerX);
if (divider >= x2) {
g.MoveTo (new Cairo.PointD (divider + 0.5, y));
g.LineTo (new Cairo.PointD (divider + 0.5, y + editor.LineHeight));
g.Color = colorMatrix[active, BOTTOM, DARK, highlighted, selected];
g.Stroke ();
}
}
}
win.DrawLayout (selected == 0 ? gc : gcSelected, x2 + (ShowIconsInBubble ? errorPixbuf.Width : 0) + border, y + (editor.LineHeight - layout.Height) / 2 + layout.Height % 2, layout.Layout);
if (ShowIconsInBubble)
win.DrawPixbuf (editor.Style.BaseGC (Gtk.StateType.Normal), errors[errorNumber].IsError ? errorPixbuf : warningPixbuf, 0, 0, x2, y + (editor.LineHeight - errorPixbuf.Height) / 2, errorPixbuf.Width, errorPixbuf.Height, Gdk.RgbDither.None, 0, 0);
}
示例12: Draw
internal protected override void Draw (Gdk.Drawable drawable, Gdk.Rectangle area, long line, int x, int y)
{
drawable.DrawRectangle (bgGC, true, x, y, Width, Editor.LineHeight);
LayoutWrapper layout = GetLayout (line);
if (!Data.IsSomethingSelected && Caret.InTextEditor && line == Data.Caret.Line) {
drawable.DrawRectangle (GetGC (Style.HighlightOffset), true, CalculateCaretXPos (false), y, byteWidth, Editor.LineHeight);
}
drawable.DrawLayout (fgGC, x, y, layout.Layout);
if (layout.IsUncached)
layout.Dispose ();
}
示例13: DrawCoords
private void DrawCoords(Gdk.Window window)
{
Gdk.GC gc;
gc = Style.ForegroundGC (StateType.Normal);
window.DrawRectangle (gc, false,
start_x - space - size / 5,
start_y - space - size / 5,
(size + space) * 8 +
2 * size / 5,
(size + space) * 8 +
2 * size / 5);
string letters = "abcdefgh";
for (int i = 0; i < 8; i++)
{
layout.SetText ((letters[i]).ToString ());
window.DrawLayout (Style.
TextGC (StateType.
Normal),
start_x + size / 2 +
(size + space) * i,
start_y - size / 5 -
2 * space, layout);
window.DrawLayout (Style.
TextGC (StateType.
Normal),
start_x + size / 2 +
(size + space) * i,
start_y + (size +
space) * 8 -
2 * space, layout);
}
string numbers = "12345678";
if (!side)
numbers = "87654321";
for (int i = 0; i < 8; i++)
{
layout.SetText ((numbers[i]).ToString ());
window.DrawLayout (Style.
TextGC (StateType.
Normal),
start_x - size / 5,
start_y + size / 2 +
(size + space) * i,
layout);
window.DrawLayout (Style.
TextGC (StateType.
Normal),
start_x + (size +
space) * 8,
start_y + size / 2 +
(size + space) * i,
layout);
}
}
示例14: Render
protected override void Render (Gdk.Drawable drawable, Widget widget, Gdk.Rectangle background_area,
Gdk.Rectangle cell_area, Gdk.Rectangle expose_area, CellRendererState flags)
{
if (source == null) {
return;
}
view = widget as SourceView;
bool selected = view != null && view.Selection.IterIsSelected (iter);
StateType state = RendererStateToWidgetState (widget, flags);
RenderSelection (drawable, background_area, selected, state);
int title_layout_width = 0, title_layout_height = 0;
int count_layout_width = 0, count_layout_height = 0;
int max_title_layout_width;
bool hide_counts = source.EnabledCount <= 0;
Pixbuf icon = SourceIconResolver.ResolveIcon (source, RowHeight);
bool dispose_icon = false;
if (state == StateType.Insensitive) {
// Code ported from gtk_cell_renderer_pixbuf_render()
var icon_source = new IconSource () {
Pixbuf = icon,
Size = IconSize.SmallToolbar,
SizeWildcarded = false
};
icon = widget.Style.RenderIcon (icon_source, widget.Direction, state,
(IconSize)(-1), widget, "SourceRowRenderer");
dispose_icon = true;
icon_source.Dispose ();
}
FontDescription fd = widget.PangoContext.FontDescription.Copy ();
fd.Weight = (ISource)ServiceManager.PlaybackController.NextSource == (ISource)source
? Pango.Weight.Bold
: Pango.Weight.Normal;
if (view != null && source == view.NewPlaylistSource) {
fd.Style = Pango.Style.Italic;
hide_counts = true;
}
Pango.Layout title_layout = new Pango.Layout (widget.PangoContext);
Pango.Layout count_layout = null;
if (!hide_counts) {
count_layout = new Pango.Layout (widget.PangoContext);
count_layout.FontDescription = fd;
count_layout.SetMarkup (String.Format ("<span size=\"small\">{0}</span>", source.EnabledCount));
count_layout.GetPixelSize (out count_layout_width, out count_layout_height);
}
max_title_layout_width = cell_area.Width - (icon == null ? 0 : icon.Width) - count_layout_width - 10;
if (!hide_counts && max_title_layout_width < 0) {
hide_counts = true;
}
title_layout.FontDescription = fd;
title_layout.Width = (int)(max_title_layout_width * Pango.Scale.PangoScale);
title_layout.Ellipsize = EllipsizeMode.End;
title_layout.SetText (source.Name);
title_layout.GetPixelSize (out title_layout_width, out title_layout_height);
Gdk.GC main_gc = widget.Style.TextGC (state);
drawable.DrawLayout (main_gc,
cell_area.X + (icon == null ? 0 : icon.Width) + 6,
Middle (cell_area, title_layout_height),
title_layout);
title_layout.Dispose ();
if (icon != null) {
drawable.DrawPixbuf (main_gc, icon, 0, 0,
cell_area.X, Middle (cell_area, icon.Height),
icon.Width, icon.Height, RgbDither.None, 0, 0);
if (dispose_icon) {
icon.Dispose ();
}
}
if (hide_counts) {
fd.Dispose ();
return;
}
if (view != null && view.Cr != null) {
view.Cr.Color = state == StateType.Normal || (view != null && state == StateType.Prelight)
? view.Theme.TextMidColor
: view.Theme.Colors.GetWidgetColor (GtkColorClass.Text, state);
view.Cr.MoveTo (
cell_area.X + cell_area.Width - count_layout_width - 2,
//.........这里部分代码省略.........
示例15: draw
public void draw(Gdk.Window win, Gdk.Color terr, Gdk.Color textcolor)
{
if (label == null)
{
/* Make label */
label = new Pango.Layout (Game.GetInstance().GUI.Map.PangoContext);
label.Wrap = Pango.WrapMode.Word;
label.Alignment = Pango.Alignment.Center;
label.FontDescription = FontDescription.FromString ("Tahoma 9");
label.SetMarkup (Name);
}
Gdk.GC field = new Gdk.GC(win);
Gdk.GC text = new Gdk.GC(win);
field.RgbFgColor = terr;
// Add transparency, somehow...
text.RgbFgColor = textcolor;
//win.DrawPolygon(field, false, borders);
win.DrawLayout (text, mathCenterX, mathCenterY, label);
}