diff --git a/src/gtk/textctrl.cpp b/src/gtk/textctrl.cpp index ba2d043c53..a61369ec02 100644 --- a/src/gtk/textctrl.cpp +++ b/src/gtk/textctrl.cpp @@ -1912,8 +1912,45 @@ bool wxTextCtrl::GetStyle(long position, wxTextAttr& style) if ( font.SetNativeFontInfo(wxString(pangoFontString)) ) style.SetFont(font); - if ( pattr->appearance.underline != PANGO_UNDERLINE_NONE ) - style.SetFontUnderlined(true); + wxTextAttrUnderlineType underlineType = wxTEXT_ATTR_UNDERLINE_NONE; + switch ( pattr->appearance.underline ) + { + case PANGO_UNDERLINE_SINGLE: + underlineType = wxTEXT_ATTR_UNDERLINE_SOLID; + break; + case PANGO_UNDERLINE_DOUBLE: + underlineType = wxTEXT_ATTR_UNDERLINE_DOUBLE; + break; + case PANGO_UNDERLINE_ERROR: + underlineType = wxTEXT_ATTR_UNDERLINE_WAVE; + break; + } + + wxColour underlineColour = wxNullColour; +#ifdef __WXGTK3__ + GSList* tags = gtk_text_iter_get_tags(&positioni); + for ( GSList* tagp = tags; tagp != NULL; tagp = tagp->next ) + { + GtkTextTag* tag = static_cast(tagp->data); + gboolean underlineSet = FALSE; + g_object_get(tag, "underline-rgba-set", &underlineSet, NULL); + if ( underlineSet ) + { + GdkRGBA* gdkColour = NULL; + g_object_get(tag, "underline-rgba", &gdkColour, NULL); + if ( gdkColour ) + underlineColour = wxColour(*gdkColour); + gdk_rgba_free(gdkColour); + break; + } + } + if ( tags ) + g_slist_free(tags); +#endif + + if ( underlineType != wxTEXT_ATTR_UNDERLINE_NONE ) + style.SetFontUnderlined(underlineType, underlineColour); + if ( pattr->appearance.strikethrough ) style.SetFontStrikethrough(true); diff --git a/src/msw/textctrl.cpp b/src/msw/textctrl.cpp index 42ea91176e..b77446a5dd 100644 --- a/src/msw/textctrl.cpp +++ b/src/msw/textctrl.cpp @@ -3259,6 +3259,61 @@ bool wxTextCtrl::GetStyle(long position, wxTextAttr& style) } #endif // wxUSE_RICHEDIT2 + wxTextAttrUnderlineType underlineType = wxTEXT_ATTR_UNDERLINE_NONE; + switch ( cf.bUnderlineType ) + { + case CFU_UNDERLINE: + underlineType = wxTEXT_ATTR_UNDERLINE_SOLID; + break; + case CFU_UNDERLINEDOUBLE: + underlineType = wxTEXT_ATTR_UNDERLINE_DOUBLE; + break; + case CFU_UNDERLINEWAVE: + underlineType = wxTEXT_ATTR_UNDERLINE_WAVE; + break; + } + + wxColour underlineColour = wxNullColour; +#if _RICHEDIT_VER >= 0x0800 + if ( cf.bUnderlineColor == 0 ) + underlineColour = wxNullColour; + else if ( cf.bUnderlineColor == 1 ) + underlineColour = wxTheColourDatabase->Find("BLACK"); + else if ( cf.bUnderlineColor == 2 ) + underlineColour = wxTheColourDatabase->Find("BLUE"); + else if ( cf.bUnderlineColor == 3 ) + underlineColour = wxTheColourDatabase->Find("CYAN"); + else if ( cf.bUnderlineColor == 4 ) + underlineColour = wxTheColourDatabase->Find("GREEN"); + else if ( cf.bUnderlineColor == 5 ) + underlineColour = wxTheColourDatabase->Find("MAGENTA"); + else if ( cf.bUnderlineColor == 6 ) + underlineColour = wxTheColourDatabase->Find("RED"); + else if ( cf.bUnderlineColor == 7 ) + underlineColour = wxTheColourDatabase->Find("YELLOW"); + else if ( cf.bUnderlineColor == 8 ) + underlineColour = wxTheColourDatabase->Find("WHITE"); + else if ( cf.bUnderlineColor == 9 ) + underlineColour = wxColour(0, 0, 128); // navy + else if ( cf.bUnderlineColor == 10 ) + underlineColour = wxTheColourDatabase->Find("TEAL"); + else if ( cf.bUnderlineColor == 11 ) + underlineColour = wxTheColourDatabase->Find("LIGHT GREEN"); + else if ( cf.bUnderlineColor == 12 ) + underlineColour = wxColour(128, 0, 128); // purple + else if ( cf.bUnderlineColor == 13 ) + underlineColour = wxColour(128, 0, 0); // maroon + else if ( cf.bUnderlineColor == 14 ) + underlineColour = wxTheColourDatabase->Find("OLIVE"); + else if ( cf.bUnderlineColor == 15 ) + underlineColour = wxTheColourDatabase->Find("GREY"); + else if ( cf.bUnderlineColor == 16 ) + underlineColour = wxTheColourDatabase->Find("LIGHT GREY"); +#endif + + if ( underlineType != wxTEXT_ATTR_UNDERLINE_NONE ) + style.SetFontUnderlined(underlineType, underlineColour); + // now get the paragraph formatting PARAFORMAT2 pf; wxZeroMemory(pf); diff --git a/src/osx/cocoa/textctrl.mm b/src/osx/cocoa/textctrl.mm index 17c6da0741..344142bd9e 100644 --- a/src/osx/cocoa/textctrl.mm +++ b/src/osx/cocoa/textctrl.mm @@ -1040,6 +1040,8 @@ bool wxNSTextViewControl::GetStyle(long position, wxTextAttr& style) NSFont* font = NULL; NSColor* bgcolor = NULL; NSColor* fgcolor = NULL; + NSNumber* ultype = NULL; + NSColor* ulcolor = NULL; // NOTE: It appears that other platforms accept GetStyle with the position == length // but that NSTextStorage does not accept length as a valid position. // Therefore we return the default control style in that case. @@ -1049,6 +1051,8 @@ bool wxNSTextViewControl::GetStyle(long position, wxTextAttr& style) font = [storage attribute:NSFontAttributeName atIndex:position effectiveRange:NULL]; bgcolor = [storage attribute:NSBackgroundColorAttributeName atIndex:position effectiveRange:NULL]; fgcolor = [storage attribute:NSForegroundColorAttributeName atIndex:position effectiveRange:NULL]; + ultype = [storage attribute:NSUnderlineStyleAttributeName atIndex:position effectiveRange:NULL]; + ulcolor = [storage attribute:NSUnderlineColorAttributeName atIndex:position effectiveRange:NULL]; } else { @@ -1056,6 +1060,8 @@ bool wxNSTextViewControl::GetStyle(long position, wxTextAttr& style) font = [attrs objectForKey:NSFontAttributeName]; bgcolor = [attrs objectForKey:NSBackgroundColorAttributeName]; fgcolor = [attrs objectForKey:NSForegroundColorAttributeName]; + ultype = [attrs objectForKey:NSUnderlineStyleAttributeName]; + ulcolor = [attrs objectForKey:NSUnderlineColorAttributeName]; } if (font) @@ -1066,6 +1072,32 @@ bool wxNSTextViewControl::GetStyle(long position, wxTextAttr& style) if (fgcolor) style.SetTextColour(wxColour(fgcolor)); + + wxTextAttrUnderlineType underlineType = wxTEXT_ATTR_UNDERLINE_NONE; + if ( ultype ) + { + NSInteger ulval = [ultype integerValue]; + switch ( ulval ) + { + case NSUnderlineStyleSingle: + underlineType = wxTEXT_ATTR_UNDERLINE_SOLID; + break; + case NSUnderlineStyleDouble: + underlineType = wxTEXT_ATTR_UNDERLINE_DOUBLE; + break; + case NSUnderlineStyleSingle | NSUnderlinePatternDot: + underlineType = wxTEXT_ATTR_UNDERLINE_WAVE; + break; + } + } + + wxColour underlineColour = wxNullColour; + if ( ulcolor ) + underlineColour = wxColour(ulcolor); + + if ( underlineType != wxTEXT_ATTR_UNDERLINE_NONE ) + style.SetFontUnderlined(underlineType, underlineColour); + return true; }