GUI enhancement: Find Characters in Range dialog

- add accelerators
- add initializers

Fix #13577, close #13578
This commit is contained in:
ozone10 2023-04-23 13:49:42 +02:00 committed by Don Ho
parent 61d2d36821
commit 997ef821d1
7 changed files with 85 additions and 53 deletions

View File

@ -490,15 +490,15 @@ The comments are here for explanation, it's not necessary to translate them.
</IncrementalFind>
<FindCharsInRange title="Find Characters in Range...">
<Item id="2" name="Close"/>
<Item id="2901" name="Non-ASCII Characters (128-255)"/>
<Item id="2902" name="ASCII Characters (0-127)"/>
<Item id="2903" name="My range:"/>
<Item id="2" name="&amp;Close"/>
<Item id="2901" name="&amp;Non-ASCII characters (128255)"/>
<Item id="2902" name="&amp;ASCII characters (0127)"/>
<Item id="2903" name="Custom &amp;range (0255):"/>
<Item id="2906" name="&amp;Up"/>
<Item id="2907" name="&amp;Down"/>
<Item id="2908" name="Direction"/>
<Item id="2909" name="Wra&amp;p around"/>
<Item id="2910" name="Find"/>
<Item id="2910" name="&amp;Find"/>
</FindCharsInRange>
<GoToLine title="Go to...">

View File

@ -485,15 +485,15 @@ The comments are here for explanation, it's not necessary to translate them.
</IncrementalFind>
<FindCharsInRange title="Find Characters in Range...">
<Item id="2" name="Close"/>
<Item id="2901" name="Non-ASCII Characters (128-255)"/>
<Item id="2902" name="ASCII Characters (0-127)"/>
<Item id="2903" name="My range:"/>
<Item id="2" name="&amp;Close"/>
<Item id="2901" name="&amp;Non-ASCII characters (128255)"/>
<Item id="2902" name="&amp;ASCII characters (0127)"/>
<Item id="2903" name="Custom &amp;range (0255):"/>
<Item id="2906" name="&amp;Up"/>
<Item id="2907" name="&amp;Down"/>
<Item id="2908" name="Direction"/>
<Item id="2909" name="Wra&amp;p around"/>
<Item id="2910" name="Find"/>
<Item id="2910" name="&amp;Find"/>
</FindCharsInRange>
<GoToLine title="Go to...">

View File

@ -2160,7 +2160,7 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT message, WPARAM wParam, LPARAM lPa
// and defer any cleanup operations until it receives WM_ENDSESSION (with WPARAM TRUE)
// for a bigger tidy-up/save operations we can kick off a background thread here to prepare for shutdown
// and when we get the WM_END­SESSION TRUE, we wait there until that background operation completes
// and when we get the WM_ENDSESSION TRUE, we wait there until that background operation completes
// before telling the system, "ok, you can shut down now...", i.e. returning 0 there
// whatever we do from here - make sure that it is ok for the operation to occur even if the shutdown

View File

