Replace recent file ValueDlg with edit fields & fix DocSwitcher RTL problem

Remove ValueDlg class.

Fix #13244, fix #13248, close #13245
This commit is contained in:
ozone10 2023-02-26 10:27:06 +01:00 committed by Don Ho
parent 21a78ed035
commit 269e78bc1e
15 changed files with 224 additions and 325 deletions

View File

@ -1109,7 +1109,7 @@ You can define several column markers by using white space to separate the diffe
<RecentFilesHistory title="Recent Files History">
<Item id="6304" name="Recent Files History"/>
<Item id="6306" name="Max. number of entries :"/>
<Item id="6306" name="Max. number of entries:"/>
<Item id="6305" name="Don't check at launch time"/>
<Item id="6429" name="Display"/>
<Item id="6424" name="In Submenu"/>
@ -1611,12 +1611,9 @@ Find in all files but exclude all folders log or logs recursively:
<tabrename-newname value="New Name: "/>
<splitter-rotate-left value="Rotate to left"/>
<splitter-rotate-right value="Rotate to right"/>
<recent-file-history-maxfile value="Max File: "/>
<recent-file-history-customlength value="Length: "/>
<userdefined-title-new value="Create New Language..."/>
<userdefined-title-save value="Save Current Language Name As..."/>
<userdefined-title-rename value="Rename Current Language Name"/>
<edit-verticaledge-nb-col value="Nb of Column:"/>
<summary value="Summary"/>
<summary-filepath value="Full file path: "/>
<summary-filecreatetime value="Created: "/>

View File

@ -1109,7 +1109,7 @@ You can define several column markers by using white space to separate the diffe
<RecentFilesHistory title="Recent Files History">
<Item id="6304" name="Recent Files History"/>
<Item id="6306" name="Max. number of entries :"/>
<Item id="6306" name="Max. number of entries:"/>
<Item id="6305" name="Don't check at launch time"/>
<Item id="6429" name="Display"/>
<Item id="6424" name="In Submenu"/>
@ -1611,12 +1611,9 @@ Find in all files but exclude all folders log or logs recursively:
<tabrename-newname value="New Name: "/>
<splitter-rotate-left value="Rotate to left"/>
<splitter-rotate-right value="Rotate to right"/>
<recent-file-history-maxfile value="Max File: "/>
<recent-file-history-customlength value="Length: "/>
<userdefined-title-new value="Create New Language..."/>
<userdefined-title-save value="Save Current Language Name As..."/>
<userdefined-title-rename value="Rename Current Language Name"/>
<edit-verticaledge-nb-col value="Nb of Column:"/>
<summary value="Summary"/>
<summary-filepath value="Full file path: "/>
<summary-filecreatetime value="Created: "/>

View File

@ -1329,15 +1329,6 @@ BEGIN
PUSHBUTTON "I'm going nowhere",IDCANCEL,181,66,70,14,BS_NOTIFY
END
IDD_VALUE_DLG DIALOGEX 0, 0, 74, 17
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU
EXSTYLE WS_EX_DLGMODALFRAME | WS_EX_WINDOWEDGE
FONT 8, TEXT("MS Shell Dlg"), 0, 0, 0x1
BEGIN
LTEXT "STATIC :",IDC_VALUE_STATIC,6,4,45,8
EDITTEXT IDC_VALUE_EDIT,49,3,18,11,ES_NUMBER
END
IDD_BUTTON_DLG DIALOGEX 0, 0, 12, 10
STYLE DS_SETFONT | DS_FIXEDSYS | WS_POPUP
FONT 8, "MS Shell Dlg", 0, 0, 0x1

View File

@ -3614,7 +3614,7 @@ void Notepad_plus::command(int id)
hImgLst = _docTabIconList.getHandle();
}
tld.init(_pPublicInterface->getHinst(), _pPublicInterface->getHSelf(), hImgLst, direction);
tld.doDialog();
tld.doDialog(_nativeLangSpeaker.isRTL());
}
}
}

View File

@ -2412,16 +2412,16 @@ void NppParameters::feedFileListParameters(TiXmlNode *node)
if (!historyRoot) return;
// nbMaxFile value
int nbMaxFile;
int nbMaxFile = _nbMaxRecentFile;
const TCHAR *strVal = (historyRoot->ToElement())->Attribute(TEXT("nbMaxFile"), &nbMaxFile);
if (strVal && (nbMaxFile >= 0) && (nbMaxFile <= 50))
if (strVal && (nbMaxFile >= 0) && (nbMaxFile <= NB_MAX_LRF_FILE))
_nbMaxRecentFile = nbMaxFile;
// customLen value
int customLen;
int customLen = RECENTFILES_SHOWFULLPATH;
strVal = (historyRoot->ToElement())->Attribute(TEXT("customLength"), &customLen);
if (strVal)
_recentFileCustomLength = customLen;
_recentFileCustomLength = std::min<int>(customLen, NB_MAX_LRF_CUSTOMLENGTH);
// inSubMenu value
strVal = (historyRoot->ToElement())->Attribute(TEXT("inSubMenu"));

