From a2a3897124dab93e11fb834205ee150121df3faf Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Tue, 21 Apr 2020 16:29:03 +0200 Subject: [PATCH] Simplify wxWindowID definition Define it in wx/defs.h directly instead of conditionally including wx/windowid.h from there just in order to get this type definition. This has several advantages: - wxWindowIDRef is not defined in (maybe) non-GUI code including wx/defs.h, as it should be the case for this class defined in core library only. - wx/windowid.h becomes a normal header, including wx/defs.h as (almost) all the other ones instead of being exceptional. - wx/windowid.h doesn't need to be included by wx/utils.h at all just to get wxWindowID definition. Closes https://github.com/wxWidgets/wxWidgets/pull/1850 --- include/wx/defs.h | 14 +++----------- include/wx/menuitem.h | 2 ++ include/wx/utils.h | 1 - include/wx/window.h | 1 + include/wx/windowid.h | 4 +--- src/common/windowid.cpp | 4 +--- 6 files changed, 8 insertions(+), 18 deletions(-) diff --git a/include/wx/defs.h b/include/wx/defs.h index 3322d7c5cf..f49ab60f29 100644 --- a/include/wx/defs.h +++ b/include/wx/defs.h @@ -1937,17 +1937,9 @@ enum wxStandardID /* wxWindowID type */ /* ---------------------------------------------------------------------------- */ -/* - * wxWindowID used to be just a typedef defined here, now it's a class, but we - * still continue to define it here for compatibility, so that the code using - * it continues to compile even if it includes just wx/defs.h. - * - * Notice that wx/windowid.h can only be included after wxID_XYZ definitions - * (as it uses them). - */ -#if defined(__cplusplus) && wxUSE_GUI - #include "wx/windowid.h" -#endif +/* Note that this is defined even in non-GUI code as the same type is also used + for e.g. timer IDs. */ +typedef int wxWindowID; /* ---------------------------------------------------------------------------- */ /* other constants */ diff --git a/include/wx/menuitem.h b/include/wx/menuitem.h index 29f63eec7d..8c1d2c68e2 100644 --- a/include/wx/menuitem.h +++ b/include/wx/menuitem.h @@ -21,6 +21,8 @@ #include "wx/object.h" // base class +#include "wx/windowid.h" + // ---------------------------------------------------------------------------- // forward declarations // ---------------------------------------------------------------------------- diff --git a/include/wx/utils.h b/include/wx/utils.h index dbb87cd0aa..4588479e98 100644 --- a/include/wx/utils.h +++ b/include/wx/utils.h @@ -20,7 +20,6 @@ #include "wx/filefn.h" #include "wx/hashmap.h" #include "wx/versioninfo.h" -#include "wx/windowid.h" #include "wx/meta/implicitconversion.h" #if wxUSE_GUI diff --git a/include/wx/window.h b/include/wx/window.h index 814e9487ad..e574fe9df2 100644 --- a/include/wx/window.h +++ b/include/wx/window.h @@ -27,6 +27,7 @@ #include "wx/intl.h" #include "wx/validate.h" // for wxDefaultValidator (always include it) +#include "wx/windowid.h" #if wxUSE_PALETTE #include "wx/palette.h" diff --git a/include/wx/windowid.h b/include/wx/windowid.h index 0c174b5f0c..a6618b6188 100644 --- a/include/wx/windowid.h +++ b/include/wx/windowid.h @@ -10,9 +10,7 @@ #ifndef _WX_WINDOWID_H_ #define _WX_WINDOWID_H_ -// NB: do not include defs.h as we are included from it - -typedef int wxWindowID; +#include "wx/defs.h" // ---------------------------------------------------------------------------- // wxWindowIDRef: reference counted id value diff --git a/src/common/windowid.cpp b/src/common/windowid.cpp index 20a0efbe20..547ff7fc46 100644 --- a/src/common/windowid.cpp +++ b/src/common/windowid.cpp @@ -22,9 +22,7 @@ #endif //WX_PRECOMP #include "wx/hashmap.h" - -// Not needed, included in defs.h -// #include "wx/windowid.h" +#include "wx/windowid.h" namespace {