Fix handling of ampersands in wxDataViewCtrl markup

Handle "&" in exactly the same way as "&" in wxMarkupParser, i.e. do not
map the former to "&&" to prevent it from being interpreted as a mnemonic as
this is incompatible with using markup for anything but the control labels,
e.g. for wxDataViewCtrl items text, in which mnemonics are not recognized.
And even when using markup for control labels, it was a questionable decision
as it's really not clear at all why should the XML entity and the raw
character itself be handled differently.

Also split wxMarkupText into two classes, wxMarkupText that handles
mnemonics in the markup (which is typically a label) and a very
similar, but not derived, wxItemMarkupText that handles mnemonics-less
markup for list etc. items, uses DrawItemText() and supports
ellipsizing.

Illustrate the use of ampersands in the dataview sample.
This commit is contained in:
Václav Slavík
2017-02-13 20:09:19 +01:00
committed by Václav Slavík
parent 0e2f6f6ec0
commit 60bd6842e4
6 changed files with 94 additions and 62 deletions

View File

@@ -1067,7 +1067,7 @@ void wxDataViewTextRenderer::EnableMarkup(bool enable)
{
if ( !m_markupText )
{
m_markupText = new wxMarkupText(wxString());
m_markupText = new wxItemMarkupText(wxString());
}
}
else
@@ -1087,7 +1087,7 @@ bool wxDataViewTextRenderer::SetValue( const wxVariant &value )
#if wxUSE_MARKUP
if ( m_markupText )
m_markupText->SetMarkupText(m_text);
m_markupText->SetMarkup(m_text);
#endif // wxUSE_MARKUP
return true;
@@ -1135,7 +1135,7 @@ bool wxDataViewTextRenderer::Render(wxRect rect, wxDC *dc, int state)
int flags = 0;
if ( state & wxDATAVIEW_CELL_SELECTED )
flags |= wxCONTROL_SELECTED;
m_markupText->RenderItemText(GetView(), *dc, rect, flags, GetEllipsizeMode());
m_markupText->Render(GetView(), *dc, rect, flags, GetEllipsizeMode());
}
else
#endif // wxUSE_MARKUP