Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add wxUILocale class usable under macOS #2464

Merged
merged 28 commits into from
Aug 26, 2021
Merged

Add wxUILocale class usable under macOS #2464

merged 28 commits into from
Aug 26, 2021

Commits on Aug 7, 2021

  1. Extract wxLocaleSetter from the tests into a private header

    This will allow using this class in the library code too.
    
    No real changes yet, this is a pure refactoring.
    
    This commit is best viewed using git --color-moved option.
    vadz committed Aug 7, 2021
    Configuration menu
    Copy the full SHA
    a4940bf View commit details
    Browse the repository at this point in the history
  2. Allow using wxLOCALE_CAT_DEFAULT for numeric or money locale info

    Make GetInfo() return information for numbers by default in the Unix
    version too instead of asserting, as this is more consistent with the
    MSW and Mac versions and also seems more useful.
    vadz committed Aug 7, 2021
    Configuration menu
    Copy the full SHA
    33ae58e View commit details
    Browse the repository at this point in the history
  3. Interpret empty language as "default" in the internat sample

    This provides a more convenient way of testing wxLANGUAGE_DEFAULT than
    selecting it from the dialog shown on startup.
    
    This commit is best viewed ignoring whitespace-only changes.
    vadz committed Aug 7, 2021
    Configuration menu
    Copy the full SHA
    93190d6 View commit details
    Browse the repository at this point in the history
  4. Show more locale-dependent controls in the internat sample

    Show that file dialogs, spin and calendar controls also respect the
    selected locale conventions.
    vadz committed Aug 7, 2021
    Configuration menu
    Copy the full SHA
    1f74e7c View commit details
    Browse the repository at this point in the history

Commits on Aug 14, 2021

  1. Show using wxNumberFormatter in the internat sample too

    This shows that C and UI (or OS) locales can be different.
    vadz committed Aug 14, 2021
    Configuration menu
    Copy the full SHA
    7dc6462 View commit details
    Browse the repository at this point in the history
  2. Use wxTranslations directly instead of passing by wxLocale

    This is slightly more verbose, but more clear and allows to separate the
    translations-related part from locale-changing one.
    vadz committed Aug 14, 2021
    Configuration menu
    Copy the full SHA
    4db5de9 View commit details
    Browse the repository at this point in the history
  3. Use a panel in internat sample to make it look better under MSW

    Creating the controls directly on wxFrame is not recommended and looks
    ugly under MSW due to the wrong background being used, so add an
    intermediate panel.
    vadz committed Aug 14, 2021
    Configuration menu
    Copy the full SHA
    e0cd2c6 View commit details
    Browse the repository at this point in the history
  4. Add an option to skip changing locale in the internat sample

    Show that we can use the translations to the user language even without
    changing the locale.
    vadz committed Aug 14, 2021
    Configuration menu
    Copy the full SHA
    4adb58b View commit details
    Browse the repository at this point in the history
  5. Stop allowing to select the language in the internat sample

    Restrict the choice to using the current system locale or not using it,
    as setting any other language doesn't, and can't, work under macOS.
    vadz committed Aug 14, 2021
    Configuration menu
    Copy the full SHA
    eb5bffd View commit details
    Browse the repository at this point in the history
  6. Don't load translations when setting the locale is disabled too

    It makes more sense to skip loading the translations too, if the user
    decided not to use the current locale.
    
    This commit is best viewed ignoring whitespace-only changes.
    vadz committed Aug 14, 2021
    Configuration menu
    Copy the full SHA
    31677e5 View commit details
    Browse the repository at this point in the history
  7. Add internat sample command line option to skip the locale dialog

    Getting this dialog all the time is annoying when testing, so add
    another command line option to set the locale unconditionally.
    
    This commit is best viewed ignoring whitespace-only changes.
    vadz committed Aug 14, 2021
    Configuration menu
    Copy the full SHA
    afe04f7 View commit details
    Browse the repository at this point in the history
  8. 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.
    vadz committed Aug 14, 2021
    Configuration menu
    Copy the full SHA
    b6d4eda View commit details
    Browse the repository at this point in the history
  9. Display locale information directly in the main sample frame

    This is more convenient than having to open the "About" dialog to see
    the details of the locale being used.
    
    It also makes it unnecessary to store wxLocale reference in the frame
    class, simplifying the sample code.
    vadz committed Aug 14, 2021
    Configuration menu
    Copy the full SHA
    b12961f View commit details
    Browse the repository at this point in the history

