This creates a Pango list and applies attributes to it with *much* less overhead than the GTK# version.
Inheritance: IDisposable
Ejemplo n.º 1
0
        protected override void OnLoadData()
        {
            var view = (ITextCellViewFrontend)Frontend;

            if (view.Markup != null)
            {
                FormattedText tx = FormattedText.FromMarkup(view.Markup);
                cellRenderer.Text = tx.Text;
                var atts = new FastPangoAttrList();
                atts.AddAttributes(new TextIndexer(tx.Text), tx.Attributes);
                cellRenderer.Attributes = new Pango.AttrList(atts.Handle);
                atts.Dispose();
                mixedMarkupText = true;
            }
            else
            {
                cellRenderer.Text = view.Text;
                if (mixedMarkupText)
                {
                    cellRenderer.Attributes = new Pango.AttrList();
                }
            }
            cellRenderer.Editable  = view.Editable;
            cellRenderer.Ellipsize = view.Ellipsize.ToGtkValue();
        }
Ejemplo n.º 2
0
        internal static TextIndexer ApplyFormattedText(this Gtk.Label label, FormattedText text)
        {
            TextIndexer indexer = null;
            var         list    = new FastPangoAttrList();

            if (text != null)
            {
                if (label.IsRealized)
                {
                    var color    = Gdk.Color.Zero;
                    var colorVal = label.StyleGetProperty("link-color");
                    if (colorVal is Gdk.Color)
                    {
                        color = (Gdk.Color)colorVal;
                    }
                    if (!color.Equals(Gdk.Color.Zero))
                    {
                        list.DefaultLinkColor = color;
                    }
                }
                indexer = new TextIndexer(text.Text);
                list.AddAttributes(indexer, text.Attributes);
            }
            gtk_label_set_attributes(label.Handle, list.Handle);

            return(indexer);
        }
Ejemplo n.º 3
0
        public void SetFormattedText(FormattedText text)
        {
            Label.Text = text.Text;
            var         list    = new FastPangoAttrList();
            TextIndexer indexer = new TextIndexer(text.Text);

            list.AddAttributes(indexer, text.Attributes);
            gtk_label_set_attributes(Label.Handle, list.Handle);
        }
Ejemplo n.º 4
0
 public void ClearAttributes()
 {
     if (attributes != null)
     {
         attributes.Dispose();
         attributes = new FastPangoAttrList();
         hasUnassignedAttributes = true;
     }
 }
Ejemplo n.º 5
0
 public void Dispose()
 {
     if (layout != null)
     {
         layout.Dispose();
         layout = null;
     }
     if (attributes != null)
     {
         attributes.Dispose();
         attributes = null;
     }
 }
Ejemplo n.º 6
0
        public void SetFormattedText(FormattedText text)
        {
            Label.Text    = text.Text;
            formattedText = text;
            var list = new FastPangoAttrList();

            if (Label.IsRealized)
            {
                var color    = Gdk.Color.Zero;
                var colorVal = Label.StyleGetProperty("link-color");
                if (colorVal is Gdk.Color)
                {
                    color = (Gdk.Color)colorVal;
                }
                if (!color.Equals(Gdk.Color.Zero))
                {
                    list.DefaultLinkColor = color;
                }
            }
            indexer = new TextIndexer(text.Text);
            list.AddAttributes(indexer, text.Attributes);
            gtk_label_set_attributes(Label.Handle, list.Handle);

            if (links != null)
            {
                links.Clear();
            }

            foreach (var attr in text.Attributes.OfType <LinkTextAttribute> ())
            {
                LabelLink ll = new LabelLink()
                {
                    StartIndex = indexer.IndexToByteIndex(attr.StartIndex),
                    EndIndex   = indexer.IndexToByteIndex(attr.StartIndex + attr.Count),
                    Target     = attr.Target
                };
                if (links == null)
                {
                    links = new List <LabelLink> ();
                    EnableLinkEvents();
                }
                links.Add(ll);
            }

            if (links == null || links.Count == 0)
            {
                links   = null;
                indexer = null;
            }
        }
Ejemplo n.º 7
0
		protected override void OnLoadData ()
		{
			var view = (ITextCellViewFrontend) Frontend;

			if (view.Markup != null) {
				FormattedText tx = FormattedText.FromMarkup (view.Markup);
				cellRenderer.Text = tx.Text;
				var atts = new FastPangoAttrList ();
				atts.AddAttributes (new TextIndexer (tx.Text), tx.Attributes);
				cellRenderer.Attributes = new Pango.AttrList (atts.Handle);
				atts.Dispose ();
			} else {
				cellRenderer.Text = view.Text;
			}
			cellRenderer.Editable = view.Editable;
			cellRenderer.Ellipsize = view.Ellipsize.ToGtkValue ();
		}
Ejemplo n.º 8
0
        public void LoadData(TreeModel treeModel, TreeIter iter)
        {
            this.treeModel = treeModel;
            this.iter = iter;
            view.Initialize (this);

            if (view.Markup != null) {
                FormattedText tx = FormattedText.FromMarkup (view.Markup);
                Text = tx.Text;
                var atts = new FastPangoAttrList ();
                atts.AddAttributes (new TextIndexer (tx.Text), tx.Attributes);
                Attributes = new Pango.AttrList (atts.Handle);
                atts.Dispose ();
            } else {
                Text = view.Text;
            }
            Editable = view.Editable;
        }
