X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/c7155388f5e7ba68d3c50c9234348c7012220c9e..05e66a7002abbc726d3aa53fc5cb42ebaf8748e8:/src/html/htmltag.cpp diff --git a/src/html/htmltag.cpp b/src/html/htmltag.cpp index 7bf1fa8d2e..bf5b298a46 100644 --- a/src/html/htmltag.cpp +++ b/src/html/htmltag.cpp @@ -587,6 +587,38 @@ bool wxHtmlTag::GetParamAsInt(const wxString& par, int *clr) const return true; } +bool +wxHtmlTag::GetParamAsIntOrPercent(const wxString& par, + int* value, + bool& isPercent) const +{ + const wxString param = GetParam(par); + if ( param.empty() ) + return false; + + wxString num; + if ( param.EndsWith("%", &num) ) + { + isPercent = true; + } + else + { + isPercent = false; + num = param; + } + + long lValue; + if ( !num.ToLong(&lValue) ) + return false; + + if ( lValue > INT_MAX || lValue < INT_MIN ) + return false; + + *value = static_cast(lValue); + + return true; +} + wxString wxHtmlTag::GetAllParams() const { // VS: this function is for backward compatibility only,