Replace bmp with ico for panels with toolbar

- use correct styles for toolbar
- change panel toolbar icons if dark/light mode has changed
- align panel toolbar icons
- add initialization

ref #14959

Close #15204
pull/15218/head
ozone10 2024-05-27 17:51:17 +02:00 committed by Don Ho
parent 0019e20f82
commit c89033bd8a
54 changed files with 163 additions and 105 deletions

View File

@ -331,55 +331,55 @@ IDR_CLOSETAB_HOVER_DM BITMAP "icons/dark/tabbar/closeTabButton_hove
IDR_CLOSETAB_PUSH_DM BITMAP "icons/dark/tabbar/closeTabButton_push.bmp" IDR_CLOSETAB_PUSH_DM BITMAP "icons/dark/tabbar/closeTabButton_push.bmp"
IDR_DOCMAP_ICO ICON "icons/standard/panels/tabbar/docMap.ico" IDR_DOCMAP_ICO ICON "icons/standard/panels/tabbar/docMap.ico"
IDR_DOCMAP_ICO2 ICON "icons/light/panels/docMap.ico" IDR_DOCMAP_ICO2 ICON "icons/light/panels/tabbar/docMap.ico"
IDR_DOCMAP_ICO_DM ICON "icons/dark/panels/docMap.ico" IDR_DOCMAP_ICO_DM ICON "icons/dark/panels/tabbar/docMap.ico"
IDR_DOCLIST_ICO ICON "icons/standard/panels/tabbar/docList.ico" IDR_DOCLIST_ICO ICON "icons/standard/panels/tabbar/docList.ico"
IDR_DOCLIST_ICO2 ICON "icons/light/panels/docList.ico" IDR_DOCLIST_ICO2 ICON "icons/light/panels/tabbar/docList.ico"
IDR_DOCLIST_ICO_DM ICON "icons/dark/panels/docList.ico" IDR_DOCLIST_ICO_DM ICON "icons/dark/panels/tabbar/docList.ico"
IDR_FUNC_LIST_ICO ICON "icons/standard/panels/tabbar/functionList.ico" IDR_FUNC_LIST_ICO ICON "icons/standard/panels/tabbar/functionList.ico"
IDR_FUNC_LIST_ICO2 ICON "icons/light/panels/functionList.ico" IDR_FUNC_LIST_ICO2 ICON "icons/light/panels/tabbar/functionList.ico"
IDR_FUNC_LIST_ICO_DM ICON "icons/dark/panels/functionList.ico" IDR_FUNC_LIST_ICO_DM ICON "icons/dark/panels/tabbar/functionList.ico"
IDR_PROJECTPANEL_ICO ICON "icons/standard/panels/tabbar/projectPanel.ico" IDR_PROJECTPANEL_ICO ICON "icons/standard/panels/tabbar/projectPanel.ico"
IDR_PROJECTPANEL_ICO2 ICON "icons/light/panels/projectPanel.ico" IDR_PROJECTPANEL_ICO2 ICON "icons/light/panels/tabbar/projectPanel.ico"
IDR_PROJECTPANEL_ICO_DM ICON "icons/dark/panels/projectPanel.ico" IDR_PROJECTPANEL_ICO_DM ICON "icons/dark/panels/tabbar/projectPanel.ico"
IDR_FILEBROWSER_ICO ICON "icons/standard/panels/tabbar/fileBrowser.ico" IDR_FILEBROWSER_ICO ICON "icons/standard/panels/tabbar/fileBrowser.ico"
IDR_FILEBROWSER_ICO2 ICON "icons/light/panels/fileBrowser.ico" IDR_FILEBROWSER_ICO2 ICON "icons/light/panels/tabbar/fileBrowser.ico"
IDR_FILEBROWSER_ICO_DM ICON "icons/dark/panels/fileBrowser.ico" IDR_FILEBROWSER_ICO_DM ICON "icons/dark/panels/tabbar/fileBrowser.ico"
IDR_CLIPBOARDPANEL_ICO ICON "icons/standard/panels/tabbar/clipboardPanel.ico" IDR_CLIPBOARDPANEL_ICO ICON "icons/standard/panels/tabbar/clipboardPanel.ico"
IDR_CLIPBOARDPANEL_ICO2 ICON "icons/light/panels/clipboardPanel.ico" IDR_CLIPBOARDPANEL_ICO2 ICON "icons/light/panels/tabbar/clipboardPanel.ico"
IDR_CLIPBOARDPANEL_ICO_DM ICON "icons/dark/panels/clipboardPanel.ico" IDR_CLIPBOARDPANEL_ICO_DM ICON "icons/dark/panels/tabbar/clipboardPanel.ico"
IDR_ASCIIPANEL_ICO ICON "icons/standard/panels/tabbar/asciiPanel.ico" IDR_ASCIIPANEL_ICO ICON "icons/standard/panels/tabbar/asciiPanel.ico"
IDR_ASCIIPANEL_ICO2 ICON "icons/light/panels/asciiPanel.ico" IDR_ASCIIPANEL_ICO2 ICON "icons/light/panels/tabbar/asciiPanel.ico"
IDR_ASCIIPANEL_ICO_DM ICON "icons/dark/panels/asciiPanel.ico" IDR_ASCIIPANEL_ICO_DM ICON "icons/dark/panels/tabbar/asciiPanel.ico"
IDI_PROJECT_WORKSPACE BITMAP "icons/standard/panels/project_work_space.bmp" IDI_PROJECT_WORKSPACE BITMAP "icons/standard/panels/treeview/project_work_space.bmp"
IDI_PROJECT_WORKSPACEDIRTY BITMAP "icons/standard/panels/project_work_space_dirty.bmp" IDI_PROJECT_WORKSPACEDIRTY BITMAP "icons/standard/panels/treeview/project_work_space_dirty.bmp"
IDI_PROJECT_PROJECT BITMAP "icons/standard/panels/project_root.bmp" IDI_PROJECT_PROJECT BITMAP "icons/standard/panels/treeview/project_root.bmp"
IDI_PROJECT_FOLDEROPEN BITMAP "icons/standard/panels/project_folder_open.bmp" IDI_PROJECT_FOLDEROPEN BITMAP "icons/standard/panels/treeview/project_folder_open.bmp"
IDI_PROJECT_FOLDERCLOSE BITMAP "icons/standard/panels/project_folder_close.bmp" IDI_PROJECT_FOLDERCLOSE BITMAP "icons/standard/panels/treeview/project_folder_close.bmp"
IDI_PROJECT_FILE BITMAP "icons/standard/panels/project_file.bmp" IDI_PROJECT_FILE BITMAP "icons/standard/panels/treeview/project_file.bmp"
IDI_PROJECT_FILEINVALID BITMAP "icons/standard/panels/project_file_invalid.bmp" IDI_PROJECT_FILEINVALID BITMAP "icons/standard/panels/treeview/project_file_invalid.bmp"
IDI_FB_ROOTOPEN BITMAP "icons/standard/panels/fb_root_open.bmp" IDI_FB_ROOTOPEN BITMAP "icons/standard/panels/treeview/fb_root_open.bmp"
IDI_FB_ROOTCLOSE BITMAP "icons/standard/panels/fb_root_close.bmp" IDI_FB_ROOTCLOSE BITMAP "icons/standard/panels/treeview/fb_root_close.bmp"
IDI_FB_SELECTCURRENTFILE BITMAP "icons/standard/panels/fb_select_current_file.bmp" IDI_FB_SELECTCURRENTFILE ICON "icons/standard/panels/toolbar/fb_select_current_file.ico"
IDI_FB_FOLDALL BITMAP "icons/standard/panels/fb_fold_all.bmp" IDI_FB_FOLDALL ICON "icons/standard/panels/toolbar/fb_fold_all.ico"
IDI_FB_EXPANDALL BITMAP "icons/standard/panels/fb_expand_all.bmp" IDI_FB_EXPANDALL ICON "icons/standard/panels/toolbar/fb_expand_all.ico"
IDI_FB_SELECTCURRENTFILE_DM BITMAP "icons/dark/panels/fb_select_current_file.bmp" IDI_FB_SELECTCURRENTFILE_DM ICON "icons/dark/panels/toolbar/fb_select_current_file.ico"
IDI_FB_FOLDALL_DM BITMAP "icons/dark/panels/fb_fold_all.bmp" IDI_FB_FOLDALL_DM ICON "icons/dark/panels/toolbar/fb_fold_all.ico"
IDI_FB_EXPANDALL_DM BITMAP "icons/dark/panels/fb_expand_all.bmp" IDI_FB_EXPANDALL_DM ICON "icons/dark/panels/toolbar/fb_expand_all.ico"
IDI_FUNCLIST_ROOT BITMAP "icons/standard/panels/project_file.bmp" IDI_FUNCLIST_ROOT BITMAP "icons/standard/panels/treeview/project_file.bmp"
IDI_FUNCLIST_NODE BITMAP "icons/standard/panels/funcList_node.bmp" IDI_FUNCLIST_NODE BITMAP "icons/standard/panels/treeview/funcList_node.bmp"
IDI_FUNCLIST_LEAF BITMAP "icons/standard/panels/funcList_leaf.bmp" IDI_FUNCLIST_LEAF BITMAP "icons/standard/panels/treeview/funcList_leaf.bmp"
IDI_FUNCLIST_SORTBUTTON BITMAP "icons/standard/panels/funclstSort.bmp" IDI_FUNCLIST_SORTBUTTON ICON "icons/standard/panels/toolbar/funclstSort.ico"
IDI_FUNCLIST_RELOADBUTTON BITMAP "icons/standard/panels/funclstReload.bmp" IDI_FUNCLIST_RELOADBUTTON ICON "icons/standard/panels/toolbar/funclstReload.ico"
IDI_FUNCLIST_PREFERENCEBUTTON BITMAP "icons/standard/panels/funclstPreferences.bmp" IDI_FUNCLIST_PREFERENCEBUTTON ICON "icons/standard/panels/toolbar/funclstPreferences.ico"
IDI_FUNCLIST_SORTBUTTON_DM BITMAP "icons/dark/panels/funclstSort.bmp" IDI_FUNCLIST_SORTBUTTON_DM ICON "icons/dark/panels/toolbar/funclstSort.ico"
IDI_FUNCLIST_RELOADBUTTON_DM BITMAP "icons/dark/panels/funclstReload.bmp" IDI_FUNCLIST_RELOADBUTTON_DM ICON "icons/dark/panels/toolbar/funclstReload.ico"
IDI_FUNCLIST_PREFERENCEBUTTON_DM BITMAP "icons/dark/panels/funclstPreferences.bmp" IDI_FUNCLIST_PREFERENCEBUTTON_DM ICON "icons/dark/panels/toolbar/funclstPreferences.ico"
IDI_GET_INFO_FROM_TOOLTIP ICON "icons/moreOnTooltip.ico" IDI_GET_INFO_FROM_TOOLTIP ICON "icons/moreOnTooltip.ico"

