示例#1
0
        public void SetFormattedText(FormattedText text)
        {
            Label.Text    = text.Text;
            formattedText = text;
            var indexer = Label.ApplyFormattedText(text);

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

            foreach (var attr in text.Attributes.OfType <LinkTextAttribute> ())
            {
                LabelLink ll = new LabelLink()
                {
                    StartIndex = indexer != null?indexer.IndexToByteIndex(attr.StartIndex) : attr.StartIndex,
                                     EndIndex = indexer != null?indexer.IndexToByteIndex(attr.StartIndex + attr.Count) : 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;
            }
        }
示例#2
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;
            }
        }
示例#3
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;
            }
        }
示例#4
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;
			}
		}
示例#5
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;
            }
        }