diff --git a/PowerEditor/src/Notepad_plus.cpp b/PowerEditor/src/Notepad_plus.cpp
index 86ae59844..b09c89971 100644
--- a/PowerEditor/src/Notepad_plus.cpp
+++ b/PowerEditor/src/Notepad_plus.cpp
@@ -140,7 +140,7 @@ Notepad_plus::Notepad_plus()
nppParam.setNativeLangSpeaker(&_nativeLangSpeaker);
- TiXmlDocument *toolIconsDocRoot = nppParam.getToolIcons();
+ TiXmlDocument *toolIconsDocRoot = nppParam.getCustomizedToolIcons();
if (toolIconsDocRoot)
{
diff --git a/PowerEditor/src/Parameters.h b/PowerEditor/src/Parameters.h
index aa07af6db..3e0accb3a 100644
--- a/PowerEditor/src/Parameters.h
+++ b/PowerEditor/src/Parameters.h
@@ -1469,7 +1469,7 @@ public:
TiXmlDocumentA * getNativeLangA() const {return _pXmlNativeLangDocA;};
- TiXmlDocument * getToolIcons() const {return _pXmlToolIconsDoc;};
+ TiXmlDocument * getCustomizedToolIcons() const {return _pXmlToolIconsDoc;};
bool isTransparentAvailable() const {
return (_transparentFuncAddr != NULL);
diff --git a/PowerEditor/src/WinControls/ImageListSet/ImageListSet.cpp b/PowerEditor/src/WinControls/ImageListSet/ImageListSet.cpp
index 643dda918..334333471 100644
--- a/PowerEditor/src/WinControls/ImageListSet/ImageListSet.cpp
+++ b/PowerEditor/src/WinControls/ImageListSet/ImageListSet.cpp
@@ -58,12 +58,12 @@ void IconList::addIcon(HICON hIcon) const
ImageList_AddIcon(_hImglst, hIcon);
};
-bool IconList::changeIcon(int index, const TCHAR *iconLocation) const
+bool IconList::changeIcon(size_t index, const TCHAR *iconLocation) const
{
HBITMAP hBmp = (HBITMAP)::LoadImage(_hInst, iconLocation, IMAGE_ICON, _iconSize, _iconSize, LR_LOADFROMFILE | LR_LOADMAP3DCOLORS | LR_LOADTRANSPARENT);
if (!hBmp)
return false;
- int i = ImageList_ReplaceIcon(_hImglst, index, (HICON)hBmp);
+ int i = ImageList_ReplaceIcon(_hImglst, int(index), (HICON)hBmp);
ImageList_AddMasked(_hImglst, (HBITMAP)hBmp, RGB(255,0,255));
::DeleteObject(hBmp);
return (i == index);
diff --git a/PowerEditor/src/WinControls/ImageListSet/ImageListSet.h b/PowerEditor/src/WinControls/ImageListSet/ImageListSet.h
index ae1fc2437..4fde88e22 100644
--- a/PowerEditor/src/WinControls/ImageListSet/ImageListSet.h
+++ b/PowerEditor/src/WinControls/ImageListSet/ImageListSet.h
@@ -42,7 +42,7 @@ public :
void addIcon(int iconID) const;
void addIcon(HICON hIcon) const;
- bool changeIcon(int index, const TCHAR *iconLocation) const;
+ bool changeIcon(size_t index, const TCHAR *iconLocation) const;
void addIcons(int size) const;
@@ -144,7 +144,7 @@ public :
return _tbiis[i]._stdIcon;
};
- bool replaceIcon(int witchList, int iconIndex, const TCHAR *iconLocation) const {
+ bool replaceIcon(size_t witchList, size_t iconIndex, const TCHAR *iconLocation) const {
if ((witchList != HLIST_DEFAULT) && (witchList != HLIST_DISABLE) &&
(witchList != HLIST_DEFAULT2) && (witchList != HLIST_DISABLE2))
return false;
diff --git a/PowerEditor/src/WinControls/ToolBar/ToolBar.cpp b/PowerEditor/src/WinControls/ToolBar/ToolBar.cpp
index 69cc6ead0..caae1389d 100644
--- a/PowerEditor/src/WinControls/ToolBar/ToolBar.cpp
+++ b/PowerEditor/src/WinControls/ToolBar/ToolBar.cpp
@@ -15,16 +15,56 @@
// along with this program. If not, see .
#include
+#include
#include "ToolBar.h"
#include "shortcut.h"
#include "Parameters.h"
#include "FindReplaceDlg_rc.h"
-
#include "NppDarkMode.h"
-#include "resource.h"
const int WS_TOOLBARSTYLE = WS_CHILD | WS_VISIBLE | WS_CLIPCHILDREN | WS_CLIPSIBLINGS | TBSTYLE_TOOLTIPS |TBSTYLE_FLAT | CCS_TOP | BTNS_AUTOSIZE | CCS_NOPARENTALIGN | CCS_NORESIZE | CCS_NODIVIDER;
+struct ToolbarIconIdUnit
+{
+ generic_string _id;
+ bool hasDisabledIcon = false;
+};
+
+ToolbarIconIdUnit toolbarIconIDs[] = {
+ { L"new", false },
+ { L"open", false },
+ { L"save", true },
+ { L"save-all", true },
+ { L"close", false },
+ { L"close-all", false },
+ { L"print", false },
+ { L"cut", true },
+ { L"copy", true },
+ { L"paste", true },
+ { L"undo", true },
+ { L"redo", true },
+ { L"find", false },
+ { L"replace", false },
+ { L"zoom-in", false },
+ { L"zoom-out", false },
+ { L"sync-vertical", false },
+ { L"sync-horizontal", false },
+ { L"word-wrap", false },
+ { L"all-chars", false },
+ { L"indent-guide", false },
+ { L"udl-dlg", false },
+ { L"doc-map", false },
+ { L"doc-list", false },
+ { L"function-list", false },
+ { L"folder-as-workspace", false },
+ { L"monitoring", true },
+ { L"record", true },
+ { L"stop-record", true },
+ { L"playback", true },
+ { L"playback-multiple", true },
+ { L"save-macro", true }
+};
+
void ToolBar::initTheme(TiXmlDocument *toolIconsDocRoot)
{
_toolIcons = toolIconsDocRoot->FirstChild(TEXT("NotepadPlus"));
@@ -33,62 +73,38 @@ void ToolBar::initTheme(TiXmlDocument *toolIconsDocRoot)
_toolIcons = _toolIcons->FirstChild(TEXT("ToolBarIcons"));
if (_toolIcons)
{
- _toolIcons = _toolIcons->FirstChild(TEXT("Theme"));
- if (_toolIcons)
+ generic_string iconFolderDir = NppParameters::getInstance().getUserPath();
+ generic_string toolbarIconsRootFolderName = TEXT("toolbarIcons");
+ pathAppend(iconFolderDir, toolbarIconsRootFolderName);
+ generic_string folderName = (_toolIcons->ToElement())->Attribute(TEXT("icoFolderName"));
+ if (folderName.empty())
+ folderName = TEXT("default");
+
+ pathAppend(iconFolderDir, folderName);
+
+ size_t i = 0;
+ generic_string disabled_suffix = L"_disabled";
+ generic_string ext = L".ico";
+ for (ToolbarIconIdUnit icoUnit : toolbarIconIDs)
{
- const TCHAR *themeDir = (_toolIcons->ToElement())->Attribute(TEXT("pathPrefix"));
-
- for (TiXmlNode *childNode = _toolIcons->FirstChildElement(TEXT("Icon"));
- childNode ;
- childNode = childNode->NextSibling(TEXT("Icon")))
+ generic_string locator = iconFolderDir;
+ locator += L"\\";
+ locator += icoUnit._id;
+ locator += ext;
+ if (::PathFileExists(locator.c_str()))
+ _customIconVect.push_back(iconLocator(0, i, locator));
+
+ if (icoUnit.hasDisabledIcon)
{
- int iIcon;
- const TCHAR *res = (childNode->ToElement())->Attribute(TEXT("id"), &iIcon);
- if (res)
- {
- TiXmlNode *grandChildNode = childNode->FirstChildElement(TEXT("normal"));
- if (grandChildNode)
- {
- TiXmlNode *valueNode = grandChildNode->FirstChild();
- //putain, enfin!!!
- if (valueNode)
- {
- generic_string locator = themeDir?themeDir:TEXT("");
-
- locator += valueNode->Value();
- _customIconVect.push_back(iconLocator(0, iIcon, locator));
- }
- }
-
- grandChildNode = childNode->FirstChildElement(TEXT("hover"));
- if (grandChildNode)
- {
- TiXmlNode *valueNode = grandChildNode->FirstChild();
- //putain, enfin!!!
- if (valueNode)
- {
- generic_string locator = themeDir?themeDir:TEXT("");
-
- locator += valueNode->Value();
- _customIconVect.push_back(iconLocator(1, iIcon, locator));
- }
- }
-
- grandChildNode = childNode->FirstChildElement(TEXT("disabled"));
- if (grandChildNode)
- {
- TiXmlNode *valueNode = grandChildNode->FirstChild();
- //putain, enfin!!!
- if (valueNode)
- {
- generic_string locator = themeDir?themeDir:TEXT("");
-
- locator += valueNode->Value();
- _customIconVect.push_back(iconLocator(2, iIcon, locator));
- }
- }
- }
+ generic_string locator_dis = iconFolderDir;
+ locator_dis += L"\\";
+ locator_dis += icoUnit._id;
+ locator_dis += disabled_suffix;
+ locator_dis += ext;
+ if (::PathFileExists(locator_dis.c_str()))
+ _customIconVect.push_back(iconLocator(1, i, locator_dis));
}
+ i++;
}
}
}
@@ -274,16 +290,16 @@ void ToolBar::reset(bool create)
}
_hSelf = ::CreateWindowEx(
- WS_EX_PALETTEWINDOW,
- TOOLBARCLASSNAME,
- TEXT(""),
- WS_TOOLBARSTYLE | dwExtraStyle,
- 0, 0,
- 0, 0,
- _hParent,
- NULL,
- _hInst,
- 0);
+ WS_EX_PALETTEWINDOW,
+ TOOLBARCLASSNAME,
+ TEXT(""),
+ WS_TOOLBARSTYLE | dwExtraStyle,
+ 0, 0,
+ 0, 0,
+ _hParent,
+ NULL,
+ _hInst,
+ 0);
NppDarkMode::setDarkTooltips(_hSelf, NppDarkMode::ToolTipsType::toolbar);
@@ -298,66 +314,75 @@ void ToolBar::reset(bool create)
throw std::runtime_error("ToolBar::reset : CreateWindowEx() function return null");
}
- if (_state != TB_STANDARD) //If non standard icons, use custom imagelists
+ bool doOverrideToolbarIcons = _customIconVect.size() > 0;
+ if (doOverrideToolbarIcons)
+ {
+ setDefaultImageList();
+ setDisableImageList();
+ }
+ else // use internal icons according the settings
{
- if (_state == TB_SMALL || _state == TB_LARGE)
+ if (_state != TB_STANDARD) //If non standard icons, use custom imagelists
{
- if (NppDarkMode::isEnabled())
+ if (_state == TB_SMALL || _state == TB_LARGE)
{
- setDefaultImageListDM();
- setDisableImageListDM();
+ if (NppDarkMode::isEnabled())
+ {
+ setDefaultImageListDM();
+ setDisableImageListDM();
- if (NppDarkMode::isWindows11())
+ if (NppDarkMode::isWindows11())
+ {
+ setHoveredImageListDM();
+ }
+ }
+ else
{
- setHoveredImageListDM();
+ setDefaultImageList();
+ setDisableImageList();
}
}
else
{
- setDefaultImageList();
- setDisableImageList();
+ if (NppDarkMode::isEnabled())
+ {
+ setDefaultImageListDM2();
+ setDisableImageListDM2();
+
+ if (NppDarkMode::isWindows11())
+ {
+ setHoveredImageListDM2();
+ }
+ }
+ else
+ {
+ setDefaultImageList2();
+ setDisableImageList2();
+ }
}
}
else
{
- if (NppDarkMode::isEnabled())
- {
- setDefaultImageListDM2();
- setDisableImageListDM2();
+ //Else set the internal imagelist with standard bitmaps
+ int iconDpiDynamicalSize = NppParameters::getInstance()._dpiManager.scaleX(16);
+ ::SendMessage(_hSelf, TB_SETBITMAPSIZE, 0, MAKELPARAM(iconDpiDynamicalSize, iconDpiDynamicalSize));
- if (NppDarkMode::isWindows11())
- {
- setHoveredImageListDM2();
- }
- }
- else
+ TBADDBITMAP addbmp = { 0, 0 };
+ TBADDBITMAP addbmpdyn = { 0, 0 };
+ for (size_t i = 0; i < _nbButtons; ++i)
{
- setDefaultImageList2();
- setDisableImageList2();
+ int icoID = _toolBarIcons.getStdIconAt(static_cast(i));
+ HBITMAP hBmp = static_cast(::LoadImage(_hInst, MAKEINTRESOURCE(icoID), IMAGE_BITMAP, iconDpiDynamicalSize, iconDpiDynamicalSize, LR_LOADMAP3DCOLORS | LR_LOADTRANSPARENT));
+ addbmp.nID = reinterpret_cast(hBmp);
+ ::SendMessage(_hSelf, TB_ADDBITMAP, 1, reinterpret_cast(&addbmp));
}
- }
- }
- else
- {
- //Else set the internal imagelist with standard bitmaps
- int iconDpiDynamicalSize = NppParameters::getInstance()._dpiManager.scaleX(16);
- ::SendMessage(_hSelf, TB_SETBITMAPSIZE, 0, MAKELPARAM(iconDpiDynamicalSize, iconDpiDynamicalSize));
-
- TBADDBITMAP addbmp = {0, 0};
- TBADDBITMAP addbmpdyn = {0, 0};
- for (size_t i = 0 ; i < _nbButtons ; ++i)
- {
- int icoID = _toolBarIcons.getStdIconAt(static_cast(i));
- HBITMAP hBmp = static_cast(::LoadImage(_hInst, MAKEINTRESOURCE(icoID), IMAGE_BITMAP, iconDpiDynamicalSize, iconDpiDynamicalSize, LR_LOADMAP3DCOLORS | LR_LOADTRANSPARENT));
- addbmp.nID = reinterpret_cast(hBmp);
- ::SendMessage(_hSelf, TB_ADDBITMAP, 1, reinterpret_cast(&addbmp));
- }
- if (_nbDynButtons > 0)
- {
- for (size_t j = 0; j < _nbDynButtons; ++j)
+ if (_nbDynButtons > 0)
{
- addbmpdyn.nID = reinterpret_cast(_vDynBtnReg.at(j)._hBmp);
- ::SendMessage(_hSelf, TB_ADDBITMAP, 1, reinterpret_cast(&addbmpdyn));
+ for (size_t j = 0; j < _nbDynButtons; ++j)
+ {
+ addbmpdyn.nID = reinterpret_cast(_vDynBtnReg.at(j)._hBmp);
+ ::SendMessage(_hSelf, TB_ADDBITMAP, 1, reinterpret_cast(&addbmpdyn));
+ }
}
}
}
diff --git a/PowerEditor/src/WinControls/ToolBar/ToolBar.h b/PowerEditor/src/WinControls/ToolBar/ToolBar.h
index aaa37ba15..447a4a8c5 100644
--- a/PowerEditor/src/WinControls/ToolBar/ToolBar.h
+++ b/PowerEditor/src/WinControls/ToolBar/ToolBar.h
@@ -34,12 +34,12 @@ enum toolBarStatusType {TB_SMALL, TB_LARGE, TB_SMALL2, TB_LARGE2, TB_STANDARD};
struct iconLocator {
- int listIndex = 0;
- int iconIndex = 0;
- generic_string iconLocation;
+ size_t _listIndex = 0;
+ size_t _iconIndex = 0;
+ generic_string _iconLocation;
- iconLocator(int iList, int iIcon, const generic_string& iconLoc)
- : listIndex(iList), iconIndex(iIcon), iconLocation(iconLoc){};
+ iconLocator(size_t iList, size_t iIcon, const generic_string& iconLoc)
+ : _listIndex(iList), _iconIndex(iIcon), _iconLocation(iconLoc){};
};
class ReBar;
@@ -86,11 +86,11 @@ public :
if (!_toolIcons) return false;
for (size_t i = 0, len = _customIconVect.size(); i < len; ++i)
- changeIcons(_customIconVect[i].listIndex, _customIconVect[i].iconIndex, (_customIconVect[i].iconLocation).c_str());
+ changeIcons(_customIconVect[i]._listIndex, _customIconVect[i]._iconIndex, (_customIconVect[i]._iconLocation).c_str());
return true;
};
- bool changeIcons(int whichLst, int iconIndex, const TCHAR *iconLocation){
+ bool changeIcons(size_t whichLst, size_t iconIndex, const TCHAR *iconLocation){
return _toolBarIcons.replaceIcon(whichLst, iconIndex, iconLocation);
};
diff --git a/PowerEditor/src/toolbarIcons.xml b/PowerEditor/src/toolbarIcons.xml
index d13f007d8..4f59435fe 100644
--- a/PowerEditor/src/toolbarIcons.xml
+++ b/PowerEditor/src/toolbarIcons.xml
@@ -1,94 +1,59 @@
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
\ No newline at end of file