From be19e967dc4dc7aa508be401b8473c1030cc4c07 Mon Sep 17 00:00:00 2001
From: Ian McInerney <ian.s.mcinerney@ieee.org>
Date: Wed, 22 Feb 2023 01:23:32 +0000
Subject: [PATCH] Remove WX_COMPATIBILITY flag

Some classes had been originally designed to be usable separate from wx,
but over time our uses of the classes have become entertwined with wx
features (e.g. colors), and various changes have also leaked wx into the
classes unguarded. So just remove the option to hide wx in those classes
to simplify the code.
---
 CMakeLists.txt                       |  4 ----
 common/gal/color4d.cpp               |  3 +--
 common/tool/tool_event.cpp           |  9 +--------
 include/gal/color4d.h                | 10 ++--------
 include/gal/gal_print.h              |  5 +----
 qa/unittests/common/test_color4d.cpp |  6 ------
 6 files changed, 5 insertions(+), 32 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 7cfb2524b6..6bb8dfc247 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -905,10 +905,6 @@ endif()
 # Find wxWidgets library, required
 #
 
-# Turn on wxWidgets compatibility mode for some classes
-add_compile_definitions( WX_COMPATIBILITY )
-
-
 # Check if '--toolkit=xxx' option has been passed
 string( REGEX MATCH "--toolkit=([a-zA-Z0-9]+)"
     WXWIDGETS_REQUESTED_TOOLKIT "${wxWidgets_CONFIG_OPTIONS}" )
diff --git a/common/gal/color4d.cpp b/common/gal/color4d.cpp
index 6aa78e390d..fea282d3e5 100644
--- a/common/gal/color4d.cpp
+++ b/common/gal/color4d.cpp
@@ -109,7 +109,6 @@ COLOR4D::COLOR4D( EDA_COLOR_T aColor )
 }
 
 
-#ifdef WX_COMPATIBILITY
 COLOR4D::COLOR4D( const wxString& aColorStr )
 {
     if( !SetFromHexString( aColorStr ) )
@@ -242,7 +241,7 @@ COLOR4D COLOR4D::LegacyMix( const COLOR4D& aColor ) const
 
     return candidate;
 }
-#endif
+
 
 namespace KIGFX {
 
diff --git a/common/tool/tool_event.cpp b/common/tool/tool_event.cpp
index df6f411df3..97a5f36a3a 100644
--- a/common/tool/tool_event.cpp
+++ b/common/tool/tool_event.cpp
@@ -30,11 +30,8 @@
 #include <tool/tool_manager.h>
 #include <tool/actions.h>
 
-#ifdef WX_COMPATIBILITY
+
 #include <wx/debug.h>
-#else
-#include <cassert>
-#endif
 
 struct FlagString
 {
@@ -75,11 +72,7 @@ void TOOL_EVENT::init()
 
 VECTOR2D TOOL_EVENT::returnCheckedPosition( const VECTOR2D& aPos ) const
 {
-#ifdef WX_COMPATIBILITY
     wxCHECK_MSG( HasPosition(), VECTOR2D(), "Attempted to get position from non-position event" );
-#else
-    assert( HasPosition() );
-#endif
 
     return aPos;
 }
diff --git a/include/gal/color4d.h b/include/gal/color4d.h
index 97dbb4ec4e..36e1ea6438 100644
--- a/include/gal/color4d.h
+++ b/include/gal/color4d.h
@@ -28,12 +28,10 @@
 #define COLOR4D_H_
 
 #include <wx/debug.h>
-#include <nlohmann/json_fwd.hpp>
-
-#ifdef WX_COMPATIBILITY
 #include <wx/colour.h>
 #include <wx/string.h>
-#endif
+#include <nlohmann/json_fwd.hpp>
+
 
 /**
  * Legacy color enumeration. Also contains a flag and the alpha value in the upper bits
@@ -145,8 +143,6 @@ public:
      */
     COLOR4D& FromCSSRGBA( int aRed, int aGreen, int aBlue, double aAlpha = 1.0 );
 
-#ifdef WX_COMPATIBILITY
-
     /**
      * Defines a color from a CSS or HTML-type string
      * @param aColorStr input string
@@ -182,8 +178,6 @@ public:
      * @param aColor The color to mix with this one
      */
     COLOR4D LegacyMix( const COLOR4D& aColor ) const;
-#endif /* WX_COMPATIBILITY */
-
 
     /**
      * Converts current color (stored in RGB) to HSL format.
diff --git a/include/gal/gal_print.h b/include/gal/gal_print.h
index e0dc01122e..5bc7df7dd6 100644
--- a/include/gal/gal_print.h
+++ b/include/gal/gal_print.h
@@ -19,9 +19,7 @@
 #ifndef GAL_PRINT_H
 #define GAL_PRINT_H
 
-#ifdef WX_COMPATIBILITY
 class wxDC;
-#endif /* WX_COMPATIBILITY */
 
 namespace KIGFX {
 class GAL;
@@ -43,9 +41,8 @@ public:
 class GAL_PRINT
 {
 public:
-#ifdef WX_COMPATIBILITY
     static std::unique_ptr<GAL_PRINT> Create( GAL_DISPLAY_OPTIONS& aOptions, wxDC* aDC );
-#endif /* WX_COMPATIBILITY */
+
     virtual ~GAL_PRINT() {}
 
     virtual GAL* GetGAL() = 0;
diff --git a/qa/unittests/common/test_color4d.cpp b/qa/unittests/common/test_color4d.cpp
index 577a6d5b9b..bd758d1c02 100644
--- a/qa/unittests/common/test_color4d.cpp
+++ b/qa/unittests/common/test_color4d.cpp
@@ -29,9 +29,7 @@
 
 #include <gal/color4d.h>
 
-#ifdef WX_COMPATIBILITY
 #include <wx/colour.h>
-#endif
 
 // All these tests are of a class in KIGFX
 using namespace KIGFX;
@@ -259,8 +257,6 @@ BOOST_AUTO_TEST_CASE( FromHsl )
 }
 
 
-#ifdef WX_COMPATIBILITY
-
 struct WX_CONV_CASE
 {
     wxColour wx;
@@ -309,6 +305,4 @@ BOOST_AUTO_TEST_CASE( FromWx )
     }
 }
 
-#endif // WX_COMPATIBILITY
-
 BOOST_AUTO_TEST_SUITE_END()