Replace references to wxLocale by wxUILocale

Use newer wxUILocale class directly instead of using wxLocale functions
that forward to it anyhow.

No real changes.

Closes #22375.
This commit is contained in:
utelle
2022-04-29 09:19:58 +02:00
committed by Vadim Zeitlin
parent a7791781d9
commit 1c65e88221
10 changed files with 37 additions and 35 deletions

View File

@@ -39,6 +39,7 @@
#include "wx/thread.h" #include "wx/thread.h"
#include "wx/vidmode.h" #include "wx/vidmode.h"
#include "wx/evtloop.h" #include "wx/evtloop.h"
#include "wx/uilocale.h"
#if wxUSE_FONTMAP #if wxUSE_FONTMAP
#include "wx/fontmap.h" #include "wx/fontmap.h"
@@ -206,19 +207,11 @@ wxVideoMode wxAppBase::GetDisplayMode() const
wxLayoutDirection wxAppBase::GetLayoutDirection() const wxLayoutDirection wxAppBase::GetLayoutDirection() const
{ {
#if wxUSE_INTL #if wxUSE_INTL
const wxLocale *const locale = wxGetLocale(); return wxUILocale::GetCurrent().GetLayoutDirection();
if ( locale ) #else
{
const wxLanguageInfo *const
info = wxLocale::GetLanguageInfo(locale->GetLanguage());
if ( info )
return info->LayoutDirection;
}
#endif // wxUSE_INTL
// we don't know // we don't know
return wxLayout_Default; return wxLayout_Default;
#endif // wxUSE_INTL
} }
#if wxUSE_CMDLINE_PARSER #if wxUSE_CMDLINE_PARSER

View File

