From 73b41ec74f52fede81c864ba0b625557a672d4a9 Mon Sep 17 00:00:00 2001 From: Ashfaaq18 Date: Fri, 10 Sep 2021 22:43:49 +0530 Subject: [PATCH] Fix docked/float panels in RTL layout issue Fixed Npp RTL context menu for Document List, Project Panels, Folder Workspace, Search Results Window, and fixed Floating Dockable Window RTL direction. Fix #10488, close #10535 --- .../src/ScintillaComponent/FindReplaceDlg.cpp | 4 +++- .../src/WinControls/DockingWnd/DockingCont.cpp | 7 ++++--- .../src/WinControls/FileBrowser/fileBrowser.cpp | 8 ++++++-- .../WinControls/ProjectPanel/ProjectPanel.cpp | 16 ++++++++++++---- .../VerticalFileSwitcher.cpp | 4 +++- 5 files changed, 28 insertions(+), 11 deletions(-) diff --git a/PowerEditor/src/ScintillaComponent/FindReplaceDlg.cpp b/PowerEditor/src/ScintillaComponent/FindReplaceDlg.cpp index 11717d2e9..b8d3ea77c 100644 --- a/PowerEditor/src/ScintillaComponent/FindReplaceDlg.cpp +++ b/PowerEditor/src/ScintillaComponent/FindReplaceDlg.cpp @@ -4453,7 +4453,9 @@ INT_PTR CALLBACK Finder::run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam) scintillaContextmenu.checkItem(NPPM_INTERNAL_SCINTILLAFINDERWRAP, _longLinesAreWrapped); - scintillaContextmenu.display(p); + ::TrackPopupMenu(scintillaContextmenu.getMenuHandle(), + NppParameters::getInstance().getNativeLangSpeaker()->isRTL() ? TPM_RIGHTALIGN | TPM_LAYOUTRTL : TPM_LEFTALIGN, + p.x, p.y, 0, _hSelf, NULL); return TRUE; } return ::DefWindowProc(_hSelf, message, wParam, lParam); diff --git a/PowerEditor/src/WinControls/DockingWnd/DockingCont.cpp b/PowerEditor/src/WinControls/DockingWnd/DockingCont.cpp index 0742c2854..d2600a1bd 100644 --- a/PowerEditor/src/WinControls/DockingWnd/DockingCont.cpp +++ b/PowerEditor/src/WinControls/DockingWnd/DockingCont.cpp @@ -95,14 +95,15 @@ void DockingCont::doDialog(bool willBeShown, bool isFloating) { if (!isCreated()) { - create(IDD_CONTAINER_DLG); + NativeLangSpeaker* pNativeSpeaker = NppParameters::getInstance().getNativeLangSpeaker(); + create(IDD_CONTAINER_DLG, pNativeSpeaker->isRTL()); _isFloating = isFloating; if (_isFloating) { ::SetWindowLongPtr(_hSelf, GWL_STYLE, POPUP_STYLES); - ::SetWindowLongPtr(_hSelf, GWL_EXSTYLE, POPUP_EXSTYLES); + ::SetWindowLongPtr(_hSelf, GWL_EXSTYLE, pNativeSpeaker->isRTL()? POPUP_EXSTYLES | WS_EX_LAYOUTRTL : POPUP_EXSTYLES); ::ShowWindow(_hCaption, SW_HIDE); } else @@ -633,7 +634,7 @@ eMousePos DockingCont::isInRect(HWND hwnd, int x, int y) eMousePos ret = posOutside; ::GetWindowRect(hwnd, &rc); - ScreenRectToClientRect(hwnd, &rc); + ::MapWindowPoints(NULL, hwnd, (LPPOINT)&rc, 2); if (_isTopCaption == TRUE) { diff --git a/PowerEditor/src/WinControls/FileBrowser/fileBrowser.cpp b/PowerEditor/src/WinControls/FileBrowser/fileBrowser.cpp index 86d64dae8..ad1bd6cfe 100644 --- a/PowerEditor/src/WinControls/FileBrowser/fileBrowser.cpp +++ b/PowerEditor/src/WinControls/FileBrowser/fileBrowser.cpp @@ -777,7 +777,9 @@ void FileBrowser::showContextMenu(int x, int y) if (tvHitInfo.hItem == nullptr) { - TrackPopupMenu(_hGlobalMenu, TPM_LEFTALIGN, x, y, 0, _hSelf, NULL); + TrackPopupMenu(_hGlobalMenu, + NppParameters::getInstance().getNativeLangSpeaker()->isRTL() ? TPM_RIGHTALIGN | TPM_LAYOUTRTL : TPM_LEFTALIGN, + x, y, 0, _hSelf, NULL); } else { @@ -794,7 +796,9 @@ void FileBrowser::showContextMenu(int x, int y) else //nodeType_file hMenu = _hFileMenu; - TrackPopupMenu(hMenu, TPM_LEFTALIGN, x, y, 0, _hSelf, NULL); + TrackPopupMenu(hMenu, + NppParameters::getInstance().getNativeLangSpeaker()->isRTL() ? TPM_RIGHTALIGN | TPM_LAYOUTRTL : TPM_LEFTALIGN, + x, y, 0, _hSelf, NULL); } } diff --git a/PowerEditor/src/WinControls/ProjectPanel/ProjectPanel.cpp b/PowerEditor/src/WinControls/ProjectPanel/ProjectPanel.cpp index 06ea4a338..00b15bb57 100644 --- a/PowerEditor/src/WinControls/ProjectPanel/ProjectPanel.cpp +++ b/PowerEditor/src/WinControls/ProjectPanel/ProjectPanel.cpp @@ -882,7 +882,9 @@ void ProjectPanel::showContextMenu(int x, int y) // Make item selected _treeView.selectItem(tvHitInfo.hItem); HMENU hMenu = getMenuHandler(tvHitInfo.hItem); - TrackPopupMenu(hMenu, TPM_LEFTALIGN, x, y, 0, _hSelf, NULL); + TrackPopupMenu(hMenu, + NppParameters::getInstance().getNativeLangSpeaker()->isRTL() ? TPM_RIGHTALIGN | TPM_LAYOUTRTL : TPM_LEFTALIGN, + x, y, 0, _hSelf, NULL); } } @@ -897,7 +899,9 @@ void ProjectPanel::showContextMenuFromMenuKey(HTREEITEM selectedItem, int x, int if (selectedItem != NULL) { HMENU hMenu = getMenuHandler(selectedItem); - TrackPopupMenu(hMenu, TPM_LEFTALIGN, p.x, p.y, 0, _hSelf, NULL); + TrackPopupMenu(hMenu, + NppParameters::getInstance().getNativeLangSpeaker()->isRTL() ? TPM_RIGHTALIGN | TPM_LAYOUTRTL : TPM_LEFTALIGN, + x, y, 0, _hSelf, NULL); } } @@ -987,7 +991,9 @@ void ProjectPanel::popupMenuCmd(int cmdID) case IDB_PROJECT_BTN: { POINT p = getMenuDisplayPoint(0); - TrackPopupMenu(_hWorkSpaceMenu, TPM_LEFTALIGN, p.x, p.y, 0, _hSelf, NULL); + TrackPopupMenu(_hWorkSpaceMenu, + NppParameters::getInstance().getNativeLangSpeaker()->isRTL() ? TPM_RIGHTALIGN | TPM_LAYOUTRTL : TPM_LEFTALIGN, + p.x, p.y, 0, _hSelf, NULL); } break; @@ -1003,7 +1009,9 @@ void ProjectPanel::popupMenuCmd(int cmdID) else if (nodeType == nodeType_file) hMenu = _hFileMenu; if (hMenu) - TrackPopupMenu(hMenu, TPM_LEFTALIGN, p.x, p.y, 0, _hSelf, NULL); + TrackPopupMenu(hMenu, + NppParameters::getInstance().getNativeLangSpeaker()->isRTL() ? TPM_RIGHTALIGN | TPM_LAYOUTRTL : TPM_LEFTALIGN, + p.x, p.y, 0, _hSelf, NULL); } break; diff --git a/PowerEditor/src/WinControls/VerticalFileSwitcher/VerticalFileSwitcher.cpp b/PowerEditor/src/WinControls/VerticalFileSwitcher/VerticalFileSwitcher.cpp index 26f44f86b..c86d96cc0 100644 --- a/PowerEditor/src/WinControls/VerticalFileSwitcher/VerticalFileSwitcher.cpp +++ b/PowerEditor/src/WinControls/VerticalFileSwitcher/VerticalFileSwitcher.cpp @@ -262,7 +262,9 @@ INT_PTR CALLBACK VerticalFileSwitcher::run_dlgProc(UINT message, WPARAM wParam, { if (nbSelectedFiles() == 0 || colHeaderRClick) { - ::TrackPopupMenu(_hGlobalMenu, TPM_LEFTALIGN, GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam), 0, _hSelf, NULL); + ::TrackPopupMenu(_hGlobalMenu, + NppParameters::getInstance().getNativeLangSpeaker()->isRTL() ? TPM_RIGHTALIGN | TPM_LAYOUTRTL : TPM_LEFTALIGN, + GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam), 0, _hSelf, NULL); colHeaderRClick = false; } return TRUE;