View File

@ -54,6 +54,15 @@ FileBrowser::~FileBrowser()
{ {
delete cd; delete cd;
} }
for (auto hImgList : _iconListVector)
{
if (hImgList != nullptr)
{
::ImageList_Destroy(hImgList);
}
}
_iconListVector.clear();
} }
vector<generic_string> split(const generic_string & string2split, TCHAR sep) vector<generic_string> split(const generic_string & string2split, TCHAR sep)
@ -99,41 +108,62 @@ intptr_t CALLBACK FileBrowser::run_dlgProc(UINT message, WPARAM wParam, LPARAM l
case WM_INITDIALOG: case WM_INITDIALOG:
{ {
NppParameters& nppParam = NppParameters::getInstance(); NppParameters& nppParam = NppParameters::getInstance();
int style = WS_CHILD | WS_VISIBLE | CCS_ADJUSTABLE | TBSTYLE_AUTOSIZE | TBSTYLE_FLAT | TBSTYLE_LIST | TBSTYLE_TRANSPARENT | BTNS_AUTOSIZE | BTNS_SEP | TBSTYLE_TOOLTIPS | TBSTYLE_CUSTOMERASE;
constexpr DWORD style = WS_CHILD | WS_VISIBLE | TBSTYLE_FLAT | TBSTYLE_LIST | TBSTYLE_TRANSPARENT | TBSTYLE_TOOLTIPS | TBSTYLE_CUSTOMERASE;
_hToolbarMenu = CreateWindowEx(WS_EX_LAYOUTRTL, TOOLBARCLASSNAME, NULL, style, 0, 0, 0, 0, _hSelf, nullptr, _hInst, NULL); _hToolbarMenu = CreateWindowEx(WS_EX_LAYOUTRTL, TOOLBARCLASSNAME, NULL, style, 0, 0, 0, 0, _hSelf, nullptr, _hInst, NULL);
// Add the bmap image into toolbar's imagelist const DWORD tbExStyle = static_cast<DWORD>(::SendMessage(_hToolbarMenu, TB_GETEXTENDEDSTYLE, 0, 0));
int iconSizeDyn = nppParam._dpiManager.scaleX(16); ::SendMessage(_hToolbarMenu, TB_SETEXTENDEDSTYLE, 0, tbExStyle | TBSTYLE_EX_DOUBLEBUFFER);
::SendMessage(_hToolbarMenu, TB_SETBITMAPSIZE, 0, MAKELPARAM(iconSizeDyn, iconSizeDyn));
TBADDBITMAP addbmp = { 0, 0 }; setDpi();
const int nbIcons = 3; const int iconSizeDyn = _dpiManager.scale(16);
constexpr int nbIcons = 3;
int iconIDs[nbIcons] = { IDI_FB_SELECTCURRENTFILE, IDI_FB_FOLDALL, IDI_FB_EXPANDALL}; int iconIDs[nbIcons] = { IDI_FB_SELECTCURRENTFILE, IDI_FB_FOLDALL, IDI_FB_EXPANDALL};
int iconDarkModeIDs[nbIcons] = { IDI_FB_SELECTCURRENTFILE_DM, IDI_FB_FOLDALL_DM, IDI_FB_EXPANDALL_DM}; int iconDarkModeIDs[nbIcons] = { IDI_FB_SELECTCURRENTFILE_DM, IDI_FB_FOLDALL_DM, IDI_FB_EXPANDALL_DM};
// Create an image lists for the toolbar icons
HIMAGELIST hImageList = ImageList_Create(iconSizeDyn, iconSizeDyn, ILC_COLOR32 | ILC_MASK, nbIcons, 0);
HIMAGELIST hImageListDm = ImageList_Create(iconSizeDyn, iconSizeDyn, ILC_COLOR32 | ILC_MASK, nbIcons, 0);
_iconListVector.push_back(hImageList);
_iconListVector.push_back(hImageListDm);
for (size_t i = 0; i < nbIcons; ++i) for (size_t i = 0; i < nbIcons; ++i)
{ {
int icoID = NppDarkMode::isEnabled() ? iconDarkModeIDs[i] : iconIDs[i]; int icoID = iconIDs[i];
HBITMAP hBmp = static_cast<HBITMAP>(::LoadImage(_hInst, MAKEINTRESOURCE(icoID), IMAGE_BITMAP, iconSizeDyn, iconSizeDyn, LR_LOADMAP3DCOLORS | LR_LOADTRANSPARENT)); HICON hIcon = nullptr;
addbmp.nID = reinterpret_cast<UINT_PTR>(hBmp); DPIManagerV2::loadIcon(_hInst, MAKEINTRESOURCE(icoID), iconSizeDyn, iconSizeDyn, &hIcon, LR_LOADMAP3DCOLORS | LR_LOADTRANSPARENT);
::SendMessage(_hToolbarMenu, TB_ADDBITMAP, 1, reinterpret_cast<LPARAM>(&addbmp)); ImageList_AddIcon(_iconListVector.at(0), hIcon);
::DestroyIcon(hIcon);
hIcon = nullptr;
icoID = iconDarkModeIDs[i];
DPIManagerV2::loadIcon(_hInst, MAKEINTRESOURCE(icoID), iconSizeDyn, iconSizeDyn, &hIcon, LR_LOADMAP3DCOLORS | LR_LOADTRANSPARENT);
ImageList_AddIcon(_iconListVector.at(1), hIcon);
::DestroyIcon(hIcon); // Clean up the loaded icon
} }
TBBUTTON tbButtons[nbIcons]; // Attach the image list to the toolbar
::SendMessage(_hToolbarMenu, TB_SETIMAGELIST, 0, reinterpret_cast<LPARAM>(_iconListVector.at(NppDarkMode::isEnabled() ? 1 : 0)));
TBBUTTON tbButtons[nbIcons]{};
tbButtons[0].idCommand = FB_CMD_AIMFILE; tbButtons[0].idCommand = FB_CMD_AIMFILE;
tbButtons[0].iBitmap = 0; tbButtons[0].iBitmap = 0;
tbButtons[0].fsState = TBSTATE_ENABLED; tbButtons[0].fsState = TBSTATE_ENABLED;
tbButtons[0].fsStyle = BTNS_BUTTON | BTNS_AUTOSIZE; tbButtons[0].fsStyle = BTNS_BUTTON;
tbButtons[0].iString = reinterpret_cast<intptr_t>(TEXT("")); tbButtons[0].iString = 0;
tbButtons[1].idCommand = FB_CMD_FOLDALL; tbButtons[1].idCommand = FB_CMD_FOLDALL;
tbButtons[1].iBitmap = 1; tbButtons[1].iBitmap = 1;
tbButtons[1].fsState = TBSTATE_ENABLED; tbButtons[1].fsState = TBSTATE_ENABLED;
tbButtons[1].fsStyle = BTNS_BUTTON | BTNS_AUTOSIZE; tbButtons[1].fsStyle = BTNS_BUTTON;
tbButtons[1].iString = reinterpret_cast<intptr_t>(TEXT("")); tbButtons[1].iString = 0;
tbButtons[2].idCommand = FB_CMD_EXPANDALL; tbButtons[2].idCommand = FB_CMD_EXPANDALL;
tbButtons[2].iBitmap = 2; tbButtons[2].iBitmap = 2;
tbButtons[2].fsState = TBSTATE_ENABLED; tbButtons[2].fsState = TBSTATE_ENABLED;
tbButtons[2].fsStyle = BTNS_BUTTON | BTNS_AUTOSIZE; tbButtons[2].fsStyle = BTNS_BUTTON;
tbButtons[2].iString = reinterpret_cast<intptr_t>(TEXT("")); tbButtons[2].iString = 0;
// tips text for toolbar buttons // tips text for toolbar buttons
NativeLangSpeaker *pNativeSpeaker = nppParam.getNativeLangSpeaker(); NativeLangSpeaker *pNativeSpeaker = nppParam.getNativeLangSpeaker();
@ -142,12 +172,10 @@ intptr_t CALLBACK FileBrowser::run_dlgProc(UINT message, WPARAM wParam, LPARAM l
_locateCurrentFile = pNativeSpeaker->getAttrNameStr(_locateCurrentFile.c_str(), FOLDERASWORKSPACE_NODE, "LocateCurrentFileTip"); _locateCurrentFile = pNativeSpeaker->getAttrNameStr(_locateCurrentFile.c_str(), FOLDERASWORKSPACE_NODE, "LocateCurrentFileTip");
::SendMessage(_hToolbarMenu, TB_BUTTONSTRUCTSIZE, sizeof(TBBUTTON), 0); ::SendMessage(_hToolbarMenu, TB_BUTTONSTRUCTSIZE, sizeof(TBBUTTON), 0);
::SendMessage(_hToolbarMenu, TB_SETBUTTONSIZE, 0, MAKELONG(nppParam._dpiManager.scaleX(20), nppParam._dpiManager.scaleY(20))); ::SendMessage(_hToolbarMenu, TB_SETBUTTONSIZE, 0, MAKELONG(iconSizeDyn, iconSizeDyn));
::SendMessage(_hToolbarMenu, TB_SETPADDING, 0, MAKELONG(nppParam._dpiManager.scaleX(10), 0));
::SendMessage(_hToolbarMenu, TB_ADDBUTTONS, sizeof(tbButtons) / sizeof(TBBUTTON), reinterpret_cast<LPARAM>(&tbButtons)); ::SendMessage(_hToolbarMenu, TB_ADDBUTTONS, sizeof(tbButtons) / sizeof(TBBUTTON), reinterpret_cast<LPARAM>(&tbButtons));
::SendMessage(_hToolbarMenu, TB_AUTOSIZE, 0, 0); ::SendMessage(_hToolbarMenu, TB_AUTOSIZE, 0, 0);
::SendMessage(_hToolbarMenu, TB_GETIMAGELIST, 0, 0);
ShowWindow(_hToolbarMenu, SW_SHOW); ShowWindow(_hToolbarMenu, SW_SHOW);
FileBrowser::initPopupMenus(); FileBrowser::initPopupMenus();
@ -181,6 +209,7 @@ intptr_t CALLBACK FileBrowser::run_dlgProc(UINT message, WPARAM wParam, LPARAM l
if (static_cast<BOOL>(lParam) != TRUE) if (static_cast<BOOL>(lParam) != TRUE)
{ {
NppDarkMode::autoThemeChildControls(_hSelf); NppDarkMode::autoThemeChildControls(_hSelf);
::SendMessage(_hToolbarMenu, TB_SETIMAGELIST, 0, reinterpret_cast<LPARAM>(_iconListVector.at(NppDarkMode::isEnabled() ? 1 : 0)));
} }
NppDarkMode::setTreeViewStyle(_treeView.getHSelf()); NppDarkMode::setTreeViewStyle(_treeView.getHSelf());
return TRUE; return TRUE;
@ -208,7 +237,7 @@ intptr_t CALLBACK FileBrowser::run_dlgProc(UINT message, WPARAM wParam, LPARAM l
{ {
int width = LOWORD(lParam); int width = LOWORD(lParam);
int height = HIWORD(lParam); int height = HIWORD(lParam);
int extraValue = NppParameters::getInstance()._dpiManager.scaleX(4); int extraValue = _dpiManager.scale(4);
RECT toolbarMenuRect; RECT toolbarMenuRect;
::GetClientRect(_hToolbarMenu, &toolbarMenuRect); ::GetClientRect(_hToolbarMenu, &toolbarMenuRect);
@ -511,7 +540,7 @@ void FileBrowser::notified(LPNMHDR notification)
else if (notification->hwndFrom == _treeView.getHSelf()) else if (notification->hwndFrom == _treeView.getHSelf())
{ {
TCHAR textBuffer[MAX_PATH] = { '\0' }; TCHAR textBuffer[MAX_PATH] = { '\0' };
TVITEM tvItem; TVITEM tvItem{};
tvItem.mask = TVIF_TEXT | TVIF_PARAM; tvItem.mask = TVIF_TEXT | TVIF_PARAM;
tvItem.pszText = textBuffer; tvItem.pszText = textBuffer;
tvItem.cchTextMax = MAX_PATH; tvItem.cchTextMax = MAX_PATH;
@ -676,7 +705,7 @@ void FileBrowser::notified(LPNMHDR notification)
BrowserNodeType FileBrowser::getNodeType(HTREEITEM hItem) BrowserNodeType FileBrowser::getNodeType(HTREEITEM hItem)
{ {
TVITEM tvItem; TVITEM tvItem{};
tvItem.hItem = hItem; tvItem.hItem = hItem;
tvItem.mask = TVIF_IMAGE | TVIF_PARAM; tvItem.mask = TVIF_IMAGE | TVIF_PARAM;
SendMessage(_treeView.getHSelf(), TVM_GETITEM, 0, reinterpret_cast<LPARAM>(&tvItem)); SendMessage(_treeView.getHSelf(), TVM_GETITEM, 0, reinterpret_cast<LPARAM>(&tvItem));
@ -1038,7 +1067,7 @@ HTREEITEM FileBrowser::getRootFromFullPath(const generic_string & rootPath) cons
hItemNode != nullptr && node == nullptr; hItemNode != nullptr && node == nullptr;
hItemNode = _treeView.getNextSibling(hItemNode)) hItemNode = _treeView.getNextSibling(hItemNode))
{ {
TVITEM tvItem; TVITEM tvItem{};
tvItem.mask = TVIF_PARAM; tvItem.mask = TVIF_PARAM;
tvItem.cchTextMax = MAX_PATH; tvItem.cchTextMax = MAX_PATH;
tvItem.hItem = hItemNode; tvItem.hItem = hItemNode;
@ -1057,7 +1086,7 @@ HTREEITEM FileBrowser::findChildNodeFromName(HTREEITEM parent, const generic_str
hItemNode = _treeView.getNextSibling(hItemNode)) hItemNode = _treeView.getNextSibling(hItemNode))
{ {
TCHAR textBuffer[MAX_PATH] = { '\0' }; TCHAR textBuffer[MAX_PATH] = { '\0' };
TVITEM tvItem; TVITEM tvItem{};
tvItem.mask = TVIF_TEXT; tvItem.mask = TVIF_TEXT;
tvItem.pszText = textBuffer; tvItem.pszText = textBuffer;
tvItem.cchTextMax = MAX_PATH; tvItem.cchTextMax = MAX_PATH;
@ -1080,7 +1109,7 @@ vector<generic_string> FileBrowser::getRoots() const
hItemNode != nullptr; hItemNode != nullptr;
hItemNode = _treeView.getNextSibling(hItemNode)) hItemNode = _treeView.getNextSibling(hItemNode))
{ {
TVITEM tvItem; TVITEM tvItem{};
tvItem.mask = TVIF_PARAM; tvItem.mask = TVIF_PARAM;
tvItem.cchTextMax = MAX_PATH; tvItem.cchTextMax = MAX_PATH;
tvItem.hItem = hItemNode; tvItem.hItem = hItemNode;
@ -1217,7 +1246,7 @@ bool FileBrowser::addToTree(FilesToChange & group, HTREEITEM node)
hItemNode = _treeView.getNextSibling(hItemNode)) hItemNode = _treeView.getNextSibling(hItemNode))
{ {
TCHAR textBuffer[MAX_PATH] = { '\0' }; TCHAR textBuffer[MAX_PATH] = { '\0' };
TVITEM tvItem; TVITEM tvItem{};
tvItem.mask = TVIF_TEXT; tvItem.mask = TVIF_TEXT;
tvItem.pszText = textBuffer; tvItem.pszText = textBuffer;
tvItem.cchTextMax = MAX_PATH; tvItem.cchTextMax = MAX_PATH;
@ -1278,7 +1307,7 @@ HTREEITEM FileBrowser::findInTree(const generic_string& rootPath, HTREEITEM node
hItemNode = _treeView.getNextSibling(hItemNode)) hItemNode = _treeView.getNextSibling(hItemNode))
{ {
TCHAR textBuffer[MAX_PATH] = { '\0' }; TCHAR textBuffer[MAX_PATH] = { '\0' };
TVITEM tvItem; TVITEM tvItem{};
tvItem.mask = TVIF_TEXT; tvItem.mask = TVIF_TEXT;
tvItem.pszText = textBuffer; tvItem.pszText = textBuffer;
tvItem.cchTextMax = MAX_PATH; tvItem.cchTextMax = MAX_PATH;
@ -1319,7 +1348,7 @@ std::vector<HTREEITEM> FileBrowser::findInTree(FilesToChange & group, HTREEITEM
hItemNode = _treeView.getNextSibling(hItemNode)) hItemNode = _treeView.getNextSibling(hItemNode))
{ {
TCHAR textBuffer[MAX_PATH] = {'\0'}; TCHAR textBuffer[MAX_PATH] = {'\0'};
TVITEM tvItem; TVITEM tvItem{};
tvItem.mask = TVIF_TEXT; tvItem.mask = TVIF_TEXT;
tvItem.pszText = textBuffer; tvItem.pszText = textBuffer;
tvItem.cchTextMax = MAX_PATH; tvItem.cchTextMax = MAX_PATH;
@ -1346,8 +1375,8 @@ std::vector<HTREEITEM> FileBrowser::findChildNodesFromNames(HTREEITEM parent, st
hItemNode = _treeView.getNextSibling(hItemNode) hItemNode = _treeView.getNextSibling(hItemNode)
) )
{ {
TCHAR textBuffer[MAX_PATH]; TCHAR textBuffer[MAX_PATH]{};
TVITEM tvItem; TVITEM tvItem{};
tvItem.mask = TVIF_TEXT; tvItem.mask = TVIF_TEXT;
tvItem.pszText = textBuffer; tvItem.pszText = textBuffer;
tvItem.cchTextMax = MAX_PATH; tvItem.cchTextMax = MAX_PATH;
@ -1372,8 +1401,8 @@ void FileBrowser::removeNamesAlreadyInNode(HTREEITEM parent, std::vector<generic
hItemNode = _treeView.getNextSibling(hItemNode) hItemNode = _treeView.getNextSibling(hItemNode)
) )
{ {
TCHAR textBuffer[MAX_PATH]; TCHAR textBuffer[MAX_PATH]{};
TVITEM tvItem; TVITEM tvItem{};
tvItem.mask = TVIF_TEXT; tvItem.mask = TVIF_TEXT;
tvItem.pszText = textBuffer; tvItem.pszText = textBuffer;
tvItem.cchTextMax = MAX_PATH; tvItem.cchTextMax = MAX_PATH;

View File

@ -162,6 +162,7 @@ public:
protected: protected:
HWND _hToolbarMenu = nullptr; HWND _hToolbarMenu = nullptr;
std::vector<HIMAGELIST> _iconListVector;
TreeView _treeView; TreeView _treeView;
HIMAGELIST _hImaLst = nullptr; HIMAGELIST _hImaLst = nullptr;
@ -207,7 +208,7 @@ protected:
void removeNamesAlreadyInNode(HTREEITEM parent, std::vector<generic_string> & labels) const; void removeNamesAlreadyInNode(HTREEITEM parent, std::vector<generic_string> & labels) const;
virtual intptr_t CALLBACK run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam); intptr_t CALLBACK run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam) override;
void notified(LPNMHDR notification); void notified(LPNMHDR notification);
void showContextMenu(int x, int y); void showContextMenu(int x, int y);
void openSelectFile(); void openSelectFile();

View File

@ -41,6 +41,15 @@ FunctionListPanel::~FunctionListPanel()
::DeleteObject(_hFontSearchEdit); ::DeleteObject(_hFontSearchEdit);
_hFontSearchEdit = nullptr; _hFontSearchEdit = nullptr;
} }
for (auto hImgList : _iconListVector)
{
if (hImgList != nullptr)
{
::ImageList_Destroy(hImgList);
}
}
_iconListVector.clear();
} }
void FunctionListPanel::addEntry(const TCHAR *nodeName, const TCHAR *displayText, size_t pos) void FunctionListPanel::addEntry(const TCHAR *nodeName, const TCHAR *displayText, size_t pos)
@ -820,33 +829,50 @@ intptr_t CALLBACK FunctionListPanel::run_dlgProc(UINT message, WPARAM wParam, LP
NppParameters& nppParams = NppParameters::getInstance(); NppParameters& nppParams = NppParameters::getInstance();
int editWidth = nppParams._dpiManager.scaleX(100); setDpi();
int editWidthSep = nppParams._dpiManager.scaleX(105); //editWidth + 5 const int editWidth = _dpiManager.scale(100);
int editHeight = nppParams._dpiManager.scaleY(20); const int editWidthSep = _dpiManager.scale(105); //editWidth + 5
const int editHeight = _dpiManager.scale(20);
// Create toolbar menu // Create toolbar menu
int style = WS_CHILD | WS_VISIBLE | CCS_ADJUSTABLE | TBSTYLE_AUTOSIZE | TBSTYLE_FLAT | TBSTYLE_LIST | TBSTYLE_TRANSPARENT | BTNS_AUTOSIZE | BTNS_SEP | TBSTYLE_TOOLTIPS; constexpr DWORD style = WS_CHILD | WS_VISIBLE | TBSTYLE_FLAT | TBSTYLE_LIST | TBSTYLE_TRANSPARENT | TBSTYLE_TOOLTIPS;
_hToolbarMenu = CreateWindowEx(0,TOOLBARCLASSNAME,NULL, style, _hToolbarMenu = CreateWindowEx(0,TOOLBARCLASSNAME,NULL, style,
0,0,0,0,_hSelf,nullptr, _hInst, NULL); 0,0,0,0,_hSelf,nullptr, _hInst, NULL);
const DWORD tbExStyle = static_cast<DWORD>(::SendMessage(_hToolbarMenu, TB_GETEXTENDEDSTYLE, 0, 0));
::SendMessage(_hToolbarMenu, TB_SETEXTENDEDSTYLE, 0, tbExStyle | TBSTYLE_EX_DOUBLEBUFFER);
oldFunclstToolbarProc = reinterpret_cast<WNDPROC>(::SetWindowLongPtr(_hToolbarMenu, GWLP_WNDPROC, reinterpret_cast<LONG_PTR>(funclstToolbarProc))); oldFunclstToolbarProc = reinterpret_cast<WNDPROC>(::SetWindowLongPtr(_hToolbarMenu, GWLP_WNDPROC, reinterpret_cast<LONG_PTR>(funclstToolbarProc)));
// Add the bmap image into toolbar's imagelist const int iconSizeDyn = _dpiManager.scale(16);
int iconSizeDyn = nppParams._dpiManager.scaleX(16); constexpr int nbIcons = 3;
::SendMessage(_hToolbarMenu, TB_SETBITMAPSIZE, 0, MAKELPARAM(iconSizeDyn, iconSizeDyn));
TBADDBITMAP addbmp = { 0, 0 };
const int nbIcons = 3;
int iconIDs[nbIcons] = { IDI_FUNCLIST_SORTBUTTON, IDI_FUNCLIST_RELOADBUTTON, IDI_FUNCLIST_PREFERENCEBUTTON }; int iconIDs[nbIcons] = { IDI_FUNCLIST_SORTBUTTON, IDI_FUNCLIST_RELOADBUTTON, IDI_FUNCLIST_PREFERENCEBUTTON };
int iconDarkModeIDs[nbIcons] = { IDI_FUNCLIST_SORTBUTTON_DM, IDI_FUNCLIST_RELOADBUTTON_DM, IDI_FUNCLIST_PREFERENCEBUTTON_DM }; int iconDarkModeIDs[nbIcons] = { IDI_FUNCLIST_SORTBUTTON_DM, IDI_FUNCLIST_RELOADBUTTON_DM, IDI_FUNCLIST_PREFERENCEBUTTON_DM };
// Create an image lists for the toolbar icons
HIMAGELIST hImageList = ImageList_Create(iconSizeDyn, iconSizeDyn, ILC_COLOR32 | ILC_MASK, nbIcons, 0);
HIMAGELIST hImageListDm = ImageList_Create(iconSizeDyn, iconSizeDyn, ILC_COLOR32 | ILC_MASK, nbIcons, 0);
_iconListVector.push_back(hImageList);
_iconListVector.push_back(hImageListDm);
for (size_t i = 0; i < nbIcons; ++i) for (size_t i = 0; i < nbIcons; ++i)
{ {
int icoID = NppDarkMode::isEnabled() ? iconDarkModeIDs[i] : iconIDs[i]; int icoID = iconIDs[i];
HBITMAP hBmp = static_cast<HBITMAP>(::LoadImage(_hInst, MAKEINTRESOURCE(icoID), IMAGE_BITMAP, iconSizeDyn, iconSizeDyn, LR_LOADMAP3DCOLORS | LR_LOADTRANSPARENT)); HICON hIcon = nullptr;
addbmp.nID = reinterpret_cast<UINT_PTR>(hBmp); DPIManagerV2::loadIcon(_hInst, MAKEINTRESOURCE(icoID), iconSizeDyn, iconSizeDyn, &hIcon, LR_LOADMAP3DCOLORS | LR_LOADTRANSPARENT);
::SendMessage(_hToolbarMenu, TB_ADDBITMAP, 1, reinterpret_cast<LPARAM>(&addbmp)); ImageList_AddIcon(_iconListVector.at(0), hIcon);
::DestroyIcon(hIcon);
hIcon = nullptr;
icoID = iconDarkModeIDs[i];
DPIManagerV2::loadIcon(_hInst, MAKEINTRESOURCE(icoID), iconSizeDyn, iconSizeDyn, &hIcon, LR_LOADMAP3DCOLORS | LR_LOADTRANSPARENT);
ImageList_AddIcon(_iconListVector.at(1), hIcon);
::DestroyIcon(hIcon); // Clean up the loaded icon
} }
// Attach the image list to the toolbar
::SendMessage(_hToolbarMenu, TB_SETIMAGELIST, 0, reinterpret_cast<LPARAM>(_iconListVector.at(NppDarkMode::isEnabled() ? 1 : 0)));
// Place holder of search text field // Place holder of search text field
TBBUTTON tbButtons[1 + nbIcons]{}; TBBUTTON tbButtons[1 + nbIcons]{};
@ -859,23 +885,23 @@ intptr_t CALLBACK FunctionListPanel::run_dlgProc(UINT message, WPARAM wParam, LP
tbButtons[1].idCommand = IDC_SORTBUTTON_FUNCLIST; tbButtons[1].idCommand = IDC_SORTBUTTON_FUNCLIST;
tbButtons[1].iBitmap = 0; tbButtons[1].iBitmap = 0;
tbButtons[1].fsState = TBSTATE_ENABLED; tbButtons[1].fsState = TBSTATE_ENABLED;
tbButtons[1].fsStyle = BTNS_CHECK | BTNS_AUTOSIZE; tbButtons[1].fsStyle = BTNS_CHECK;
tbButtons[1].iString = reinterpret_cast<intptr_t>(TEXT("")); tbButtons[1].iString = 0;
tbButtons[2].idCommand = IDC_RELOADBUTTON_FUNCLIST; tbButtons[2].idCommand = IDC_RELOADBUTTON_FUNCLIST;
tbButtons[2].iBitmap = 1; tbButtons[2].iBitmap = 1;
tbButtons[2].fsState = TBSTATE_ENABLED; tbButtons[2].fsState = TBSTATE_ENABLED;
tbButtons[2].fsStyle = BTNS_BUTTON | BTNS_AUTOSIZE; tbButtons[2].fsStyle = BTNS_BUTTON;
tbButtons[2].iString = reinterpret_cast<intptr_t>(TEXT("")); tbButtons[2].iString = 0;
tbButtons[3].idCommand = IDC_PREFERENCEBUTTON_FUNCLIST; tbButtons[3].idCommand = IDC_PREFERENCEBUTTON_FUNCLIST;
tbButtons[3].iBitmap = 2; tbButtons[3].iBitmap = 2;
tbButtons[3].fsState = TBSTATE_ENABLED; tbButtons[3].fsState = TBSTATE_ENABLED;
tbButtons[3].fsStyle = BTNS_BUTTON | BTNS_AUTOSIZE; tbButtons[3].fsStyle = BTNS_BUTTON;
tbButtons[3].iString = reinterpret_cast<intptr_t>(TEXT("")); tbButtons[3].iString = 0;
::SendMessage(_hToolbarMenu, TB_BUTTONSTRUCTSIZE, sizeof(TBBUTTON), 0); ::SendMessage(_hToolbarMenu, TB_BUTTONSTRUCTSIZE, sizeof(TBBUTTON), 0);
::SendMessage(_hToolbarMenu, TB_SETBUTTONSIZE, 0, MAKELONG(nppParams._dpiManager.scaleX(16), nppParams._dpiManager.scaleY(16))); ::SendMessage(_hToolbarMenu, TB_SETBUTTONSIZE, 0, MAKELONG(iconSizeDyn, iconSizeDyn));
::SendMessage(_hToolbarMenu, TB_ADDBUTTONS, sizeof(tbButtons) / sizeof(TBBUTTON), reinterpret_cast<LPARAM>(&tbButtons)); ::SendMessage(_hToolbarMenu, TB_ADDBUTTONS, sizeof(tbButtons) / sizeof(TBBUTTON), reinterpret_cast<LPARAM>(&tbButtons));
::SendMessage(_hToolbarMenu, TB_AUTOSIZE, 0, 0); ::SendMessage(_hToolbarMenu, TB_AUTOSIZE, 0, 0);
@ -887,7 +913,7 @@ intptr_t CALLBACK FunctionListPanel::run_dlgProc(UINT message, WPARAM wParam, LP
_reloadTipStr = pNativeSpeaker->getAttrNameStr(_reloadTipStr.c_str(), FL_FUCTIONLISTROOTNODE, FL_RELOADLOCALNODENAME); _reloadTipStr = pNativeSpeaker->getAttrNameStr(_reloadTipStr.c_str(), FL_FUCTIONLISTROOTNODE, FL_RELOADLOCALNODENAME);
_preferenceTipStr = pNativeSpeaker->getAttrNameStr(_preferenceTipStr.c_str(), FL_FUCTIONLISTROOTNODE, FL_PREFERENCESLOCALNODENAME); _preferenceTipStr = pNativeSpeaker->getAttrNameStr(_preferenceTipStr.c_str(), FL_FUCTIONLISTROOTNODE, FL_PREFERENCESLOCALNODENAME);
_hSearchEdit = CreateWindowEx(WS_EX_CLIENTEDGE, L"Edit", NULL, _hSearchEdit = CreateWindowEx(WS_EX_CLIENTEDGE, WC_EDIT, NULL,
WS_CHILD | WS_VISIBLE | ES_AUTOVSCROLL, WS_CHILD | WS_VISIBLE | ES_AUTOVSCROLL,
2, 2, editWidth, editHeight, 2, 2, editWidth, editHeight,
_hToolbarMenu, reinterpret_cast<HMENU>(IDC_SEARCHFIELD_FUNCLIST), _hInst, 0 ); _hToolbarMenu, reinterpret_cast<HMENU>(IDC_SEARCHFIELD_FUNCLIST), _hInst, 0 );
@ -896,7 +922,7 @@ intptr_t CALLBACK FunctionListPanel::run_dlgProc(UINT message, WPARAM wParam, LP
if (_hFontSearchEdit == nullptr) if (_hFontSearchEdit == nullptr)
{ {
LOGFONT lf{ DPIManagerV2::getDefaultGUIFontForDpi(_hParent) }; LOGFONT lf{ _dpiManager.getDefaultGUIFontForDpi() };
_hFontSearchEdit = ::CreateFontIndirect(&lf); _hFontSearchEdit = ::CreateFontIndirect(&lf);
} }
@ -925,6 +951,7 @@ intptr_t CALLBACK FunctionListPanel::run_dlgProc(UINT message, WPARAM wParam, LP
if (static_cast<BOOL>(lParam) != TRUE) if (static_cast<BOOL>(lParam) != TRUE)
{ {
NppDarkMode::autoThemeChildControls(_hSelf); NppDarkMode::autoThemeChildControls(_hSelf);
::SendMessage(_hToolbarMenu, TB_SETIMAGELIST, 0, reinterpret_cast<LPARAM>(_iconListVector.at(NppDarkMode::isEnabled() ? 1 : 0)));
} }
NppDarkMode::setTreeViewStyle(_treeView.getHSelf()); NppDarkMode::setTreeViewStyle(_treeView.getHSelf());
return TRUE; return TRUE;
@ -1000,7 +1027,7 @@ intptr_t CALLBACK FunctionListPanel::run_dlgProc(UINT message, WPARAM wParam, LP
{ {
int width = LOWORD(lParam); int width = LOWORD(lParam);
int height = HIWORD(lParam); int height = HIWORD(lParam);
int extraValue = NppParameters::getInstance()._dpiManager.scaleX(4); int extraValue = _dpiManager.scale(4);
RECT toolbarMenuRect; RECT toolbarMenuRect;
::GetClientRect(_hToolbarMenu, &toolbarMenuRect); ::GetClientRect(_hToolbarMenu, &toolbarMenuRect);

View File

@ -111,6 +111,7 @@ private:
HWND _hToolbarMenu = nullptr; HWND _hToolbarMenu = nullptr;
HWND _hSearchEdit = nullptr; HWND _hSearchEdit = nullptr;
HFONT _hFontSearchEdit = nullptr; HFONT _hFontSearchEdit = nullptr;
std::vector<HIMAGELIST> _iconListVector;
TreeView *_pTreeView = nullptr; TreeView *_pTreeView = nullptr;
TreeView _treeView; TreeView _treeView;

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 246 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 KiB

View File

Before

Width:  |  Height:  |  Size: 902 B

After

Width:  |  Height:  |  Size: 902 B

View File

Before

Width:  |  Height:  |  Size: 902 B

After

Width:  |  Height:  |  Size: 902 B

View File

Before

Width:  |  Height:  |  Size: 902 B

After

Width:  |  Height:  |  Size: 902 B

View File

Before

Width:  |  Height:  |  Size: 902 B

After

Width:  |  Height:  |  Size: 902 B

View File

Before

Width:  |  Height:  |  Size: 902 B

After

Width:  |  Height:  |  Size: 902 B

View File

Before

Width:  |  Height:  |  Size: 902 B

After

Width:  |  Height:  |  Size: 902 B

View File

Before

Width:  |  Height:  |  Size: 902 B

After

Width:  |  Height:  |  Size: 902 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 523 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 521 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 586 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 356 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 434 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 486 B

View File

Before

Width:  |  Height:  |  Size: 902 B

After

Width:  |  Height:  |  Size: 902 B

View File

Before

Width:  |  Height:  |  Size: 902 B

After

Width:  |  Height:  |  Size: 902 B

View File

Before

Width:  |  Height:  |  Size: 902 B

After

Width:  |  Height:  |  Size: 902 B

View File

Before

Width:  |  Height:  |  Size: 902 B

After

Width:  |  Height:  |  Size: 902 B

View File

Before

Width:  |  Height:  |  Size: 902 B

After

Width:  |  Height:  |  Size: 902 B

View File

Before

Width:  |  Height:  |  Size: 902 B

After

Width:  |  Height:  |  Size: 902 B

View File

Before

Width:  |  Height:  |  Size: 902 B

After

Width:  |  Height:  |  Size: 902 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 246 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 511 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 509 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 664 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 350 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 419 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 455 B

View File

Before

Width:  |  Height:  |  Size: 822 B

After

Width:  |  Height:  |  Size: 822 B

View File

Before

Width:  |  Height:  |  Size: 822 B

After

Width:  |  Height:  |  Size: 822 B

View File

Before

Width:  |  Height:  |  Size: 822 B

After

Width:  |  Height:  |  Size: 822 B

View File

Before

Width:  |  Height:  |  Size: 822 B

After

Width:  |  Height:  |  Size: 822 B

View File

Before

Width:  |  Height:  |  Size: 822 B

After

Width:  |  Height:  |  Size: 822 B

View File

Before

Width:  |  Height:  |  Size: 822 B

After

Width:  |  Height:  |  Size: 822 B

View File

Before

Width:  |  Height:  |  Size: 822 B

After

Width:  |  Height:  |  Size: 822 B

View File

Before

Width:  |  Height:  |  Size: 822 B

After

Width:  |  Height:  |  Size: 822 B

View File

Before

Width:  |  Height:  |  Size: 822 B

After

Width:  |  Height:  |  Size: 822 B

View File

Before

Width:  |  Height:  |  Size: 822 B

After

Width:  |  Height:  |  Size: 822 B