当前位置: 首页>>代码示例>>C#>>正文


C# Pango.Layout.SetText方法代码示例

本文整理汇总了C#中Pango.Layout.SetText方法的典型用法代码示例。如果您正苦于以下问题:C# Pango.Layout.SetText方法的具体用法?C# Pango.Layout.SetText怎么用?C# Pango.Layout.SetText使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Pango.Layout的用法示例。


在下文中一共展示了Pango.Layout.SetText方法的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;
        }
开发者ID:knocte,项目名称:hyena,代码行数:34,代码来源:ShadingTestWindow.cs

示例2: FormattedTextImpl

        public FormattedTextImpl(
            Pango.Context context,
            string text,
            string fontFamily,
            double fontSize,
            FontStyle fontStyle,
            TextAlignment textAlignment,
            FontWeight fontWeight)
        {
            Contract.Requires<ArgumentNullException>(context != null);
            Contract.Requires<ArgumentNullException>(text != null);
            Layout = new Pango.Layout(context);
            _text = text;
            Layout.SetText(text);
            Layout.FontDescription = new Pango.FontDescription
            {
                Family = fontFamily,
                Size = Pango.Units.FromDouble(CorrectScale(fontSize)),
                Style = (Pango.Style)fontStyle,
                Weight = fontWeight.ToCairo()
            };

            Layout.Alignment = textAlignment.ToCairo();
            Layout.Attributes = new Pango.AttrList();
        }
开发者ID:CarlSosaDev,项目名称:Avalonia,代码行数:25,代码来源:FormattedTextImpl.cs

示例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);
            }
        }
开发者ID:Yetangitu,项目名称:f-spot,代码行数:25,代码来源:ThumbnailTextCaptionRenderer.cs

示例4: CodeSegmentPreviewWindow

		public CodeSegmentPreviewWindow (TextEditor editor, bool hideCodeSegmentPreviewInformString, ISegment segment, int width, int height) : base (Gtk.WindowType.Popup)
		{
			this.HideCodeSegmentPreviewInformString = hideCodeSegmentPreviewInformString;
			this.editor = editor;
			this.AppPaintable = true;
			layout = PangoUtil.CreateLayout (this);
			informLayout = PangoUtil.CreateLayout (this);
			informLayout.SetText (CodeSegmentPreviewInformString);
			
			fontDescription = Pango.FontDescription.FromString (editor.Options.FontName);
			fontDescription.Size = (int)(fontDescription.Size * 0.8f);
			layout.FontDescription = fontDescription;
			layout.Ellipsize = Pango.EllipsizeMode.End;
			// setting a max size for the segment (40 lines should be enough), 
			// no need to markup thousands of lines for a preview window
			int startLine = editor.Document.OffsetToLineNumber (segment.Offset);
			int endLine = editor.Document.OffsetToLineNumber (segment.EndOffset);
			const int maxLines = 40;
			bool pushedLineLimit = endLine - startLine > maxLines;
			if (pushedLineLimit)
				segment = new Segment (segment.Offset, editor.Document.GetLine (startLine + maxLines).Offset - segment.Offset);
			layout.Ellipsize = Pango.EllipsizeMode.End;
			layout.SetMarkup (editor.Document.SyntaxMode.GetMarkup (editor.Document,
			                                                        editor.Options,
			                                                        editor.ColorStyle,
			                                                        segment.Offset,
			                                                        segment.Length,
			                                                        true) + (pushedLineLimit ? Environment.NewLine + "..." : ""));
			CalculateSize ();
		}
开发者ID:transformersprimeabcxyz,项目名称:monodevelop-1,代码行数:30,代码来源:CodeSegmentPreviewWindow.cs

示例5: RenderLine

		protected override LayoutWrapper RenderLine (long line)
		{
			Pango.Layout layout = new Pango.Layout (Editor.PangoContext);
			layout.FontDescription = Editor.Options.Font;
			layout.SetText (string.Format ("{0:X}", line * Editor.BytesInRow));
			return new LayoutWrapper (layout);
		}