View File

@ -983,6 +983,9 @@ const int NB_MAX_USER_LANG = 30;
const int NB_MAX_EXTERNAL_LANG = 30;
const int NB_MAX_IMPORTED_UDL = 50;
constexpr int NB_DEFAULT_LRF_CUSTOMLENGTH = 100;
constexpr int NB_MAX_LRF_CUSTOMLENGTH = MAX_PATH - 1;
const int NB_MAX_FINDHISTORY_FIND = 30;
const int NB_MAX_FINDHISTORY_REPLACE = 30;
const int NB_MAX_FINDHISTORY_PATH = 30;
@ -1460,11 +1463,11 @@ public:
return _LRFileList[index];
};
void setNbMaxRecentFile(int nb) {
void setNbMaxRecentFile(UINT nb) {
_nbMaxRecentFile = nb;
};
int getNbMaxRecentFile() const {return _nbMaxRecentFile;};
UINT getNbMaxRecentFile() const {return _nbMaxRecentFile;};
void setPutRecentFileInSubMenu(bool doSubmenu) {
_putRecentFileInSubMenu = doSubmenu;
@ -1817,7 +1820,7 @@ private:
// Recent File History
generic_string* _LRFileList[NB_MAX_LRF_FILE] = { nullptr };
int _nbRecentFile = 0;
int _nbMaxRecentFile = 10;
UINT _nbMaxRecentFile = 10;
bool _putRecentFileInSubMenu = false;
int _recentFileCustomLength = RECENTFILES_SHOWFULLPATH; // <0: Full File Path Name
// =0: Only File Name

View File

@ -224,16 +224,19 @@ IDD_PREFERENCE_SUB_RECENTFILESHISTORY DIALOGEX 115, 10, 460, 205
STYLE DS_SETFONT | DS_FIXEDSYS | DS_CONTROL | WS_CHILD
FONT 8, "MS Shell Dlg", 0, 0, 0x1
BEGIN
GROUPBOX "Recent Files History",IDC_HISTORY_GB_STATIC,104,25,260,126,BS_CENTER
RTEXT "Max. number of entries :",IDC_MAXNBFILE_STATIC,108,52,112,8
LTEXT "0",IDC_MAXNBFILEVAL_STATIC,229,52,15,8,WS_TABSTOP
CONTROL "Don't check at launch time",IDC_CHECK_DONTCHECKHISTORY,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,121,39,140,10
GROUPBOX "Display",IDC_DISPLAY_STATIC,121,65,225,73,BS_CENTER
CONTROL "In Submenu",IDC_CHECK_INSUBMENU,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,132,76,79,10
CONTROL "Only File Name",IDC_RADIO_ONLYFILENAME,"Button",BS_AUTORADIOBUTTON | WS_GROUP,133,92,170,10
CONTROL "Full File Name Path",IDC_RADIO_FULLFILENAMEPATH,"Button",BS_AUTORADIOBUTTON,133,106,170,10
CONTROL "Customize Maximum Length:",IDC_RADIO_CUSTOMIZELENTH,"Button",BS_AUTORADIOBUTTON,133,120,120,10
LTEXT "0",IDC_CUSTOMIZELENGTHVAL_STATIC,255,120,18,8,WS_TABSTOP
GROUPBOX "Recent Files History",IDC_HISTORY_GB_STATIC,94,25,270,125,BS_CENTER
CONTROL "Don't check at launch time",IDC_CHECK_DONTCHECKHISTORY,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,100,38,140,10
RTEXT "Max. number of entries:",IDC_MAXNBFILE_STATIC,98,52,112,8
EDITTEXT IDC_EDIT_MAXNBFILEVAL,214,51,14,12,ES_CENTER | ES_NUMBER | WS_TABSTOP
LTEXT "(0 30)",IDC_MAXNBFILE_RANGE_STATIC,234,52,90,8
GROUPBOX "Display",IDC_DISPLAY_STATIC,100,70,258,74,BS_CENTER
CONTROL "In Submenu",IDC_CHECK_INSUBMENU,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,106,83,79,10
CONTROL "Only File Name",IDC_RADIO_ONLYFILENAME,"Button",BS_AUTORADIOBUTTON | WS_GROUP | WS_TABSTOP,106,98,170,10
CONTROL "Full File Name Path",IDC_RADIO_FULLFILENAMEPATH,"Button",BS_AUTORADIOBUTTON,106,113,170,10
CONTROL "Customize Maximum Length:",IDC_RADIO_CUSTOMIZELENTH,"Button",BS_AUTORADIOBUTTON,106,128,120,10
EDITTEXT IDC_EDIT_CUSTOMIZELENGTHVAL,230,127,20,12,ES_CENTER | ES_NUMBER | WS_TABSTOP
LTEXT "(1 259)",IDC_CUSTOMIZELENGTH_RANGE_STATIC,256,129,95,8
END

View File

@ -2263,14 +2263,6 @@ intptr_t CALLBACK MiscSubDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM)
return FALSE;
}
void RecentFilesHistorySubDlg::setCustomLen(int val)
{
::EnableWindow(::GetDlgItem(_hSelf, IDC_CUSTOMIZELENGTHVAL_STATIC), val > 0);
::SetDlgItemInt(_hSelf, IDC_CUSTOMIZELENGTHVAL_STATIC, val, FALSE);
::ShowWindow(::GetDlgItem(_hSelf, IDC_CUSTOMIZELENGTHVAL_STATIC), val > 0?SW_SHOW:SW_HIDE);
}
intptr_t CALLBACK NewDocumentSubDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM)
{
NppParameters& nppParam = NppParameters::getInstance();
@ -2630,20 +2622,23 @@ intptr_t CALLBACK DefaultDirectorySubDlg::run_dlgProc(UINT message, WPARAM wPara
return FALSE;
}
intptr_t CALLBACK RecentFilesHistorySubDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM)
void RecentFilesHistorySubDlg::setCustomLen(int val)
{
::SetDlgItemInt(_hSelf, IDC_EDIT_CUSTOMIZELENGTHVAL, val, FALSE);
::EnableWindow(::GetDlgItem(_hSelf, IDC_EDIT_CUSTOMIZELENGTHVAL), val > 0);
}
intptr_t CALLBACK RecentFilesHistorySubDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam)
{
NppParameters& nppParam = NppParameters::getInstance();
NppGUI & nppGUI = (NppGUI & )nppParam.getNppGUI();
NativeLangSpeaker *pNativeSpeaker = nppParam.getNativeLangSpeaker();
NppGUI& nppGUI = nppParam.getNppGUI();
switch (message)
{
case WM_INITDIALOG :
case WM_INITDIALOG:
{
// Max number recent file setting
::SetDlgItemInt(_hSelf, IDC_MAXNBFILEVAL_STATIC, nppParam.getNbMaxRecentFile(), FALSE);
_nbHistoryVal.init(_hInst, _hSelf);
_nbHistoryVal.create(::GetDlgItem(_hSelf, IDC_MAXNBFILEVAL_STATIC), IDC_MAXNBFILEVAL_STATIC);
::SetDlgItemInt(_hSelf, IDC_EDIT_MAXNBFILEVAL, nppParam.getNbMaxRecentFile(), FALSE);
// Check on launch time settings
::SendDlgItemMessage(_hSelf, IDC_CHECK_DONTCHECKHISTORY, BM_SETCHECK, !nppGUI._checkHistoryFiles, 0);
@ -2666,25 +2661,40 @@ intptr_t CALLBACK RecentFilesHistorySubDlg::run_dlgProc(UINT message, WPARAM wPa
id = IDC_RADIO_FULLFILENAMEPATH;
length = 0;
}
::SendDlgItemMessage(_hSelf, id, BM_SETCHECK, BST_CHECKED, 0);
::EnableWindow(::GetDlgItem(_hSelf, IDC_CUSTOMIZELENGTHVAL_STATIC), id == IDC_RADIO_CUSTOMIZELENTH);
::ShowWindow(::GetDlgItem(_hSelf, IDC_CUSTOMIZELENGTHVAL_STATIC), id == IDC_RADIO_CUSTOMIZELENTH?SW_SHOW:SW_HIDE);
::SetDlgItemInt(_hSelf, IDC_CUSTOMIZELENGTHVAL_STATIC, length, FALSE);
_customLenVal.init(_hInst, _hSelf);
_customLenVal.create(::GetDlgItem(_hSelf, IDC_CUSTOMIZELENGTHVAL_STATIC), nullptr);
setChecked(id);
setCustomLen(length);
return TRUE;
}
case WM_CTLCOLOREDIT:
{
return NppDarkMode::onCtlColorSofter(reinterpret_cast<HDC>(wParam));
}
case WM_CTLCOLORDLG:
{
return NppDarkMode::onCtlColorDarker(reinterpret_cast<HDC>(wParam));
}
case WM_CTLCOLORSTATIC:
{
if (NppDarkMode::isEnabled())
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_CUSTOMIZELENGTH_RANGE_STATIC)
{
return NppDarkMode::onCtlColorDarker(reinterpret_cast<HDC>(wParam));
const bool isTextEnabled = isCheckedOrNot(IDC_RADIO_CUSTOMIZELENTH);
return NppDarkMode::onCtlColorDarkerBGStaticText(hdcStatic, isTextEnabled);
}
break;
if (dlgCtrlID == IDC_EDIT_CUSTOMIZELENGTHVAL)
{
return NppDarkMode::onCtlColor(hdcStatic);
}
return NppDarkMode::onCtlColorDarker(hdcStatic);
}
case WM_PRINTCLIENT:
@ -2696,84 +2706,170 @@ intptr_t CALLBACK RecentFilesHistorySubDlg::run_dlgProc(UINT message, WPARAM wPa
break;
}
case WM_COMMAND :
case WM_COMMAND:
{
switch (LOWORD(wParam))
{
case IDC_EDIT_MAXNBFILEVAL:
{
switch (HIWORD(wParam))
{
case EN_KILLFOCUS:
{
constexpr int stringSize = 3;
wchar_t str[stringSize]{};
::GetDlgItemText(_hSelf, IDC_EDIT_MAXNBFILEVAL, str, stringSize);
if (lstrcmp(str, L"") == 0)
{
::SetDlgItemInt(_hSelf, IDC_EDIT_MAXNBFILEVAL, nppParam.getNbMaxRecentFile(), FALSE);
return FALSE;
}
UINT nbMaxFile = ::GetDlgItemInt(_hSelf, IDC_EDIT_MAXNBFILEVAL, nullptr, FALSE);
if (nbMaxFile == nppParam.getNbMaxRecentFile())
{
return FALSE;
}
if (nbMaxFile > NB_MAX_LRF_FILE)
{
::SetDlgItemInt(_hSelf, IDC_EDIT_MAXNBFILEVAL, NB_MAX_LRF_FILE, FALSE);
nbMaxFile = NB_MAX_LRF_FILE;
}
nppParam.setNbMaxRecentFile(nbMaxFile);
::SendMessage(::GetParent(_hParent), NPPM_INTERNAL_SETTING_HISTORY_SIZE, 0, 0);
return TRUE;
}
default:
{
break;
}
}
return FALSE;
}
case IDC_EDIT_CUSTOMIZELENGTHVAL:
{
if (!isCheckedOrNot(IDC_RADIO_CUSTOMIZELENTH))
{
return FALSE;
}
switch (HIWORD(wParam))
{
case EN_KILLFOCUS:
{
constexpr int stringSize = 4;
wchar_t str[stringSize]{};
::GetDlgItemText(_hSelf, IDC_EDIT_CUSTOMIZELENGTHVAL, str, stringSize);
if (lstrcmp(str, L"") == 0)
{
::SetDlgItemInt(_hSelf, IDC_EDIT_CUSTOMIZELENGTHVAL, nppParam.getRecentFileCustomLength(), FALSE);
return FALSE;
}
UINT size = ::GetDlgItemInt(_hSelf, IDC_EDIT_CUSTOMIZELENGTHVAL, nullptr, FALSE);
if (size == static_cast<UINT>(nppParam.getRecentFileCustomLength()))
{
return FALSE;
}
bool change = false;
if (size == 0)
{
size = NB_DEFAULT_LRF_CUSTOMLENGTH;
change = true;
}
else if (size > NB_MAX_LRF_CUSTOMLENGTH)
{
size = NB_MAX_LRF_CUSTOMLENGTH;
change = true;
}
if (change)
{
::SetDlgItemInt(_hSelf, IDC_EDIT_CUSTOMIZELENGTHVAL, size, FALSE);
}
nppParam.setRecentFileCustomLength(size);
::SendMessage(::GetParent(_hParent), NPPM_INTERNAL_RECENTFILELIST_UPDATE, 0, 0);
return TRUE;
}
default:
{
break;
}
}
return FALSE;
}
default:
{
break;
}
}
switch (wParam)
{
case IDC_CHECK_DONTCHECKHISTORY:
nppGUI._checkHistoryFiles = !isCheckedOrNot(IDC_CHECK_DONTCHECKHISTORY);
return TRUE;
case IDC_MAXNBFILEVAL_STATIC:
{
generic_string staticText = pNativeSpeaker->getLocalizedStrFromID("recent-file-history-maxfile", TEXT("Max File: "));
ValueDlg nbFileMaxDlg;
nbFileMaxDlg.init(NULL, _hSelf, nppParam.getNbMaxRecentFile(), staticText.c_str());
POINT p;
::GetCursorPos(&p);
int nbMaxFile = nbFileMaxDlg.doDialog(p);
if (nbMaxFile != -1)
{
if (nbMaxFile > NB_MAX_LRF_FILE)
nbMaxFile = NB_MAX_LRF_FILE;
nppParam.setNbMaxRecentFile(nbMaxFile);
::SetDlgItemInt(_hSelf, IDC_MAXNBFILEVAL_STATIC, nbMaxFile, FALSE);
// Validate modified value
::SendMessage(::GetParent(_hParent), NPPM_INTERNAL_SETTING_HISTORY_SIZE, 0, 0);
}
return TRUE;
}
case IDC_CHECK_INSUBMENU:
nppParam.setPutRecentFileInSubMenu(isCheckedOrNot(IDC_CHECK_INSUBMENU));
::SendMessage(::GetParent(_hParent), NPPM_INTERNAL_RECENTFILELIST_SWITCH, 0, 0);
return TRUE;
case IDC_RADIO_ONLYFILENAME:
{
setCustomLen(0);
nppParam.setRecentFileCustomLength(0);
::SendMessage(::GetParent(_hParent), NPPM_INTERNAL_RECENTFILELIST_UPDATE, 0, 0);
redrawDlgItem(IDC_CUSTOMIZELENGTH_RANGE_STATIC);
return TRUE;
}
case IDC_RADIO_FULLFILENAMEPATH:
{
setCustomLen(0);
nppParam.setRecentFileCustomLength(-1);
::SendMessage(::GetParent(_hParent), NPPM_INTERNAL_RECENTFILELIST_UPDATE, 0, 0);
redrawDlgItem(IDC_CUSTOMIZELENGTH_RANGE_STATIC);
return TRUE;
}
case IDC_RADIO_CUSTOMIZELENTH:
{
int len = nppParam.getRecentFileCustomLength();
if (len <= 0)
{
setCustomLen(100);
nppParam.setRecentFileCustomLength(100);
setCustomLen(NB_DEFAULT_LRF_CUSTOMLENGTH);
nppParam.setRecentFileCustomLength(NB_DEFAULT_LRF_CUSTOMLENGTH);
::SendMessage(::GetParent(_hParent), NPPM_INTERNAL_RECENTFILELIST_UPDATE, 0, 0);
}
redrawDlgItem(IDC_CUSTOMIZELENGTH_RANGE_STATIC);
return TRUE;
}
case IDC_CUSTOMIZELENGTHVAL_STATIC:
{
generic_string staticText = pNativeSpeaker->getLocalizedStrFromID("recent-file-history-customlength", TEXT("Length: "));
ValueDlg customLengthDlg;
customLengthDlg.init(NULL, _hSelf, nppParam.getRecentFileCustomLength(), staticText.c_str());
customLengthDlg.setNBNumber(3);
POINT p;
::GetCursorPos(&p);
int size = customLengthDlg.doDialog(p);
if (size != -1)
{
::SetDlgItemInt(_hSelf, IDC_CUSTOMIZELENGTHVAL_STATIC, size, FALSE);
nppParam.setRecentFileCustomLength(size);
::SendMessage(::GetParent(_hParent), NPPM_INTERNAL_RECENTFILELIST_UPDATE, 0, 0);
}
return TRUE;
}
default:
return FALSE;
}

View File

@ -19,7 +19,6 @@
#include "ControlsTab.h"
#include "preference_rc.h"
#include "URLCtrl.h"
#include "Parameters.h"
#include "regExtDlg.h"
#include "WordStyleDlg.h"
@ -147,15 +146,9 @@ class RecentFilesHistorySubDlg : public StaticDialog
{
public :
RecentFilesHistorySubDlg() = default;
virtual void destroy() {
_nbHistoryVal.destroy();
_customLenVal.destroy();
};
private :
URLCtrl _nbHistoryVal;
URLCtrl _customLenVal;
void setCustomLen(int val);
intptr_t CALLBACK run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam);
intptr_t CALLBACK run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam) override;
};
class LanguageSubDlg : public StaticDialog

