From b6d4eda4ad14e22a8168c9f9baccad3f289d46a7 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Fri, 13 Aug 2021 19:09:13 +0200 Subject: [PATCH] Extract wxLOCALE_XXX constants into their own header No real changes, just make it possible to use these constants without including the entire wx/intl.h. Note that the existing headers including wx/intl.h need to keep including it, unfortunately, as not doing it any longer would break compilation of any code including them which relies on _() or wxGetTranslation() being defined after including e.g. wx/dc.h. This was, of course, never guaranteed, but in practice it worked for a very long time, so don't break it now. This commit is best viewed with --color-moved git option. --- Makefile.in | 2 + build/bakefiles/files.bkl | 1 + build/cmake/files.cmake | 1 + build/files | 1 + build/msw/wx_base.vcxproj | 1 + build/msw/wx_base.vcxproj.filters | 3 ++ build/msw/wx_vc8_base.vcproj | 4 ++ build/msw/wx_vc9_base.vcproj | 4 ++ include/wx/intl.h | 57 +---------------------- include/wx/localedefs.h | 77 +++++++++++++++++++++++++++++++ 10 files changed, 95 insertions(+), 56 deletions(-) create mode 100644 include/wx/localedefs.h diff --git a/Makefile.in b/Makefile.in index 3ce1f73320..c24df6bdc2 100644 --- a/Makefile.in +++ b/Makefile.in @@ -581,6 +581,7 @@ ALL_BASE_HEADERS = \ wx/generic/fswatcher.h \ wx/secretstore.h \ wx/lzmastream.h \ + wx/localedefs.h \ $(BASE_PLATFORM_HDR) \ wx/fs_inet.h \ wx/protocol/file.h \ @@ -766,6 +767,7 @@ ALL_PORTS_BASE_HEADERS = \ wx/generic/fswatcher.h \ wx/secretstore.h \ wx/lzmastream.h \ + wx/localedefs.h \ wx/unix/app.h \ wx/unix/apptbase.h \ wx/unix/apptrait.h \ diff --git a/build/bakefiles/files.bkl b/build/bakefiles/files.bkl index ab4f770305..32dca4cde8 100644 --- a/build/bakefiles/files.bkl +++ b/build/bakefiles/files.bkl @@ -735,6 +735,7 @@ IMPORTANT: please read docs/tech/tn0016.txt before modifying this file! wx/generic/fswatcher.h wx/secretstore.h wx/lzmastream.h + wx/localedefs.h diff --git a/build/cmake/files.cmake b/build/cmake/files.cmake index 3b90eda592..535259b3a5 100644 --- a/build/cmake/files.cmake +++ b/build/cmake/files.cmake @@ -651,6 +651,7 @@ set(BASE_CMN_HDR wx/fswatcher.h wx/generic/fswatcher.h wx/lzmastream.h + wx/localedefs.h ) set(NET_UNIX_SRC diff --git a/build/files b/build/files index 5c68b80c8d..574cbb6e37 100644 --- a/build/files +++ b/build/files @@ -574,6 +574,7 @@ BASE_CMN_HDR = wx/link.h wx/list.h wx/listimpl.cpp + wx/localedefs.h wx/log.h wx/longlong.h wx/lzmastream.h diff --git a/build/msw/wx_base.vcxproj b/build/msw/wx_base.vcxproj index 102a6974d7..8f8c9ae262 100644 --- a/build/msw/wx_base.vcxproj +++ b/build/msw/wx_base.vcxproj @@ -823,6 +823,7 @@ + diff --git a/build/msw/wx_base.vcxproj.filters b/build/msw/wx_base.vcxproj.filters index 44e8f07935..4c57355ba1 100644 --- a/build/msw/wx_base.vcxproj.filters +++ b/build/msw/wx_base.vcxproj.filters @@ -598,6 +598,9 @@ Common Headers + + Common Headers + Common Headers diff --git a/build/msw/wx_vc8_base.vcproj b/build/msw/wx_vc8_base.vcproj index 5708485856..69963dce91 100644 --- a/build/msw/wx_vc8_base.vcproj +++ b/build/msw/wx_vc8_base.vcproj @@ -2103,6 +2103,10 @@ RelativePath="..\..\include\wx\list.h" > + + diff --git a/build/msw/wx_vc9_base.vcproj b/build/msw/wx_vc9_base.vcproj index 1accda8c00..1776e4de02 100644 --- a/build/msw/wx_vc9_base.vcproj +++ b/build/msw/wx_vc9_base.vcproj @@ -2099,6 +2099,10 @@ RelativePath="..\..\include\wx\list.h" > + + diff --git a/include/wx/intl.h b/include/wx/intl.h index 2ce148dd54..b5c3458d6c 100644 --- a/include/wx/intl.h +++ b/include/wx/intl.h @@ -13,19 +13,10 @@ #define _WX_INTL_H_ #include "wx/defs.h" +#include "wx/localedefs.h" #include "wx/string.h" #include "wx/translation.h" -// Make wxLayoutDirection enum available without need for wxUSE_INTL so wxWindow, wxApp -// and other classes are not distrubed by wxUSE_INTL - -enum wxLayoutDirection -{ - wxLayout_Default, - wxLayout_LeftToRight, - wxLayout_RightToLeft -}; - #if wxUSE_INTL #include "wx/fontenc.h" @@ -84,52 +75,6 @@ struct WXDLLIMPEXP_BASE wxLanguageInfo const char* TrySetLocale() const; }; -// ---------------------------------------------------------------------------- -// wxLocaleCategory: the category of locale settings -// ---------------------------------------------------------------------------- - -enum wxLocaleCategory -{ - // (any) numbers - wxLOCALE_CAT_NUMBER, - - // date/time - wxLOCALE_CAT_DATE, - - // monetary value - wxLOCALE_CAT_MONEY, - - // default category for wxLocaleInfo values which only apply to a single - // category (e.g. wxLOCALE_SHORT_DATE_FMT) - wxLOCALE_CAT_DEFAULT, - - wxLOCALE_CAT_MAX -}; - -// ---------------------------------------------------------------------------- -// wxLocaleInfo: the items understood by wxLocale::GetInfo() -// ---------------------------------------------------------------------------- - -enum wxLocaleInfo -{ - // the thousands separator (for wxLOCALE_CAT_NUMBER or MONEY) - wxLOCALE_THOUSANDS_SEP, - - // the character used as decimal point (for wxLOCALE_CAT_NUMBER or MONEY) - wxLOCALE_DECIMAL_POINT, - - // the stftime()-formats used for short/long date and time representations - // (under some platforms short and long date formats are the same) - // - // NB: these elements should appear in this order, code in GetInfo() relies - // on it - wxLOCALE_SHORT_DATE_FMT, - wxLOCALE_LONG_DATE_FMT, - wxLOCALE_DATE_TIME_FMT, - wxLOCALE_TIME_FMT - -}; - // ---------------------------------------------------------------------------- // wxLocale: encapsulates all language dependent settings, including current // message catalogs, date, time and currency formats (TODO) &c diff --git a/include/wx/localedefs.h b/include/wx/localedefs.h new file mode 100644 index 0000000000..727c79bbd0 --- /dev/null +++ b/include/wx/localedefs.h @@ -0,0 +1,77 @@ +/////////////////////////////////////////////////////////////////////////////// +// Name: wx/localedefs.h +// Purpose: Definitions of common locale-related constants +// Author: Vadim Zeitlin +// Created: 2021-07-31 (extracted from wx/intl.h) +// Copyright: (c) 2021 Vadim Zeitlin +// Licence: wxWindows licence +/////////////////////////////////////////////////////////////////////////////// + +#ifndef _WX_LOCALEDEFS_H_ +#define _WX_LOCALEDEFS_H_ + +// ---------------------------------------------------------------------------- +// wxLayoutDirection: used by wxWindow, wxDC etc +// ---------------------------------------------------------------------------- + +// Note that this one must be available even when wxUSE_INTL == 0 as it's used +// outside of locale code too. + +enum wxLayoutDirection +{ + wxLayout_Default, + wxLayout_LeftToRight, + wxLayout_RightToLeft +}; + +#if wxUSE_INTL + +// ---------------------------------------------------------------------------- +// wxLocaleCategory: the category of locale settings +// ---------------------------------------------------------------------------- + +enum wxLocaleCategory +{ + // (any) numbers + wxLOCALE_CAT_NUMBER, + + // date/time + wxLOCALE_CAT_DATE, + + // monetary value + wxLOCALE_CAT_MONEY, + + // default category for wxLocaleInfo values which only apply to a single + // category (e.g. wxLOCALE_SHORT_DATE_FMT) + wxLOCALE_CAT_DEFAULT, + + wxLOCALE_CAT_MAX +}; + +// ---------------------------------------------------------------------------- +// wxLocaleInfo: the items understood by wxLocale::GetInfo() +// ---------------------------------------------------------------------------- + +enum wxLocaleInfo +{ + // the thousands separator (for wxLOCALE_CAT_NUMBER or MONEY) + wxLOCALE_THOUSANDS_SEP, + + // the character used as decimal point (for wxLOCALE_CAT_NUMBER or MONEY) + wxLOCALE_DECIMAL_POINT, + + // the stftime()-formats used for short/long date and time representations + // (under some platforms short and long date formats are the same) + // + // NB: these elements should appear in this order, code in GetInfo() relies + // on it + wxLOCALE_SHORT_DATE_FMT, + wxLOCALE_LONG_DATE_FMT, + wxLOCALE_DATE_TIME_FMT, + wxLOCALE_TIME_FMT + +}; + +#endif // wxUSE_INTL + +#endif // _WX_LOCALEDEFS_H_