]> git.saurik.com Git - wxWidgets.git/commitdiff
implement wxLocale::GetInfo() using CFLocale (modified patch 1760939)
authorVadim Zeitlin <vadim@wxwidgets.org>
Sun, 4 Nov 2007 16:01:05 +0000 (16:01 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Sun, 4 Nov 2007 16:01:05 +0000 (16:01 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@49623 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

docs/changes.txt
src/common/intl.cpp

index 79c2c314d5917203e7c605a3e9b2e0bee90ec659..45fcba561a8259bd516fd6c2354b236c1f9a5ba4 100644 (file)
@@ -248,6 +248,7 @@ wxMac:
 - Fix duplicate (empty) help menu in non-English programs (Andreas Jacobs).
 - Allow accelerators to be used with buttons too (Ryan Wilcox).
 - Support resource forks in wxCopyFile() (Hank Schultz).
+- Implement wxLocale::GetInfo() using CFLocale
 
 wxMSW:
 
index a90f2526d0cad1597b22b4a43108b9c616c77d4f..58aaf5c0184307dc8d534ead0a146ab49a320884 100644 (file)
 #include "wx/filesys.h"
 
 #if defined(__WXMAC__)
-    #include  "wx/mac/private.h"  // includes mac headers
+    #include "wx/mac/private.h"  // includes mac headers
+#endif
+
+#if defined(__WXOSX__)
+    #include "wx/mac/corefoundation/cfstring.h"
+    #include "wx/mac/corefoundation/cfref.h"
 #endif
 
 // ----------------------------------------------------------------------------
@@ -2860,7 +2865,7 @@ bool wxLocale::AddCatalog(const wxString& szDomain,
 // accessors for locale-dependent data
 // ----------------------------------------------------------------------------
 
-#ifdef __WXMSW__
+#if defined(__WXMSW__)
 
 /* static */
 wxString wxLocale::GetInfo(wxLocaleInfo index, wxLocaleCategory WXUNUSED(cat))
@@ -2900,7 +2905,33 @@ wxString wxLocale::GetInfo(wxLocaleInfo index, wxLocaleCategory WXUNUSED(cat))
     return str;
 }
 
-#else // !__WXMSW__
+#elif defined(__WXOSX__)
+
+/* static */
+wxString wxLocale::GetInfo(wxLocaleInfo index, wxLocaleCategory WXUNUSED(cat))
+{
+    wxCFRef<CFLocaleRef> userLocaleRef(CFLocaleCopyCurrent());
+    CFTypeRef cfstr;
+    switch ( index )
+    {
+        case wxLOCALE_THOUSANDS_SEP:
+            cfstr = CFLocaleGetValue(userLocaleRef, kCFLocaleGroupingSeparator);
+            break;
+
+        case wxLOCALE_DECIMAL_POINT:
+            cfstr = CFLocaleGetValue(userLocaleRef, kCFLocaleDecimalSeparator);
+            break;
+
+        default:
+            wxFAIL_MSG( "Unknown locale info" );
+    }
+
+    wxMacCFStringHolder
+        str(CFStringCreateCopy(NULL, static_cast<CFStringRef>(cfstr)));
+    return str.AsString();
+}
+
+#else // !__WXMSW__ && !__WXMAC__
 
 /* static */
 wxString wxLocale::GetInfo(wxLocaleInfo index, wxLocaleCategory cat)
@@ -2937,7 +2968,7 @@ wxString wxLocale::GetInfo(wxLocaleInfo index, wxLocaleCategory cat)
     }
 }
 
-#endif // __WXMSW__/!__WXMSW__
+#endif // platform
 
 // ----------------------------------------------------------------------------
 // global functions and variables