View File

@ -211,7 +211,7 @@
#define IDC_CHECK_MIN2SYSTRAY (IDD_PREFERENCE_SUB_MISC + 8)
#define IDC_CHECK_REMEMBERSESSION (IDD_PREFERENCE_SUB_MISC + 9)
//#define IDC_TABSIZEVAL_STATIC (IDD_PREFERENCE_SUB_MISC + 10)
#define IDC_MAXNBFILEVAL_STATIC (IDD_PREFERENCE_SUB_MISC + 11)
//#define IDC_MAXNBFILEVAL_STATIC (IDD_PREFERENCE_SUB_MISC + 11)
#define IDC_FILEAUTODETECTION_STATIC (IDD_PREFERENCE_SUB_MISC + 12)
#define IDC_CHECK_UPDATESILENTLY (IDD_PREFERENCE_SUB_MISC + 13)
#define IDC_RADIO_BKNONE (IDD_PREFERENCE_SUB_MISC + 15)
@ -287,12 +287,16 @@
#define IDC_RADIO_ONLYFILENAME (IDD_PREFERENCE_SUB_NEWDOCUMENT + 25)
#define IDC_RADIO_FULLFILENAMEPATH (IDD_PREFERENCE_SUB_NEWDOCUMENT + 26)
#define IDC_RADIO_CUSTOMIZELENTH (IDD_PREFERENCE_SUB_NEWDOCUMENT + 27)
#define IDC_CUSTOMIZELENGTHVAL_STATIC (IDD_PREFERENCE_SUB_NEWDOCUMENT + 28)
//#define IDC_CUSTOMIZELENGTHVAL_STATIC (IDD_PREFERENCE_SUB_NEWDOCUMENT + 28)
#define IDC_DISPLAY_STATIC (IDD_PREFERENCE_SUB_NEWDOCUMENT + 29)
#define IDC_OPENSAVEDIR_CHECK_DRROPFOLDEROPENFILES (IDD_PREFERENCE_SUB_NEWDOCUMENT + 31)
#define IDD_PREFERENCE_SUB_DEFAULTDIRECTORY 6450 //(IDD_PREFERENCE_BOX + 400)
#define IDD_PREFERENCE_SUB_RECENTFILESHISTORY 6460 //(IDD_PREFERENCE_BOX + 400)
#define IDC_EDIT_MAXNBFILEVAL (IDD_PREFERENCE_SUB_RECENTFILESHISTORY + 1)
#define IDC_MAXNBFILE_RANGE_STATIC (IDD_PREFERENCE_SUB_RECENTFILESHISTORY + 2)
#define IDC_EDIT_CUSTOMIZELENGTHVAL (IDD_PREFERENCE_SUB_RECENTFILESHISTORY + 3)
#define IDC_CUSTOMIZELENGTH_RANGE_STATIC (IDD_PREFERENCE_SUB_RECENTFILESHISTORY + 4)
#define IDD_PREFERENCE_SUB_LANGUAGE 6500 //(IDD_PREFERENCE_BOX + 500)
#define IDC_LIST_ENABLEDLANG (IDD_PREFERENCE_SUB_LANGUAGE + 1)

