Add a wxHtmlTag helper parsing both absolute values and percents.
This allows to avoid some code duplication in different handlers. Closes #14868. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@73142 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -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<int>(lValue);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
wxString wxHtmlTag::GetAllParams() const
|
||||
{
|
||||
// VS: this function is for backward compatibility only,
|
||||
|
||||
Reference in New Issue
Block a user