From 55be0ed986d5889ea132e37788a00b0bf9543bc4 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Mon, 16 Dec 2024 01:22:29 +0100 Subject: [PATCH] Stop using GDK functions for parsing colours names This shouldn't be necessary now as they use the same CSS colour names that we use too by default and like this switching to "Traditional" colour names also changes wxGTK behaviour to use wxMSW colour values. --- include/wx/gtk/colour.h | 2 -- interface/wx/gdicmn.h | 8 +++++++- src/gtk/colour.cpp | 21 --------------------- 3 files changed, 7 insertions(+), 24 deletions(-) diff --git a/include/wx/gtk/colour.h b/include/wx/gtk/colour.h index 9787519862..b19b8bafc1 100644 --- a/include/wx/gtk/colour.h +++ b/include/wx/gtk/colour.h @@ -49,8 +49,6 @@ protected: virtual void InitRGBA(unsigned char r, unsigned char g, unsigned char b, unsigned char a) override; - virtual bool FromString(const wxString& str) override; - wxDECLARE_DYNAMIC_CLASS(wxColour); }; diff --git a/interface/wx/gdicmn.h b/interface/wx/gdicmn.h index de8a9c4832..9501cae6b6 100644 --- a/interface/wx/gdicmn.h +++ b/interface/wx/gdicmn.h @@ -974,7 +974,13 @@ public: wxTheColourDatabase->UseScheme(wxColourDatabase::Traditional); @endcode - during the application initialization. + during the application initialization. Please note that in the previous + versions wxGTK already used CSS colour values, unlike all the other + ports, so @c Traditional is not actually backwards compatible for + wxGTK, but does make the colour values consistent across all platforms + and the same as had been used by wxMSW and wxOSX before. In other + words, to obtain 100% compatibility with the previous versions, the + UseScheme() call above should be made for all ports except wxGTK. Note that the colour names defined only by wxWidgets, which notably includes all colour variants with spaces in their names, are still diff --git a/src/gtk/colour.cpp b/src/gtk/colour.cpp index adcd081e1a..1dd1c5da61 100644 --- a/src/gtk/colour.cpp +++ b/src/gtk/colour.cpp @@ -253,24 +253,3 @@ wxColour::operator const GdkRGBA*() const return c; } #endif - -bool wxColour::FromString(const wxString& str) -{ -#ifdef __WXGTK3__ - GdkRGBA gdkRGBA; - if (gdk_rgba_parse(&gdkRGBA, str.utf8_str())) - { - *this = wxColour(gdkRGBA); - return true; - } -#else - GdkColor colGDK; - if ( gdk_color_parse( str.utf8_str(), &colGDK ) ) - { - *this = wxColour(colGDK); - return true; - } -#endif - - return wxColourBase::FromString(str); -}