Developer forums (C::B DEVELOPMENT STRICTLY!) > Development

C::B dark mode in Windows

<< < (2/3) > >>

Miguel Gimenez:
You can test something like this when loading from the lexer

--- Code: ---wxColor fg = LoadFromLexer(FOREGROUND);
wxColor bg = LoadFromLexer(BACKGROUND);
if (DarkMode)
{
    fg.SetRGBA(fg.GetRGBA() ^ 0x00FFFFFF);
    bg.SetRGBA(bg.GetRGBA() ^ 0x00FFFFFF);
}

--- End code ---
inverting them again when saving.

omlk:

--- Quote from: adalbert on November 22, 2023, 12:30:54 pm ---Hello,
I am trying to enable dark mode in MSW build. I think this may be a cool feature for some people who tend to use dark mode in everything.
This is easy if I compile it with wxWidgets 3.3 (from GitHub), one line of code is needed after app starts (https://docs.wxwidgets.org/latest/classwx_app.html#af8c93d7e3345e62a58325f3ab1d158d6)

I will post the code soon. However, I cannot find where in the code of C::B are the default values for editor colors. Where in the source code can I find the colors for editor background/foreground and syntax highlighting? Background is white by default even when using the dark mode.

--- End quote ---
I hope it's not photoshopped. I'm joking. You are still the first to do it (congratulations), but can you use any color in the color palette instead of the black interface, for example?

gd_on:
Don't forget that dark mode for Windows is only supported by wxWidgets 3.3, still a beta version, and until now no provisionnal date has been given for its release.
The only date given is for wxWidgets 3.2.5, in april 2024. v3.2.4 has just been released. So, C::B will certainly not officially support this dark mode for Windows until official wxWidgets 3.3 release.
But of course, you can try it. There are several discussions on this subject on github forums, at least this one : https://github.com/wxWidgets/wxWidgets/pull/23028.
The simplest way to obtain this dark mode (without modifying C::B code), is of course to first compile and link C::B with wxWidgets 3.3.0 under Windows and simply launch it by adding a command line in a batch file like :
set WX_MSW_DARK_MODE=2
codeblocks.exe

Background and standard text colors are set inside wxWidgets. Some others are set by Windows itself. It's also possible to adjust a few colors, but not everything.

adalbert:
OK, I uploaded the code/build files and binaries to GitHub.

https://github.com/adbrt/codeblocks-dark-mode-msw/releases/tag/release
https://github.com/adbrt/codeblocks-dark-mode-msw

Currently I just wanted to create a working proof of concept, so the dark mode is hardcoded using MSWEnableDarkMode(), I adjusted lexers XML files to have dark mode by defauld and also added a default.conf file which changes additional colors (this is necessary to change ie. the caret color). You need to run it using CbLauncher.exe so the default.conf file gets loaded from the app directory.

To make everything proper, a toggle switch for light/dark mode, automatic theme switching etc. would need to be added. But that will require more time.

Also, not only background/foreground of code editor needs to be adjusted, colours of text need to be adjusted individually for normal and dark mode, so it is readable and looks good.



--- Quote from: omlk on November 23, 2023, 08:59:55 pm ---can you use any color in the color palette instead of the black interface, for example?
--- End quote ---
Probably not, at least not without going really deep into the wxWidgets/CodeBlocks code, the dark interface colours are probably hardcoded somewhere, or maybe even hardcoded in the Windows itself

gd_on:
Reading your modifications in C::B code, I think you should guard them at least in  wxscolourproperty.cpp :

--- Code: ---#if wxCHECK_VERSION(3, 3, 0)
    #define wxPG_FL_IN_HANDLECUSTOMEDITOREVENT 0x00080000
#endif // wxCHECK_VERSION

--- End code ---
because the value is not the same in wxWidgets 3.2.3 (or 3.2.4), and with those previous official wxWidgets versions, the compiler has no problems to find it in propgrid.h. I have until now no idea why this value is not found correctly with wxWidgets 3.3.0.

May be you can also guard inclusion of wx/hashmap.h in wxsitemeditorcontent.h, but it's probably not very useful.

--- Code: ---#if wxCHECK_VERSION(3, 3, 0)
    #include <wx/hashmap.h>
#endif // wxCHECK_VERSION

--- End code ---


Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version