@ -20,7 +20,7 @@
#include "Parameters.h"
#include "localization.h"
intptr_t CALLBACK FindCharsInRangeDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM)
intptr_t CALLBACK FindCharsInRangeDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam)
{
switch (message)
{
@ -32,27 +32,40 @@ intptr_t CALLBACK FindCharsInRangeDlg::run_dlgProc(UINT message, WPARAM wParam,
::SendDlgItemMessage(_hSelf, IDC_RANGEEND_EDIT, EM_LIMITTEXT, 3, 0);
::SendDlgItemMessage(_hSelf, IDC_NONASCCI_RADIO, BM_SETCHECK, TRUE, 0);
::SendDlgItemMessage(_hSelf, ID_FINDCHAR_DIRDOWN, BM_SETCHECK, TRUE, 0);
goToCenter();
::SetDlgItemInt(_hSelf, IDC_RANGESTART_EDIT, 0, FALSE);
::SetDlgItemInt(_hSelf, IDC_RANGEEND_EDIT, 255, FALSE);
::EnableWindow(::GetDlgItem(_hSelf, IDC_RANGESTART_EDIT), FALSE);
::EnableWindow(::GetDlgItem(_hSelf, IDC_RANGEEND_EDIT), FALSE);
goToCenter(SWP_SHOWWINDOW | SWP_NOSIZE);
return TRUE;
}
case WM_CTLCOLOREDIT:
{
if (NppDarkMode::isEnabled())
{
return NppDarkMode::onCtlColorSofter(reinterpret_cast<HDC>(wParam));
}
break;
}
case WM_CTLCOLORDLG:
case WM_CTLCOLORSTATIC:
{
if (NppDarkMode::isEnabled())
{
return NppDarkMode::onCtlColorDarker(reinterpret_cast<HDC>(wParam));
}
break;
case WM_CTLCOLORSTATIC:
{
const auto hdcStatic = reinterpret_cast<HDC>(wParam);
const auto dlgCtrlID = ::GetDlgCtrlID(reinterpret_cast<HWND>(lParam));
//set the static text colors to show enable/disable instead of ::EnableWindow which causes blurry text
if (dlgCtrlID == IDC_STATIC)
{
const bool isTextEnabled = isCheckedOrNot(IDC_MYRANGE_RADIO);
return NppDarkMode::onCtlColorDarkerBGStaticText(hdcStatic, isTextEnabled);
}
return NppDarkMode::onCtlColorDarker(hdcStatic);
}
case WM_PRINTCLIENT:
@ -68,7 +81,7 @@ intptr_t CALLBACK FindCharsInRangeDlg::run_dlgProc(UINT message, WPARAM wParam,
{
if (NppDarkMode::isEnabled())
{
RECT rc = {};
RECT rc{};
getClientRect(rc);
::FillRect(reinterpret_cast<HDC>(wParam), &rc, NppDarkMode::getDarkerBackgroundBrush());
return TRUE;
@ -86,6 +99,25 @@ intptr_t CALLBACK FindCharsInRangeDlg::run_dlgProc(UINT message, WPARAM wParam,
{
switch (wParam)
{
case IDC_NONASCCI_RADIO:
case IDC_ASCCI_RADIO:
{
::EnableWindow(::GetDlgItem(_hSelf, IDC_RANGESTART_EDIT), FALSE);
::EnableWindow(::GetDlgItem(_hSelf, IDC_RANGEEND_EDIT), FALSE);
redrawDlgItem(IDC_STATIC);
return TRUE;
}
case IDC_MYRANGE_RADIO:
{
::EnableWindow(::GetDlgItem(_hSelf, IDC_RANGESTART_EDIT), TRUE);
::EnableWindow(::GetDlgItem(_hSelf, IDC_RANGEEND_EDIT), TRUE);
redrawDlgItem(IDC_STATIC);
return TRUE;
}
case IDCANCEL: // Close
display(false);
return TRUE;
@ -204,7 +236,8 @@ bool FindCharsInRangeDlg::getRangeFromUI(unsigned char & startRange, unsigned ch
if (isCheckedOrNot(IDC_MYRANGE_RADIO))
{
BOOL startBool, endBool;
BOOL startBool = FALSE;
BOOL endBool = FALSE;
int start = ::GetDlgItemInt(_hSelf, IDC_RANGESTART_EDIT, &startBool, FALSE);
int end = ::GetDlgItemInt(_hSelf, IDC_RANGEEND_EDIT, &endBool, FALSE);

View File

@ -32,22 +32,18 @@ public :
_ppEditView = ppEditView;
};
virtual void create(int dialogID, bool isRTL = false, bool msgDestParent = true) {
StaticDialog::create(dialogID, isRTL, msgDestParent);
};
void doDialog(bool isRTL = false) {
if (!isCreated())
create(IDD_FINDCHARACTERS, isRTL);
display();
};
virtual void display(bool toShow = true) const {
void display(bool toShow = true) const override {
Window::display(toShow);
};
protected :
virtual intptr_t CALLBACK run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam);
intptr_t CALLBACK run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam) override;
private :
ScintillaEditView **_ppEditView = nullptr;

View File

@ -14,26 +14,30 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
#pragma code_page(65001)
#include <windows.h>
#include "findCharsInRange_rc.h"
IDD_FINDCHARACTERS DIALOGEX 26, 41, 263, 126
IDD_FINDCHARACTERS DIALOGEX 0, 0, 267, 99
STYLE DS_SETFONT | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU
EXSTYLE WS_EX_DLGMODALFRAME | WS_EX_WINDOWEDGE
CAPTION "Find Characters in Range..."
FONT 8, "MS Shell Dlg", 0, 0, 0x0
BEGIN
CONTROL "Non-ASCII Characters (128-255)",IDC_NONASCCI_RADIO,"Button",BS_AUTORADIOBUTTON,22,13,146,10
CONTROL "ASCII Characters (0 - 127)",IDC_ASCCI_RADIO,"Button",BS_AUTORADIOBUTTON,22,32,151,10
CONTROL "My Range:",IDC_MYRANGE_RADIO,"Button",BS_AUTORADIOBUTTON,22,51,67,10
EDITTEXT IDC_RANGESTART_EDIT,91,49,25,14,ES_AUTOHSCROLL | ES_NUMBER
LTEXT "-",IDC_STATIC,122,52,8,8
EDITTEXT IDC_RANGEEND_EDIT,129,49,25,14,ES_AUTOHSCROLL | ES_NUMBER
CONTROL "&Up",ID_FINDCHAR_DIRUP,"Button",BS_AUTORADIOBUTTON | WS_GROUP | WS_TABSTOP,25,91,64,12
CONTROL "&Down",ID_FINDCHAR_DIRDOWN,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,25,103,63,12
GROUPBOX "Direction",IDC_FINDCHAR_DIR_STATIC,19,79,74,42,WS_GROUP
CONTROL "Wra&p around",ID_FINDCHAR_WRAP,"Button",BS_AUTOCHECKBOX | BS_MULTILINE | WS_TABSTOP,105,102,110,15
DEFPUSHBUTTON "Find",ID_FINDCHAR_NEXT,182,8,70,14,BS_NOTIFY
PUSHBUTTON "Close",IDCANCEL,181,27,70,14,BS_NOTIFY
CONTROL "&Non-ASCII characters (128255)",IDC_NONASCCI_RADIO,"Button",BS_AUTORADIOBUTTON | WS_GROUP | WS_TABSTOP,7,6,160,10
CONTROL "&ASCII characters (0127)",IDC_ASCCI_RADIO,"Button",BS_AUTORADIOBUTTON,7,21,160,10
CONTROL "Custom &range (0255):",IDC_MYRANGE_RADIO,"Button",BS_AUTORADIOBUTTON,7,36,110,10
EDITTEXT IDC_RANGESTART_EDIT,120,35,20,12,ES_AUTOHSCROLL | ES_CENTER | ES_NUMBER
CTEXT "",IDC_STATIC,143,37,8,8
EDITTEXT IDC_RANGEEND_EDIT,154,35,20,12,ES_AUTOHSCROLL | ES_CENTER | ES_NUMBER
GROUPBOX "Direction",IDC_FINDCHAR_DIR_STATIC,7,56,74,36,WS_GROUP
CONTROL "&Up",ID_FINDCHAR_DIRUP,"Button",BS_AUTORADIOBUTTON | WS_GROUP | WS_TABSTOP,13,68,64,10
CONTROL "&Down",ID_FINDCHAR_DIRDOWN,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,13,80,63,10
CONTROL "Wra&p around",ID_FINDCHAR_WRAP,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,85,80,110,10
DEFPUSHBUTTON "&Find",ID_FINDCHAR_NEXT,190,6,70,14
PUSHBUTTON "&Close",IDCANCEL,190,24,70,14
END

View File

@ -33,7 +33,7 @@
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<DisableSpecificWarnings>4456;4457;4459</DisableSpecificWarnings>
<AdditionalOptions>/w15262 %(AdditionalOptions)</AdditionalOptions>
<AdditionalOptions>/Zc:__cplusplus /source-charset:utf-8 /Zc:strictStrings /w15262 %(AdditionalOptions)</AdditionalOptions>
<ConformanceMode>true</ConformanceMode>
<LanguageStandard>stdcpp20</LanguageStandard>
<TreatAngleIncludeAsExternal>true</TreatAngleIncludeAsExternal>
@ -57,7 +57,7 @@
<ItemDefinitionGroup Condition="'$(PlatformToolset)'=='ClangCL'">
<ClCompile>
<TreatWarningAsError>false</TreatWarningAsError>
<AdditionalOptions>-Wno-c++98-compat -Wno-c++98-compat-pedantic -Wno-reserved-id-macro -Wno-pragma-pack -Wno-unknown-pragmas -Wno-unused-command-line-argument -Wno-overloaded-virtual %(AdditionalOptions)</AdditionalOptions>
<AdditionalOptions>-Wextra -Wimplicit-fallthrough -Wformat=2 -Wno-c++98-compat -Wno-c++98-compat-pedantic -Wno-reserved-id-macro -Wno-pragma-pack -Wno-unknown-pragmas -Wno-unused-command-line-argument -Wno-overloaded-virtual %(AdditionalOptions)</AdditionalOptions>
</ClCompile>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)'=='Debug'">
@ -66,7 +66,6 @@
<PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<BasicRuntimeChecks>UninitializedLocalUsageCheck</BasicRuntimeChecks>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
<AdditionalOptions>/Zc:strictStrings %(AdditionalOptions)</AdditionalOptions>
</ClCompile>
<Link>
<FixedBaseAddress>false</FixedBaseAddress>
@ -77,7 +76,7 @@
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<AdditionalOptions>/Zc:strictStrings /analyze:WX- %(AdditionalOptions)</AdditionalOptions>
<AdditionalOptions>/analyze:WX- %(AdditionalOptions)</AdditionalOptions>
<EnablePREfast>true</EnablePREfast>
</ClCompile>
</ItemDefinitionGroup>
@ -90,7 +89,7 @@
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<AdditionalOptions>/Zc:strictStrings /Gw %(AdditionalOptions)</AdditionalOptions>
<AdditionalOptions>/Gw /GA %(AdditionalOptions)</AdditionalOptions>
<WholeProgramOptimization>true</WholeProgramOptimization>
</ClCompile>
<Link>