📄 preferencedlg.cpp
字号:
varList.push_back(strCouple("Short date format", "$(SHORT_DATE)"));
varList.push_back(strCouple("Long date format", "$(LONG_DATE)"));
varList.push_back(strCouple("Time", "$(TIME)"));
for (size_t i = 0 ; i < varList.size() ; i++)
{
int j = ::SendDlgItemMessage(_hSelf, IDC_COMBO_VARLIST, CB_ADDSTRING, 0, (LPARAM)varList[i]._varDesc.c_str());
::SendDlgItemMessage(_hSelf, IDC_COMBO_VARLIST, CB_SETITEMDATA, j, (LPARAM)varList[i]._var.c_str());
}
::SendDlgItemMessage(_hSelf, IDC_COMBO_VARLIST, CB_SETCURSEL, 0, 0);
//_colourHooker.setColour(RGB(0, 0, 0xFF));
//_colourHooker.hookOn(::GetDlgItem(_hSelf, IDC_VIEWPANEL_STATIC));
ETDTProc enableDlgTheme = (ETDTProc)pNppParam->getEnableThemeDlgTexture();
if (enableDlgTheme)
enableDlgTheme(_hSelf, ETDT_ENABLETAB);
return TRUE;
}
case WM_COMMAND :
{
if (HIWORD(wParam) == EN_CHANGE)
{
char str[256];
_focusedEditCtrl = LOWORD(wParam);
::GetDlgItemText(_hSelf, _focusedEditCtrl, str, sizeof(str));
::SendDlgItemMessage(_hSelf, IDC_VIEWPANEL_STATIC, WM_SETTEXT, 0, (LPARAM)str);
switch (LOWORD(wParam))
{
case IDC_EDIT_HLEFT:
nppGUI._printSettings._headerLeft = str;
trim(nppGUI._printSettings._headerLeft);
return TRUE;
case IDC_EDIT_HMIDDLE:
nppGUI._printSettings._headerMiddle = str;
trim(nppGUI._printSettings._headerMiddle);
return TRUE;
case IDC_EDIT_HRIGHT :
nppGUI._printSettings._headerRight = str;
trim(nppGUI._printSettings._headerRight);
return TRUE;
case IDC_EDIT_FLEFT:
nppGUI._printSettings._footerLeft = str;
trim(nppGUI._printSettings._footerLeft);
return TRUE;
case IDC_EDIT_FMIDDLE:
nppGUI._printSettings._footerMiddle = str;
trim(nppGUI._printSettings._footerMiddle);
return TRUE;
case IDC_EDIT_FRIGHT :
nppGUI._printSettings._footerRight = str;
trim(nppGUI._printSettings._footerRight);
return TRUE;
default :
return FALSE;
}
}
else if (HIWORD(wParam) == EN_SETFOCUS)
{
char str[256];
_focusedEditCtrl = LOWORD(wParam);
::GetDlgItemText(_hSelf, _focusedEditCtrl, str, sizeof(str));
//_colourHooker.setColour(RGB(0, 0, 0xFF));
::SendDlgItemMessage(_hSelf, IDC_VIEWPANEL_STATIC, WM_SETTEXT, 0, (LPARAM)str);
int focusedEditStatic;
int groupStatic;
switch (_focusedEditCtrl)
{
case IDC_EDIT_HLEFT : focusedEditStatic = IDC_HL_STATIC; groupStatic = IDC_HGB_STATIC; break;
case IDC_EDIT_HMIDDLE : focusedEditStatic = IDC_HM_STATIC; groupStatic = IDC_HGB_STATIC; break;
case IDC_EDIT_HRIGHT : focusedEditStatic = IDC_HR_STATIC; groupStatic = IDC_HGB_STATIC; break;
case IDC_EDIT_FLEFT : focusedEditStatic = IDC_FL_STATIC; groupStatic = IDC_FGB_STATIC; break;
case IDC_EDIT_FMIDDLE : focusedEditStatic = IDC_FM_STATIC; groupStatic = IDC_FGB_STATIC; break;
case IDC_EDIT_FRIGHT : focusedEditStatic = IDC_FR_STATIC; groupStatic = IDC_FGB_STATIC; break;
}
::GetDlgItemText(_hSelf, groupStatic, str, sizeof(str));
string title = str;
title += " ";
::GetDlgItemText(_hSelf, focusedEditStatic, str, sizeof(str));
title += str;
title += " : ";
::SendDlgItemMessage(_hSelf, IDC_WHICHPART_STATIC, WM_SETTEXT, 0, (LPARAM)title.c_str());
return TRUE;
}
else if (HIWORD(wParam) == CBN_SELCHANGE)
{
int iSel = ::SendDlgItemMessage(_hSelf, LOWORD(wParam), CB_GETCURSEL, 0, 0);
switch (LOWORD(wParam))
{
case IDC_COMBO_HFONTNAME :
case IDC_COMBO_FFONTNAME :
{
char *fnStr = (char *)::SendDlgItemMessage(_hSelf, LOWORD(wParam), CB_GETITEMDATA, iSel, 0);
if (LOWORD(wParam) == IDC_COMBO_HFONTNAME)
nppGUI._printSettings._headerFontName = fnStr;
else
nppGUI._printSettings._footerFontName = fnStr;
}
break;
case IDC_COMBO_HFONTSIZE :
case IDC_COMBO_FFONTSIZE :
{
char intStr[5];
::SendDlgItemMessage(_hSelf, LOWORD(wParam), CB_GETLBTEXT, iSel, (LPARAM)intStr);
int *pVal = (LOWORD(wParam) == IDC_COMBO_HFONTSIZE)?&(nppGUI._printSettings._headerFontSize):&(nppGUI._printSettings._footerFontSize);
if ((!intStr) || (!intStr[0]))
*pVal = 0;
else
*pVal = strtol(intStr, NULL, 10);
}
break;
case IDC_COMBO_VARLIST :
{
}
break;
}
return TRUE;
}
switch (wParam)
{
case IDC_CHECK_HBOLD:
nppGUI._printSettings._headerFontStyle ^= FONTSTYLE_BOLD;
break;
case IDC_CHECK_HITALIC:
nppGUI._printSettings._headerFontStyle ^= FONTSTYLE_ITALIC;
break;
case IDC_CHECK_FBOLD:
nppGUI._printSettings._footerFontStyle ^= FONTSTYLE_BOLD;
break;
case IDC_CHECK_FITALIC:
nppGUI._printSettings._footerFontStyle ^= FONTSTYLE_ITALIC;
break;
case IDC_BUTTON_ADDVAR:
{
if (!_focusedEditCtrl)
return TRUE;
int iSel = ::SendDlgItemMessage(_hSelf, IDC_COMBO_VARLIST, CB_GETCURSEL, 0, 0);
char *varStr = (char *)::SendDlgItemMessage(_hSelf, IDC_COMBO_VARLIST, CB_GETITEMDATA, iSel, 0);
::SendDlgItemMessage(_hSelf, _focusedEditCtrl, EM_GETSEL, (WPARAM)&_selStart, (LPARAM)&_selEnd);
/*
char toto[32];
sprintf(toto, "_selStart = %d\r_selEnd = %d", _selStart, _selEnd);
::MessageBox(NULL, toto, "", MB_OK);
*/
char str[256];
::SendDlgItemMessage(_hSelf, _focusedEditCtrl, WM_GETTEXT, sizeof(str), (LPARAM)str);
//::MessageBox(NULL, str, "", MB_OK);
string str2Set(str);
str2Set.replace(_selStart, _selEnd - _selStart, varStr);
::SetDlgItemText(_hSelf, _focusedEditCtrl, str2Set.c_str());
}
break;
}
return TRUE;
}
}
return FALSE;
}
BOOL CALLBACK BackupDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM lParam)
{
NppParameters *pNppParam = NppParameters::getInstance();
NppGUI & nppGUI = (NppGUI &)pNppParam->getNppGUI();
switch (Message)
{
case WM_INITDIALOG :
{
char nbStr[10];
itoa(nppGUI._autocFromLen, nbStr, 10);
HWND hNbChar_val = ::GetDlgItem(_hSelf, IDD_AUTOC_STATIC_N);
::SetWindowText(hNbChar_val, nbStr);
_nbCharVal.init(_hInst, _hSelf);
_nbCharVal.create(hNbChar_val, IDM_SETTING_AUTOCNBCHAR);
int ID2Check = 0;
switch (nppGUI._backup)
{
case bak_simple :
ID2Check = IDC_RADIO_BKSIMPLE;
break;
case bak_verbose :
ID2Check = IDC_RADIO_BKVERBOSE;
break;
default : //bak_none
ID2Check = IDC_RADIO_BKNONE;
}
::SendDlgItemMessage(_hSelf, ID2Check, BM_SETCHECK, BST_CHECKED, 0);
if (nppGUI._useDir)
::SendDlgItemMessage(_hSelf, IDC_BACKUPDIR_CHECK, BM_SETCHECK, BST_CHECKED, 0);
::SendDlgItemMessage(_hSelf, IDC_BACKUPDIR_EDIT, WM_SETTEXT, 0, (LPARAM)nppGUI._backupDir);
bool isEnableAutoC = nppGUI._autocStatus != nppGUI.autoc_none;
::SendDlgItemMessage(_hSelf, IDD_AUTOC_ENABLECHECK, BM_SETCHECK, isEnableAutoC?BST_CHECKED:BST_UNCHECKED, 0);
::SendDlgItemMessage(_hSelf, IDD_AUTOC_FUNCRADIO, BM_SETCHECK, nppGUI._autocStatus == nppGUI.autoc_func?BST_CHECKED:BST_UNCHECKED, 0);
::SendDlgItemMessage(_hSelf, IDD_AUTOC_WORDRADIO, BM_SETCHECK, nppGUI._autocStatus == nppGUI.autoc_word?BST_CHECKED:BST_UNCHECKED, 0);
if (!isEnableAutoC)
{
::EnableWindow(::GetDlgItem(_hSelf, IDD_AUTOC_FUNCRADIO), FALSE);
::EnableWindow(::GetDlgItem(_hSelf, IDD_AUTOC_WORDRADIO), FALSE);
::EnableWindow(::GetDlgItem(_hSelf, IDD_AUTOC_STATIC_FROM), FALSE);
::EnableWindow(::GetDlgItem(_hSelf, IDD_AUTOC_STATIC_N), FALSE);
::EnableWindow(::GetDlgItem(_hSelf, IDD_AUTOC_STATIC_CHAR), FALSE);
::EnableWindow(::GetDlgItem(_hSelf, IDD_AUTOC_STATIC_NOTE), FALSE);
}
updateBackupGUI();
return TRUE;
}
case WM_COMMAND :
{
if (HIWORD(wParam) == EN_CHANGE)
{
switch (LOWORD(wParam))
{
case IDC_BACKUPDIR_EDIT:
{
char inputDir[MAX_PATH];
::SendDlgItemMessage(_hSelf, IDC_BACKUPDIR_EDIT, WM_GETTEXT, sizeof(inputDir), (LPARAM)inputDir);
strcpy(nppGUI._backupDir, inputDir);
return TRUE;
}
}
}
switch (wParam)
{
case IDC_RADIO_BKSIMPLE:
{
nppGUI._backup = bak_simple;
updateBackupGUI();
return TRUE;
}
case IDC_RADIO_BKVERBOSE:
{
nppGUI._backup = bak_verbose;
updateBackupGUI();
return TRUE;
}
case IDC_RADIO_BKNONE:
{
nppGUI._backup = bak_none;
updateBackupGUI();
return TRUE;
}
case IDC_BACKUPDIR_CHECK:
{
nppGUI._useDir = !nppGUI._useDir;
updateBackupGUI();
return TRUE;
}
case IDD_BACKUPDIR_BROWSE_BUTTON :
{
folderBrowser(_hSelf, IDC_BACKUPDIR_EDIT);
return TRUE;
}
case IDD_AUTOC_ENABLECHECK :
{
bool isEnableAutoC = BST_CHECKED == ::SendDlgItemMessage(_hSelf, IDD_AUTOC_ENABLECHECK, BM_GETCHECK, 0, 0);
if (isEnableAutoC)
{
::SendDlgItemMessage(_hSelf, IDD_AUTOC_FUNCRADIO, BM_SETCHECK, BST_CHECKED, 0);
nppGUI._autocStatus = nppGUI.autoc_func;
}
else
{
::SendDlgItemMessage(_hSelf, IDD_AUTOC_FUNCRADIO, BM_SETCHECK, BST_UNCHECKED, 0);
::SendDlgItemMessage(_hSelf, IDD_AUTOC_WORDRADIO, BM_SETCHECK, BST_UNCHECKED, 0);
nppGUI._autocStatus = nppGUI.autoc_none;
}
::EnableWindow(::GetDlgItem(_hSelf, IDD_AUTOC_FUNCRADIO), isEnableAutoC);
::EnableWindow(::GetDlgItem(_hSelf, IDD_AUTOC_WORDRADIO), isEnableAutoC);
::EnableWindow(::GetDlgItem(_hSelf, IDD_AUTOC_STATIC_FROM), isEnableAutoC);
::EnableWindow(::GetDlgItem(_hSelf, IDD_AUTOC_STATIC_N), isEnableAutoC);
::EnableWindow(::GetDlgItem(_hSelf, IDD_AUTOC_STATIC_CHAR), isEnableAutoC);
::EnableWindow(::GetDlgItem(_hSelf, IDD_AUTOC_STATIC_NOTE), isEnableAutoC);
return TRUE;
}
case IDD_AUTOC_FUNCRADIO :
{
nppGUI._autocStatus = nppGUI.autoc_func;
return TRUE;
}
case IDD_AUTOC_WORDRADIO :
{
nppGUI._autocStatus = nppGUI.autoc_word;
return TRUE;
}
case IDM_SETTING_AUTOCNBCHAR :
{
::SendMessage(_hParent, WM_COMMAND, IDM_SETTING_AUTOCNBCHAR, 0);
char nbStr[10];
sprintf(nbStr, "%d", pNppParam->getNppGUI()._autocFromLen);
::SetWindowText(::GetDlgItem(_hSelf, IDD_AUTOC_STATIC_N), nbStr);
return TRUE;
}
default :
return FALSE;
}
}
}
return FALSE;
}
void BackupDlg::updateBackupGUI()
{
bool noBackup = BST_CHECKED == ::SendDlgItemMessage(_hSelf, IDC_RADIO_BKNONE, BM_GETCHECK, 0, 0);
bool isEnableGlobableCheck = false;
bool isEnableLocalCheck = false;
if (!noBackup)
{
isEnableGlobableCheck = true;
isEnableLocalCheck = BST_CHECKED == ::SendDlgItemMessage(_hSelf, IDC_BACKUPDIR_CHECK, BM_GETCHECK, 0, 0);
}
::EnableWindow(::GetDlgItem(_hSelf, IDC_BACKUPDIR_USERCUSTOMDIR_GRPSTATIC), isEnableGlobableCheck);
::EnableWindow(::GetDlgItem(_hSelf, IDC_BACKUPDIR_CHECK), isEnableGlobableCheck);
::EnableWindow(::GetDlgItem(_hSelf, IDD_BACKUPDIR_STATIC), isEnableLocalCheck);
::EnableWindow(::GetDlgItem(_hSelf, IDC_BACKUPDIR_EDIT), isEnableLocalCheck);
::EnableWindow(::GetDlgItem(_hSelf, IDD_BACKUPDIR_BROWSE_BUTTON), isEnableLocalCheck);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -