public static Gdk.Size GetSize(this Pango.FontDescription font) { var widget = new Gtk.TextView(); widget.ModifyFont(font); var layout = widget.CreatePangoLayout("W"); int width, height; layout.GetPixelSize(out width, out height); return new Gdk.Size() { Width = width, Height = height }; }
/// <summary> /// Builds the check framework. /// </summary> private void BuildCheckFramework() { this.actCheck.Sensitive = false; this.txtCorrection = new Gtk.TextView(); this.imgCorrection = new Gtk.Image( "tsty-check" ); this.expCorrection = new Gtk.Expander( "Check" ); this.hbxChkContainer = new Gtk.HBox( false, 5 ); var scrl = new Gtk.ScrolledWindow(); // Build the view scrl.Add( this.txtCorrection ); this.expCorrection.Add( scrl ); this.hbxChkContainer.PackStart( this.imgCorrection, false, false, 5 ); this.hbxChkContainer.PackEnd( this.expCorrection, true, true, 5 ); this.VBox.Add( this.hbxChkContainer ); // Prepare the txtCorrection TextView var font = new Pango.FontDescription(); font.Family = "Monospace"; txtCorrection.ModifyFont( font ); txtCorrection.WrapMode = Gtk.WrapMode.None; txtCorrection.Editable = false; // Prepare the expander this.expCorrection.Activated += (o, e) => { bool isExpanded = this.expCorrection.Expanded; this.VBox.SetChildPacking( this.hbxChkContainer, isExpanded, isExpanded, 5, Gtk.PackType.End ); }; this.hbxChkContainer.ShowAll(); return; }