예제 #1
0
파일: GtkInterop.cs 프로젝트: vipyami/xwt
        public void AddAttribute(TextIndexer indexer, TextAttribute attr)
        {
            var start = (uint)indexer.IndexToByteIndex(attr.StartIndex);
            var end   = (uint)indexer.IndexToByteIndex(attr.StartIndex + attr.Count);

            if (attr is BackgroundTextAttribute)
            {
                var xa = (BackgroundTextAttribute)attr;
                AddBackgroundAttribute(xa.Color.ToGtkValue(), start, end);
            }
            else if (attr is ColorTextAttribute)
            {
                var xa = (ColorTextAttribute)attr;
                AddForegroundAttribute(xa.Color.ToGtkValue(), start, end);
            }
            else if (attr is FontWeightTextAttribute)
            {
                var xa = (FontWeightTextAttribute)attr;
                AddWeightAttribute((Pango.Weight)(int) xa.Weight, start, end);
            }
            else if (attr is FontStyleTextAttribute)
            {
                var xa = (FontStyleTextAttribute)attr;
                AddStyleAttribute((Pango.Style)(int) xa.Style, start, end);
            }
            else if (attr is UnderlineTextAttribute)
            {
                var xa = (UnderlineTextAttribute)attr;
                AddUnderlineAttribute(xa.Underline ? Pango.Underline.Single : Pango.Underline.None, start, end);
            }
            else if (attr is StrikethroughTextAttribute)
            {
                var xa = (StrikethroughTextAttribute)attr;
                AddStrikethroughAttribute(xa.Strikethrough, start, end);
            }
            else if (attr is FontTextAttribute)
            {
                var xa = (FontTextAttribute)attr;
                AddFontAttribute((Pango.FontDescription)Toolkit.GetBackend(xa.Font), start, end);
            }
            else if (attr is LinkTextAttribute)
            {
                // TODO: support "link-color" style prop for TextLayoutBackendHandler and CellRendererText
                AddUnderlineAttribute(Pango.Underline.Single, start, end);
                AddForegroundAttribute(DefaultLinkColor, start, end);
            }
        }
예제 #2
0
파일: GtkInterop.cs 프로젝트: wesreid/xwt
        public void AddAttribute(TextIndexer indexer, TextAttribute attr)
        {
            var start = (uint)indexer.IndexToByteIndex(attr.StartIndex);
            var end   = (uint)indexer.IndexToByteIndex(attr.StartIndex + attr.Count);

            if (attr is BackgroundTextAttribute)
            {
                var xa = (BackgroundTextAttribute)attr;
                AddBackgroundAttribute(xa.Color.ToGdkColor(), start, end);
            }
            else if (attr is ColorTextAttribute)
            {
                var xa = (ColorTextAttribute)attr;
                AddForegroundAttribute(xa.Color.ToGdkColor(), start, end);
            }
            else if (attr is FontWeightTextAttribute)
            {
                var xa = (FontWeightTextAttribute)attr;
                AddWeightAttribute((Pango.Weight)(int) xa.Weight, start, end);
            }
            else if (attr is FontStyleTextAttribute)
            {
                var xa = (FontStyleTextAttribute)attr;
                AddStyleAttribute((Pango.Style)(int) xa.Style, start, end);
            }
            else if (attr is UnderlineTextAttribute)
            {
                var xa = (UnderlineTextAttribute)attr;
                AddUnderlineAttribute(xa.Underline ? Pango.Underline.Single : Pango.Underline.None, start, end);
            }
            else if (attr is StrikethroughTextAttribute)
            {
                var xa = (StrikethroughTextAttribute)attr;
                AddStrikethroughAttribute(xa.Strikethrough, start, end);
            }
            else if (attr is FontTextAttribute)
            {
                var xa = (FontTextAttribute)attr;
                AddFontAttribute((Pango.FontDescription)Toolkit.GetBackend(xa.Font), start, end);
            }
        }
예제 #3
0
파일: GtkInterop.cs 프로젝트: StEvUgnIn/xwt
		public void AddAttribute (TextIndexer indexer, TextAttribute attr)
		{
			var start = (uint) indexer.IndexToByteIndex (attr.StartIndex);
			var end = (uint) indexer.IndexToByteIndex (attr.StartIndex + attr.Count);

			if (attr is BackgroundTextAttribute) {
				var xa = (BackgroundTextAttribute)attr;
				AddBackgroundAttribute (xa.Color.ToGtkValue (), start, end);
			}
			else if (attr is ColorTextAttribute) {
				var xa = (ColorTextAttribute)attr;
				AddForegroundAttribute (xa.Color.ToGtkValue (), start, end);
			}
			else if (attr is FontWeightTextAttribute) {
				var xa = (FontWeightTextAttribute)attr;
				AddWeightAttribute ((Pango.Weight)(int)xa.Weight, start, end);
			}
			else if (attr is FontStyleTextAttribute) {
				var xa = (FontStyleTextAttribute)attr;
				AddStyleAttribute ((Pango.Style)(int)xa.Style, start, end);
			}
			else if (attr is UnderlineTextAttribute) {
				var xa = (UnderlineTextAttribute)attr;
				AddUnderlineAttribute (xa.Underline ? Pango.Underline.Single : Pango.Underline.None, start, end);
			}
			else if (attr is StrikethroughTextAttribute) {
				var xa = (StrikethroughTextAttribute)attr;
				AddStrikethroughAttribute (xa.Strikethrough, start, end);
			}
			else if (attr is FontTextAttribute) {
				var xa = (FontTextAttribute)attr;
				AddFontAttribute ((Pango.FontDescription)Toolkit.GetBackend (xa.Font), start, end);
			}
			else if (attr is LinkTextAttribute) {
				AddUnderlineAttribute (Pango.Underline.Single, start, end);
				AddForegroundAttribute (Colors.Blue.ToGtkValue (), start, end);
			}
		}
예제 #4
0
        internal static void ApplyFormattedText(this Gtk.Label label, FormattedText text)
        {
            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;
                    }
                }
                var indexer = new TextIndexer(text.Text);
                list.AddAttributes(indexer, text.Attributes);
            }
            gtk_label_set_attributes(label.Handle, list.Handle);
        }
예제 #5
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;
            }
        }
예제 #6
0
 public void AddAttributes(TextIndexer indexer, IEnumerable<TextAttribute> attrs)
 {
     foreach (var attr in attrs)
         AddAttribute (indexer, attr);
 }
예제 #7
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;
			}
		}
예제 #8
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);
 }
예제 #9
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;
            }
        }