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


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

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


在下文中一共展示了Pango.Layout.SetMarkup方法的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);
				}
			}
		}
开发者ID:Kalnor,项目名称:monodevelop,代码行数:28,代码来源:PackageSourceCellRenderer.cs

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

示例3: 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;
 }
开发者ID:abock,项目名称:cubano,代码行数:9,代码来源:CubanoTitleCell.cs

示例4: 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;
	}
开发者ID:alfredodev,项目名称:mono-tools,代码行数:43,代码来源:list.cs

示例5: 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

示例6: 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

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

示例8: AddOverload

		public void AddOverload (CompletionData data)
		{
			var tooltipInformation = data.CreateTooltipInformation (false);
			if (string.IsNullOrEmpty (tooltipInformation.SignatureMarkup))
				return;

			using (var layout = new Pango.Layout (PangoContext)) {
				var des = FontService.GetFontDescription ("Editor");
				layout.FontDescription = des;
				layout.SetMarkup (tooltipInformation.SignatureMarkup);
				int w, h;
				layout.GetPixelSize (out w, out h);
				if (w >= Allocation.Width - 10) {
					tooltipInformation = data.CreateTooltipInformation (true);
				}
			}
			AddOverload (tooltipInformation);
		}
开发者ID:hippiehunter,项目名称:monodevelop,代码行数:18,代码来源:TooltipInformationWindow.cs

示例9: Render

		protected override void Render (Gdk.Drawable window, Widget widget, Gdk.Rectangle background_area, Gdk.Rectangle cell_area, Gdk.Rectangle expose_area, CellRendererState flags)
		{
			using (var cr = Gdk.CairoHelper.Create (window)) {
				Pango.Rectangle ink, logical;
				using (var layout = new Pango.Layout (Context)) {
					layout.FontDescription = font;
					layout.SetMarkup (GetFileMarkup ((flags & CellRendererState.Selected) != 0));
					layout.GetPixelExtents (out ink, out logical);
					var width = widget.Allocation.Width;
					cr.Translate (width - logical.Width - 10, cell_area.Y);
					cr.ShowLayout (layout);

					cr.IdentityMatrix ();

					layout.SetMarkup (GetMethodMarkup ((flags & CellRendererState.Selected) != 0));
					layout.Width = (int)((width - logical.Width - 35) * Pango.Scale.PangoScale);
					layout.Ellipsize = Pango.EllipsizeMode.Middle;
					cr.Translate (cell_area.X + 10, cell_area.Y);
					cr.ShowLayout (layout);
				}
			}
		}
开发者ID:kdubau,项目名称:monodevelop,代码行数:22,代码来源:ExceptionCaughtDialog.cs

示例10: GetSize

		public override void GetSize (Widget widget, ref Gdk.Rectangle cell_area, out int x_offset, out int y_offset, out int width, out int height)
		{
			using (var layout = new Pango.Layout (Context)) {
				Pango.Rectangle ink, logical;
				layout.FontDescription = font;
				layout.SetMarkup (GetMethodMarkup (false));
				layout.GetPixelExtents (out ink, out logical);

				height = logical.Height;
				width = 0;
				x_offset = 0;
				y_offset = 0;
			}
		}
开发者ID:kdubau,项目名称:monodevelop,代码行数:14,代码来源:ExceptionCaughtDialog.cs

示例11: OnSizeAllocated

			protected override void OnSizeAllocated (Gdk.Rectangle allocation)
			{
				base.OnSizeAllocated (allocation);
				if (!resizeRequested)
					return;
				using (var layout = new Pango.Layout (this.PangoContext)) {
					layout.Width = (int)(allocation.Width * Pango.Scale.PangoScale);
					layout.Wrap = Pango.WrapMode.Word;
					layout.Alignment = Pango.Alignment.Left;
					layout.SetMarkup (Markup);
					int w, h;
					layout.GetPixelSize (out w, out h);
					if (h > 0 && h != allocation.Height) {
						HeightRequest = h;
						resizeRequested = false;
						QueueResize ();
					}
				}
			
			}
开发者ID:rajeshpillai,项目名称:monodevelop,代码行数:20,代码来源:ParameterInformationWindow.cs