开发者ID:transformersprimeabcxyz,项目名称:monodevelop-1,代码行数:7,代码来源:GutterMargin.cs

示例6: 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;
     }
 }
开发者ID:kelsieflynn,项目名称:banshee,代码行数:9,代码来源:ColumnCellArtistText.cs

示例7: 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 ();
		}
开发者ID:transformersprimeabcxyz,项目名称:monodevelop-1,代码行数:9,代码来源:GutterMargin.cs

示例8: 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);
		}
开发者ID:transformersprimeabcxyz,项目名称:monodevelop-1,代码行数:11,代码来源:TextEditorMargin.cs

示例9: 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);
		}
开发者ID:transformersprimeabcxyz,项目名称:monodevelop-1,代码行数:21,代码来源:HexEditorMargin.cs

示例10: 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 ();
		}
开发者ID:transformersprimeabcxyz,项目名称:monodevelop-1,代码行数:14,代码来源:IconMargin.cs

示例11: Render

		protected override void Render (Drawable window, Widget widget, Gdk.Rectangle background_area, Gdk.Rectangle cell_area, Gdk.Rectangle expose_area, CellRendererState flags)
		{
			try{
				Gdk.Rectangle text_area1 = new Gdk.Rectangle();
			Gdk.Rectangle text_area2 = new Gdk.Rectangle();
			Gdk.Rectangle text_area3 = new Gdk.Rectangle();
				text_area1.Y= cell_area.Y;
				text_area2.Y= cell_area.Y+33;

				text_area3.X = cell_area.Width-20;
				text_area3.Y= cell_area.Y+33;
				text_area3.Width = 75;

				Pango.Layout text_l1 = new Pango.Layout(widget.PangoContext);
				text_l1.FontDescription = Pango.FontDescription.FromString ("Meiryo,Arial 10.5");
				text_l1.SetText(text1);

				Pango.Layout text_l2 = new Pango.Layout(widget.PangoContext);
				text_l2.FontDescription = Pango.FontDescription.FromString ("Meiryo,MS Gothic,Arial 8");
				text_l2.SetText(text2);
				text_l2.Alignment = Pango.Alignment.Right;


				Pango.Layout text_l3 = new Pango.Layout(widget.PangoContext);
				text_l3.Width = Pango.Units.FromPixels(text_area3.Width);
				text_l3.FontDescription = Pango.FontDescription.FromString ("Meiryo,MS Gothic,Arial 8");
				text_l3.Alignment = Pango.Alignment.Right;
				text_l3.SetText(text3);
				text_l2.Width = Pango.Units.FromPixels(cell_area.Width-text_l3.Text.Length*8-13);

				StateType state = flags.HasFlag(CellRendererState.Selected) ?
				widget.IsFocus ? StateType.Selected : StateType.Active : StateType.Normal;
				text_l3.SetMarkup("<span color=" + (char)34 + "grey" + (char)34 + ">" + text_l3.Text + "</span>");;
				window.DrawLayout(widget.Style.TextGC(state), 55, text_area1.Y, text_l1);
				window.DrawLayout(widget.Style.TextGC(state), 55, text_area2.Y, text_l2);
				window.DrawLayout(widget.Style.TextGC(state), text_area3.X, text_area3.Y, text_l3);

				text_l1.Dispose ();
				text_l2.Dispose ();
				text_l3.Dispose ();

			}catch(Exception e){
				Console.WriteLine (e);
			}

		}
开发者ID:takoyaki-hunter,项目名称:niconama-feeder,代码行数:46,代码来源:Program.cs

