diff --git a/PowerEditor/src/Notepad_plus.rc b/PowerEditor/src/Notepad_plus.rc index c4bc1feae..4c40a278f 100644 --- a/PowerEditor/src/Notepad_plus.rc +++ b/PowerEditor/src/Notepad_plus.rc @@ -1321,22 +1321,22 @@ BEGIN PUSHBUTTON "&No",IDNO,167,75,50,14,BS_FLAT END -IDD_GOLINE DIALOGEX 26, 41, 261, 88 +IDD_GOLINE DIALOGEX 0, 0, 258, 75 STYLE DS_SETFONT | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU EXSTYLE WS_EX_DLGMODALFRAME | WS_EX_WINDOWEDGE CAPTION "Go To..." FONT 8, TEXT("MS Shell Dlg"), 0, 0, 0x0 BEGIN - CONTROL "&Line",IDC_RADIO_GOTOLINE,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,5,9,80,10 - CONTROL "&Offset",IDC_RADIO_GOTOOFFSET,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,98,9,80,10 - LTEXT "You are here :",ID_URHERE_STATIC,5,34,95,8,NOT WS_GROUP - LTEXT "0123456789",ID_CURRLINE,100,34,45,8,NOT WS_GROUP - LTEXT "You want to &go to :",ID_UGO_STATIC,5,51,95,8 - EDITTEXT ID_GOLINE_EDIT,98,49,71,12,ES_NUMBER - LTEXT "You can't go further than :",ID_NOMORETHAN_STATIC,5,68,92,8,NOT WS_GROUP - LTEXT "0123456789",ID_LASTLINE,100,68,45,8,NOT WS_GROUP - DEFPUSHBUTTON "Go",IDOK,181,48,70,14,BS_NOTIFY - PUSHBUTTON "I'm going nowhere",IDCANCEL,181,66,70,14,BS_NOTIFY + CONTROL "&Line",IDC_RADIO_GOTOLINE,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,8,5,80,10 + CONTROL "&Offset",IDC_RADIO_GOTOOFFSET,"Button",BS_AUTORADIOBUTTON,98,5,80,10 + LTEXT "You are here:",ID_URHERE_STATIC,8,25,95,8 + LTEXT "0123456789",ID_CURRLINE,106,25,45,8 + LTEXT "You want to &go to:",ID_UGO_STATIC,8,40,95,8 + EDITTEXT ID_GOLINE_EDIT,104,38,71,12,ES_NUMBER + LTEXT "You can't go further than:",ID_NOMORETHAN_STATIC,8,55,95,8 + LTEXT "0123456789",ID_LASTLINE,106,55,45,8 + DEFPUSHBUTTON "Go",IDOK,181,37,70,14 + PUSHBUTTON "I'm going nowhere",IDCANCEL,181,55,70,14 END IDD_BUTTON_DLG DIALOGEX 0, 0, 12, 10 diff --git a/PowerEditor/src/ScintillaComponent/GoToLineDlg.cpp b/PowerEditor/src/ScintillaComponent/GoToLineDlg.cpp index a20f3871e..54e1f6f9d 100644 --- a/PowerEditor/src/ScintillaComponent/GoToLineDlg.cpp +++ b/PowerEditor/src/ScintillaComponent/GoToLineDlg.cpp @@ -26,28 +26,20 @@ intptr_t CALLBACK GoToLineDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM) { NppDarkMode::autoSubclassAndThemeChildControls(_hSelf); - ::SendDlgItemMessage(_hSelf, IDC_RADIO_GOTOLINE, BM_SETCHECK, TRUE, 0); - goToCenter(); + setChecked(IDC_RADIO_GOTOLINE); + goToCenter(SWP_SHOWWINDOW | SWP_NOSIZE); return TRUE; } case WM_CTLCOLOREDIT: { - if (NppDarkMode::isEnabled()) - { - return NppDarkMode::onCtlColorSofter(reinterpret_cast(wParam)); - } - break; + return NppDarkMode::onCtlColorSofter(reinterpret_cast(wParam)); } case WM_CTLCOLORDLG: case WM_CTLCOLORSTATIC: { - if (NppDarkMode::isEnabled()) - { - return NppDarkMode::onCtlColorDarker(reinterpret_cast(wParam)); - } - break; + return NppDarkMode::onCtlColorDarker(reinterpret_cast(wParam)); } case WM_PRINTCLIENT: @@ -63,7 +55,7 @@ intptr_t CALLBACK GoToLineDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM) { if (NppDarkMode::isEnabled()) { - RECT rc = {}; + RECT rc{}; getClientRect(rc); ::FillRect(reinterpret_cast(wParam), &rc, NppDarkMode::getDarkerBackgroundBrush()); return TRUE; @@ -77,13 +69,12 @@ intptr_t CALLBACK GoToLineDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM) return TRUE; } - case WM_COMMAND : + case WM_COMMAND: { switch (wParam) { case IDCANCEL : // Close display(false); - cleanLineEdit(); return TRUE; case IDOK : @@ -92,7 +83,6 @@ intptr_t CALLBACK GoToLineDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM) if (line != -1) { display(false); - cleanLineEdit(); if (_mode == go2line) { (*_ppEditView)->execute(SCI_ENSUREVISIBLE, static_cast(line - 1)); @@ -114,7 +104,7 @@ intptr_t CALLBACK GoToLineDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM) } } - SCNotification notification = {}; + SCNotification notification{}; notification.nmhdr.code = SCN_PAINTED; notification.nmhdr.hwndFrom = _hSelf; notification.nmhdr.idFrom = ::GetDlgCtrlID(_hSelf); @@ -124,40 +114,24 @@ intptr_t CALLBACK GoToLineDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM) return TRUE; } - case IDC_RADIO_GOTOLINE : - case IDC_RADIO_GOTOOFFSET : + case IDC_RADIO_GOTOLINE: + case IDC_RADIO_GOTOOFFSET: { - - bool isLine, isOffset; if (wParam == IDC_RADIO_GOTOLINE) { - isLine = true; - isOffset = false; _mode = go2line; } else { - isLine = false; - isOffset = true; _mode = go2offsset; } - ::SendDlgItemMessage(_hSelf, IDC_RADIO_GOTOLINE, BM_SETCHECK, isLine, 0); - ::SendDlgItemMessage(_hSelf, IDC_RADIO_GOTOOFFSET, BM_SETCHECK, isOffset, 0); + updateLinesNumbers(); return TRUE; } - default : + default: { - switch (HIWORD(wParam)) - { - case EN_SETFOCUS : - case BN_SETFOCUS : - updateLinesNumbers(); - return TRUE; - default : - return TRUE; - } break; } } @@ -185,8 +159,7 @@ void GoToLineDlg::updateLinesNumbers() const size_t currentDocLength = (*_ppEditView)->getCurrentDocLen(); limit = (currentDocLength > 0 ? currentDocLength - 1 : 0); } - - + ::SetDlgItemTextA(_hSelf, ID_CURRLINE, std::to_string(current).c_str()); ::SetDlgItemTextA(_hSelf, ID_LASTLINE, std::to_string(limit).c_str()); } diff --git a/PowerEditor/src/ScintillaComponent/GoToLineDlg.h b/PowerEditor/src/ScintillaComponent/GoToLineDlg.h index 1d6847a79..b6599c06e 100644 --- a/PowerEditor/src/ScintillaComponent/GoToLineDlg.h +++ b/PowerEditor/src/ScintillaComponent/GoToLineDlg.h @@ -31,45 +31,43 @@ 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_GOLINE, isRTL); display(); }; - virtual void display(bool toShow = true) const { - Window::display(toShow); - if (toShow) - ::SetFocus(::GetDlgItem(_hSelf, ID_GOLINE_EDIT)); - }; - - void updateLinesNumbers() const; + void display(bool toShow = true) const override { + Window::display(toShow); + if (toShow) + { + updateLinesNumbers(); + ::SetFocus(::GetDlgItem(_hSelf, ID_GOLINE_EDIT)); + } + else + { + // clean Line Edit + ::SetDlgItemText(_hSelf, ID_GOLINE_EDIT, TEXT("")); + } + }; + + void updateLinesNumbers() const; protected : enum mode {go2line, go2offsset}; mode _mode = go2line; - 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; + ScintillaEditView **_ppEditView = nullptr; - void cleanLineEdit() const { - ::SetDlgItemText(_hSelf, ID_GOLINE_EDIT, TEXT("")); - }; - - long long getLine() const { - const int maxLen = 256; + long long getLine() const { + constexpr int maxLen = 256; char goLineEditStr[maxLen] = {'\0'}; UINT count = ::GetDlgItemTextA(_hSelf, ID_GOLINE_EDIT, goLineEditStr, maxLen); if (!count) return -1; - char* p_end; + char* p_end = nullptr; return strtoll(goLineEditStr, &p_end, 10); - }; - + }; }; -