GUI enhancement: use split button for find dlg swap/copy button

- Reorder controls for consistent tab switching.
- Fix visual glitch for checkbox button focus rectangles.

Fix #13368, fix #13021close #13372
This commit is contained in:
ozone10 2023-03-19 10:18:01 +01:00 committed by Don Ho
parent d37c7c396a
commit 7e4b281b8a
3 changed files with 119 additions and 92 deletions

View File

@ -2067,8 +2067,10 @@ namespace NppDarkMode
break;
}
case BS_DEFPUSHBUTTON:
case BS_PUSHBUTTON:
case BS_DEFPUSHBUTTON:
case BS_SPLITBUTTON:
case BS_DEFSPLITBUTTON:
{
if (p._theme)
{

View File

@ -320,7 +320,7 @@ void FindReplaceDlg::create(int dialogID, bool isRTL, bool msgDestParent, bool t
//fill min dialog size info
getWindowRect(_initialWindowRect);
_initialWindowRect.right = _initialWindowRect.right - _initialWindowRect.left;
_initialWindowRect.right = _initialWindowRect.right - _initialWindowRect.left + dpiManager.scaleX(10);
_initialWindowRect.left = 0;
_initialWindowRect.bottom = _initialWindowRect.bottom - _initialWindowRect.top;
_initialWindowRect.top = 0;
@ -1418,34 +1418,6 @@ intptr_t CALLBACK FindReplaceDlg::run_dlgProc(UINT message, WPARAM wParam, LPARA
return TRUE;
}
case WM_RBUTTONUP:
{
if (!_swapPopupMenu.isCreated())
{
vector<MenuItemUnit> itemUnitArray;
itemUnitArray.push_back(MenuItemUnit(IDC_SWAP_FIND_REPLACE, TEXT("⇅ Swap Find with Replace")));
itemUnitArray.push_back(MenuItemUnit(IDC_COPY_FIND2REPLACE, TEXT("⤵ Copy from Find to Replace")));
itemUnitArray.push_back(MenuItemUnit(IDC_COPY_REPLACE2FIND, TEXT("⤴ Copy from Replace to Find")));
NativeLangSpeaker* pNativeSpeaker = (NppParameters::getInstance()).getNativeLangSpeaker();
for (auto&& i : itemUnitArray)
{
i._itemName = pNativeSpeaker->getDlgLangMenuStr("Dialog", "Find", i._cmdID, i._itemName.c_str());
}
_swapPopupMenu.create(_hSelf, itemUnitArray);
}
RECT rc{};
::GetClientRect(_hSwapButton, &rc);
POINT p{};
::ClientToScreen(_hSwapButton, &p);
p.y += rc.bottom;
_swapPopupMenu.display(p);
return TRUE;
}
case WM_DRAWITEM :
{
drawItem((DRAWITEMSTRUCT *)lParam);
@ -1469,18 +1441,54 @@ intptr_t CALLBACK FindReplaceDlg::run_dlgProc(UINT message, WPARAM wParam, LPARA
case WM_NOTIFY:
{
NMHDR *nmhdr = (NMHDR *)lParam;
if (nmhdr->code == TCN_SELCHANGE)
auto lpnmhdr = reinterpret_cast<LPNMHDR>(lParam);
switch (lpnmhdr->code)
{
HWND tabHandle = _tab.getHSelf();
if (nmhdr->hwndFrom == tabHandle)
case TCN_SELCHANGE:
{
int indexClicked = int(::SendMessage(tabHandle, TCM_GETCURSEL, 0, 0));
doDialog((DIALOG_TYPE)indexClicked);
const HWND tabHandle = _tab.getHSelf();
if (lpnmhdr->hwndFrom == tabHandle)
{
const auto indexClicked = static_cast<int>(::SendMessage(tabHandle, TCM_GETCURSEL, 0, 0));
doDialog(static_cast<DIALOG_TYPE>(indexClicked));
return TRUE;
}
break;
}
case BCN_DROPDOWN:
{
if (lpnmhdr->hwndFrom == _hSwapButton)
{
if (!_swapPopupMenu.isCreated())
{
vector<MenuItemUnit> itemUnitArray;
itemUnitArray.push_back(MenuItemUnit(IDC_SWAP_FIND_REPLACE, TEXT("⇅ Swap Find with Replace")));
itemUnitArray.push_back(MenuItemUnit(IDC_COPY_FIND2REPLACE, TEXT("⤵ Copy from Find to Replace")));
itemUnitArray.push_back(MenuItemUnit(IDC_COPY_REPLACE2FIND, TEXT("⤴ Copy from Replace to Find")));
NativeLangSpeaker* pNativeSpeaker = (NppParameters::getInstance()).getNativeLangSpeaker();
for (auto&& i : itemUnitArray)
{
i._itemName = pNativeSpeaker->getDlgLangMenuStr("Dialog", "Find", i._cmdID, i._itemName.c_str());
}
_swapPopupMenu.create(_hSelf, itemUnitArray);
}
RECT rc{};
::GetClientRect(_hSwapButton, &rc);
POINT p{};
::ClientToScreen(_hSwapButton, &p);
p.y += rc.bottom;
_swapPopupMenu.display(p);
return TRUE;
}
break;
}
return TRUE;
}
break;
return FALSE;
}
case WM_ACTIVATE :

View File

@ -19,64 +19,78 @@
#include <windows.h>
#include "FindReplaceDlg_rc.h"
IDD_FIND_REPLACE_DLG DIALOGEX 36, 44, 382, 200
IDD_FIND_REPLACE_DLG DIALOGEX 0, 0, 392, 200
STYLE DS_SETFONT | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME
EXSTYLE WS_EX_DLGMODALFRAME | WS_EX_WINDOWEDGE
CAPTION "Replace"
FONT 8, "MS Shell Dlg", 0, 0, 0x0
BEGIN
RTEXT "&Find what :",IDFINDWHAT_STATIC,1,22,73,8
RTEXT "&Find what:",IDFINDWHAT_STATIC,1,22,73,8
COMBOBOX IDFINDWHAT,76,20,170,150,CBS_DROPDOWN | CBS_AUTOHSCROLL | WS_VSCROLL | WS_TABSTOP
RTEXT "Rep&lace with :",ID_STATICTEXT_REPLACE,1,40,73,8
RTEXT "Rep&lace with:",ID_STATICTEXT_REPLACE,1,40,73,8
COMBOBOX IDREPLACEWITH,76,38,170,50,CBS_DROPDOWN | CBS_AUTOHSCROLL | WS_VSCROLL | WS_TABSTOP
PUSHBUTTON "",IDD_FINDREPLACE_SWAP_BUTTON,248,27,16,17
RTEXT "Filter&s :",IDD_FINDINFILES_FILTERS_STATIC,1,58,73,8, SS_NOTIFY
CONTROL "",IDD_FINDREPLACE_SWAP_BUTTON,"Button",BS_SPLITBUTTON | WS_TABSTOP,250,27,24,17
RTEXT "Filter&s:",IDD_FINDINFILES_FILTERS_STATIC,1,58,73,8, SS_NOTIFY
COMBOBOX IDD_FINDINFILES_FILTERS_COMBO,76,56,170,150,CBS_DROPDOWN | CBS_AUTOHSCROLL | WS_VSCROLL | WS_TABSTOP
RTEXT "Dir&ectory :",IDD_FINDINFILES_DIR_STATIC,7,76,41,8
RTEXT "Dir&ectory:",IDD_FINDINFILES_DIR_STATIC,7,76,41,8
COMBOBOX IDD_FINDINFILES_DIR_COMBO,50,74,196,150,CBS_DROPDOWN | CBS_AUTOHSCROLL | WS_VSCROLL | WS_TABSTOP
PUSHBUTTON "...",IDD_FINDINFILES_BROWSE_BUTTON,248,73,16,14
CONTROL "Follow current doc.",IDD_FINDINFILES_FOLDERFOLLOWSDOC_CHECK,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,270,73,94,15
CONTROL "In all su&b-folders",IDD_FINDINFILES_RECURSIVE_CHECK,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,270,87,94,15
CONTROL "In &hidden folders",IDD_FINDINFILES_INHIDDENDIR_CHECK,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,270,101,94,15
CONTROL "Project Panel 1",IDD_FINDINFILES_PROJECT1_CHECK,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,270,73,94,15
CONTROL "Project Panel 2",IDD_FINDINFILES_PROJECT2_CHECK,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,270,87,94,15
CONTROL "Project Panel 3",IDD_FINDINFILES_PROJECT3_CHECK,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,270,101,94,15
CONTROL "Book&mark line",IDC_MARKLINE_CHECK,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,52,140,15
CONTROL "Purge for each search",IDC_PURGE_CHECK,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,64,140,15
PUSHBUTTON "Mark All",IDCMARKALL,268,20,91,14
GROUPBOX "",IDC_REPLACEINSELECTION,192,50,170,23
CONTROL "In select&ion",IDC_IN_SELECTION_CHECK,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,200,58,59,10
PUSHBUTTON "Clear all marks",IDC_CLEAR_ALL,268,38,91,14
CONTROL "Backward direction", IDC_BACKWARDDIRECTION, "Button", BS_AUTOCHECKBOX | WS_TABSTOP, 12, 76, 140, 15
CONTROL "Match &whole word only",IDWHOLEWORD,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,88,140,15
CONTROL "Match &case",IDMATCHCASE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,100,140,15
CONTROL "Wra&p around",IDWRAP,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,112,140,15
GROUPBOX "Search Mode",IDC_MODE_STATIC,6,131,159,48
PUSHBUTTON "...",IDD_FINDINFILES_BROWSE_BUTTON,250,73,16,14
CONTROL "Follow current doc.",IDD_FINDINFILES_FOLDERFOLLOWSDOC_CHECK,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,280,78,94,10
CONTROL "In all su&b-folders",IDD_FINDINFILES_RECURSIVE_CHECK,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,280,90,94,10
CONTROL "In &hidden folders",IDD_FINDINFILES_INHIDDENDIR_CHECK,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,280,102,94,10
CONTROL "Project Panel 1",IDD_FINDINFILES_PROJECT1_CHECK,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,280,78,94,10
CONTROL "Project Panel 2",IDD_FINDINFILES_PROJECT2_CHECK,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,280,90,94,10
CONTROL "Project Panel 3",IDD_FINDINFILES_PROJECT3_CHECK,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,280,102,94,10
CONTROL "Book&mark line",IDC_MARKLINE_CHECK,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,54,140,10
CONTROL "Purge for each search",IDC_PURGE_CHECK,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,66,140,10
CONTROL "Backward direction",IDC_BACKWARDDIRECTION,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,78,140,10
CONTROL "Match &whole word only",IDWHOLEWORD,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,90,140,10
CONTROL "Match &case",IDMATCHCASE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,102,140,10
CONTROL "Wra&p around",IDWRAP,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,114,140,10
GROUPBOX "Search Mode",IDC_MODE_STATIC,6,131,164,48
CONTROL "&Normal",IDNORMAL,"Button",BS_AUTORADIOBUTTON | WS_GROUP,12,143,126,10
CONTROL "E&xtended (\\n, \\r, \\t, \\0, \\x...)",IDEXTENDED,"Button",BS_AUTORADIOBUTTON,12,155,145,10
CONTROL "Re&gular expression",IDREGEXP,"Button",BS_AUTORADIOBUTTON,12,167,78,10
CONTROL "&. matches newline",IDREDOTMATCHNL,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,93,167,68,9
PUSHBUTTON "", IDC_FINDPREV, 268, 20, 18, 14, WS_GROUP | BS_MULTILINE
PUSHBUTTON "", IDC_FINDNEXT, 289, 20, 70, 14, WS_GROUP | BS_MULTILINE
PUSHBUTTON "Find Next",IDOK,268,20,91,14,WS_GROUP
CONTROL "", IDC_2_BUTTONS_MODE, "Button", BS_AUTOCHECKBOX | WS_TABSTOP, 363, 20, 15, 15
PUSHBUTTON "Coun&t",IDCCOUNTALL,268,38,91,14
PUSHBUTTON "Find All in Current &Document",IDC_FINDALL_CURRENTFILE,268,56,91,21,BS_MULTILINE
PUSHBUTTON "Find All in All &Opened Documents",IDC_FINDALL_OPENEDFILES,268,80,91,21,BS_MULTILINE
PUSHBUTTON "&Replace",IDREPLACE,268,38,91,14
PUSHBUTTON "Replace &All",IDREPLACEALL,268,56,91,14
PUSHBUTTON "Replace All in All Opened Doc&uments",IDC_REPLACE_OPENEDFILES,268,74,91,21,BS_MULTILINE
PUSHBUTTON "Find All",IDD_FINDINFILES_FIND_BUTTON,268,20,91,14,WS_GROUP
PUSHBUTTON "Replace in Files",IDD_FINDINFILES_REPLACEINFILES,268,38,91,14
PUSHBUTTON "Replace in Projects",IDD_FINDINFILES_REPLACEINPROJECTS,268,38,91,14
PUSHBUTTON "Copy Marked Text",IDC_COPY_MARKED_TEXT,268,56,91,14
PUSHBUTTON "Close",IDCANCEL,268,98,91,14
GROUPBOX "",IDC_TRANSPARENT_GRPBOX,258,131,99,48
CONTROL "Transparenc&y",IDC_TRANSPARENT_CHECK,"Button",BS_AUTOCHECKBOX | NOT WS_VISIBLE | WS_TABSTOP,254,131,80,10
CONTROL "On losing focus",IDC_TRANSPARENT_LOSSFOCUS_RADIO,"Button",BS_AUTORADIOBUTTON | WS_GROUP | WS_TABSTOP,268,143,85,10
CONTROL "Always",IDC_TRANSPARENT_ALWAYS_RADIO,"Button",BS_AUTORADIOBUTTON ,268,155,85,10
CONTROL "",IDC_PERCENTAGE_SLIDER,"msctls_trackbar32",TBS_BOTH | TBS_NOTICKS | TBS_TRANSPARENTBKGND | NOT WS_VISIBLE | WS_TABSTOP,265,166,85,10
PUSHBUTTON "",IDD_RESIZE_TOGGLE_BUTTON,365,171,16,14
CONTROL "&. matches newline",IDREDOTMATCHNL,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,93,167,72,10
GROUPBOX "",IDC_REPLACEINSELECTION,192,50,180,23
CONTROL "In select&ion",IDC_IN_SELECTION_CHECK,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,200,58,59,10
PUSHBUTTON "",IDC_FINDPREV,278,20,18,14,WS_GROUP | BS_MULTILINE
PUSHBUTTON "",IDC_FINDNEXT,299,20,70,14,WS_GROUP | BS_MULTILINE
PUSHBUTTON "Find Next",IDOK,278,20,91,14,WS_GROUP
CONTROL "",IDC_2_BUTTONS_MODE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,373,22,14,10
PUSHBUTTON "Coun&t",IDCCOUNTALL,278,38,91,14
PUSHBUTTON "Find All in Current &Document",IDC_FINDALL_CURRENTFILE,278,56,91,21,BS_MULTILINE
PUSHBUTTON "Find All in All &Opened Documents",IDC_FINDALL_OPENEDFILES,278,80,91,21,BS_MULTILINE
PUSHBUTTON "&Replace",IDREPLACE,278,38,91,14
PUSHBUTTON "Replace &All",IDREPLACEALL,278,56,91,14
PUSHBUTTON "Replace All in All Opened Doc&uments",IDC_REPLACE_OPENEDFILES,278,74,91,21,BS_MULTILINE
PUSHBUTTON "Find All",IDD_FINDINFILES_FIND_BUTTON,278,20,91,14,WS_GROUP
PUSHBUTTON "Replace in Files",IDD_FINDINFILES_REPLACEINFILES,278,38,91,14
PUSHBUTTON "Replace in Projects",IDD_FINDINFILES_REPLACEINPROJECTS,278,38,91,14
PUSHBUTTON "Mark All",IDCMARKALL,278,20,91,14
PUSHBUTTON "Clear all marks",IDC_CLEAR_ALL,278,38,91,14
PUSHBUTTON "Copy Marked Text",IDC_COPY_MARKED_TEXT,278,56,91,14
PUSHBUTTON "Close",IDCANCEL,278,98,91,14
GROUPBOX "",IDC_TRANSPARENT_GRPBOX,268,131,99,48
CONTROL "Transparenc&y",IDC_TRANSPARENT_CHECK,"Button",BS_AUTOCHECKBOX | NOT WS_VISIBLE | WS_TABSTOP,264,131,80,10
CONTROL "On losing focus",IDC_TRANSPARENT_LOSSFOCUS_RADIO,"Button",BS_AUTORADIOBUTTON | WS_GROUP | WS_TABSTOP,278,143,85,10
CONTROL "Always",IDC_TRANSPARENT_ALWAYS_RADIO,"Button",BS_AUTORADIOBUTTON ,278,155,85,10
CONTROL "",IDC_PERCENTAGE_SLIDER,"msctls_trackbar32",TBS_BOTH | TBS_NOTICKS | TBS_TRANSPARENTBKGND | NOT WS_VISIBLE | WS_TABSTOP,275,166,85,10
PUSHBUTTON "",IDD_RESIZE_TOGGLE_BUTTON,375,171,16,14
END
IDB_INCREMENTAL_BG BITMAP "../icons/incrementalBg.bmp"
@ -104,22 +118,25 @@ BEGIN
DEFPUSHBUTTON ">",IDC_INCFINDNXTOK,243,0,16,14, NOT WS_VISIBLE
END
IDD_FINDINFINDER_DLG DIALOGEX 36, 44, 367, 200
IDD_FINDINFINDER_DLG DIALOGEX 0, 0, 367, 200
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU
EXSTYLE WS_EX_DLGMODALFRAME | WS_EX_WINDOWEDGE
CAPTION "Find in search results"
FONT 8, "MS Shell Dlg", 0, 0, 0x0
BEGIN
RTEXT "&Find what :",IDFINDWHAT_STATIC_FIFOLDER,6,22,75,8
RTEXT "&Find what:",IDFINDWHAT_STATIC_FIFOLDER,6,22,75,8
COMBOBOX IDFINDWHAT_FIFOLDER,83,20,178,150,CBS_DROPDOWN | CBS_AUTOHSCROLL | WS_TABSTOP
CONTROL "Search only in found lines",IDC_MATCHLINENUM_CHECK_FIFOLDER,"Button",BS_AUTOCHECKBOX | BS_MULTILINE | WS_TABSTOP,12,66,99,16
CONTROL "Match &whole word only",IDWHOLEWORD_FIFOLDER,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,88,140,15
CONTROL "Match &case",IDMATCHCASE_FIFOLDER,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,100,140,15
GROUPBOX "Search Mode",IDC_MODE_STATIC_FIFOLDER,6,131,159,48
CONTROL "Search only in found lines",IDC_MATCHLINENUM_CHECK_FIFOLDER,"Button",BS_AUTOCHECKBOX | BS_MULTILINE | WS_TABSTOP,12,66,99,16
CONTROL "Match &whole word only",IDWHOLEWORD_FIFOLDER,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,88,140,10
CONTROL "Match &case",IDMATCHCASE_FIFOLDER,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,100,140,10
GROUPBOX "Search Mode",IDC_MODE_STATIC_FIFOLDER,6,131,164,48
CONTROL "&Normal",IDNORMAL_FIFOLDER,"Button",BS_AUTORADIOBUTTON | WS_GROUP,12,143,126,10
CONTROL "E&xtended (\\n, \\r, \\t, \\0, \\x...)",IDEXTENDED_FIFOLDER, "Button",BS_AUTORADIOBUTTON,12,155,145,10
CONTROL "Re&gular expression",IDREGEXP_FIFOLDER,"Button",BS_AUTORADIOBUTTON,12,167,78,10
CONTROL "&. matches newline",IDREDOTMATCHNL_FIFOLDER,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,93,167,68,9
CONTROL "&. matches newline",IDREDOTMATCHNL_FIFOLDER,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,93,167,72,10
PUSHBUTTON "Find All",IDOK,268,20,90,14,WS_GROUP
PUSHBUTTON "Close",IDCANCEL,268,38,90,14
PUSHBUTTON "Close",IDCANCEL,268,38,90,14
END