backported Mac version of GetInfo() from trunk

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_8_BRANCH@51626 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2008-02-10 00:12:55 +00:00
parent b03cf964a3
commit e0c3d1e0d5

View File

@@ -74,6 +74,12 @@
#include "wx/mac/private.h" // includes mac headers #include "wx/mac/private.h" // includes mac headers
#endif #endif
#if defined(__DARWIN__)
#include "wx/mac/corefoundation/cfref.h"
#include <CoreFoundation/CFLocale.h>
#include "wx/mac/corefoundation/cfstring.h"
#endif
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// simple types // simple types
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
@@ -2871,7 +2877,48 @@ wxString wxLocale::GetInfo(wxLocaleInfo index, wxLocaleCategory WXUNUSED(cat))
return str; return str;
} }
#else // !__WXMSW__ #elif defined(__DARWIN__)
/* static */
wxString wxLocale::GetInfo(wxLocaleInfo index, wxLocaleCategory WXUNUSED(cat))
{
CFLocaleRef userLocaleRefRaw;
if ( wxGetLocale() )
{
userLocaleRefRaw = CFLocaleCreate
(
kCFAllocatorDefault,
wxCFStringRef(wxGetLocale()->GetCanonicalName())
);
}
else // no current locale, use the default one
{
userLocaleRefRaw = CFLocaleCopyCurrent();
}
wxCFRef<CFLocaleRef> userLocaleRef(userLocaleRefRaw);
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" );
}
wxCFStringRef
str(CFStringCreateCopy(NULL, static_cast<CFStringRef>(cfstr)));
return str.AsString();
}
#else // !__WXMSW__ && !__DARWIN__
/* static */ /* static */
wxString wxLocale::GetInfo(wxLocaleInfo index, wxLocaleCategory cat) wxString wxLocale::GetInfo(wxLocaleInfo index, wxLocaleCategory cat)