AddAttributes() 공개 메소드

public AddAttributes ( TextIndexer indexer, IEnumerable attrs ) : void
indexer TextIndexer
attrs IEnumerable
리턴 void
예제 #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);
        }
예제 #2
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();
        }
예제 #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);
        }
예제 #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;
            }
        }
예제 #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 ();
		}
예제 #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;
        }
예제 #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;
        }
예제 #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;
            }
        }
예제 #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;
			}
		}
예제 #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);
 }
예제 #11
0
파일: LabelBackend.cs 프로젝트: mono/xwt
        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;
            }
        }