Commits on Aug 20, 2021

  1. Add wxUILocale with minimal functionality

    Use it in the sample to show what (little) it can do right now.
    vadz committed Aug 20, 2021
    Configuration menu
    Copy the full SHA
    b9cbe67 View commit details
    Browse the repository at this point in the history
  2. Remove obsolete AIX workaround from wxLocale code

    This code, added back in 420de41 (workaround for buggy setlocale()
    under AIX (without this wxLocale didn't work at all), 2005-09-18), is
    probably irrelevant anyhow because AIX 5.2 must not be used any more,
    but also seems to have lost its purpose at some time during the
    intervening years, as we don't use "retloc" as argument to setlocale()
    anyhow, so it is doubly safe to simply remove it.
    vadz committed Aug 20, 2021
    Configuration menu
    Copy the full SHA
    8f20dd3 View commit details
    Browse the repository at this point in the history
  3. Use Core Foundation for testing locale availability under Mac

    Using setlocale() is not the right way to do it there, try checking if
    the locale is supported by Core Foundation instead of whether it's
    supported by the Unix layer which is neglected and not used under Mac.
    vadz committed Aug 20, 2021
    Configuration menu
    Copy the full SHA
    59a4505 View commit details
    Browse the repository at this point in the history
  4. Move wxLanguageInfo declaration to wx/localedefs.h too

    No real changes, just allow wxUILocale code to use this struct without
    including the full wx/intl.h.
    
    This commit is best viewed with --color-moved git option.
    vadz committed Aug 20, 2021
    Configuration menu
    Copy the full SHA
    405bb3e View commit details
    Browse the repository at this point in the history
  5. Untangle Mac and POSIX code in wxLocale::GetSystemLanguage()

    Most of the code in this function was Unix-specific and didn't make
    sense for Mac, where we never have to apply the workarounds in it nor
    deal with languages specified without the territory etc, so separate Mac
    branch using CoreFouundation API from the rest of the Unix code to make
    things more understandable.
    
    No real changes.
    vadz committed Aug 20, 2021
    Configuration menu
    Copy the full SHA
    d3a1aba View commit details
    Browse the repository at this point in the history
  6. Move platform-specific parts of wxLocale::Init() to wxUILocale

    This is tidier than using #ifdefs in the same common file and also
    ensures that initializing wxLocale affects wxUILocale too, which will be
    important for compatibility when the code elsewhere is modified to use
    wxUILocale::GetInfo() instead of wxLocale::GetInfo() in the upcoming
    commits.
    
    This commit is best viewed with --color-moved git option.
    vadz committed Aug 20, 2021
    Configuration menu
    Copy the full SHA
    37a23e1 View commit details
    Browse the repository at this point in the history
  7. Use wxUILocale in wxNumberFormatter

    Always use the UI locale conventions for floating point numbers in
    wxNumberFormatter, making it different from wxString::{To,From}Double()
    functions that use C locale, which may, or not, correspond to the UI
    locale.
    vadz committed Aug 20, 2021
    Configuration menu
    Copy the full SHA
    b3cab73 View commit details
    Browse the repository at this point in the history
  8. Use wxUILocale in wxSpinCtrlDouble

    This ensures that we use the decimal separator corresponding to the UI
    locale of the application, rather than C locale, so that e.g. comma is
    used under macOS even if setlocale() is not used.
    vadz committed Aug 20, 2021
    Configuration menu
    Copy the full SHA
    85d3799 View commit details
    Browse the repository at this point in the history
  9. Add wxNumberFormatter::Format() for floating point numbers

    The existing ToString() is not flexible enough to be used in wxGrid,
    which supports specifying the width (and not just the precision) as well
    as using formats other than "%g" and "%f" which are the only ones
    supported by the existing function.
    
    Note that currently the implementation simply calls wxString::Format()
    and then adjusts the decimal separator, but it could, in principle, use
    wxUILocale methods for formatting the floating point numbers using
    native platform functions for doing this, e.g. CFNumberFormatter under
    macOS.
    vadz committed Aug 20, 2021
    Configuration menu
    Copy the full SHA
    3fc031e View commit details
    Browse the repository at this point in the history
  10. Use wxNumberFormatter in wxGrid number renderer and editor

    This ensures that the correct, i.e. matching the users default, decimal
    point separator is used even if setlocale() is not called.
    
    Also simplify the code a bit by removing checks for wxUSE_INTL already
    present in wxNumberFormatter itself.
    vadz committed Aug 20, 2021
    Configuration menu
    Copy the full SHA
    e438f9a View commit details
    Browse the repository at this point in the history
  11. Add wxGetUIDateFormat() helper function

    Retrieve thr date format to use, even when wxUSE_INTL==0.
    vadz committed Aug 20, 2021
    Configuration menu
    Copy the full SHA
    8fa853a View commit details
    Browse the repository at this point in the history
  12. Use wxUILocale for formatting dates in wxGrid

    This is similar to the previous commit and ensures that the correct date
    format is used even if setlocale() is not called.
    vadz committed Aug 20, 2021
    Configuration menu
    Copy the full SHA
    d08fc75 View commit details
    Browse the repository at this point in the history
  13. Add a wxGrid with numbers and dates to the internat sample

    Show that the numbers and dates in wxGrid use the expected formats.
    vadz committed Aug 20, 2021
    Configuration menu
    Copy the full SHA
    8373b14 View commit details
    Browse the repository at this point in the history
  14. Use wxUILocale for date formatting in wxDataViewDateRenderer

    Use the appropriate format for the dates by using the UI, rather than C,
    locale, similarly to wxGrid.
    vadz committed Aug 20, 2021
    Configuration menu
    Copy the full SHA
    c746953 View commit details
    Browse the repository at this point in the history
  15. Demonstrate the thousands separator in internat sample too

    Use a number > 1000 to show the difference between the locales.
    vadz committed Aug 20, 2021
    Configuration menu
    Copy the full SHA
    9205209 View commit details
    Browse the repository at this point in the history