示例12: InsertionCursorLayoutModeHelpWindow

		public InsertionCursorLayoutModeHelpWindow ()
		{
			titleLayout = new Pango.Layout (PangoContext);
			descriptionLayout = new Pango.Layout (PangoContext);
			descriptionLayout.SetMarkup ("<small>Use Up/Down to move to another location.\nPress Enter to select the location\nPress Esc to cancel this operation</small>");
		}
开发者ID:RainsSoft,项目名称:playscript-monodevelop,代码行数:6,代码来源:ModeHelpWindow.cs

示例13: DrawAfterEol

		public override void DrawAfterEol (TextEditor textEditor, Cairo.Context g, double y, EndOfLineMetrics metrics)
		{
			if (!IsVisible)
				return;
			EnsureLayoutCreated (editor);
			int errorCounterWidth = 0, eh = 0;
			if (errorCountLayout != null) {
				errorCountLayout.GetPixelSize (out errorCounterWidth, out eh);
				errorCounterWidth = Math.Max (15, Math.Max (errorCounterWidth + 3, (int)(editor.LineHeight * 3 / 4)));
			}

			var sx = metrics.TextRenderEndPosition;
			var width = LayoutWidth + errorCounterWidth + editor.LineHeight;
			var drawLayout = layouts[0].Layout;
			int ex = 0 , ey = 0;
			bool customLayout = true; //sx + width > editor.Allocation.Width;
			bool hideText = false;
			bubbleIsReduced = customLayout;
			var showErrorCount = errorCounterWidth > 0 && errorCountLayout != null;
			if (customLayout) {
				width = editor.Allocation.Width - sx;
				string text = layouts[0].Layout.Text;
				drawLayout = new Pango.Layout (editor.PangoContext);
				drawLayout.FontDescription = cache.fontDescription;
				var paintWidth = (width - errorCounterWidth - editor.LineHeight + 4);
				var minWidth = Math.Max (17, errorCounterWidth) + editor.LineHeight;
				if (paintWidth < minWidth) {
					hideText = true;
					drawLayout.SetMarkup ("<span weight='heavy'>···</span>");
					width = minWidth;
					showErrorCount = false;
					sx = Math.Min (sx, editor.Allocation.Width - width);
				} else {
					drawLayout.Ellipsize = Pango.EllipsizeMode.End;
					drawLayout.Width = (int)(paintWidth * Pango.Scale.PangoScale);
					drawLayout.SetText (text);
					int w2, h2;
					drawLayout.GetPixelSize (out w2, out h2);
					width = w2 + errorCounterWidth + editor.LineHeight;
				}
			}
			bubbleDrawX = sx - editor.TextViewMargin.XOffset;
			bubbleDrawY = y;
			bubbleWidth = width;

			var bubbleHeight = editor.LineHeight - 1;
			g.RoundedRectangle (sx, y + 1, width, bubbleHeight, editor.LineHeight / 2 - 1);
			g.SetSourceColor (TagColor.Color);
			g.Fill ();

			// Draw error count icon
			if (showErrorCount) {
				var errorCounterHeight = bubbleHeight - 2;
				var errorCounterX = sx + width - errorCounterWidth - 3;
				var errorCounterY = y + 1 + (bubbleHeight - errorCounterHeight) / 2;

				g.RoundedRectangle (
					errorCounterX - 1, 
					errorCounterY - 1, 
					errorCounterWidth + 2, 
					errorCounterHeight + 2, 
					editor.LineHeight / 2 - 3
				);

				g.SetSourceColor (new Cairo.Color (0, 0, 0, 0.081));
				g.Fill ();

				g.RoundedRectangle (
					errorCounterX, 
					errorCounterY, 
					errorCounterWidth, 
					errorCounterHeight, 
					editor.LineHeight / 2 - 3
				);
				using (var lg = new Cairo.LinearGradient (errorCounterX, errorCounterY, errorCounterX, errorCounterY + errorCounterHeight)) {
					lg.AddColorStop (0, CounterColor.Color);
					lg.AddColorStop (1, CounterColor.Color.AddLight (-0.1));
					g.Pattern = lg;
					g.Fill ();
				}

				g.Save ();

				int ew;
				errorCountLayout.GetPixelSize (out ew, out eh);

				g.Translate (
					errorCounterX + (errorCounterWidth - ew) / 2,
					errorCounterY + (errorCounterHeight - eh) / 2
				);
				g.SetSourceColor (CounterColor.SecondColor);
				g.ShowLayout (errorCountLayout);
				g.Restore ();
			}

			// Draw label text
			if (!showErrorCount || !hideText) {
				g.Save ();
				g.Translate (sx + editor.LineHeight / 2, y + (editor.LineHeight - layouts [0].Height) / 2 + 1);

//.........这里部分代码省略.........
开发者ID:llucenic,项目名称:monodevelop,代码行数:101,代码来源:MessageBubbleTextMarker.cs

示例14: CreateLayout

			private void CreateLayout ()
			{
				if (layout != null) {
					layout.Dispose ();
				}
				
				layout = PangoUtil.CreateLayout (this, null);
				if (use_markup) {
					layout.SetMarkup (brokentext != null? brokentext : (text ?? string.Empty));
				} else {
					layout.SetText (brokentext != null? brokentext : (text ?? string.Empty));
				}
				layout.Indent = (int) (indent * Pango.Scale.PangoScale);
				layout.Wrap = wrapMode;
				if (width >= 0)
					layout.Width = (int)(width * Pango.Scale.PangoScale);
				else
					layout.Width = int.MaxValue;
				QueueResize ();
			}
开发者ID:RainsSoft,项目名称:playscript-monodevelop,代码行数:20,代码来源:TooltipWindow.cs

示例15: OnExposeEvent

        protected override bool OnExposeEvent(Gdk.EventExpose evnt)
        {
            using (var ctx = Gdk.CairoHelper.Create (evnt.Window)) {
                if (mouseOver)
                    DrawHoverBackground (ctx);

                // Draw the icon
                DrawIcon (ctx);

                // Draw the text

                int textWidth = Allocation.Width - LeftTextPadding - InternalPadding * 2;

                Pango.Layout titleLayout = new Pango.Layout (PangoContext);
                titleLayout.Width = Pango.Units.FromPixels (textWidth);
                titleLayout.Ellipsize = Pango.EllipsizeMode.End;
                titleLayout.SetMarkup (WelcomePageSection.FormatText (TitleFontFace, titleFontSize, TitleFontWeight, MediumTitleColor, title));

                Pango.Layout subtitleLayout = null;

                if (!string.IsNullOrEmpty (subtitle)) {
                    subtitleLayout = new Pango.Layout (PangoContext);
                    subtitleLayout.Width = Pango.Units.FromPixels (textWidth);
                    subtitleLayout.Ellipsize = Pango.EllipsizeMode.Start;
                    subtitleLayout.SetMarkup (WelcomePageSection.FormatText (SmallTitleFontFace, smallTitleFontSize, Pango.Weight.Normal, SmallTitleColor, subtitle));
                }

                int height = 0;
                int w, h1, h2;
                titleLayout.GetPixelSize (out w, out h1);
                height += h1;

                if (subtitleLayout != null) {
                    height += Styles.WelcomeScreen.Pad.Solutions.SolutionTile.TitleBottomMargin;
                    subtitleLayout.GetPixelSize (out w, out h2);
                    height += h2;
                }

                int tx = Allocation.X + InternalPadding + LeftTextPadding;
                int ty = Allocation.Y + (Allocation.Height - height) / 2;
                DrawLayout (ctx, titleLayout, TitleFontFace, titleFontSize, TitleFontWeight, MediumTitleColor, tx, ty);

                if (subtitleLayout != null) {
                    ty += h1 + Styles.WelcomeScreen.Pad.Solutions.SolutionTile.TitleBottomMargin;
                    DrawLayout (ctx, subtitleLayout, SmallTitleFontFace, smallTitleFontSize, Pango.Weight.Normal, SmallTitleColor, tx, ty);
                }
            }
            return true;
        }
开发者ID:Kalnor,项目名称:monodevelop,代码行数:49,代码来源:WelcomePageListButton.cs


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