Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file removed Resources/Autocheck-bmp.bmp
Binary file not shown.
Binary file removed Resources/Autocheck.bmp
Binary file not shown.
Binary file added Resources/Autocheck16.bmp
Binary file not shown.
Binary file removed Resources/Autocheck2.bmp
Binary file not shown.
Binary file added Resources/Autocheck24.bmp
Binary file not shown.
Binary file added Resources/Autocheck32.bmp
Binary file not shown.
Binary file added Resources/Autocheck64.bmp
Binary file not shown.
Binary file modified Resources/arrow_refresh.ico
Binary file not shown.
1 change: 0 additions & 1 deletion Resources/convert-icon.bat

This file was deleted.

4 changes: 4 additions & 0 deletions Resources/convert-svg-to-bmp.bat
Original file line number Diff line number Diff line change
@@ -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
1 change: 1 addition & 0 deletions Resources/convert-svg-to-ico.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
magick -density 384 -background none %1.svg -define icon:auto-resize=64,48,32,16 %1.ico
22 changes: 18 additions & 4 deletions src/common/raii.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include "Notepad_plus_msgs.h"

#include <OleCtl.h>
#include <cassert>

ToolbarIconsWrapper::ToolbarIconsWrapper() : m_icons{std::make_unique<toolbarIconsWithDarkMode>()} {
m_icons->hToolbarBmp = nullptr;
Expand All @@ -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<const BmpData> 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<size_t>(icon_width) && size == static_cast<size_t>(icon_height); }, &BmpData::size);
if (it == std::cend(bmp_icons)) {
it = std::prev(it);
}
m_icons->hToolbarBmp = static_cast<HBITMAP>(::LoadImage(h_inst, it->name, IMAGE_BITMAP, icon_width, icon_height, style));
m_icons->hToolbarIcon = static_cast<HICON>(::LoadImage(h_inst, normal_name, IMAGE_ICON, icon_width, icon_height, style));
m_icons->hToolbarIconDarkMode = ::LoadIcon(h_inst, dark_mode_name);
}

Expand Down
10 changes: 9 additions & 1 deletion src/common/raii.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,18 @@

#pragma once

#include <span>

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<const BmpData> bmp_icons);
const toolbarIconsWithDarkMode *get();
~ToolbarIconsWrapper();

Expand Down
Binary file modified src/plugin/DSpellCheck.rc
Binary file not shown.
11 changes: 9 additions & 2 deletions src/plugin/Plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -385,8 +385,15 @@ static void command_menu_init() {
}

static void add_icons() {
static ToolbarIconsWrapper auto_check_icon{static_cast<HINSTANCE>(h_module), MAKEINTRESOURCE(IDI_AUTOCHECK), MAKEINTRESOURCE(IDI_AUTOCHECK_DARK),
MAKEINTRESOURCE(IDB_AUTOCHECK_BMP)};
static ToolbarIconsWrapper auto_check_icon{static_cast<HINSTANCE>(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<WPARAM>(func_item[0].cmd_id), reinterpret_cast<LPARAM>(auto_check_icon.get()));
}

Expand Down
6 changes: 5 additions & 1 deletion src/plugin/resource.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down