Apply wxTextCtrl underline review suggestions
This commit is contained in:
@@ -275,7 +275,7 @@ enum wxTextAttrUnderlineType
|
||||
wxTEXT_ATTR_UNDERLINE_NONE,
|
||||
wxTEXT_ATTR_UNDERLINE_SOLID,
|
||||
wxTEXT_ATTR_UNDERLINE_DOUBLE,
|
||||
wxTEXT_ATTR_UNDERLINE_WAVE
|
||||
wxTEXT_ATTR_UNDERLINE_SPECIAL
|
||||
};
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
@@ -229,7 +229,7 @@ enum wxTextAttrUnderlineType
|
||||
wxTEXT_ATTR_UNDERLINE_NONE,
|
||||
wxTEXT_ATTR_UNDERLINE_SOLID,
|
||||
wxTEXT_ATTR_UNDERLINE_DOUBLE,
|
||||
wxTEXT_ATTR_UNDERLINE_WAVE
|
||||
wxTEXT_ATTR_UNDERLINE_SPECIAL
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -830,20 +830,29 @@ public:
|
||||
void SetFontStyle(wxFontStyle fontStyle);
|
||||
|
||||
/**
|
||||
Sets the font underlining (solid line, using text colour).
|
||||
Sets the font underlining (solid line, text colour).
|
||||
*/
|
||||
void SetFontUnderlined(bool underlined);
|
||||
|
||||
/**
|
||||
Sets the font underlining with a wxTextAttrUnderlineType and wxColour.
|
||||
Specifying wxNullColour will use the text colour.
|
||||
Sets the font underlining.
|
||||
|
||||
@note On wxMSW, wxTEXT_ATTR_UNDERLINE_DOUBLE is shown as wxTEXT_ATTR_UNDERLINE_SOLID. There is only a limited number of colours supported,
|
||||
the RGB values are listed <a href="https://docs.microsoft.com/en-us/windows/win32/api/tom/nf-tom-itextdocument2-geteffectcolor">here</a>.
|
||||
@param type Type of underline.
|
||||
|
||||
@note On wxGTK, underline colour is only supported by wxGTK3. GTK might overrule the colour of wxTEXT_ATTR_UNDERLINE_WAVE.
|
||||
@param colour Colour to use for underlining, text colour is used by
|
||||
default.
|
||||
|
||||
@note On wxOSX, wxTEXT_ATTR_UNDERLINE_WAVE is shown as a dotted line.
|
||||
@note On wxMSW, wxTEXT_ATTR_UNDERLINE_DOUBLE is shown as
|
||||
wxTEXT_ATTR_UNDERLINE_SOLID. There is only a limited number of colours
|
||||
supported, the RGB values are listed
|
||||
<a href="https://docs.microsoft.com/en-us/windows/win32/api/tom/nf-tom-itextdocument2-geteffectcolor">here</a>.
|
||||
wxTEXT_ATTR_UNDERLINE_SPECIAL is shown as a waved line.
|
||||
|
||||
@note On wxGTK, underline colour is only supported by wxGTK3.
|
||||
wxTEXT_ATTR_UNDERLINE_SPECIAL is shown as a waved line. GTK might
|
||||
overrule the colour of wxTEXT_ATTR_UNDERLINE_SPECIAL.
|
||||
|
||||
@note On wxOSX, wxTEXT_ATTR_UNDERLINE_SPECIAL is shown as a dotted line.
|
||||
|
||||
@since 3.1.3
|
||||
*/
|
||||
|
@@ -1237,7 +1237,7 @@ MyPanel::MyPanel( wxFrame *frame, int x, int y, int w, int h )
|
||||
attr.SetFontUnderlined(false);
|
||||
m_textrich->SetDefaultStyle(attr);
|
||||
m_textrich->AppendText(" is a ");
|
||||
attr.SetFontUnderlined(wxTEXT_ATTR_UNDERLINE_WAVE, *wxRED);
|
||||
attr.SetFontUnderlined(wxTEXT_ATTR_UNDERLINE_SPECIAL, *wxRED);
|
||||
m_textrich->SetDefaultStyle(attr);
|
||||
m_textrich->AppendText("mispeled");
|
||||
attr.SetFontUnderlined(false);
|
||||
|
@@ -126,21 +126,21 @@ static void wxGtkTextApplyTagsFromAttr(GtkWidget *text,
|
||||
|
||||
if ( attr.HasFontUnderlined() )
|
||||
{
|
||||
PangoUnderline pangoUnderlineStyle;
|
||||
PangoUnderline pangoUnderlineStyle = PANGO_UNDERLINE_NONE;
|
||||
switch ( attr.GetUnderlineType() )
|
||||
{
|
||||
case wxTEXT_ATTR_UNDERLINE_NONE:
|
||||
pangoUnderlineStyle = PANGO_UNDERLINE_NONE;
|
||||
break;
|
||||
case wxTEXT_ATTR_UNDERLINE_SOLID:
|
||||
pangoUnderlineStyle = PANGO_UNDERLINE_SINGLE;
|
||||
break;
|
||||
case wxTEXT_ATTR_UNDERLINE_DOUBLE:
|
||||
pangoUnderlineStyle = PANGO_UNDERLINE_DOUBLE;
|
||||
break;
|
||||
case wxTEXT_ATTR_UNDERLINE_WAVE:
|
||||
case wxTEXT_ATTR_UNDERLINE_SPECIAL:
|
||||
pangoUnderlineStyle = PANGO_UNDERLINE_ERROR;
|
||||
break;
|
||||
default:
|
||||
pangoUnderlineStyle = PANGO_UNDERLINE_NONE;
|
||||
break;
|
||||
}
|
||||
|
||||
g_snprintf(buf, sizeof(buf), "WXFONTUNDERLINESTYLE %u",
|
||||
@@ -1922,7 +1922,10 @@ bool wxTextCtrl::GetStyle(long position, wxTextAttr& style)
|
||||
underlineType = wxTEXT_ATTR_UNDERLINE_DOUBLE;
|
||||
break;
|
||||
case PANGO_UNDERLINE_ERROR:
|
||||
underlineType = wxTEXT_ATTR_UNDERLINE_WAVE;
|
||||
underlineType = wxTEXT_ATTR_UNDERLINE_SPECIAL;
|
||||
break;
|
||||
default:
|
||||
underlineType = wxTEXT_ATTR_UNDERLINE_NONE;
|
||||
break;
|
||||
}
|
||||
|
||||
|
@@ -2910,21 +2910,23 @@ bool wxTextCtrl::MSWSetCharFormat(const wxTextAttr& style, long start, long end)
|
||||
if ( style.HasFontUnderlined() )
|
||||
{
|
||||
cf.dwMask |= CFM_UNDERLINETYPE;
|
||||
BYTE underlineType = CFU_UNDERLINENONE;
|
||||
switch ( style.GetUnderlineType() )
|
||||
{
|
||||
case wxTEXT_ATTR_UNDERLINE_NONE:
|
||||
cf.bUnderlineType = CFU_UNDERLINENONE;
|
||||
break;
|
||||
case wxTEXT_ATTR_UNDERLINE_SOLID:
|
||||
cf.bUnderlineType = CFU_UNDERLINE;
|
||||
underlineType = CFU_UNDERLINE;
|
||||
break;
|
||||
case wxTEXT_ATTR_UNDERLINE_DOUBLE:
|
||||
cf.bUnderlineType = CFU_UNDERLINEDOUBLE;
|
||||
underlineType = CFU_UNDERLINEDOUBLE;
|
||||
break;
|
||||
case wxTEXT_ATTR_UNDERLINE_WAVE:
|
||||
cf.bUnderlineType = CFU_UNDERLINEWAVE;
|
||||
case wxTEXT_ATTR_UNDERLINE_SPECIAL:
|
||||
underlineType = CFU_UNDERLINEWAVE;
|
||||
break;
|
||||
default:
|
||||
underlineType = CFU_UNDERLINENONE;
|
||||
break;
|
||||
}
|
||||
cf.bUnderlineType = underlineType;
|
||||
|
||||
#if _RICHEDIT_VER >= 0x0800
|
||||
BYTE colour = 0;
|
||||
@@ -3266,7 +3268,10 @@ bool wxTextCtrl::GetStyle(long position, wxTextAttr& style)
|
||||
underlineType = wxTEXT_ATTR_UNDERLINE_DOUBLE;
|
||||
break;
|
||||
case CFU_UNDERLINEWAVE:
|
||||
underlineType = wxTEXT_ATTR_UNDERLINE_WAVE;
|
||||
underlineType = wxTEXT_ATTR_UNDERLINE_SPECIAL;
|
||||
break;
|
||||
default:
|
||||
underlineType = wxTEXT_ATTR_UNDERLINE_NONE;
|
||||
break;
|
||||
}
|
||||
|
||||
|
@@ -1086,12 +1086,15 @@ bool wxNSTextViewControl::GetStyle(long position, wxTextAttr& style)
|
||||
underlineType = wxTEXT_ATTR_UNDERLINE_DOUBLE;
|
||||
break;
|
||||
case NSUnderlineStyleSingle | NSUnderlinePatternDot:
|
||||
underlineType = wxTEXT_ATTR_UNDERLINE_WAVE;
|
||||
underlineType = wxTEXT_ATTR_UNDERLINE_SPECIAL;
|
||||
break;
|
||||
default:
|
||||
underlineType = wxTEXT_ATTR_UNDERLINE_NONE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
wxColour underlineColour = wxNullColour;
|
||||
wxColour underlineColour;
|
||||
if ( ulcolor )
|
||||
underlineColour = wxColour(ulcolor);
|
||||
|
||||
@@ -1123,24 +1126,23 @@ void wxNSTextViewControl::SetStyle(long start,
|
||||
[attrs setValue:style.GetTextColour().OSXGetNSColor() forKey:NSForegroundColorAttributeName];
|
||||
if ( style.HasFontUnderlined() )
|
||||
{
|
||||
int underlineStyle = NSUnderlineStyleNone;
|
||||
switch ( style.GetUnderlineType() )
|
||||
{
|
||||
case wxTEXT_ATTR_UNDERLINE_NONE:
|
||||
[attrs setObject:[NSNumber numberWithInt:( NSUnderlineStyleNone )] forKey:NSUnderlineStyleAttributeName];
|
||||
break;
|
||||
|
||||
case wxTEXT_ATTR_UNDERLINE_SOLID:
|
||||
[attrs setObject:[NSNumber numberWithInt:( NSUnderlineStyleSingle )] forKey:NSUnderlineStyleAttributeName];
|
||||
underlineStyle = NSUnderlineStyleSingle;
|
||||
break;
|
||||
|
||||
case wxTEXT_ATTR_UNDERLINE_DOUBLE:
|
||||
[attrs setObject:[NSNumber numberWithInt:( NSUnderlineStyleDouble )] forKey:NSUnderlineStyleAttributeName];
|
||||
underlineStyle = NSUnderlineStyleDouble;
|
||||
break;
|
||||
|
||||
case wxTEXT_ATTR_UNDERLINE_WAVE:
|
||||
[attrs setObject:[NSNumber numberWithInt:( NSUnderlineStyleSingle | NSUnderlinePatternDot )] forKey:NSUnderlineStyleAttributeName];
|
||||
case wxTEXT_ATTR_UNDERLINE_SPECIAL:
|
||||
underlineStyle = NSUnderlineStyleSingle | NSUnderlinePatternDot;
|
||||
break;
|
||||
default:
|
||||
underlineStyle = NSUnderlineStyleNone;
|
||||
break;
|
||||
}
|
||||
[attrs setObject:[NSNumber numberWithInt:( underlineStyle )] forKey:NSUnderlineStyleAttributeName];
|
||||
wxColour colour = style.GetUnderlineColour();
|
||||
if ( colour.IsOk() )
|
||||
{
|
||||
@@ -1166,24 +1168,23 @@ void wxNSTextViewControl::SetStyle(long start,
|
||||
if( style.HasFontUnderlined() )
|
||||
{
|
||||
NSMutableDictionary *dict = [[NSMutableDictionary alloc] init];
|
||||
int underlineStyle = NSUnderlineStyleNone;
|
||||
switch ( style.GetUnderlineType() )
|
||||
{
|
||||
case wxTEXT_ATTR_UNDERLINE_NONE:
|
||||
[dict setObject:[NSNumber numberWithInt:( NSUnderlineStyleNone )] forKey:NSUnderlineStyleAttributeName];
|
||||
break;
|
||||
|
||||
case wxTEXT_ATTR_UNDERLINE_SOLID:
|
||||
[dict setObject:[NSNumber numberWithInt:( NSUnderlineStyleSingle )] forKey:NSUnderlineStyleAttributeName];
|
||||
underlineStyle = NSUnderlineStyleSingle;
|
||||
break;
|
||||
|
||||
case wxTEXT_ATTR_UNDERLINE_DOUBLE:
|
||||
[dict setObject:[NSNumber numberWithInt:( NSUnderlineStyleDouble )] forKey:NSUnderlineStyleAttributeName];
|
||||
underlineStyle = NSUnderlineStyleDouble;
|
||||
break;
|
||||
|
||||
case wxTEXT_ATTR_UNDERLINE_WAVE:
|
||||
[dict setObject:[NSNumber numberWithInt:( NSUnderlineStyleSingle | NSUnderlinePatternDot )] forKey:NSUnderlineStyleAttributeName];
|
||||
case wxTEXT_ATTR_UNDERLINE_SPECIAL:
|
||||
underlineStyle = NSUnderlineStyleSingle | NSUnderlinePatternDot;
|
||||
break;
|
||||
default:
|
||||
underlineStyle = NSUnderlineStyleNone;
|
||||
break;
|
||||
}
|
||||
[dict setObject:[NSNumber numberWithInt:( underlineStyle )] forKey:NSUnderlineStyleAttributeName];
|
||||
wxColour colour = style.GetUnderlineColour();
|
||||
if ( colour.IsOk() )
|
||||
{
|
||||
|
Reference in New Issue
Block a user