Author Topic: Dark mode support in wx3.3.0  (Read 1513 times)

Offline Miguel Gimenez

  • Developer
  • Lives here!
  • *****
  • Posts: 1640
Dark mode support in wx3.3.0
« on: October 31, 2024, 01:08:24 pm »
I personally hate dark mode, but there is an increasing demand for it.

A recent article from Vadz explains the basics, and looks straightforward to implement the call to SetAppearance() and a setting with three options: use system default, use light and use dark.

EDIT: probably cbStyledTextCtrl needs an update, so this may be not so straightforward.
« Last Edit: October 31, 2024, 02:07:56 pm by Miguel Gimenez »

Offline stahta01

  • Lives here!
  • ****
  • Posts: 7695
    • My Best Post
Re: Dark mode support in wx3.3.0
« Reply #1 on: October 31, 2024, 04:48:18 pm »
Till they release the wxWidgets 3.3.0 development tar ball, I would hold off on most work by the CB Dev team.

Tim S.
« Last Edit: October 31, 2024, 07:34:00 pm by stahta01 »
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 64 bit.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline stahta01

  • Lives here!
  • ****
  • Posts: 7695
    • My Best Post
Re: Dark mode support in wx3.3.0
« Reply #2 on: November 23, 2024, 08:01:55 pm »
Till they release the wxWidgets 3.3.0 development tar ball, I would hold off on most work by the CB Dev team.

Tim S.

Patch I needed to build wxSmith against wxWidgets master branch. It built but, it had run-time issues that I am guessing is a bug that the wxTeam needs to fix. In a few weeks, I will try again and if the problem still exists will try wx sample to confirm it is not an CB issue. It just started happening so I am guessing in the last 30 days the wx master had a bug added. Edit7: The problem went away when I removed wxWidgets 3.2 and the packages that needed it; I am guessing having CB Plugins depends on two different version of wxWidgets resulted in errors loading png files on startup used by wxSmith plugin.

EDIT: Spoke way too soon; the problem is in a contrib package likely wxSmith. It is image loading related to png files from the wxSmith plugin.
Edit3: The problem even happens if I start codeblocks in safe mode; so, wxSmith images are a problem even when the plugin is not running.
I am building an Nov 2 version of wxWidgets to see if it is a recent change that caused the problem there are at least 4 commits about image code changes in the around 20 commits since Nov 2.
Edit4: Problem still exists without the patches started with Mon, 4 Nov 2024 19:38:54 -0800 b21642b72b4128f0b64ed7d79b4d320cbfc35497
I am going to give up for now and sleep; likely build wxWidgets sample to see if the problem happens with them.
Edit5: The issue was happening in the MINGW64 environment; just checked the UCRT64 environment and the problem was gone. So, neither and CB or WX caused image loading bug. So, this patch is ready for someone to use when they want; remember I am still just an C programmer with a little C++ know how.
Edit6: My wild guess is having CB Plugins loaded from two different versions of wxWidgets can cause weird issues. Now, MINGW64 is working after I uninstalled the wxWidgets 3.2 libraries.

Tim S.

Code
diff --git a/src/plugins/contrib/wxSmith/wxwidgets/properties/wxsstyleproperty.cpp b/src/plugins/contrib/wxSmith/wxwidgets/properties/wxsstyleproperty.cpp
index 47861d7b7..aada3a7f9 100644
--- a/src/plugins/contrib/wxSmith/wxwidgets/properties/wxsstyleproperty.cpp
+++ b/src/plugins/contrib/wxSmith/wxwidgets/properties/wxsstyleproperty.cpp
@@ -25,6 +25,7 @@
 #include "../wxsflags.h"
 
 #include <wx/tokenzr.h>
+#include <wx/propgrid/propgrid.h>
 
 // Helper macro for fetching variables
 #define STYLEBITS   wxsVARIABLE(Object,Offset,long)
diff --git a/src/plugins/contrib/wxSmith/wxwidgets/properties/wxscolourproperty.cpp b/src/plugins/contrib/wxSmith/wxwidgets/properties/wxscolourproperty.cpp
index 1474aab1c..6e4a75264 100644
--- a/src/plugins/contrib/wxSmith/wxwidgets/properties/wxscolourproperty.cpp
+++ b/src/plugins/contrib/wxSmith/wxwidgets/properties/wxscolourproperty.cpp
@@ -480,7 +480,11 @@ namespace
         wxASSERT( propgrid );

         // Must only occur when user triggers event
+#if wxCHECK_VERSION(3, 3, 0)
+        if ( !(propgrid->GetInternalFlags() & wxPropertyGrid::wxPG_FL_IN_HANDLECUSTOMEDITOREVENT) )
+#else
         if ( !(propgrid->GetInternalFlags() & wxPG_FL_IN_HANDLECUSTOMEDITOREVENT) )
+#endif
             return res;

         wxColourPropertyValue val = GetVal();
diff --git a/src/plugins/contrib/wxSmith/wxwidgets/wxsitemeditorcontent.h b/src/plugins/contrib/wxSmith/wxwidgets/wxsitemeditorcontent.h
index 57b42059a..78442594f 100644
--- a/src/plugins/contrib/wxSmith/wxwidgets/wxsitemeditorcontent.h
+++ b/src/plugins/contrib/wxSmith/wxwidgets/wxsitemeditorcontent.h
@@ -23,6 +23,7 @@
 #ifndef WXSITEMEDITORCONTENT_H
 #define WXSITEMEDITORCONTENT_H

+#include <wx/hashmap.h>
 #include "wxsdrawingwindow.h"

 class wxsItemEditorDragAssist;

diff --git a/src/plugins/contrib/wxSmith/properties/wxsproperty.h b/src/plugins/contrib/wxSmith/properties/wxsproperty.h
index c55fb5fa8..31d9f6c38 100644
--- a/src/plugins/contrib/wxSmith/properties/wxsproperty.h
+++ b/src/plugins/contrib/wxSmith/properties/wxsproperty.h
@@ -49,7 +49,11 @@ class wxsPropertyContainer;
 #define wxEnumPropertyClass             wxEnumProperty
 #define wxPG_VALUETYPE(T)               wxT(#T)
 #define wxPGVariantToWxObjectPtr(A,B)   wxDynamicCast(A.GetWxObjectPtr(),B)
+#if wxCHECK_VERSION(3, 3, 0)
+#define wxPG_PROP_UNSPECIFIED           wxPGPropertyFlags::AutoUnspecified
+#else
 #define wxPG_PROP_UNSPECIFIED           wxPG_EX_AUTO_UNSPECIFIED_VALUES
+#endif


 /** \brief Class representing one property
---
« Last Edit: November 25, 2024, 05:32:08 pm by stahta01 »
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 64 bit.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org