Browse Source

Add dark mode to project panel file relocalizer dlg

Fix #12713, close #12714
pull/12722/head
ozone10 2 years ago committed by Don Ho
parent
commit
6a8a446eb6
  1. 64
      PowerEditor/src/WinControls/ProjectPanel/ProjectPanel.cpp
  2. 2
      PowerEditor/src/WinControls/ProjectPanel/ProjectPanel.rc

64
PowerEditor/src/WinControls/ProjectPanel/ProjectPanel.cpp

@ -33,7 +33,7 @@
ProjectPanel::~ProjectPanel()
{
for (const auto s : fullPathStrs)
for (const auto& s : fullPathStrs)
{
delete s;
}
@ -52,7 +52,7 @@ intptr_t CALLBACK ProjectPanel::run_dlgProc(UINT message, WPARAM wParam, LPARAM
_hToolbarMenu = CreateWindowEx(0,TOOLBARCLASSNAME,NULL, style,
0,0,0,0,_hSelf, nullptr, _hInst, nullptr);
TBBUTTON tbButtons[2];
TBBUTTON tbButtons[2]{};
NativeLangSpeaker *pNativeSpeaker = (NppParameters::getInstance()).getNativeLangSpeaker();
generic_string workspace_entry = pNativeSpeaker->getProjectPanelLangMenuStr("Entries", 0, PM_WORKSPACEMENUENTRY);
@ -150,7 +150,7 @@ intptr_t CALLBACK ProjectPanel::run_dlgProc(UINT message, WPARAM wParam, LPARAM
if (selectedItem)
{
RECT selectedItemRect;
RECT selectedItemRect{};
if (TreeView_GetItemRect(_treeView.getHSelf(), selectedItem, &selectedItemRect, TRUE))
{
showContextMenuFromMenuKey(selectedItem, (selectedItemRect.left + selectedItemRect.right) / 2, (selectedItemRect.top + selectedItemRect.bottom) / 2);
@ -391,8 +391,8 @@ bool ProjectPanel::writeWorkSpace(const TCHAR *projectFileName)
TiXmlDocument projDoc(fn2write);
TiXmlNode *root = projDoc.InsertEndChild(TiXmlElement(TEXT("NotepadPlus")));
TCHAR textBuffer[MAX_PATH];
TVITEM tvItem;
TCHAR textBuffer[MAX_PATH] = { '\0' };
TVITEM tvItem{};
tvItem.mask = TVIF_TEXT;
tvItem.pszText = textBuffer;
tvItem.cchTextMax = MAX_PATH;
@ -435,8 +435,8 @@ bool ProjectPanel::writeWorkSpace(const TCHAR *projectFileName)
void ProjectPanel::buildProjectXml(TiXmlNode *node, HTREEITEM hItem, const TCHAR* fn2write)
{
TCHAR textBuffer[MAX_PATH];
TVITEM tvItem;
TCHAR textBuffer[MAX_PATH] = { '\0' };
TVITEM tvItem{};
tvItem.mask = TVIF_TEXT | TVIF_PARAM;
tvItem.pszText = textBuffer;
tvItem.cchTextMax = MAX_PATH;
@ -465,8 +465,8 @@ void ProjectPanel::buildProjectXml(TiXmlNode *node, HTREEITEM hItem, const TCHAR
bool ProjectPanel::enumWorkSpaceFiles(HTREEITEM tvFrom, const std::vector<generic_string> & patterns, std::vector<generic_string> & fileNames)
{
TCHAR textBuffer[MAX_PATH];
TVITEM tvItem;
TCHAR textBuffer[MAX_PATH] = { '\0' };
TVITEM tvItem{};
tvItem.mask = TVIF_TEXT | TVIF_PARAM;
tvItem.pszText = textBuffer;
tvItem.cchTextMax = MAX_PATH;
@ -498,7 +498,7 @@ bool ProjectPanel::enumWorkSpaceFiles(HTREEITEM tvFrom, const std::vector<generi
generic_string ProjectPanel::getRelativePath(const generic_string & filePath, const TCHAR *workSpaceFileName)
{
TCHAR wsfn[MAX_PATH];
TCHAR wsfn[MAX_PATH] = { '\0' };
wcscpy_s(wsfn, workSpaceFileName);
::PathRemoveFileSpec(wsfn);
@ -550,7 +550,7 @@ generic_string ProjectPanel::getAbsoluteFilePath(const TCHAR * relativePath)
if (!::PathIsRelative(relativePath))
return relativePath;
TCHAR absolutePath[MAX_PATH];
TCHAR absolutePath[MAX_PATH] = { '\0' };
wcscpy_s(absolutePath, _workSpaceFilePath.c_str());
::PathRemoveFileSpec(absolutePath);
::PathAppend(absolutePath, relativePath);
@ -559,7 +559,7 @@ generic_string ProjectPanel::getAbsoluteFilePath(const TCHAR * relativePath)
void ProjectPanel::openSelectFile()
{
TVITEM tvItem;
TVITEM tvItem{};
tvItem.mask = TVIF_PARAM;
tvItem.hItem = _treeView.getSelection();
::SendMessage(_treeView.getHSelf(), TVM_GETITEM, 0, reinterpret_cast<LPARAM>(&tvItem));
@ -595,7 +595,7 @@ void ProjectPanel::notified(LPNMHDR notification)
else if ((notification->hwndFrom == _treeView.getHSelf()))
{
TCHAR textBuffer[MAX_PATH] = { '\0' };
TVITEM tvItem;
TVITEM tvItem{};
tvItem.mask = TVIF_TEXT | TVIF_PARAM;
tvItem.pszText = textBuffer;
tvItem.cchTextMax = MAX_PATH;
@ -1308,7 +1308,7 @@ void ProjectPanel::addFilesFromDirectory(HTREEITEM hTreeItem)
{
if (_selDirOfFilesFromDirDlg == TEXT("") && _workSpaceFilePath != TEXT(""))
{
TCHAR dir[MAX_PATH];
TCHAR dir[MAX_PATH] = { '\0' };
wcscpy_s(dir, _workSpaceFilePath.c_str());
::PathRemoveFileSpec(dir);
_selDirOfFilesFromDirDlg = dir;
@ -1336,15 +1336,47 @@ intptr_t CALLBACK FileRelocalizerDlg::run_dlgProc(UINT Message, WPARAM wParam, L
{
goToCenter();
::SetDlgItemText(_hSelf, IDC_EDIT_FILEFULLPATHNAME, _fullFilePath.c_str());
NppDarkMode::autoSubclassAndThemeChildControls(_hSelf);
return TRUE;
}
case WM_ERASEBKGND:
{
if (NppDarkMode::isEnabled())
{
RECT rect{};
GetClientRect(_hSelf, &rect);
::FillRect(reinterpret_cast<HDC>(wParam), &rect, NppDarkMode::getDarkerBackgroundBrush());
return TRUE;
}
break;
}
case WM_CTLCOLOREDIT:
{
if (NppDarkMode::isEnabled())
{
return NppDarkMode::onCtlColorSofter(reinterpret_cast<HDC>(wParam));
}
break;
}
case WM_PRINTCLIENT:
{
if (NppDarkMode::isEnabled())
{
return TRUE;
}
break;
}
case WM_COMMAND :
{
switch (wParam)
{
case IDOK :
{
TCHAR textBuf[MAX_PATH];
TCHAR textBuf[MAX_PATH] = { '\0' };
::GetDlgItemText(_hSelf, IDC_EDIT_FILEFULLPATHNAME, textBuf, MAX_PATH);
_fullFilePath = textBuf;
::EndDialog(_hSelf, 0);
@ -1362,6 +1394,7 @@ intptr_t CALLBACK FileRelocalizerDlg::run_dlgProc(UINT Message, WPARAM wParam, L
default :
return FALSE;
}
return FALSE;
}
int FileRelocalizerDlg::doDialog(const TCHAR *fn, bool isRTL)
@ -1378,4 +1411,3 @@ int FileRelocalizerDlg::doDialog(const TCHAR *fn, bool isRTL)
}
return static_cast<int32_t>(::DialogBoxParam(_hInst, MAKEINTRESOURCE(IDD_FILERELOCALIZER_DIALOG), _hParent, dlgProc, reinterpret_cast<LPARAM>(this)));
}

2
PowerEditor/src/WinControls/ProjectPanel/ProjectPanel.rc

@ -29,7 +29,7 @@ END
IDD_FILERELOCALIZER_DIALOG DIALOGEX 0, 0, 350, 48
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU
EXSTYLE WS_EX_TOOLWINDOW
EXSTYLE WS_EX_DLGMODALFRAME | WS_EX_WINDOWEDGE
CAPTION "Change file full path name"
FONT 8, "MS Shell Dlg", 400, 0, 0x1
BEGIN

Loading…
Cancel
Save