Determine underline type and colour in wxTextCtrl::GetStyle
This commit is contained in:
@@ -1912,8 +1912,45 @@ bool wxTextCtrl::GetStyle(long position, wxTextAttr& style)
|
|||||||
if ( font.SetNativeFontInfo(wxString(pangoFontString)) )
|
if ( font.SetNativeFontInfo(wxString(pangoFontString)) )
|
||||||
style.SetFont(font);
|
style.SetFont(font);
|
||||||
|
|
||||||
if ( pattr->appearance.underline != PANGO_UNDERLINE_NONE )
|
wxTextAttrUnderlineType underlineType = wxTEXT_ATTR_UNDERLINE_NONE;
|
||||||
style.SetFontUnderlined(true);
|
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<GtkTextTag*>(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 )
|
if ( pattr->appearance.strikethrough )
|
||||||
style.SetFontStrikethrough(true);
|
style.SetFontStrikethrough(true);
|
||||||
|
|
||||||
|
@@ -3259,6 +3259,61 @@ bool wxTextCtrl::GetStyle(long position, wxTextAttr& style)
|
|||||||
}
|
}
|
||||||
#endif // wxUSE_RICHEDIT2
|
#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
|
// now get the paragraph formatting
|
||||||
PARAFORMAT2 pf;
|
PARAFORMAT2 pf;
|
||||||
wxZeroMemory(pf);
|
wxZeroMemory(pf);
|
||||||
|
@@ -1040,6 +1040,8 @@ bool wxNSTextViewControl::GetStyle(long position, wxTextAttr& style)
|
|||||||
NSFont* font = NULL;
|
NSFont* font = NULL;
|
||||||
NSColor* bgcolor = NULL;
|
NSColor* bgcolor = NULL;
|
||||||
NSColor* fgcolor = NULL;
|
NSColor* fgcolor = NULL;
|
||||||
|
NSNumber* ultype = NULL;
|
||||||
|
NSColor* ulcolor = NULL;
|
||||||
// NOTE: It appears that other platforms accept GetStyle with the position == length
|
// NOTE: It appears that other platforms accept GetStyle with the position == length
|
||||||
// but that NSTextStorage does not accept length as a valid position.
|
// but that NSTextStorage does not accept length as a valid position.
|
||||||
// Therefore we return the default control style in that case.
|
// 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];
|
font = [storage attribute:NSFontAttributeName atIndex:position effectiveRange:NULL];
|
||||||
bgcolor = [storage attribute:NSBackgroundColorAttributeName atIndex:position effectiveRange:NULL];
|
bgcolor = [storage attribute:NSBackgroundColorAttributeName atIndex:position effectiveRange:NULL];
|
||||||
fgcolor = [storage attribute:NSForegroundColorAttributeName 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
|
else
|
||||||
{
|
{
|
||||||
@@ -1056,6 +1060,8 @@ bool wxNSTextViewControl::GetStyle(long position, wxTextAttr& style)
|
|||||||
font = [attrs objectForKey:NSFontAttributeName];
|
font = [attrs objectForKey:NSFontAttributeName];
|
||||||
bgcolor = [attrs objectForKey:NSBackgroundColorAttributeName];
|
bgcolor = [attrs objectForKey:NSBackgroundColorAttributeName];
|
||||||
fgcolor = [attrs objectForKey:NSForegroundColorAttributeName];
|
fgcolor = [attrs objectForKey:NSForegroundColorAttributeName];
|
||||||
|
ultype = [attrs objectForKey:NSUnderlineStyleAttributeName];
|
||||||
|
ulcolor = [attrs objectForKey:NSUnderlineColorAttributeName];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (font)
|
if (font)
|
||||||
@@ -1066,6 +1072,32 @@ bool wxNSTextViewControl::GetStyle(long position, wxTextAttr& style)
|
|||||||
|
|
||||||
if (fgcolor)
|
if (fgcolor)
|
||||||
style.SetTextColour(wxColour(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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user