X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/38ddd614f2329793d7b5a75c4c2fa1e3b5f0fb76..b25278d885906c601a53fe4ddb246da2f68f66f9:/src/common/ctrlcmn.cpp?ds=inline diff --git a/src/common/ctrlcmn.cpp b/src/common/ctrlcmn.cpp old mode 100755 new mode 100644 index ce76a88625..1382c3102c --- a/src/common/ctrlcmn.cpp +++ b/src/common/ctrlcmn.cpp @@ -38,6 +38,8 @@ #include "wx/settings.h" #endif +#include "wx/private/markupparser.h" + const char wxControlNameStr[] = "control"; // ============================================================================ @@ -230,6 +232,31 @@ wxControlBase::GetCompositeControlsDefaultAttributes(wxWindowVariant WXUNUSED(va return attrs; } +// ---------------------------------------------------------------------------- +// wxControl markup support +// ---------------------------------------------------------------------------- + +#if wxUSE_MARKUP + +/* static */ +wxString wxControlBase::RemoveMarkup(const wxString& markup) +{ + return wxMarkupParser::Strip(markup); +} + +bool wxControlBase::DoSetLabelMarkup(const wxString& markup) +{ + const wxString label = RemoveMarkup(markup); + if ( label.empty() && !markup.empty() ) + return false; + + SetLabel(label); + + return true; +} + +#endif // wxUSE_MARKUP + // ---------------------------------------------------------------------------- // wxControlBase - ellipsization code // ---------------------------------------------------------------------------- @@ -402,6 +429,11 @@ wxString wxControlBase::DoEllipsizeSingleLine(const wxString& curLine, const wxD calc.Init(0, 1); while ( !calc.IsShortEnough() ) calc.RemoveFromEnd(); + + // always show at least one character of the string: + if ( calc.m_nCharsToRemove == len ) + return wxString(wxELLIPSE_REPLACEMENT) + curLine[len-1]; + break; } @@ -444,6 +476,15 @@ wxString wxControlBase::DoEllipsizeSingleLine(const wxString& curLine, const wxD else calc.RemoveFromEnd(); } + + // Always show at least one character of the string. + // Additionally, if there's only one character left, prefer + // "a..." to "...a": + if ( calc.m_nCharsToRemove == len || + calc.m_nCharsToRemove == len - 1 ) + { + return curLine[0] + wxString(wxELLIPSE_REPLACEMENT); + } } break; @@ -452,6 +493,11 @@ wxString wxControlBase::DoEllipsizeSingleLine(const wxString& curLine, const wxD calc.Init(len - 1, 1); while ( !calc.IsShortEnough() ) calc.RemoveFromStart(); + + // always show at least one character of the string: + if ( calc.m_nCharsToRemove == len ) + return curLine[0] + wxString(wxELLIPSE_REPLACEMENT); + break; } @@ -542,7 +588,7 @@ wxSize wxStaticBitmapBase::DoGetBestSize() const { wxSize best; wxBitmap bmp = GetBitmap(); - if ( bmp.Ok() ) + if ( bmp.IsOk() ) best = wxSize(bmp.GetWidth(), bmp.GetHeight()); else // this is completely arbitrary