X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/6f5d78250c6dd003e8d06fea9e04b710bffdb41f..fd2be5df8d8a250c7987631e996f49ab024a4b54:/src/common/colourcmn.cpp diff --git a/src/common/colourcmn.cpp b/src/common/colourcmn.cpp index a77017922f..a6626f91e2 100644 --- a/src/common/colourcmn.cpp +++ b/src/common/colourcmn.cpp @@ -23,6 +23,7 @@ #include "wx/log.h" #include "wx/utils.h" #include "wx/gdicmn.h" + #include "wx/wxcrtvararg.h" #endif #if wxUSE_VARIANT @@ -33,9 +34,9 @@ IMPLEMENT_VARIANT_OBJECT_EXPORTED(wxColour,WXDLLEXPORT) // wxString <-> wxColour conversions // ============================================================================ -bool wxColourBase::FromString(const wxChar *str) +bool wxColourBase::FromString(const wxString& str) { - if ( str == NULL || str[0] == wxT('\0')) + if ( str.empty() ) return false; // invalid or empty string if ( wxStrncmp(str, wxT("RGB"), 3) == 0 || @@ -45,7 +46,7 @@ bool wxColourBase::FromString(const wxChar *str) // according to http://www.w3.org/TR/REC-CSS2/syndata.html#color-units // values outside 0-255 range are allowed but should be clipped int red, green, blue; - if (wxSscanf(&str[3], wxT("(%d, %d, %d)"), &red, &green, &blue) != 3) + if (wxSscanf(str.wx_str() + 3, wxT("(%d, %d, %d)"), &red, &green, &blue) != 3) return false; Set((unsigned char)wxClip(red,0,255), @@ -56,7 +57,7 @@ bool wxColourBase::FromString(const wxChar *str) { // hexadecimal prefixed with # (HTML syntax) unsigned long tmp; - if (wxSscanf(&str[1], wxT("%lx"), &tmp) != 1) + if (wxSscanf(str.wx_str() + 1, wxT("%lx"), &tmp) != 1) return false; Set((unsigned char)(tmp >> 16),