View File

@ -35,7 +35,7 @@ static LRESULT CALLBACK hookProc(int nCode, WPARAM wParam, LPARAM lParam)
else if ((nCode >= 0) && (wParam == WM_MOUSEWHEEL) && windowsVersion >= WV_WIN10)
{
MSLLHOOKSTRUCT* pMD = (MSLLHOOKSTRUCT*)lParam;
RECT rCtrl;
RECT rCtrl{};
GetWindowRect(hWndServer, &rCtrl);
//to avoid duplicate messages, only send this message to the list control if it comes from outside the control window. if the message occurs whilst the mouse is inside the control, the control will have receive the mouse wheel message itself
if (false == PtInRect(&rCtrl, pMD->pt))
@ -51,8 +51,8 @@ static LRESULT CALLBACK hookProc(int nCode, WPARAM wParam, LPARAM lParam)
{
if (isRTL)
{
DLGTEMPLATE *pMyDlgTemplate = NULL;
HGLOBAL hMyDlgTemplate = makeRTLResource(IDD_VALUE_DLG, &pMyDlgTemplate);
DLGTEMPLATE *pMyDlgTemplate = nullptr;
HGLOBAL hMyDlgTemplate = makeRTLResource(IDD_TASKLIST_DLG, &pMyDlgTemplate);
int result = static_cast<int32_t>(::DialogBoxIndirectParam(_hInst, pMyDlgTemplate, _hParent, dlgProc, reinterpret_cast<LPARAM>(this)));
::GlobalFree(hMyDlgTemplate);
return result;
@ -101,11 +101,7 @@ intptr_t CALLBACK TaskListDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM l
case WM_CTLCOLORDLG:
case WM_CTLCOLORSTATIC:
{
if (NppDarkMode::isEnabled())
{
return NppDarkMode::onCtlColorDarker(reinterpret_cast<HDC>(wParam));
}
break;
return NppDarkMode::onCtlColorDarker(reinterpret_cast<HDC>(wParam));
}
case WM_PRINTCLIENT:
@ -224,7 +220,7 @@ void TaskListDlg::drawItem(LPDRAWITEMSTRUCT lpDrawItemStruct)
//
HIMAGELIST hImgLst = _taskList.getImgLst();
IMAGEINFO info;
IMAGEINFO info{};
::ImageList_GetImageInfo(hImgLst, iImage, &info);
RECT & imageRect = info.rcImage;

View File

@ -53,10 +53,10 @@ public :
_initDir = dir;
};
int doDialog(bool isRTL = false);
virtual void destroy() {};
void destroy() override {};
protected :
intptr_t CALLBACK run_dlgProc(UINT Message, WPARAM wParam, LPARAM lParam);
intptr_t CALLBACK run_dlgProc(UINT Message, WPARAM wParam, LPARAM lParam) override;
private :
TaskList _taskList;

View File

@ -20,95 +20,20 @@
#include "menuCmdID.h"
#include "NppDarkMode.h"
void ValueDlg::init(HINSTANCE hInst, HWND parent, int valueToSet, const TCHAR *text)
{
Window::init(hInst, parent);
_defaultValue = valueToSet;
_name = text;
}
int ValueDlg::doDialog(POINT p, bool isRTL)
{
_p = p;
if (isRTL)
{
DLGTEMPLATE *pMyDlgTemplate = NULL;
HGLOBAL hMyDlgTemplate = makeRTLResource(IDD_VALUE_DLG, &pMyDlgTemplate);
int result = static_cast<int32_t>(::DialogBoxIndirectParam(_hInst, pMyDlgTemplate, _hParent, dlgProc, reinterpret_cast<LPARAM>(this)));
::GlobalFree(hMyDlgTemplate);
return result;
}
return static_cast<int32_t>(::DialogBoxParam(_hInst, MAKEINTRESOURCE(IDD_VALUE_DLG), _hParent, dlgProc, reinterpret_cast<LPARAM>(this)));
}
int ValueDlg::reSizeValueBox()
{
if (_nbNumber == DEFAULT_NB_NUMBER) return 0;
RECT rect;
POINT p;
HWND hEdit = ::GetDlgItem(_hSelf, IDC_VALUE_EDIT);
//get screen coordonnees (x,y)
::GetWindowRect(hEdit, &rect);
int w = rect.right - rect.left;
int h = rect.bottom - rect.top;
p.x = rect.left;
p.y = rect.top;
// convert screen coordonnees to client coordonnees
::ScreenToClient(_hSelf, &p);
RECT rcText;
::SendMessage(hEdit, EM_GETRECT, 0, reinterpret_cast<LPARAM>(&rcText));
DWORD m = (DWORD)::SendMessage(hEdit, EM_GETMARGINS, 0, 0);
int margins = LOWORD(m) + HIWORD(m);
int textWidth = rcText.right - rcText.left;
int frameWidth = w - textWidth;
int newTextWidth = ((textWidth - margins) * _nbNumber / DEFAULT_NB_NUMBER) + margins + 1;
int newWidth = newTextWidth + frameWidth;
::MoveWindow(hEdit, p.x, p.y, newWidth, h, FALSE);
return newWidth - w;
}
intptr_t CALLBACK ValueDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM)
intptr_t CALLBACK ButtonDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM /*lParam*/)
{
switch (Message)
{
case WM_INITDIALOG :
case WM_INITDIALOG:
{
NppDarkMode::autoSubclassAndThemeChildControls(_hSelf);
::SetDlgItemText(_hSelf, IDC_VALUE_STATIC, _name.c_str());
::SetDlgItemInt(_hSelf, IDC_VALUE_EDIT, _defaultValue, FALSE);
RECT rc;
::GetWindowRect(_hSelf, &rc);
int size = reSizeValueBox();
::MoveWindow(_hSelf, _p.x, _p.y, rc.right - rc.left + size, rc.bottom - rc.top, TRUE);
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;
return NppDarkMode::onCtlColorDarker(reinterpret_cast<HDC>(wParam));
}
case WM_PRINTCLIENT:
@ -124,7 +49,7 @@ intptr_t CALLBACK ValueDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM)
{
if (NppDarkMode::isEnabled())
{
RECT rc = {};
RECT rc{};
getClientRect(rc);
::FillRect(reinterpret_cast<HDC>(wParam), &rc, NppDarkMode::getDarkerBackgroundBrush());
return TRUE;
@ -138,93 +63,11 @@ intptr_t CALLBACK ValueDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM)
return TRUE;
}
case WM_COMMAND :
case WM_COMMAND:
{
switch (wParam)
{
case IDOK :
{
int i = ::GetDlgItemInt(_hSelf, IDC_VALUE_EDIT, NULL, FALSE);
::EndDialog(_hSelf, i);
return TRUE;
}
case IDCANCEL :
::EndDialog(_hSelf, -1);
return TRUE;
default:
return FALSE;
}
}
default :
return FALSE;
}
return FALSE;
}
intptr_t CALLBACK ButtonDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM)
{
switch (Message)
{
case WM_INITDIALOG :
{
NppDarkMode::autoSubclassAndThemeChildControls(_hSelf);
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_PRINTCLIENT:
{
if (NppDarkMode::isEnabled())
{
return TRUE;
}
break;
}
case WM_ERASEBKGND:
{
if (NppDarkMode::isEnabled())
{
RECT rc = {};
getClientRect(rc);
::FillRect(reinterpret_cast<HDC>(wParam), &rc, NppDarkMode::getDarkerBackgroundBrush());
return TRUE;
}
break;
}
case NPPM_INTERNAL_REFRESHDARKMODE:
{
NppDarkMode::autoThemeChildControls(_hSelf);
return TRUE;
}
case WM_COMMAND :
{
switch (wParam)
{
case IDC_RESTORE_BUTTON :
case IDC_RESTORE_BUTTON:
{
int bs = getButtonStatus();

View File

@ -20,29 +20,6 @@
#include "StaticDialog.h"
#include "Common.h"
const int DEFAULT_NB_NUMBER = 2;
class ValueDlg : public StaticDialog
{
public :
ValueDlg() = default;
void init(HINSTANCE hInst, HWND parent, int valueToSet, const TCHAR *text);
int doDialog(POINT p, bool isRTL = false);
void setNBNumber(int nbNumber) {
if (nbNumber > 0)
_nbNumber = nbNumber;
};
int reSizeValueBox();
void destroy() {};
protected :
intptr_t CALLBACK run_dlgProc(UINT Message, WPARAM wParam, LPARAM);
private :
int _nbNumber = DEFAULT_NB_NUMBER;
int _defaultValue = 0;
generic_string _name;
POINT _p = {0, 0};
};
// 0 : normal window
// 1 : fullscreen
@ -55,14 +32,14 @@ const int buttonStatus_distractionFree = 4; // 0000 0100
class ButtonDlg : public StaticDialog
{
public :
public:
ButtonDlg() = default;
void init(HINSTANCE hInst, HWND parent){
void init(HINSTANCE hInst, HWND parent) override {
Window::init(hInst, parent);
};
void doDialog(bool isRTL = false);
void destroy() {};
void destroy() override {};
int getButtonStatus() const {
return _buttonStatus;
};
@ -70,17 +47,16 @@ public :
_buttonStatus = buttonStatus;
};
void display(bool toShow = true) const {
void display(bool toShow = true) const override {
int cmdToShow = toShow?SW_SHOW:SW_HIDE;
if (!toShow)
{
cmdToShow = (_buttonStatus != buttonStatus_nada)?SW_SHOW:SW_HIDE;
}
::ShowWindow(_hSelf, cmdToShow);
};
::ShowWindow(_hSelf, cmdToShow);
};
protected :
intptr_t CALLBACK run_dlgProc(UINT Message, WPARAM wParam, LPARAM);
protected:
intptr_t CALLBACK run_dlgProc(UINT Message, WPARAM wParam, LPARAM lParam) override;
int _buttonStatus = buttonStatus_nada;
};

View File

@ -517,9 +517,9 @@
//#define IDD_STYLER_DLG 2200
//#define IDD_GLOBAL_STYLER_DLG 2300
#define IDD_VALUE_DLG 2400
#define IDC_VALUE_STATIC 2401
#define IDC_VALUE_EDIT 2402
//#define IDD_VALUE_DLG 2400
//#define IDC_VALUE_STATIC 2401
//#define IDC_VALUE_EDIT 2402
#define IDD_BUTTON_DLG 2410
#define IDC_RESTORE_BUTTON 2411