]> git.saurik.com Git - wxWidgets.git/blobdiff - src/common/variant.cpp
Clip drawing in wxRendererGeneric::DrawHeaderButtonContents().
[wxWidgets.git] / src / common / variant.cpp
index f297b3c4d67e7f81d23968cf132380abec6cbdd5..1820f4b8d5ef41912126fc9a2e31fc4b0ec9b387 100644 (file)
@@ -225,11 +225,10 @@ wxVariant::wxVariant(const wxAny& any)
 
 wxAny wxVariant::GetAny() const
 {
-    wxAny any;
-
     if ( IsNull() )
-        return any;
+        return wxAny();
 
+    wxAny any;
     wxVariantData* data = GetData();
 
     if ( data->GetAsAny(&any) )
@@ -880,6 +879,26 @@ protected:
 
 IMPLEMENT_TRIVIAL_WXANY_CONVERSION(wxString, wxVariantDataString)
 
+#if wxUSE_ANY
+// This allows converting string literal wxAnys to string variants
+wxVariantData* wxVariantDataFromConstCharPAny(const wxAny& any)
+{
+    return new wxVariantDataString(wxANY_AS(any, const char*));
+}
+
+wxVariantData* wxVariantDataFromConstWchar_tPAny(const wxAny& any)
+{
+    return new wxVariantDataString(wxANY_AS(any, const wchar_t*));
+}
+
+_REGISTER_WXANY_CONVERSION(const char*,
+                           ConstCharP,
+                           wxVariantDataFromConstCharPAny)
+_REGISTER_WXANY_CONVERSION(const wchar_t*,
+                           ConstWchar_tP,
+                           wxVariantDataFromConstWchar_tPAny)
+#endif
+
 bool wxVariantDataString::Eq(wxVariantData& data) const
 {
     wxASSERT_MSG( (data.GetType() == wxT("string")), wxT("wxVariantDataString::Eq: argument mismatch") );