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