@@ -52,6 +52,7 @@
#include "wx/datetime.h" #include "wx/datetime.h"
#include "wx/time.h" #include "wx/time.h"
#include "wx/uilocale.h"
// ============================================================================ // ============================================================================
// implementation of wxDateTime // implementation of wxDateTime
@@ -320,11 +321,11 @@ wxString wxDateTime::Format(const wxString& formatp, const TimeZone& tz) const
wxString format = formatp; wxString format = formatp;
#ifdef __WXOSX__ #ifdef __WXOSX__
if ( format.Contains("%c") ) if ( format.Contains("%c") )
format.Replace("%c", wxLocale::GetInfo(wxLOCALE_DATE_TIME_FMT)); format.Replace("%c", wxUILocale::GetCurrent().GetInfo(wxLOCALE_DATE_TIME_FMT));
if ( format.Contains("%x") ) if ( format.Contains("%x") )
format.Replace("%x", wxLocale::GetInfo(wxLOCALE_SHORT_DATE_FMT)); format.Replace("%x", wxUILocale::GetCurrent().GetInfo(wxLOCALE_SHORT_DATE_FMT));
if ( format.Contains("%X") ) if ( format.Contains("%X") )
format.Replace("%X", wxLocale::GetInfo(wxLOCALE_TIME_FMT)); format.Replace("%X", wxUILocale::GetCurrent().GetInfo(wxLOCALE_TIME_FMT));
#endif #endif
// we have to use our own implementation if the date is out of range of // we have to use our own implementation if the date is out of range of
// strftime() // strftime()
@@ -1177,7 +1178,7 @@ wxDateTime::ParseFormat(const wxString& date,
#if wxUSE_INTL #if wxUSE_INTL
const wxString const wxString
fmtDateTime = wxLocale::GetInfo(wxLOCALE_DATE_TIME_FMT); fmtDateTime = wxUILocale::GetCurrent().GetInfo(wxLOCALE_DATE_TIME_FMT);
if ( !fmtDateTime.empty() ) if ( !fmtDateTime.empty() )
dt = ParseFormatAt(input, end, fmtDateTime); dt = ParseFormatAt(input, end, fmtDateTime);
#endif // wxUSE_INTL #endif // wxUSE_INTL
@@ -1399,8 +1400,8 @@ wxDateTime::ParseFormat(const wxString& date,
{ {
#if wxUSE_INTL #if wxUSE_INTL
wxString wxString
fmtDate = wxLocale::GetInfo(wxLOCALE_SHORT_DATE_FMT), fmtDate = wxUILocale::GetCurrent().GetInfo(wxLOCALE_SHORT_DATE_FMT),
fmtDateAlt = wxLocale::GetInfo(wxLOCALE_LONG_DATE_FMT); fmtDateAlt = wxUILocale::GetCurrent().GetInfo(wxLOCALE_LONG_DATE_FMT);
#else // !wxUSE_INTL #else // !wxUSE_INTL
wxString fmtDate, fmtDateAlt; wxString fmtDate, fmtDateAlt;
#endif // wxUSE_INTL/!wxUSE_INTL #endif // wxUSE_INTL/!wxUSE_INTL
@@ -1449,7 +1450,7 @@ wxDateTime::ParseFormat(const wxString& date,
case wxT('X'): // locale default time representation case wxT('X'): // locale default time representation
{ {
#if wxUSE_INTL #if wxUSE_INTL
wxString fmtTime = wxLocale::GetInfo(wxLOCALE_TIME_FMT), wxString fmtTime = wxUILocale::GetCurrent().GetInfo(wxLOCALE_TIME_FMT),
fmtTimeAlt; fmtTimeAlt;
#else // !wxUSE_INTL #else // !wxUSE_INTL
wxString fmtTime, fmtTimeAlt; wxString fmtTime, fmtTimeAlt;

View File

@@ -32,6 +32,7 @@
#include <stdlib.h> #include <stdlib.h>
#include "wx/hashmap.h" #include "wx/hashmap.h"
#include "wx/uilocale.h"
#include "wx/vector.h" #include "wx/vector.h"
#include "wx/xlocale.h" #include "wx/xlocale.h"
@@ -1811,8 +1812,8 @@ bool wxString::ToCDouble(double *pVal) const
// Create a copy of this string using the decimal point instead of whatever // Create a copy of this string using the decimal point instead of whatever
// separator the current locale uses. // separator the current locale uses.
#if wxUSE_INTL #if wxUSE_INTL
wxString sep = wxLocale::GetInfo(wxLOCALE_DECIMAL_POINT, wxString sep = wxUILocale::GetCurrent().GetInfo(wxLOCALE_DECIMAL_POINT,
wxLOCALE_CAT_NUMBER); wxLOCALE_CAT_NUMBER);
if ( sep == "." ) if ( sep == "." )
{ {
// We can avoid an unnecessary string copy in this case. // We can avoid an unnecessary string copy in this case.
@@ -1880,8 +1881,8 @@ wxString wxString::FromCDouble(double val, int precision)
wxString s = FromDouble(val, precision); wxString s = FromDouble(val, precision);
#if wxUSE_INTL #if wxUSE_INTL
wxString sep = wxLocale::GetInfo(wxLOCALE_DECIMAL_POINT, wxString sep = wxUILocale::GetCurrent().GetInfo(wxLOCALE_DECIMAL_POINT,
wxLOCALE_CAT_NUMBER); wxLOCALE_CAT_NUMBER);
#else // !wxUSE_INTL #else // !wxUSE_INTL
// As above, this is the most common alternative value. Notice that here it // As above, this is the most common alternative value. Notice that here it
// doesn't matter if we guess wrongly and the current separator is already // doesn't matter if we guess wrongly and the current separator is already

View File

@@ -25,6 +25,7 @@
#include "wx/module.h" #include "wx/module.h"
#endif #endif
#include "wx/uilocale.h"
#include "wx/xlocale.h" #include "wx/xlocale.h"
#include <errno.h> #include <errno.h>
@@ -89,7 +90,7 @@ wxXLocale::wxXLocale(wxLanguage lang)
{ {
m_locale = NULL; m_locale = NULL;
const wxLanguageInfo * const info = wxLocale::GetLanguageInfo(lang); const wxLanguageInfo * const info = wxUILocale::GetLanguageInfo(lang);
if ( info ) if ( info )
{ {
Init(info->GetLocaleName().c_str()); Init(info->GetLocaleName().c_str());

View File

@@ -35,6 +35,7 @@
#include "wx/datectrl.h" #include "wx/datectrl.h"
#include "wx/generic/datectrl.h" #include "wx/generic/datectrl.h"
#include "wx/uilocale.h"
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// constants // constants
@@ -243,7 +244,7 @@ private:
wxString GetLocaleDateFormat() const wxString GetLocaleDateFormat() const
{ {
#if wxUSE_INTL #if wxUSE_INTL
wxString fmt = wxLocale::GetInfo(wxLOCALE_SHORT_DATE_FMT); wxString fmt = wxUILocale::GetCurrent().GetInfo(wxLOCALE_SHORT_DATE_FMT);
if ( HasDPFlag(wxDP_SHOWCENTURY) ) if ( HasDPFlag(wxDP_SHOWCENTURY) )
fmt.Replace("%y", "%Y"); fmt.Replace("%y", "%Y");

View File

@@ -26,6 +26,7 @@
#include "wx/filename.h" #include "wx/filename.h"
#include "wx/textfile.h" #include "wx/textfile.h"
#include "wx/generic/helpext.h" #include "wx/generic/helpext.h"
#include "wx/uilocale.h"
#include <stdio.h> #include <stdio.h>
#include <ctype.h> #include <ctype.h>
@@ -220,10 +221,10 @@ bool wxExtHelpController::LoadFile(const wxString& file)
// "/usr/local/myapp/help" and the current wxLocale is set to be "de", then // "/usr/local/myapp/help" and the current wxLocale is set to be "de", then
// look in "/usr/local/myapp/help/de/" first and fall back to // look in "/usr/local/myapp/help/de/" first and fall back to
// "/usr/local/myapp/help" if that doesn't exist. // "/usr/local/myapp/help" if that doesn't exist.
const wxLocale * const loc = wxGetLocale(); wxLocaleIdent locId = wxUILocale::GetCurrent().GetLocaleId();
if ( loc ) if ( !locId.IsEmpty() )
{ {
wxString locName = loc->GetName(); wxString locName = locId.GetTag(wxLOCALE_TAGTYPE_POSIX);
// the locale is in general of the form xx_YY.zzzz, try the full firm // the locale is in general of the form xx_YY.zzzz, try the full firm
// first and then also more general ones // first and then also more general ones

View File

@@ -27,6 +27,7 @@
#endif // WX_PRECOMP #endif // WX_PRECOMP
#include "wx/timectrl.h" #include "wx/timectrl.h"
#include "wx/uilocale.h"
// This class is only compiled if there is no native version or if we // This class is only compiled if there is no native version or if we
// explicitly want to use both the native and generic one (this is useful for // explicitly want to use both the native and generic one (this is useful for
@@ -85,7 +86,7 @@ public:
// instead of zeros) too as this is the most common unsupported case in // instead of zeros) too as this is the most common unsupported case in
// practice. // practice.
#if wxUSE_INTL #if wxUSE_INTL
m_useAMPM = wxLocale::GetInfo(wxLOCALE_TIME_FMT).Contains("%p"); m_useAMPM = wxUILocale::GetCurrent().GetInfo(wxLOCALE_TIME_FMT).Contains("%p");
#else #else
m_useAMPM = false; m_useAMPM = false;
#endif #endif

View File

@@ -20,6 +20,7 @@
#include "wx/datetimectrl.h" #include "wx/datetimectrl.h"
#include "wx/uilocale.h"
#ifdef wxNEEDS_DATETIMEPICKCTRL #ifdef wxNEEDS_DATETIMEPICKCTRL
@@ -231,7 +232,7 @@ wxSize wxDateTimePickerCtrl::DoGetBestSize() const
{ {
// Use the same native format as the underlying native control. // Use the same native format as the underlying native control.
#if wxUSE_INTL #if wxUSE_INTL
wxString s = wxDateTime::Now().Format(wxLocale::GetOSInfo(MSWGetFormat())); wxString s = wxDateTime::Now().Format(wxUILocale::GetCurrent().GetInfo(MSWGetFormat()));
#else // !wxUSE_INTL #else // !wxUSE_INTL
wxString s("XXX-YYY-ZZZZ"); wxString s("XXX-YYY-ZZZZ");
#endif // wxUSE_INTL/!wxUSE_INTL #endif // wxUSE_INTL/!wxUSE_INTL

View File

@@ -31,6 +31,8 @@
#include "wx/odcombo.h" #include "wx/odcombo.h"
#include "wx/uilocale.h"
// Drawing ARGB on standard DC is supported by OSX and GTK3 // Drawing ARGB on standard DC is supported by OSX and GTK3
#if defined(__WXOSX__) || defined(__WXGTK3__) #if defined(__WXOSX__) || defined(__WXGTK3__)
#define wxPG_DC_SUPPORTS_ALPHA 1 #define wxPG_DC_SUPPORTS_ALPHA 1
@@ -2226,7 +2228,7 @@ wxString wxDateProperty::DetermineDefaultDateFormat( bool showCentury )
{ {
// This code is based on datectlg.cpp's GetLocaleDateFormat() // This code is based on datectlg.cpp's GetLocaleDateFormat()
#if wxUSE_INTL #if wxUSE_INTL
wxString format = wxLocale::GetOSInfo(wxLOCALE_SHORT_DATE_FMT); wxString format = wxUILocale::GetCurrent().GetInfo(wxLOCALE_SHORT_DATE_FMT);
if ( showCentury ) if ( showCentury )
format.Replace(wxS("%y"), wxS("%Y")); format.Replace(wxS("%y"), wxS("%Y"));
else else

View File

@@ -34,6 +34,7 @@
#include "wx/filename.h" #include "wx/filename.h"
#include "wx/app.h" #include "wx/app.h"
#include "wx/apptrait.h" #include "wx/apptrait.h"
#include "wx/uilocale.h"
// other standard headers // other standard headers
#include <ctype.h> #include <ctype.h>
@@ -155,9 +156,8 @@ void wxMimeTypesManagerImpl::LoadXDGApp(const wxString& filename)
wxString nameapp; wxString nameapp;
nIndex = wxNOT_FOUND; nIndex = wxNOT_FOUND;
#if wxUSE_INTL // try "Name[locale name]" first #if wxUSE_INTL // try "Name[locale name]" first
wxLocale *locale = wxGetLocale(); if ( wxUILocale::GetCurrent().IsSupported() )
if ( locale ) nIndex = file.pIndexOf(wxT("Name[")+wxUILocale::GetCurrent().GetName()+wxT("]="));
nIndex = file.pIndexOf(wxT("Name[")+locale->GetName()+wxT("]="));
#endif // wxUSE_INTL #endif // wxUSE_INTL
if(nIndex == wxNOT_FOUND) if(nIndex == wxNOT_FOUND)
nIndex = file.pIndexOf( wxT("Name=") ); nIndex = file.pIndexOf( wxT("Name=") );
@@ -168,8 +168,8 @@ void wxMimeTypesManagerImpl::LoadXDGApp(const wxString& filename)
wxString nameicon, namemini; wxString nameicon, namemini;
nIndex = wxNOT_FOUND; nIndex = wxNOT_FOUND;
#if wxUSE_INTL // try "Icon[locale name]" first #if wxUSE_INTL // try "Icon[locale name]" first
if ( locale ) if ( wxUILocale::GetCurrent().IsSupported() )
nIndex = file.pIndexOf(wxT("Icon[")+locale->GetName()+wxT("]=")); nIndex = file.pIndexOf(wxT("Icon[")+wxUILocale::GetCurrent().GetName()+wxT("]="));
#endif // wxUSE_INTL #endif // wxUSE_INTL
if(nIndex == wxNOT_FOUND) if(nIndex == wxNOT_FOUND)
nIndex = file.pIndexOf( wxT("Icon=") ); nIndex = file.pIndexOf( wxT("Icon=") );