From db4a6f5ec6834c4513d650053e46aea2eaa4b5e7 Mon Sep 17 00:00:00 2001 From: Don HO Date: Fri, 11 Dec 2020 20:09:55 +0100 Subject: [PATCH] Fix dockable panels display issue in RTL direction Fix #9241 --- PowerEditor/src/Notepad_plus.cpp | 30 +++++++------- .../src/ScitillaComponent/FindReplaceDlg.cpp | 20 +++++++--- .../DockingWnd/DockingDlgInterface.h | 39 ++++++++----------- 3 files changed, 47 insertions(+), 42 deletions(-) diff --git a/PowerEditor/src/Notepad_plus.cpp b/PowerEditor/src/Notepad_plus.cpp index 0011c7d9..50e8eb48 100644 --- a/PowerEditor/src/Notepad_plus.cpp +++ b/PowerEditor/src/Notepad_plus.cpp @@ -6346,8 +6346,10 @@ void Notepad_plus::launchClipboardHistoryPanel() _pClipboardHistoryPanel->init(_pPublicInterface->getHinst(), _pPublicInterface->getHSelf(), &_pEditView); + NativeLangSpeaker *pNativeSpeaker = (NppParameters::getInstance()).getNativeLangSpeaker(); + bool isRTL = pNativeSpeaker->isRTL(); tTbData data = {0}; - _pClipboardHistoryPanel->create(&data); + _pClipboardHistoryPanel->create(&data, isRTL); ::SendMessage(_pPublicInterface->getHSelf(), NPPM_MODELESSDIALOG, MODELESSDIALOGREMOVE, reinterpret_cast(_pClipboardHistoryPanel->getHSelf())); // define the default docking behaviour @@ -6359,7 +6361,7 @@ void Notepad_plus::launchClipboardHistoryPanel() // in this case is DOCKABLE_DEMO_INDEX // In the case of Notepad++ internal function, it'll be the command ID which triggers this dialog data.dlgID = IDM_EDIT_CLIPBOARDHISTORY_PANEL; - NativeLangSpeaker *pNativeSpeaker = (NppParameters::getInstance()).getNativeLangSpeaker(); + generic_string title_temp = pNativeSpeaker->getAttrNameStr(CH_PROJECTPANELTITLE, "ClipboardHistory", "PanelTitle"); static TCHAR title[32]; if (title_temp.length() < 32) @@ -6387,9 +6389,10 @@ void Notepad_plus::launchFileSwitcherPanel() _pFileSwitcherPanel = new VerticalFileSwitcher; HIMAGELIST hImgLst = _docTabIconList.getHandle(); _pFileSwitcherPanel->init(_pPublicInterface->getHinst(), _pPublicInterface->getHSelf(), hImgLst); - + NativeLangSpeaker *pNativeSpeaker = (NppParameters::getInstance()).getNativeLangSpeaker(); + bool isRTL = pNativeSpeaker->isRTL(); tTbData data = {0}; - _pFileSwitcherPanel->create(&data); + _pFileSwitcherPanel->create(&data, isRTL); ::SendMessage(_pPublicInterface->getHSelf(), NPPM_MODELESSDIALOG, MODELESSDIALOGREMOVE, reinterpret_cast(_pFileSwitcherPanel->getHSelf())); // define the default docking behaviour @@ -6402,7 +6405,6 @@ void Notepad_plus::launchFileSwitcherPanel() // In the case of Notepad++ internal function, it'll be the command ID which triggers this dialog data.dlgID = IDM_VIEW_FILESWITCHER_PANEL; - NativeLangSpeaker *pNativeSpeaker = (NppParameters::getInstance()).getNativeLangSpeaker(); generic_string title_temp = pNativeSpeaker->getAttrNameStr(FS_PROJECTPANELTITLE, "DocSwitcher", "PanelTitle"); static TCHAR title[32]; if (title_temp.length() < 32) @@ -6429,8 +6431,10 @@ void Notepad_plus::launchAnsiCharPanel() _pAnsiCharPanel = new AnsiCharPanel(); _pAnsiCharPanel->init(_pPublicInterface->getHinst(), _pPublicInterface->getHSelf(), &_pEditView); + NativeLangSpeaker *pNativeSpeaker = (NppParameters::getInstance()).getNativeLangSpeaker(); + bool isRTL = pNativeSpeaker->isRTL(); tTbData data = {0}; - _pAnsiCharPanel->create(&data); + _pAnsiCharPanel->create(&data, isRTL); ::SendMessage(_pPublicInterface->getHSelf(), NPPM_MODELESSDIALOG, MODELESSDIALOGREMOVE, reinterpret_cast(_pAnsiCharPanel->getHSelf())); // define the default docking behaviour @@ -6443,7 +6447,6 @@ void Notepad_plus::launchAnsiCharPanel() // In the case of Notepad++ internal function, it'll be the command ID which triggers this dialog data.dlgID = IDM_EDIT_CHAR_PANEL; - NativeLangSpeaker *pNativeSpeaker = (NppParameters::getInstance()).getNativeLangSpeaker(); generic_string title_temp = pNativeSpeaker->getAttrNameStr(AI_PROJECTPANELTITLE, "AsciiInsertion", "PanelTitle"); static TCHAR title[85]; if (title_temp.length() < 85) @@ -6472,7 +6475,7 @@ void Notepad_plus::launchFileBrowser(const vector & folders, con tTbData data; memset(&data, 0, sizeof(data)); - _pFileBrowser->create(&data); + _pFileBrowser->create(&data, _nativeLangSpeaker.isRTL()); data.pszName = TEXT("ST"); ::SendMessage(_pPublicInterface->getHSelf(), NPPM_MODELESSDIALOG, MODELESSDIALOGREMOVE, reinterpret_cast(_pFileBrowser->getHSelf())); @@ -6569,10 +6572,11 @@ void Notepad_plus::launchProjectPanel(int cmdID, ProjectPanel ** pProjPanel, int (*pProjPanel) = new ProjectPanel; (*pProjPanel)->init(_pPublicInterface->getHinst(), _pPublicInterface->getHSelf(), panelID); (*pProjPanel)->setWorkSpaceFilePath(nppParam.getWorkSpaceFilePath(panelID)); - + NativeLangSpeaker *pNativeSpeaker = (NppParameters::getInstance()).getNativeLangSpeaker(); + bool isRTL = pNativeSpeaker->isRTL(); tTbData data; memset(&data, 0, sizeof(data)); - (*pProjPanel)->create(&data); + (*pProjPanel)->create(&data, isRTL); data.pszName = TEXT("ST"); ::SendMessage(_pPublicInterface->getHSelf(), NPPM_MODELESSDIALOG, MODELESSDIALOGREMOVE, reinterpret_cast((*pProjPanel)->getHSelf())); @@ -6586,7 +6590,6 @@ void Notepad_plus::launchProjectPanel(int cmdID, ProjectPanel ** pProjPanel, int // In the case of Notepad++ internal function, it'll be the command ID which triggers this dialog data.dlgID = cmdID; - NativeLangSpeaker *pNativeSpeaker = (NppParameters::getInstance()).getNativeLangSpeaker(); generic_string title_no = to_wstring (panelID + 1); generic_string title_temp = pNativeSpeaker->getAttrNameStr(PM_PROJECTPANELTITLE, "ProjectManager", "PanelTitle") + TEXT(" ") + title_no; (*pProjPanel)->setPanelTitle(title_temp); @@ -6669,8 +6672,10 @@ void Notepad_plus::launchFunctionList() _pFuncList = new FunctionListPanel(); _pFuncList->init(_pPublicInterface->getHinst(), _pPublicInterface->getHSelf(), &_pEditView); + NativeLangSpeaker *pNativeSpeaker = (NppParameters::getInstance()).getNativeLangSpeaker(); + bool isRTL = pNativeSpeaker->isRTL(); tTbData data = {0}; - _pFuncList->create(&data); + _pFuncList->create(&data, isRTL); ::SendMessage(_pPublicInterface->getHSelf(), NPPM_MODELESSDIALOG, MODELESSDIALOGREMOVE, reinterpret_cast(_pFuncList->getHSelf())); // define the default docking behaviour @@ -6683,7 +6688,6 @@ void Notepad_plus::launchFunctionList() // In the case of Notepad++ internal function, it'll be the command ID which triggers this dialog data.dlgID = IDM_VIEW_FUNC_LIST; - NativeLangSpeaker *pNativeSpeaker = (NppParameters::getInstance()).getNativeLangSpeaker(); generic_string title_temp = pNativeSpeaker->getAttrNameStr(FL_PANELTITLE, FL_FUCTIONLISTROOTNODE, "PanelTitle"); static TCHAR title[32]; diff --git a/PowerEditor/src/ScitillaComponent/FindReplaceDlg.cpp b/PowerEditor/src/ScitillaComponent/FindReplaceDlg.cpp index 206b89f7..35b5770d 100644 --- a/PowerEditor/src/ScitillaComponent/FindReplaceDlg.cpp +++ b/PowerEditor/src/ScitillaComponent/FindReplaceDlg.cpp @@ -2359,9 +2359,13 @@ void FindReplaceDlg::findAllIn(InWhat op) _pFinder = new Finder(); _pFinder->init(_hInst, (*_ppEditView)->getHParent(), _ppEditView); _pFinder->setVolatiled(false); - + + NativeLangSpeaker *pNativeSpeaker = (NppParameters::getInstance()).getNativeLangSpeaker(); + bool isRTL = pNativeSpeaker->isRTL(); + tTbData data = {0}; - _pFinder->create(&data, false); + + _pFinder->create(&data, isRTL); ::SendMessage(_hParent, NPPM_MODELESSDIALOG, MODELESSDIALOGREMOVE, reinterpret_cast(_pFinder->getHSelf())); // define the default docking behaviour data.uMask = DWS_DF_CONT_BOTTOM | DWS_ICONTAB | DWS_ADDINFO; @@ -2374,8 +2378,8 @@ void FindReplaceDlg::findAllIn(InWhat op) // in this case is DOCKABLE_DEMO_INDEX data.dlgID = 0; - NativeLangSpeaker *pNativeSpeaker = (NppParameters::getInstance()).getNativeLangSpeaker(); generic_string text = pNativeSpeaker->getLocalizedStrFromID("find-result-caption", TEXT("")); + if (!text.empty()) { _findResTitle = text; @@ -2385,6 +2389,7 @@ void FindReplaceDlg::findAllIn(InWhat op) ::SendMessage(_hParent, NPPM_DMMREGASDCKDLG, 0, reinterpret_cast(&data)); _pFinder->_scintView.init(_hInst, _pFinder->getHSelf()); + _pFinder->_scintView.changeTextDirection(isRTL); // Subclass the ScintillaEditView for the Finder (Scintilla doesn't notify all key presses) originalFinderProc = SetWindowLongPtr(_pFinder->_scintView.getHSelf(), GWLP_WNDPROC, reinterpret_cast(finderProc)); @@ -2471,11 +2476,14 @@ void FindReplaceDlg::findAllIn(InWhat op) Finder * FindReplaceDlg::createFinder() { Finder *pFinder = new Finder(); - pFinder->init(_hInst, (*_ppEditView)->getHParent(), _ppEditView); + NativeLangSpeaker *pNativeSpeaker = (NppParameters::getInstance()).getNativeLangSpeaker(); + bool isRTL = pNativeSpeaker->isRTL(); + tTbData data = { 0 }; - pFinder->create(&data, false); + + pFinder->create(&data, isRTL); ::SendMessage(_hParent, NPPM_MODELESSDIALOG, MODELESSDIALOGREMOVE, reinterpret_cast(pFinder->getHSelf())); // define the default docking behaviour data.uMask = DWS_DF_CONT_BOTTOM | DWS_ICONTAB | DWS_ADDINFO; @@ -2488,7 +2496,6 @@ Finder * FindReplaceDlg::createFinder() // in this case is DOCKABLE_DEMO_INDEX data.dlgID = 0; - NativeLangSpeaker *pNativeSpeaker = (NppParameters::getInstance()).getNativeLangSpeaker(); generic_string text = pNativeSpeaker->getLocalizedStrFromID("find-result-caption", TEXT("")); if (!text.empty()) { @@ -2499,6 +2506,7 @@ Finder * FindReplaceDlg::createFinder() ::SendMessage(_hParent, NPPM_DMMREGASDCKDLG, 0, reinterpret_cast(&data)); pFinder->_scintView.init(_hInst, pFinder->getHSelf()); + pFinder->_scintView.changeTextDirection(isRTL); // Subclass the ScintillaEditView for the Finder (Scintilla doesn't notify all key presses) originalFinderProc = SetWindowLongPtr(pFinder->_scintView.getHSelf(), GWLP_WNDPROC, reinterpret_cast(finderProc)); diff --git a/PowerEditor/src/WinControls/DockingWnd/DockingDlgInterface.h b/PowerEditor/src/WinControls/DockingWnd/DockingDlgInterface.h index 249a4706..e661c58c 100644 --- a/PowerEditor/src/WinControls/DockingWnd/DockingDlgInterface.h +++ b/PowerEditor/src/WinControls/DockingWnd/DockingDlgInterface.h @@ -43,16 +43,14 @@ public: DockingDlgInterface() = default; explicit DockingDlgInterface(int dlgID): _dlgID(dlgID) {} - virtual void init(HINSTANCE hInst, HWND parent) - { + virtual void init(HINSTANCE hInst, HWND parent) { StaticDialog::init(hInst, parent); TCHAR temp[MAX_PATH]; ::GetModuleFileName(reinterpret_cast(hInst), temp, MAX_PATH); _moduleName = ::PathFindFileName(temp); } - void create(tTbData * data, bool isRTL = false) - { + void create(tTbData* data, bool isRTL = false) { assert(data != nullptr); StaticDialog::create(_dlgID, isRTL); TCHAR temp[MAX_PATH]; @@ -60,18 +58,17 @@ public: _pluginName = temp; // user information - data->hClient = _hSelf; - data->pszName = _pluginName.c_str(); + data->hClient = _hSelf; + data->pszName = _pluginName.c_str(); // supported features by plugin - data->uMask = 0; + data->uMask = 0; // additional info - data->pszAddInfo = NULL; + data->pszAddInfo = NULL; } - virtual void updateDockingDlg() - { + virtual void updateDockingDlg() { ::SendMessage(_hParent, NPPM_DMMUPDATEDISPINFO, 0, reinterpret_cast(_hSelf)); } @@ -97,11 +94,16 @@ public: } protected : - virtual INT_PTR CALLBACK run_dlgProc(UINT message, WPARAM, LPARAM lParam) - { - switch (message) - { + int _dlgID = -1; + bool _isFloating = true; + int _iDockedPos = 0; + generic_string _moduleName; + generic_string _pluginName; + bool _isClosed = false; + virtual INT_PTR CALLBACK run_dlgProc(UINT message, WPARAM, LPARAM lParam) { + switch (message) + { case WM_NOTIFY: { LPNMHDR pnmh = reinterpret_cast(lParam); @@ -136,13 +138,4 @@ protected : } return FALSE; }; - - // Handles - HWND _HSource = NULL; - int _dlgID = -1; - bool _isFloating = true; - int _iDockedPos = 0; - generic_string _moduleName; - generic_string _pluginName; - bool _isClosed = false; };