AddAttributes() public method

public AddAttributes ( TextIndexer indexer, IEnumerable attrs ) : void
indexer TextIndexer
attrs IEnumerable
return void
Example #1
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);
        }
        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();
        }
Example #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);
        }
Example #4
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;
            }
        }
Example #5
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 ();
		}
Example #6
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;
        }
Example #7
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;
        }
Example #8
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;
            }
        }
Example #9
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;
			}
		}
Example #10
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);
 }
Example #11
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;
            }
        }