public Pango.Context CreateContext() { IntPtr raw_ret = pango_font_map_create_context(Handle); Pango.Context ret = GLib.Object.GetObject(raw_ret) as Pango.Context; return(ret); }
public static Pango.Context ContextGetForScreen(Gdk.Screen screen) { IntPtr raw_ret = gdk_pango_context_get_for_screen(screen == null ? IntPtr.Zero : screen.Handle); Pango.Context ret = GLib.Object.GetObject(raw_ret) as Pango.Context; return(ret); }
/// <summary> /// Paints cell on cairo context /// </summary> /// <param name="aArgs"> /// A <see cref="CellExposeEventArgs"/> /// </param> public override void Paint(CellExposeEventArgs aArgs) { if (Area.IsInsideArea(aArgs.ClippingArea) == false) { return; } Pango.Context pContext = PangoContext; if ((DisplayText == "") || (pContext == null)) { return; } Pango.Layout layout = SetLayout(); layout.Width = Pango.Units.FromPixels(System.Convert.ToInt32(aArgs.CellArea.Width)); layout.SetMarkup(DisplayText); int width, height; layout.GetPixelSize(out width, out height); double xdiff = Area.Width - width; double ydiff = Area.Height - ySize; aArgs.Context.Color = Color; aArgs.Context.MoveTo(aArgs.CellArea.X + (xdiff * XPos), aArgs.CellArea.Y + (ydiff * YPos)); Pango.CairoHelper.ShowLayout(aArgs.Context, layout); layout.SetMarkup(""); FreeLayout(layout); }
public static Pango.Context ContextGet() { IntPtr raw_ret = gdk_pango_context_get(); Pango.Context ret = GLib.Object.GetObject(raw_ret) as Pango.Context; return(ret); }
/// <summary> /// Renders the pager. /// </summary> public virtual void RenderPager(Cairo.Context context, Pango.Context pangoContext, Gdk.Rectangle region) { //set global clip to avoid going outside general rendering area CairoExtensions.RoundedRectangle(context, region.X, region.Y, region.Width, region.Height, CornerRadius); context.Clip(); Pango.Layout layout = SetupPagerText(context, pangoContext); int textWidth, textHeight; layout.GetPixelSize(out textWidth, out textHeight); int width = textWidth + Styles.PopoverWindow.PagerTriangleSize * 2 + 20; int height = Styles.PopoverWindow.PagerHeight; Gdk.Rectangle boundingBox = new Gdk.Rectangle(region.X + region.Width - width, 0, width, height); RenderPagerBackground(context, boundingBox); int arrowPadding = 4; Gdk.Rectangle arrowRect = new Gdk.Rectangle(boundingBox.X + arrowPadding, boundingBox.Y + (boundingBox.Height - Styles.PopoverWindow.PagerTriangleSize) / 2, Styles.PopoverWindow.PagerTriangleSize, Styles.PopoverWindow.PagerTriangleSize); RenderPagerArrow(context, arrowRect, PagerVertical ? ArrowType.Up : ArrowType.Left); arrowRect.X = boundingBox.X + boundingBox.Width - (arrowPadding + Styles.PopoverWindow.PagerTriangleSize); RenderPagerArrow(context, arrowRect, PagerVertical ? ArrowType.Down : ArrowType.Right); RenderPagerText(context, layout, boundingBox); }
public Pango.Context CreatePangoContext() { IntPtr raw_ret = gtk_print_context_create_pango_context(Handle); Pango.Context ret = GLib.Object.GetObject(raw_ret) as Pango.Context; return(ret); }
public FlatButton(Pixbuf pb, string text = null) { pixbuf = pb; buttonText = text; Events |= Gdk.EventMask.ButtonPressMask | EventMask.EnterNotifyMask | EventMask.LeaveNotifyMask | EventMask.ButtonReleaseMask; if (text == null) { WidthRequest = GtkUtils.ScaleGtkWidget(40); HeightRequest = GtkUtils.ScaleGtkWidget(40); } #if FAMISTUDIO_LINUX if (context == null) { context = CreatePangoContext(); } var fontSize = Pango.Units.ToPixels(Style.FontDesc.Size); layoutNormal = new Pango.Layout(context); layoutNormal.Alignment = Pango.Alignment.Left; layoutNormal.SetText(text); layoutNormal.FontDescription = Pango.FontDescription.FromString($"Quicksand {fontSize}"); layoutBold = new Pango.Layout(context); layoutBold.Alignment = Pango.Alignment.Left; layoutBold.SetText(text); layoutBold.FontDescription = Pango.FontDescription.FromString($"Quicksand Bold {fontSize}"); #endif }
public FlatButton(Pixbuf pb, string text = null) { image = GdkPixbufToCairoImageSurface(pb); Events |= Gdk.EventMask.ButtonPressMask | EventMask.EnterNotifyMask | EventMask.LeaveNotifyMask | EventMask.ButtonReleaseMask; if (text != null) { if (context == null) { context = CreatePangoContext(); } layoutNormal = new Pango.Layout(context); layoutNormal.Alignment = Pango.Alignment.Left; layoutNormal.SetText(text); layoutNormal.FontDescription = Pango.FontDescription.FromString("Quicksand 14"); layoutBold = new Pango.Layout(context); layoutBold.Alignment = Pango.Alignment.Left; layoutBold.SetText(text); layoutBold.FontDescription = Pango.FontDescription.FromString("Quicksand Bold 14"); } else { WidthRequest = 40; HeightRequest = 40; } }
public static Pango.Context CreateContext(Cairo.Context cr) { IntPtr raw_ret = pango_cairo_create_context(cr == null ? IntPtr.Zero : cr.Handle); Pango.Context ret = GLib.Object.GetObject(raw_ret) as Pango.Context; return(ret); }
public static double ContextGetResolution(Pango.Context context) { double raw_ret = pango_cairo_context_get_resolution(context == null ? IntPtr.Zero : context.Handle); double ret = raw_ret; return(ret); }
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(); }
public Pango.Fontset LoadFontset(Pango.Context context, Pango.FontDescription desc, Pango.Language language) { IntPtr raw_ret = pango_font_map_load_fontset(Handle, context == null ? IntPtr.Zero : context.Handle, desc == null ? IntPtr.Zero : desc.Handle, language == null ? IntPtr.Zero : language.Handle); Pango.Fontset ret = GLib.Object.GetObject(raw_ret) as Pango.Fontset; return(ret); }
public static Pango.Context ContextGetForDisplay(Gdk.Display display) { IntPtr raw_ret = gdk_pango_context_get_for_display(display == null ? IntPtr.Zero : display.Handle); Pango.Context ret = GLib.Object.GetObject(raw_ret) as Pango.Context; return(ret); }
/* public methods */ public GtkStyleProvider(Style style, StateType state, Pango.Context context) { this.gtk_style = style; this.state = state; this.context = context; this.context.ToString(); }
/// <summary> /// Sets the Pango.Layout for pager text as it will be rendered. This will be used to perform sizing on the rest of the pager. /// </summary> protected virtual Pango.Layout SetupPagerText(Pango.Context pangoContext) { Pango.Layout pl = new Pango.Layout(pangoContext); pl.SetText(string.Format("{0} of {1}", CurrentPage + 1, NumPages)); pl.FontDescription = Font; pl.FontDescription.AbsoluteSize = Pango.Units.FromPixels(Styles.PopoverWindow.PagerHeight - 5); return(pl); }
public static GLib.List ItemizeWithBaseDir(Pango.Context context, Pango.Direction base_dir, string text, int start_index, int length, Pango.AttrList attrs, Pango.AttrIterator cached_iter) { IntPtr native_text = GLib.Marshaller.StringToPtrGStrdup(text); IntPtr raw_ret = pango_itemize_with_base_dir(context == null ? IntPtr.Zero : context.Handle, (int)base_dir, native_text, start_index, length, attrs == null ? IntPtr.Zero : attrs.Handle, cached_iter == null ? IntPtr.Zero : cached_iter.Handle); GLib.List ret = new GLib.List(raw_ret); GLib.Marshaller.Free(native_text); return(ret); }
Pango.Layout ButtonLayout(Pango.Context context) { var layout = new Pango.Layout(context); layout.FontDescription = Pango.FontDescription.FromString(Platform.IsMac ? Styles.WelcomeScreen.FontFamilyMac : Styles.WelcomeScreen.FontFamilyWindows); layout.FontDescription.AbsoluteSize = Pango.Units.FromPixels(16); layout.SetText("Start Building Apps"); return(layout); }
Pango.Layout TitleLayout(Pango.Context context) { var layout = new Pango.Layout(context); layout.FontDescription = Pango.FontDescription.FromString(Platform.IsMac ? Styles.WelcomeScreen.FontFamilyMac : Styles.WelcomeScreen.FontFamilyWindows); layout.FontDescription.AbsoluteSize = Pango.Units.FromPixels(26); layout.SetText("Welcome To " + BrandingService.SuiteName + "!"); return(layout); }
public Layout(Pango.Context context) : base(IntPtr.Zero) { if (GetType() != typeof(Layout)) { var vals = new List <GLib.Value> (); var names = new List <string> (); CreateNativeObject(names.ToArray(), vals.ToArray()); return; } Raw = pango_layout_new(context == null ? IntPtr.Zero : context.Handle); }
public bool HitTestPagerRightArrow(Pango.Context pangoContext, Gdk.Rectangle region, Gdk.Point hitPoint) { using (Pango.Layout layout = SetupPagerText(pangoContext)) { var boundingBox = GetPagerBounds(layout, region); Gdk.Rectangle arrowActiveRect = new Gdk.Rectangle(boundingBox.X + boundingBox.Width - (pagerArrowPadding * 2 + Styles.PopoverWindow.PagerTriangleSize), boundingBox.Y, Styles.PopoverWindow.PagerTriangleSize + (pagerArrowPadding * 2), boundingBox.Height); return(arrowActiveRect.Contains(hitPoint)); } }
public LineRenderer(Pango.Context ctx, string str) { var pieces = str.Split(null as string[], StringSplitOptions.RemoveEmptyEntries); List <TokenRenderer> line = new List <TokenRenderer> (); var currentLine = ""; var desc = ctx.FontDescription.Copy(); desc.AbsoluteSize = Pango.Units.FromPixels(14); desc.Weight = Pango.Weight.Bold; var layout = new Pango.Layout(ctx); layout.SetMarkup(" "); int w, h; layout.GetPixelSize(out w, out h); Spacing = w; foreach (var token in pieces) { if (rx.IsMatch(token)) { if (!String.IsNullOrEmpty(currentLine)) { line.Add(new TokenRenderer(ctx, currentLine, false)); } line.Add(new TokenRenderer(ctx, token.Substring(1, token.Length - 2), true)); currentLine = ""; } else { if (!String.IsNullOrEmpty(currentLine)) { currentLine += " "; } currentLine += token; } } if (!String.IsNullOrEmpty(currentLine)) { line.Add(new TokenRenderer(ctx, currentLine, false)); } tokens = line.ToArray(); Width = tokens.Sum(t => t.Width + t.Spacing); Height = tokens.Max(t => t.Height); }
public static Pango.Layout CreateLayout(Gtk.Widget widget, Cairo.Context cairo_context) { Pango.Layout layout = PangoCairoHelper.CreateLayout(cairo_context); layout.FontDescription = widget.PangoContext.FontDescription.Copy(); double resolution = widget.Screen.Resolution; if (resolution != -1) { Pango.Context context = PangoCairoHelper.LayoutGetContext(layout); PangoCairoHelper.ContextSetResolution(context, resolution); context.Dispose(); } return(layout); }
public static Pango.Layout CreateLayout(this Gtk.Widget widget, Context cairo_context) { Pango.Layout layout = cairo_context.CreateLayout(); layout.FontDescription = widget.PangoContext.FontDescription.Copy(); double resolution = -1;//widget.Screen.Resolution; if (resolution != -1) { Pango.Context context = layout.GetContext(); context.SetResolution(resolution); context.Dispose(); } return(layout); }
public FormattedTextImpl( Pango.Context context, string text, Typeface typeface, TextAlignment textAlignment, TextWrapping wrapping, Size constraint, IReadOnlyList <FormattedTextStyleSpan> spans) { Contract.Requires <ArgumentNullException>(context != null); Contract.Requires <ArgumentNullException>(text != null); Layout = new Pango.Layout(context); Layout.SetText(text); Layout.FontDescription = new Pango.FontDescription { Family = typeface?.FontFamilyName ?? "monospace", Size = Pango.Units.FromDouble(CorrectScale(typeface?.FontSize ?? 12)), Style = (Pango.Style)(typeface?.Style ?? FontStyle.Normal), Weight = (typeface?.Weight ?? FontWeight.Normal).ToCairo(), }; Layout.Alignment = textAlignment.ToCairo(); Layout.Attributes = new Pango.AttrList(); Layout.Width = double.IsPositiveInfinity(constraint.Width) ? -1 : Pango.Units.FromDouble(constraint.Width); if (spans != null) { foreach (var span in spans) { if (span.ForegroundBrush is SolidColorBrush scb) { var color = new Pango.Color(); color.Parse(string.Format("#{0}", scb.Color.ToString().Substring(3))); var brushAttr = new Pango.AttrForeground(color); brushAttr.StartIndex = (uint)TextIndexToPangoIndex(span.StartIndex); brushAttr.EndIndex = (uint)TextIndexToPangoIndex(span.StartIndex + span.Length); this.Layout.Attributes.Insert(brushAttr); } } } Size = Measure(); }
public static void SetResolution(this Pango.Context context, double dpi) { switch (platform) { case PlatformTypes.Windows: pango_cairo_context_set_resolution_win(context == null ? IntPtr.Zero : context.Handle, dpi); break; case PlatformTypes.MacOSX: pango_cairo_context_set_resolution_mac(context == null ? IntPtr.Zero : context.Handle, dpi); break; default: pango_cairo_context_set_resolution(context == null ? IntPtr.Zero : context.Handle, dpi); break; } }
public static Pango.Layout CreateLayout(Gtk.Widget widget, Cairo.Context cairo_context) { Pango.Layout layout = Pango.CairoHelper.CreateLayout(cairo_context); layout.FontDescription = widget.PangoContext.FontDescription; double resolution = widget.Screen.Resolution; if (resolution != -1) { Pango.Context context = layout.Context; Pango.CairoHelper.ContextSetResolution(context, resolution); context.Dispose(); } Log.Debug("Creating Pango.Layout, configuring Cairo.Context"); return(layout); }
public static void ContextSetShapeRenderer(Pango.Context context, Pango.CairoShapeRendererFunc func) { PangoSharp.CairoShapeRendererFuncWrapper func_wrapper = new PangoSharp.CairoShapeRendererFuncWrapper(func); IntPtr data; GLib.DestroyNotify dnotify; if (func == null) { data = IntPtr.Zero; dnotify = null; } else { data = (IntPtr)GCHandle.Alloc(func_wrapper); dnotify = GLib.DestroyHelper.NotifyHandler; } pango_cairo_context_set_shape_renderer(context == null ? IntPtr.Zero : context.Handle, func_wrapper.NativeDelegate, data, dnotify); }
public void HandleDrawn(object o, Gtk.DrawnArgs args) { var h = Handler; var allocation = h.Control.Allocation.Size; args.Cr.Rectangle(new Cairo.Rectangle(0, 0, allocation.Width, allocation.Height)); args.Cr.Clip(); Gdk.Rectangle rect = new Gdk.Rectangle(); if (!GraphicsHandler.GetClipRectangle(args.Cr, ref rect)) { rect = new Gdk.Rectangle(Gdk.Point.Zero, allocation); } #if old using (var graphics = new Graphics(new GraphicsHandler(args.Cr, h.Control.CreatePangoContext(), false))) { if (h.SelectedBackgroundColor != null) { graphics.Clear(h.SelectedBackgroundColor.Value); } h.Callback.OnPaint(h.Widget, new PaintEventArgs(graphics, rect.ToEto())); } #else //CreatePangoContext - creates a new one each time. local owned //GetPangoContext - gets a context owned by the control // only get the pango context once, using a context owned by the widget if (Pcontext == null) { Pcontext = h.Control.GetPangoContext(); } using (var graphics = new Graphics(new GraphicsHandler(args.Cr, Pcontext, false))) { if (h.SelectedBackgroundColor != null) { graphics.Clear(h.SelectedBackgroundColor.Value); } h.Callback.OnPaint(h.Widget, new PaintEventArgs(graphics, rect.ToEto())); } #endif }
public TextBox(int nlines) { ShadowType = Gtk.ShadowType.In; SetPolicy(Gtk.PolicyType.Never, Gtk.PolicyType.Automatic); textview = new Gtk.TextView(); textview.WrapMode = Gtk.WrapMode.Word; textview.Show(); Add(textview); Pango.Context ctx = textview.PangoContext; Pango.FontMetrics metrics = ctx.GetMetrics(textview.Style.FontDescription, ctx.Language); int lineHeight = (metrics.Ascent + metrics.Descent) / (int)Pango.Scale.PangoScale; SetSizeRequest(-1, lineHeight * nlines); textview.Buffer.Changed += Buffer_Changed; }
private Pango.Layout CreateAdaptLayout(Pango.Layout layout, bool small, bool bold) { if (layout == null) { Pango.Context context = CreatePangoContext(); layout = new Pango.Layout(context); layout.FontDescription = context.FontDescription; pango_size_normal = layout.FontDescription.Size; } layout.FontDescription.Size = small ? (int)(layout.FontDescription.Size * Pango.Scale.Small) : pango_size_normal; layout.FontDescription.Weight = bold ? Pango.Weight.Bold : Pango.Weight.Normal; return(layout); }
public StackFrameCellRenderer (Pango.Context ctx) { Context = ctx; }