diff --git a/docs/doxygen/overviews/xrc_format.h b/docs/doxygen/overviews/xrc_format.h
index 4fbf46b86c..a23fba23d1 100644
--- a/docs/doxygen/overviews/xrc_format.h
+++ b/docs/doxygen/overviews/xrc_format.h
@@ -2674,14 +2674,15 @@ should be processed on. It is filtered out and ignored on any other platforms.
Possible elemental values are:
@beginDefList
-@itemdef{ @c win, Windows }
-@itemdef{ @c mac, macOS (or Mac Classic in wxWidgets version supporting it) }
+@itemdef{ @c msw, Windows, preferred platform name }
+@itemdef{ @c win, Windows, alternative synonym }
+@itemdef{ @c mac, macOS or iOS }
@itemdef{ @c unix, Any Unix platform @em except macOS }
@endDefList
Examples:
@code
-
+
Not a Windows machine
diff --git a/include/wx/platinfo.h b/include/wx/platinfo.h
index 863d94f51f..03c5dcc602 100644
--- a/include/wx/platinfo.h
+++ b/include/wx/platinfo.h
@@ -137,6 +137,40 @@ struct wxLinuxDistributionInfo
{ return !(*this == ldi); }
};
+// Platform ID is a very broad platform categorization used in external files
+// (e.g. XRC), so the values here must remain stable and cannot be changed.
+class wxPlatformId
+{
+public:
+ // Returns the preferred current platform name, use MatchesCurrent() to
+ // check if the name is one of the possibly several names corresponding to
+ // the current platform.
+ static wxString GetCurrent()
+ {
+#ifdef __WINDOWS__
+ return wxASCII_STR("msw");
+#elif defined(__APPLE__)
+ return wxASCII_STR("mac");
+#elif defined(__UNIX__)
+ return wxASCII_STR("unix");
+#else
+ return wxString();
+#endif
+ }
+
+ // Returns true if the given string matches the current platform.
+ static bool MatchesCurrent(const wxString& s)
+ {
+ // Under MSW we also support "win" platform name for compatibility with
+ // the existing XRC files using it.
+#ifdef __WINDOWS__
+ if (s == wxASCII_STR("win"))
+ return true;
+#endif // __WINDOWS__
+
+ return s == GetCurrent();
+ }
+};
// ----------------------------------------------------------------------------
// wxPlatformInfo
diff --git a/interface/wx/platinfo.h b/interface/wx/platinfo.h
index 67cd046f97..1c37e09626 100644
--- a/interface/wx/platinfo.h
+++ b/interface/wx/platinfo.h
@@ -138,6 +138,45 @@ struct wxLinuxDistributionInfo
};
+/**
+ @class wxPlatformId
+
+ Defines a very broad platform categorization.
+
+ Usually you would use wxPlatformInfo to get all the platform details rather
+ than this class which only distinguishes between MSW, Mac and Unix
+ platforms.
+
+ This class is mostly useful if a short string describing the platform
+ corresponds to the current platform, i.e. the platform under which the
+ executable runs. The recognized strings are:
+
+ - "msw" (preferred) or "win" (for compatibility) for MSW.
+ - "mac" for Apple systems, i.e. macOS and iOS.
+ - "unix" for the (other) Unix-like systems.
+
+ @since 3.1.5
+ */
+class wxPlatformId
+{
+ /**
+ Returns the preferred current platform name.
+
+ Use MatchesCurrent() to check if the name is one of the possibly
+ several names corresponding to the current platform.
+
+ Returns one of "msw", "mac" or "unix" or an empty string if the current
+ platform is not recognized.
+ */
+ static wxString GetCurrent();
+
+ /**
+ Returns true if the given string matches the current platform.
+ */
+ static bool MatchesCurrent(const wxString& s);
+};
+
+
/**
@class wxPlatformInfo
@@ -590,4 +629,3 @@ public:
//@}
};
-
diff --git a/src/xrc/xmlres.cpp b/src/xrc/xmlres.cpp
index 6b0d8d7a11..4ffeda9723 100644
--- a/src/xrc/xmlres.cpp
+++ b/src/xrc/xmlres.cpp
@@ -42,6 +42,7 @@
#include "wx/hashset.h"
#include "wx/scopedptr.h"
#include "wx/config.h"
+#include "wx/platinfo.h"
#include
#include
@@ -585,15 +586,7 @@ static void ProcessPlatformProperty(wxXmlNode *node)
while (tkn.HasMoreTokens())
{
- s = tkn.GetNextToken();
-#ifdef __WINDOWS__
- if (s == wxT("win")) isok = true;
-#endif
-#if defined(__MAC__) || defined(__APPLE__)
- if (s == wxT("mac")) isok = true;
-#elif defined(__UNIX__)
- if (s == wxT("unix")) isok = true;
-#endif
+ isok = wxPlatformId::MatchesCurrent(tkn.GetNextToken());
if (isok)
break;