Ejemplo n.º 9
0
        public void LoadData(TreeModel treeModel, TreeIter iter)
        {
            this.treeModel = treeModel;
            this.iter      = iter;
            view.Initialize(this);

            if (view.Markup != null)
            {
                FormattedText tx = FormattedText.FromMarkup(view.Markup);
                Text = tx.Text;
                var atts = new FastPangoAttrList();
                atts.AddAttributes(new TextIndexer(tx.Text), tx.Attributes);
                Attributes = new Pango.AttrList(atts.Handle);
                atts.Dispose();
            }
            else
            {
                Text = view.Text;
            }
            Editable = view.Editable;
        }
Ejemplo n.º 10
0
        public void SetFormattedText(FormattedText text)
        {
            Label.Text = text.Text;
            var list = new FastPangoAttrList();

            indexer = new TextIndexer(text.Text);
            list.AddAttributes(indexer, text.Attributes);
            gtk_label_set_attributes(Label.Handle, list.Handle);

            if (links != null)
            {
                links.Clear();
            }

            foreach (var attr in text.Attributes.OfType <LinkTextAttribute> ())
            {
                LabelLink ll = new LabelLink()
                {
                    StartIndex = indexer.IndexToByteIndex(attr.StartIndex),
                    EndIndex   = indexer.IndexToByteIndex(attr.StartIndex + attr.Count),
                    Target     = attr.Target
                };
                if (links == null)
                {
                    links = new List <LabelLink> ();
                    EnableLinkEvents();
                }
                links.Add(ll);
            }

            if (links == null || links.Count == 0)
            {
                links   = null;
                indexer = null;
            }
        }
Ejemplo n.º 11
0
 public void Dispose()
 {
     Layout.Dispose ();
     if (attributes != null) {
         attributes.Dispose ();
         attributes = null;
     }
 }
Ejemplo n.º 12
0
 public void Dispose()
 {
     if (layout != null) {
         layout.Dispose ();
         layout = null;
     }
     if (attributes != null) {
         attributes.Dispose ();
         attributes = null;
     }
 }
Ejemplo n.º 13
0
 public void ClearAttributes()
 {
     if (attributes != null) {
         attributes.Dispose ();
         attributes = new FastPangoAttrList ();
         hasUnassignedAttributes = true;
     }
 }
Ejemplo n.º 14
0
		public void SetFormattedText (FormattedText text)
		{
			Label.Text = text.Text;
			var list = new FastPangoAttrList ();
			indexer = new TextIndexer (text.Text);
			list.AddAttributes (indexer, text.Attributes);
			gtk_label_set_attributes (Label.Handle, list.Handle);

			if (links != null)
				links.Clear ();

			foreach (var attr in text.Attributes.OfType<LinkTextAttribute> ()) {
				LabelLink ll = new LabelLink () {
					StartIndex = indexer.IndexToByteIndex (attr.StartIndex),
					EndIndex = indexer.IndexToByteIndex (attr.StartIndex + attr.Count),
					Target = attr.Target
				};
				if (links == null) {
					links = new List<LabelLink> ();
					EnableLinkEvents ();
				}
				links.Add (ll);
			}

			if (links == null || links.Count == 0) {
				links = null;
				indexer = null;
			}
		}
Ejemplo n.º 15
0
 public void SetFormattedText(FormattedText text)
 {
     Label.Text = text.Text;
     var list = new FastPangoAttrList ();
     TextIndexer indexer = new TextIndexer (text.Text);
     list.AddAttributes (indexer, text.Attributes);
     gtk_label_set_attributes (Label.Handle, list.Handle);
 }
Ejemplo n.º 16
0
        public void SetFormattedText(FormattedText text)
        {
            Label.Text = text.Text;
            formattedText = text;
            var list = new FastPangoAttrList ();
            if (Label.IsRealized) {
                var color = Gdk.Color.Zero;
                var colorVal = Label.StyleGetProperty ("link-color");
                if (colorVal is Gdk.Color)
                    color = (Gdk.Color)colorVal;
                if (!color.Equals (Gdk.Color.Zero))
                    list.DefaultLinkColor = color;
            }
            indexer = new TextIndexer (text.Text);
            list.AddAttributes (indexer, text.Attributes);
            gtk_label_set_attributes (Label.Handle, list.Handle);

            if (links != null)
                links.Clear ();

            foreach (var attr in text.Attributes.OfType<LinkTextAttribute> ()) {
                LabelLink ll = new LabelLink () {
                    StartIndex = indexer.IndexToByteIndex (attr.StartIndex),
                    EndIndex = indexer.IndexToByteIndex (attr.StartIndex + attr.Count),
                    Target = attr.Target
                };
                if (links == null) {
                    links = new List<LabelLink> ();
                    EnableLinkEvents ();
                }
                links.Add (ll);
            }

            if (links == null || links.Count == 0) {
                links = null;
                indexer = null;
            }
        }