diff --git a/Resources/Autocheck-bmp.bmp b/Resources/Autocheck-bmp.bmp deleted file mode 100644 index b5f271c7..00000000 Binary files a/Resources/Autocheck-bmp.bmp and /dev/null differ diff --git a/Resources/Autocheck.bmp b/Resources/Autocheck.bmp deleted file mode 100644 index d4e830b8..00000000 Binary files a/Resources/Autocheck.bmp and /dev/null differ diff --git a/Resources/Autocheck16.bmp b/Resources/Autocheck16.bmp new file mode 100644 index 00000000..716aff6a Binary files /dev/null and b/Resources/Autocheck16.bmp differ diff --git a/Resources/Autocheck2.bmp b/Resources/Autocheck2.bmp deleted file mode 100644 index 88156429..00000000 Binary files a/Resources/Autocheck2.bmp and /dev/null differ diff --git a/Resources/Autocheck24.bmp b/Resources/Autocheck24.bmp new file mode 100644 index 00000000..c7a82e69 Binary files /dev/null and b/Resources/Autocheck24.bmp differ diff --git a/Resources/Autocheck32.bmp b/Resources/Autocheck32.bmp new file mode 100644 index 00000000..cfb3d49a Binary files /dev/null and b/Resources/Autocheck32.bmp differ diff --git a/Resources/Autocheck64.bmp b/Resources/Autocheck64.bmp new file mode 100644 index 00000000..abf2224d Binary files /dev/null and b/Resources/Autocheck64.bmp differ diff --git a/Resources/arrow_refresh.ico b/Resources/arrow_refresh.ico index 61b5d56a..00366b62 100644 Binary files a/Resources/arrow_refresh.ico and b/Resources/arrow_refresh.ico differ diff --git a/Resources/convert-icon.bat b/Resources/convert-icon.bat deleted file mode 100644 index ffda0566..00000000 --- a/Resources/convert-icon.bat +++ /dev/null @@ -1 +0,0 @@ -magick convert -density 384 -background none %1.svg -define icon:auto-resize=64,48,32,16 %1.ico \ No newline at end of file diff --git a/Resources/convert-svg-to-bmp.bat b/Resources/convert-svg-to-bmp.bat new file mode 100644 index 00000000..c6f6926c --- /dev/null +++ b/Resources/convert-svg-to-bmp.bat @@ -0,0 +1,4 @@ +magick %1.svg -resize 16x16 -density 384 BMP3:%116.bmp +magick %1.svg -resize 24x24 -density 384 BMP3:%124.bmp +magick %1.svg -resize 32x32 -density 384 BMP3:%132.bmp +magick %1.svg -resize 64x64 -density 384 BMP3:%164.bmp diff --git a/Resources/convert-svg-to-ico.bat b/Resources/convert-svg-to-ico.bat new file mode 100644 index 00000000..320fd379 --- /dev/null +++ b/Resources/convert-svg-to-ico.bat @@ -0,0 +1 @@ +magick -density 384 -background none %1.svg -define icon:auto-resize=64,48,32,16 %1.ico \ No newline at end of file diff --git a/src/common/raii.cpp b/src/common/raii.cpp index a97634b8..a1765630 100644 --- a/src/common/raii.cpp +++ b/src/common/raii.cpp @@ -17,6 +17,7 @@ #include "Notepad_plus_msgs.h" #include +#include ToolbarIconsWrapper::ToolbarIconsWrapper() : m_icons{std::make_unique()} { m_icons->hToolbarBmp = nullptr; @@ -35,10 +36,23 @@ ToolbarIconsWrapper::~ToolbarIconsWrapper() { DeleteObject(m_icons->hToolbarIconDarkMode); } -ToolbarIconsWrapper::ToolbarIconsWrapper(HINSTANCE h_inst, LPCWSTR normal_name, LPCWSTR dark_mode_name, LPCWSTR bmp_name) - : ToolbarIconsWrapper() { - m_icons->hToolbarBmp = ::LoadBitmap(h_inst, bmp_name); - m_icons->hToolbarIcon = ::LoadIcon(h_inst, normal_name); +ToolbarIconsWrapper::ToolbarIconsWrapper(HINSTANCE h_inst, LPCWSTR normal_name, LPCWSTR dark_mode_name, std::span bmp_icons) + : ToolbarIconsWrapper() { + HDC hdc = ::GetDC(NULL); + int icon_width = 0; + int icon_height = 0; + if (hdc) { + icon_width = ::MulDiv(16, GetDeviceCaps(hdc, LOGPIXELSX), 96); + icon_height = ::MulDiv(16, GetDeviceCaps(hdc, LOGPIXELSY), 96); + } + auto style = (LR_LOADTRANSPARENT | LR_DEFAULTSIZE | LR_LOADMAP3DCOLORS); + assert(!bmp_icons.empty()); + auto it = std::ranges::find_if(bmp_icons, [&](size_t size) { return size == static_cast(icon_width) && size == static_cast(icon_height); }, &BmpData::size); + if (it == std::cend(bmp_icons)) { + it = std::prev(it); + } + m_icons->hToolbarBmp = static_cast(::LoadImage(h_inst, it->name, IMAGE_BITMAP, icon_width, icon_height, style)); + m_icons->hToolbarIcon = static_cast(::LoadImage(h_inst, normal_name, IMAGE_ICON, icon_width, icon_height, style)); m_icons->hToolbarIconDarkMode = ::LoadIcon(h_inst, dark_mode_name); } diff --git a/src/common/raii.h b/src/common/raii.h index 1aa77684..e93cd78b 100644 --- a/src/common/raii.h +++ b/src/common/raii.h @@ -14,10 +14,18 @@ #pragma once +#include + struct toolbarIconsWithDarkMode; +struct BmpData +{ + size_t size; + LPCWSTR name; +}; + struct ToolbarIconsWrapper { - ToolbarIconsWrapper(HINSTANCE h_inst, LPCWSTR normal_name, LPCWSTR dark_mode_name, LPCWSTR bmp_name); + ToolbarIconsWrapper(HINSTANCE h_inst, LPCWSTR normal_name, LPCWSTR dark_mode_name, std::span bmp_icons); const toolbarIconsWithDarkMode *get(); ~ToolbarIconsWrapper(); diff --git a/src/plugin/DSpellCheck.rc b/src/plugin/DSpellCheck.rc index 6b1c94b4..98661a6f 100644 Binary files a/src/plugin/DSpellCheck.rc and b/src/plugin/DSpellCheck.rc differ diff --git a/src/plugin/Plugin.cpp b/src/plugin/Plugin.cpp index 66443b4f..5665901a 100644 --- a/src/plugin/Plugin.cpp +++ b/src/plugin/Plugin.cpp @@ -385,8 +385,15 @@ static void command_menu_init() { } static void add_icons() { - static ToolbarIconsWrapper auto_check_icon{static_cast(h_module), MAKEINTRESOURCE(IDI_AUTOCHECK), MAKEINTRESOURCE(IDI_AUTOCHECK_DARK), - MAKEINTRESOURCE(IDB_AUTOCHECK_BMP)}; + static ToolbarIconsWrapper auto_check_icon{static_cast(h_module), + MAKEINTRESOURCE(IDI_AUTOCHECK), + MAKEINTRESOURCE(IDI_AUTOCHECK_DARK), + std::array{ + BmpData{16, MAKEINTRESOURCE(IDB_AUTOCHECK_BMP_16)}, + BmpData{24, MAKEINTRESOURCE(IDB_AUTOCHECK_BMP_24)}, + BmpData{32, MAKEINTRESOURCE(IDB_AUTOCHECK_BMP_32)}, + BmpData{64, MAKEINTRESOURCE(IDB_AUTOCHECK_BMP_64)} + }}; ::SendMessage(npp_data.npp_handle, NPPM_ADDTOOLBARICON_FORDARKMODE, static_cast(func_item[0].cmd_id), reinterpret_cast(auto_check_icon.get())); } diff --git a/src/plugin/resource.h b/src/plugin/resource.h index d88d18e7..0d30d6a0 100644 --- a/src/plugin/resource.h +++ b/src/plugin/resource.h @@ -9,7 +9,11 @@ #define IDR_DOWNARROW_PUSH 104 #define IDD_CHOOSE_MULTIPLE_LANGUAGES 106 #define IDD_ABOUT 107 +#define IDB_AUTOCHECK_BMP_16 107 +#define IDB_AUTOCHECK_BMP_24 108 #define IDD_DOWNLOADDICS 109 +#define IDB_AUTOCHECK_BMP_32 109 +#define IDB_AUTOCHECK_BMP_64 110 #define IDD_DIALOGPROGRESS 111 #define IDD_REMOVE_DICS 113 #define IDI_REFRESH 128 @@ -227,7 +231,7 @@ // #ifdef APSTUDIO_INVOKED #ifndef APSTUDIO_READONLY_SYMBOLS -#define _APS_NEXT_RESOURCE_VALUE 106 +#define _APS_NEXT_RESOURCE_VALUE 111 #define _APS_NEXT_COMMAND_VALUE 40001 #define _APS_NEXT_CONTROL_VALUE 1010 #define _APS_NEXT_SYMED_VALUE 101