mirror of
https://github.com/notepad-plus-plus/notepad-plus-plus.git
synced 2025-07-21 12:54:42 +02:00
GUI Enhancement: Go to Line dialog
- optimize dark mode - simplify code - fix override warnings Fix #13665, close #13666
This commit is contained in:
parent
a1d7db8049
commit
779db128ac
@ -1321,22 +1321,22 @@ BEGIN
|
|||||||
PUSHBUTTON "&No",IDNO,167,75,50,14,BS_FLAT
|
PUSHBUTTON "&No",IDNO,167,75,50,14,BS_FLAT
|
||||||
END
|
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
|
STYLE DS_SETFONT | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU
|
||||||
EXSTYLE WS_EX_DLGMODALFRAME | WS_EX_WINDOWEDGE
|
EXSTYLE WS_EX_DLGMODALFRAME | WS_EX_WINDOWEDGE
|
||||||
CAPTION "Go To..."
|
CAPTION "Go To..."
|
||||||
FONT 8, TEXT("MS Shell Dlg"), 0, 0, 0x0
|
FONT 8, TEXT("MS Shell Dlg"), 0, 0, 0x0
|
||||||
BEGIN
|
BEGIN
|
||||||
CONTROL "&Line",IDC_RADIO_GOTOLINE,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,5,9,80,10
|
CONTROL "&Line",IDC_RADIO_GOTOLINE,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,8,5,80,10
|
||||||
CONTROL "&Offset",IDC_RADIO_GOTOOFFSET,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,98,9,80,10
|
CONTROL "&Offset",IDC_RADIO_GOTOOFFSET,"Button",BS_AUTORADIOBUTTON,98,5,80,10
|
||||||
LTEXT "You are here :",ID_URHERE_STATIC,5,34,95,8,NOT WS_GROUP
|
LTEXT "You are here:",ID_URHERE_STATIC,8,25,95,8
|
||||||
LTEXT "0123456789",ID_CURRLINE,100,34,45,8,NOT WS_GROUP
|
LTEXT "0123456789",ID_CURRLINE,106,25,45,8
|
||||||
LTEXT "You want to &go to :",ID_UGO_STATIC,5,51,95,8
|
LTEXT "You want to &go to:",ID_UGO_STATIC,8,40,95,8
|
||||||
EDITTEXT ID_GOLINE_EDIT,98,49,71,12,ES_NUMBER
|
EDITTEXT ID_GOLINE_EDIT,104,38,71,12,ES_NUMBER
|
||||||
LTEXT "You can't go further than :",ID_NOMORETHAN_STATIC,5,68,92,8,NOT WS_GROUP
|
LTEXT "You can't go further than:",ID_NOMORETHAN_STATIC,8,55,95,8
|
||||||
LTEXT "0123456789",ID_LASTLINE,100,68,45,8,NOT WS_GROUP
|
LTEXT "0123456789",ID_LASTLINE,106,55,45,8
|
||||||
DEFPUSHBUTTON "Go",IDOK,181,48,70,14,BS_NOTIFY
|
DEFPUSHBUTTON "Go",IDOK,181,37,70,14
|
||||||
PUSHBUTTON "I'm going nowhere",IDCANCEL,181,66,70,14,BS_NOTIFY
|
PUSHBUTTON "I'm going nowhere",IDCANCEL,181,55,70,14
|
||||||
END
|
END
|
||||||
|
|
||||||
IDD_BUTTON_DLG DIALOGEX 0, 0, 12, 10
|
IDD_BUTTON_DLG DIALOGEX 0, 0, 12, 10
|
||||||
|
@ -26,29 +26,21 @@ intptr_t CALLBACK GoToLineDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM)
|
|||||||
{
|
{
|
||||||
NppDarkMode::autoSubclassAndThemeChildControls(_hSelf);
|
NppDarkMode::autoSubclassAndThemeChildControls(_hSelf);
|
||||||
|
|
||||||
::SendDlgItemMessage(_hSelf, IDC_RADIO_GOTOLINE, BM_SETCHECK, TRUE, 0);
|
setChecked(IDC_RADIO_GOTOLINE);
|
||||||
goToCenter();
|
goToCenter(SWP_SHOWWINDOW | SWP_NOSIZE);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
case WM_CTLCOLOREDIT:
|
case WM_CTLCOLOREDIT:
|
||||||
{
|
|
||||||
if (NppDarkMode::isEnabled())
|
|
||||||
{
|
{
|
||||||
return NppDarkMode::onCtlColorSofter(reinterpret_cast<HDC>(wParam));
|
return NppDarkMode::onCtlColorSofter(reinterpret_cast<HDC>(wParam));
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case WM_CTLCOLORDLG:
|
case WM_CTLCOLORDLG:
|
||||||
case WM_CTLCOLORSTATIC:
|
case WM_CTLCOLORSTATIC:
|
||||||
{
|
|
||||||
if (NppDarkMode::isEnabled())
|
|
||||||
{
|
{
|
||||||
return NppDarkMode::onCtlColorDarker(reinterpret_cast<HDC>(wParam));
|
return NppDarkMode::onCtlColorDarker(reinterpret_cast<HDC>(wParam));
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case WM_PRINTCLIENT:
|
case WM_PRINTCLIENT:
|
||||||
{
|
{
|
||||||
@ -63,7 +55,7 @@ intptr_t CALLBACK GoToLineDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM)
|
|||||||
{
|
{
|
||||||
if (NppDarkMode::isEnabled())
|
if (NppDarkMode::isEnabled())
|
||||||
{
|
{
|
||||||
RECT rc = {};
|
RECT rc{};
|
||||||
getClientRect(rc);
|
getClientRect(rc);
|
||||||
::FillRect(reinterpret_cast<HDC>(wParam), &rc, NppDarkMode::getDarkerBackgroundBrush());
|
::FillRect(reinterpret_cast<HDC>(wParam), &rc, NppDarkMode::getDarkerBackgroundBrush());
|
||||||
return TRUE;
|
return TRUE;
|
||||||
@ -77,13 +69,12 @@ intptr_t CALLBACK GoToLineDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM)
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
case WM_COMMAND :
|
case WM_COMMAND:
|
||||||
{
|
{
|
||||||
switch (wParam)
|
switch (wParam)
|
||||||
{
|
{
|
||||||
case IDCANCEL : // Close
|
case IDCANCEL : // Close
|
||||||
display(false);
|
display(false);
|
||||||
cleanLineEdit();
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
||||||
case IDOK :
|
case IDOK :
|
||||||
@ -92,7 +83,6 @@ intptr_t CALLBACK GoToLineDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM)
|
|||||||
if (line != -1)
|
if (line != -1)
|
||||||
{
|
{
|
||||||
display(false);
|
display(false);
|
||||||
cleanLineEdit();
|
|
||||||
if (_mode == go2line)
|
if (_mode == go2line)
|
||||||
{
|
{
|
||||||
(*_ppEditView)->execute(SCI_ENSUREVISIBLE, static_cast<WPARAM>(line - 1));
|
(*_ppEditView)->execute(SCI_ENSUREVISIBLE, static_cast<WPARAM>(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.code = SCN_PAINTED;
|
||||||
notification.nmhdr.hwndFrom = _hSelf;
|
notification.nmhdr.hwndFrom = _hSelf;
|
||||||
notification.nmhdr.idFrom = ::GetDlgCtrlID(_hSelf);
|
notification.nmhdr.idFrom = ::GetDlgCtrlID(_hSelf);
|
||||||
@ -124,40 +114,24 @@ intptr_t CALLBACK GoToLineDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM)
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
case IDC_RADIO_GOTOLINE :
|
case IDC_RADIO_GOTOLINE:
|
||||||
case IDC_RADIO_GOTOOFFSET :
|
case IDC_RADIO_GOTOOFFSET:
|
||||||
{
|
{
|
||||||
|
|
||||||
bool isLine, isOffset;
|
|
||||||
if (wParam == IDC_RADIO_GOTOLINE)
|
if (wParam == IDC_RADIO_GOTOLINE)
|
||||||
{
|
{
|
||||||
isLine = true;
|
|
||||||
isOffset = false;
|
|
||||||
_mode = go2line;
|
_mode = go2line;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
isLine = false;
|
|
||||||
isOffset = true;
|
|
||||||
_mode = go2offsset;
|
_mode = go2offsset;
|
||||||
}
|
}
|
||||||
::SendDlgItemMessage(_hSelf, IDC_RADIO_GOTOLINE, BM_SETCHECK, isLine, 0);
|
|
||||||
::SendDlgItemMessage(_hSelf, IDC_RADIO_GOTOOFFSET, BM_SETCHECK, isOffset, 0);
|
|
||||||
updateLinesNumbers();
|
updateLinesNumbers();
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
default :
|
default:
|
||||||
{
|
{
|
||||||
switch (HIWORD(wParam))
|
|
||||||
{
|
|
||||||
case EN_SETFOCUS :
|
|
||||||
case BN_SETFOCUS :
|
|
||||||
updateLinesNumbers();
|
|
||||||
return TRUE;
|
|
||||||
default :
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -186,7 +160,6 @@ void GoToLineDlg::updateLinesNumbers() const
|
|||||||
limit = (currentDocLength > 0 ? currentDocLength - 1 : 0);
|
limit = (currentDocLength > 0 ? currentDocLength - 1 : 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
::SetDlgItemTextA(_hSelf, ID_CURRLINE, std::to_string(current).c_str());
|
::SetDlgItemTextA(_hSelf, ID_CURRLINE, std::to_string(current).c_str());
|
||||||
::SetDlgItemTextA(_hSelf, ID_LASTLINE, std::to_string(limit).c_str());
|
::SetDlgItemTextA(_hSelf, ID_LASTLINE, std::to_string(limit).c_str());
|
||||||
}
|
}
|
||||||
|
@ -31,20 +31,24 @@ public :
|
|||||||
_ppEditView = ppEditView;
|
_ppEditView = ppEditView;
|
||||||
};
|
};
|
||||||
|
|
||||||
virtual void create(int dialogID, bool isRTL = false, bool msgDestParent = true) {
|
|
||||||
StaticDialog::create(dialogID, isRTL, msgDestParent);
|
|
||||||
};
|
|
||||||
|
|
||||||
void doDialog(bool isRTL = false) {
|
void doDialog(bool isRTL = false) {
|
||||||
if (!isCreated())
|
if (!isCreated())
|
||||||
create(IDD_GOLINE, isRTL);
|
create(IDD_GOLINE, isRTL);
|
||||||
display();
|
display();
|
||||||
};
|
};
|
||||||
|
|
||||||
virtual void display(bool toShow = true) const {
|
void display(bool toShow = true) const override {
|
||||||
Window::display(toShow);
|
Window::display(toShow);
|
||||||
if (toShow)
|
if (toShow)
|
||||||
|
{
|
||||||
|
updateLinesNumbers();
|
||||||
::SetFocus(::GetDlgItem(_hSelf, ID_GOLINE_EDIT));
|
::SetFocus(::GetDlgItem(_hSelf, ID_GOLINE_EDIT));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// clean Line Edit
|
||||||
|
::SetDlgItemText(_hSelf, ID_GOLINE_EDIT, TEXT(""));
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
void updateLinesNumbers() const;
|
void updateLinesNumbers() const;
|
||||||
@ -52,24 +56,18 @@ public :
|
|||||||
protected :
|
protected :
|
||||||
enum mode {go2line, go2offsset};
|
enum mode {go2line, go2offsset};
|
||||||
mode _mode = go2line;
|
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 :
|
private :
|
||||||
ScintillaEditView **_ppEditView = nullptr;
|
ScintillaEditView **_ppEditView = nullptr;
|
||||||
|
|
||||||
void cleanLineEdit() const {
|
|
||||||
::SetDlgItemText(_hSelf, ID_GOLINE_EDIT, TEXT(""));
|
|
||||||
};
|
|
||||||
|
|
||||||
long long getLine() const {
|
long long getLine() const {
|
||||||
const int maxLen = 256;
|
constexpr int maxLen = 256;
|
||||||
char goLineEditStr[maxLen] = {'\0'};
|
char goLineEditStr[maxLen] = {'\0'};
|
||||||
UINT count = ::GetDlgItemTextA(_hSelf, ID_GOLINE_EDIT, goLineEditStr, maxLen);
|
UINT count = ::GetDlgItemTextA(_hSelf, ID_GOLINE_EDIT, goLineEditStr, maxLen);
|
||||||
if (!count)
|
if (!count)
|
||||||
return -1;
|
return -1;
|
||||||
char* p_end;
|
char* p_end = nullptr;
|
||||||
return strtoll(goLineEditStr, &p_end, 10);
|
return strtoll(goLineEditStr, &p_end, 10);
|
||||||
};
|
};
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user