示例12: RenderLine

		protected override LayoutWrapper RenderLine (long line)
		{
			Pango.Layout layout = new Pango.Layout (Editor.PangoContext);
			layout.FontDescription = Editor.Options.Font;
			StringBuilder sb = new StringBuilder ();
			long startOffset = line * Editor.BytesInRow;
			long endOffset   = System.Math.Min (startOffset + Editor.BytesInRow, Data.Length);
			byte[] lineBytes = Data.GetBytes (startOffset, (int)(endOffset - startOffset));
			for (int i = 0; i < lineBytes.Length; i++) {
				byte b = lineBytes[i];
				char ch = (char)b;
				if (b < 128 && (Char.IsLetterOrDigit (ch) || Char.IsPunctuation (ch))) {
					sb.Append (ch);
				} else {
					sb.Append (".");
				}
			}
			
			layout.SetText (sb.ToString ());
			char[] lineChars = layout.Text.ToCharArray ();
			Margin.LayoutWrapper result = new LayoutWrapper (layout);
			uint curIndex = 0, byteIndex = 0;
			if (Data.IsSomethingSelected) {
				ISegment selection = Data.MainSelection.Segment;
				HandleSelection (selection.Offset, selection.EndOffset, startOffset, endOffset, null, delegate(long start, long end) {
					Pango.AttrForeground selectedForeground = new Pango.AttrForeground (Style.Selection.Red, 
					                                                                    Style.Selection.Green, 
					                                                                    Style.Selection.Blue);
					selectedForeground.StartIndex = TranslateToUTF8Index (lineChars, (uint)(start - startOffset), ref curIndex, ref byteIndex);
					selectedForeground.EndIndex = TranslateToUTF8Index (lineChars, (uint)(end - startOffset), ref curIndex, ref byteIndex);
					
					result.Add (selectedForeground);
					
					Pango.AttrBackground attrBackground = new Pango.AttrBackground (Style.SelectionBg.Red, 
					                                                                Style.SelectionBg.Green, 
					                                                                Style.SelectionBg.Blue);
					attrBackground.StartIndex = selectedForeground.StartIndex;
					attrBackground.EndIndex = selectedForeground.EndIndex;
					result.Add (attrBackground);

				});
			}
			result.SetAttributes ();
			return result;
		}
开发者ID:transformersprimeabcxyz,项目名称:monodevelop-1,代码行数:45,代码来源:TextEditorMargin.cs

示例13: 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);
            }
        }
开发者ID:revenz,项目名称:iMeta,代码行数:18,代码来源:TreeItemCellRenderer.cs

示例14: 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;
		}
开发者ID:FreeBSD-DotNet,项目名称:monodevelop,代码行数:42,代码来源:ExtendedLabel.cs

示例15: CodeSegmentPreviewWindow

		public CodeSegmentPreviewWindow (TextEditor editor, bool hideCodeSegmentPreviewInformString, TextSegment segment, int width, int height, bool removeIndent = true) : base (Gtk.WindowType.Popup)
		{
			this.HideCodeSegmentPreviewInformString = hideCodeSegmentPreviewInformString;
			this.Segment = segment;
			this.editor = editor;
			this.AppPaintable = true;
			this.SkipPagerHint = this.SkipTaskbarHint = true;
			this.TypeHint = WindowTypeHint.Menu;
			layout = PangoUtil.CreateLayout (this);
			informLayout = PangoUtil.CreateLayout (this);
			informLayout.SetText (CodeSegmentPreviewInformString);
			
			fontDescription = Pango.FontDescription.FromString (editor.Options.FontName);
			fontDescription.Size = (int)(fontDescription.Size * 0.8f);
			layout.FontDescription = fontDescription;
			layout.Ellipsize = Pango.EllipsizeMode.End;
			// setting a max size for the segment (40 lines should be enough), 
			// no need to markup thousands of lines for a preview window
			SetSegment (segment, removeIndent);
			CalculateSize (width);
		}
开发者ID:Kalnor,项目名称:monodevelop,代码行数:21,代码来源:CodeSegmentPreviewWindow.cs


注:本文中的Pango.Layout.SetText方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。