[NEW_FEATURE] Make Recent File List totally customizable (in progress).

git-svn-id: svn://svn.tuxfamily.org/svnroot/notepadplus/repository/trunk@780 f5eea248-9336-0410-98b8-ebc06183d4e3
remotes/trunk
Don Ho 2011-06-26 02:09:56 +00:00
parent daaaabe744
commit 16bae1a4a5
13 changed files with 174 additions and 66 deletions

View File

@ -1794,7 +1794,7 @@ void Notepad_plus::command(int id)
{
ValueDlg nbHistoryDlg;
NppParameters *pNppParam = NppParameters::getInstance();
nbHistoryDlg.init(_pPublicInterface->getHinst(), _preference.getHSelf(), pNppParam->getNbMaxFile(), TEXT("Max File : "));
nbHistoryDlg.init(_pPublicInterface->getHinst(), _preference.getHSelf(), pNppParam->getNbMaxRecentFile(), TEXT("Max File : "));
POINT p;
::GetCursorPos(&p);
::ScreenToClient(_pPublicInterface->getHParent(), &p);
@ -1804,7 +1804,7 @@ void Notepad_plus::command(int id)
{
if (size > NB_MAX_LRF_FILE)
size = NB_MAX_LRF_FILE;
pNppParam->setNbMaxFile(size);
pNppParam->setNbMaxRecentFile(size);
_lastRecentFileList.setUserMaxNbLRF(size);
}
break;

View File

@ -606,7 +606,8 @@ int FileDialog::_dialogFileBoxId = (NppParameters::getInstance())->getWinVersion
NppParameters::NppParameters() : _pXmlDoc(NULL),_pXmlUserDoc(NULL), _pXmlUserStylerDoc(NULL),\
_pXmlUserLangDoc(NULL), _pXmlNativeLangDocA(NULL),\
_nbLang(0), _nbFile(0), _nbMaxFile(10), _pXmlToolIconsDoc(NULL),\
_nbLang(0), _pXmlToolIconsDoc(NULL),\
_nbRecentFile(0), _nbMaxRecentFile(10), _recentFileCustomLength(RECENTFILES_SHOWFULLPATH),_putRecentFileInSubMenu(false),
_pXmlShortcutDoc(NULL), _pXmlContextMenuDocA(NULL), _pXmlSessionDoc(NULL), _pXmlBlacklistDoc(NULL),\
_nbUserLang(0), _nbExternalLang(0), _hUser32(NULL), _hUXTheme(NULL),\
_transparentFuncAddr(NULL), _enableThemeDialogTextureFuncAddr(NULL), _pNativeLangSpeaker(NULL),\
@ -649,7 +650,7 @@ NppParameters::~NppParameters()
{
for (int i = 0 ; i < _nbLang ; i++)
delete _langList[i];
for (int i = 0 ; i < _nbFile ; i++)
for (int i = 0 ; i < _nbRecentFile ; i++)
delete _LRFileList[i];
for (int i = 0 ; i < _nbUserLang ; i++)
delete _userLangArray[i];
@ -1702,17 +1703,17 @@ void NppParameters::feedFileListParameters(TiXmlNode *node)
return;
if (nbMaxFileStr)
_nbMaxFile = nbMaxFile;
_nbMaxRecentFile = nbMaxFile;
for (TiXmlNode *childNode = historyRoot->FirstChildElement(TEXT("File"));
childNode && (_nbFile < NB_MAX_LRF_FILE);
childNode && (_nbRecentFile < NB_MAX_LRF_FILE);
childNode = childNode->NextSibling(TEXT("File")) )
{
const TCHAR *filePath = (childNode->ToElement())->Attribute(TEXT("filename"));
if (filePath)
{
_LRFileList[_nbFile] = new generic_string(filePath);
_nbFile++;
_LRFileList[_nbRecentFile] = new generic_string(filePath);
_nbRecentFile++;
}
}
}

View File

@ -1089,6 +1089,9 @@ const int NB_LANG = 80;
const bool DUP = true;
const bool FREE = false;
const int RECENTFILES_SHOWFULLPATH = -1;
const int RECENTFILES_SHOWONLYFILENAME = 0;
class NppParameters
{
public:
@ -1149,17 +1152,30 @@ public:
return NULL;
};
int getNbLRFile() const {return _nbFile;};
int getNbLRFile() const {return _nbRecentFile;};
generic_string *getLRFile(int index) const {
return _LRFileList[index];
};
void setNbMaxFile(int nb) {
_nbMaxFile = nb;
void setNbMaxRecentFile(int nb) {
_nbMaxRecentFile = nb;
};
int getNbMaxFile() const {return _nbMaxFile;};
int getNbMaxRecentFile() const {return _nbMaxRecentFile;};
void setPutRecentFileInSubMenu(bool doSubmenu) {
_putRecentFileInSubMenu = doSubmenu;
};
int putRecentFileInSubMenu() const {return _putRecentFileInSubMenu;};
void setRecentFileCustomLength(int len) {
_recentFileCustomLength = len;
};
int getRecentFileCustomLength() const {return _recentFileCustomLength;};
const ScintillaViewParams & getSVP() const {
return _svp;
@ -1424,9 +1440,14 @@ private:
Lang *_langList[NB_LANG];
int _nbLang;
// Recent File History
generic_string *_LRFileList[NB_MAX_LRF_FILE];
int _nbFile;
int _nbMaxFile;
int _nbRecentFile;
int _nbMaxRecentFile;
bool _putRecentFileInSubMenu;
int _recentFileCustomLength; // <0: Full File Path Name
// =0: Only File Name
// >0: Custom Entry Length
FindHistory _findHistory;

View File

@ -317,10 +317,6 @@ private :
_tab.activateAt(_currentStatus);
};
bool isCheckedOrNot(int checkControlID) const {
return (BST_CHECKED == ::SendMessage(::GetDlgItem(_hSelf, checkControlID), BM_GETCHECK, 0, 0));
};
void updateCombos();
void updateCombo(int comboID) {
bool isUnicode = (*_ppEditView)->getCurrentBuffer()->getUnicodeMode() != uni8Bit;

View File

@ -60,9 +60,6 @@ private :
bool findCharInRange(unsigned char beginRange, unsigned char endRange, int startPos, bool direction, bool wrap);
bool getRangeFromUI(unsigned char & startRange, unsigned char & endRange);
void getDirectionFromUI(bool & whichDirection, bool & isWrap);
bool isCheckedOrNot(int checkControlID) const {
return (BST_CHECKED == ::SendMessage(::GetDlgItem(_hSelf, checkControlID), BM_GETCHECK, 0, 0));
};
};
#endif //FINDCHARSINRANGE_DLG_H

View File

@ -101,11 +101,13 @@ IDD_PREFERENCE_SETTING_BOX DIALOGEX 0, 0, 455, 185
STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD
FONT 8, "MS Shell Dlg", 0, 0, 0x1
BEGIN
/*
GROUPBOX "Recent Files History",IDC_HISTORY_GB_STATIC,37,4,155,39,BS_CENTER
RTEXT "Max. number of entries :",IDC_MAXNBFILE_STATIC,40,14,112,8
LTEXT "0",IDC_MAXNBFILEVAL_STATIC,176,14,15,8
CONTROL "Don't check at launch time",IDC_CHECK_DONTCHECKHISTORY,
"Button",BS_AUTOCHECKBOX | WS_TABSTOP,45,27,140,10
*/
GROUPBOX "Document Switcher (Ctrl+TAB)",IDC_DOCUMENTSWITCHER_STATIC,37,48,155,39,BS_CENTER
CONTROL "Enable",IDC_CHECK_ENABLEDOCSWITCHER,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,45,59,69,10
CONTROL "Enable MRU behaviour",IDC_CHECK_STYLEMRU,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,45,72,140,10
@ -169,6 +171,19 @@ BEGIN
PUSHBUTTON "...",IDD_OPENSAVEDIR_ALWAYSON_BROWSE_BUTTON,423,41,16,14
CONTROL "Apply to opened ANSI files",IDC_CHECK_OPENANSIASUTF8,
"Button",BS_AUTOCHECKBOX | WS_TABSTOP,37,79,124,10
GROUPBOX "Recent Files History",IDC_HISTORY_GB_STATIC,213,69,232,110,BS_CENTER
RTEXT "Max. number of entries :",IDC_MAXNBFILE_STATIC,217,91,112,8
LTEXT "0",IDC_MAXNBFILEVAL_STATIC,338,91,15,8
CONTROL "Don't check at launch time",IDC_CHECK_DONTCHECKHISTORY,
"Button",BS_AUTOCHECKBOX | WS_TABSTOP,221,78,140,10
GROUPBOX "Display",IDC_STATIC,226,103,207,69,BS_CENTER
CONTROL "In Submenu",IDC_CHECK_INSUBMENU,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,234,114,79,10
CONTROL "Only File Name",IDC_RADIO_ONLYFILENAME,"Button",BS_AUTORADIOBUTTON | WS_GROUP,235,130,88,10
CONTROL "Full File Name Path",IDC_RADIO_FULLFILENAMEPATH,"Button",BS_AUTORADIOBUTTON,235,144,109,10
CONTROL "Customize Maximum Length:",IDC_RADIO_CUSTOMIZELENTH,
"Button",BS_AUTORADIOBUTTON,235,157,114,10
LTEXT "0",IDC_CUSTOMIZELENGTHVAL_STATIC,353,158,18,8
END
IDD_PREFERENCE_LANG_BOX DIALOGEX 0, 0, 455, 185

View File

@ -630,15 +630,6 @@ BOOL CALLBACK SettingsDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM)
{
case WM_INITDIALOG :
{
TCHAR nbStr[10];
wsprintf(nbStr, TEXT("%d"), pNppParam->getNbMaxFile());
::SetWindowText(::GetDlgItem(_hSelf, IDC_MAXNBFILEVAL_STATIC), nbStr);
_nbHistoryVal.init(_hInst, _hSelf);
_nbHistoryVal.create(::GetDlgItem(_hSelf, IDC_MAXNBFILEVAL_STATIC), IDM_SETTING_HISTORY_SIZE);
::SendDlgItemMessage(_hSelf, IDC_CHECK_DONTCHECKHISTORY, BM_SETCHECK, !nppGUI._checkHistoryFiles, 0);
if (nppGUI._fileAutoDetection == cdEnabled)
{
::SendDlgItemMessage(_hSelf, IDC_CHECK_FILEAUTODETECTION, BM_SETCHECK, BST_CHECKED, 0);
@ -739,10 +730,6 @@ BOOL CALLBACK SettingsDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM)
switch (wParam)
{
case IDC_CHECK_DONTCHECKHISTORY:
nppGUI._checkHistoryFiles = !isCheckedOrNot(IDC_CHECK_DONTCHECKHISTORY);
return TRUE;
case IDC_CHECK_FILEAUTODETECTION:
{
bool isChecked = isCheckedOrNot(IDC_CHECK_FILEAUTODETECTION);
@ -810,15 +797,6 @@ BOOL CALLBACK SettingsDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM)
nppGUI._rememberLastSession = isCheckedOrNot(wParam);
return TRUE;
case IDM_SETTING_HISTORY_SIZE:
{
::SendMessage(_hParent, WM_COMMAND, IDM_SETTING_HISTORY_SIZE, 0);
TCHAR nbStr[10];
wsprintf(nbStr, TEXT("%d"), pNppParam->getNbMaxFile());
::SetWindowText(::GetDlgItem(_hSelf, IDC_MAXNBFILEVAL_STATIC), nbStr);
return TRUE;
}
case IDC_CHECK_ENABLEDOCSWITCHER :
{
nppGUI._doTaskList = !nppGUI._doTaskList;
@ -899,6 +877,13 @@ BOOL CALLBACK SettingsDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM)
return FALSE;
}
void DefaultNewDocDlg::setCustomLen(int val)
{
::EnableWindow(::GetDlgItem(_hSelf, IDC_CUSTOMIZELENGTHVAL_STATIC), val > 0);
::SetDlgItemInt(_hSelf, IDC_CUSTOMIZELENGTHVAL_STATIC, val, FALSE);
}
BOOL CALLBACK DefaultNewDocDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM)
{
NppParameters *pNppParam = NppParameters::getInstance();
@ -1016,7 +1001,47 @@ BOOL CALLBACK DefaultNewDocDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM)
::SendDlgItemMessage(_hSelf, IDC_OPENSAVEDIR_ALWAYSON_EDIT, WM_SETTEXT, 0, (LPARAM)nppGUI._defaultDir);
::EnableWindow(::GetDlgItem(_hSelf, IDC_OPENSAVEDIR_ALWAYSON_EDIT), shouldActivated);
::EnableWindow(::GetDlgItem(_hSelf, IDD_OPENSAVEDIR_ALWAYSON_BROWSE_BUTTON), shouldActivated);
//
// Recent File History
//
// Max number recent file setting
::SetDlgItemInt(_hSelf, IDC_MAXNBFILEVAL_STATIC, pNppParam->getNbMaxRecentFile(), FALSE);
_nbHistoryVal.init(_hInst, _hSelf);
_nbHistoryVal.create(::GetDlgItem(_hSelf, IDC_MAXNBFILEVAL_STATIC), IDM_SETTING_HISTORY_SIZE);
// Check on launch time settings
::SendDlgItemMessage(_hSelf, IDC_CHECK_DONTCHECKHISTORY, BM_SETCHECK, !nppGUI._checkHistoryFiles, 0);
// Disply in submenu setting
::SendDlgItemMessage(_hSelf, IDC_CHECK_INSUBMENU, BM_SETCHECK, pNppParam->putRecentFileInSubMenu(), 0);
// Recent File menu entry length setting
int customLength = pNppParam->getRecentFileCustomLength();
int id = IDC_RADIO_CUSTOMIZELENTH;
int length = customLength;
if (customLength == RECENTFILES_SHOWONLYFILENAME)
{
id = IDC_RADIO_ONLYFILENAME;
length = 0;
}
else if (customLength == RECENTFILES_SHOWFULLPATH || customLength < 0)
{
id = IDC_RADIO_FULLFILENAMEPATH;
length = 0;
}
::SendDlgItemMessage(_hSelf, id, BM_SETCHECK, BST_CHECKED, 0);
::SetDlgItemInt(_hSelf, IDC_CUSTOMIZELENGTHVAL_STATIC, length, FALSE);
_customLenVal.init(_hInst, _hSelf);
_customLenVal.create(::GetDlgItem(_hSelf, IDC_CUSTOMIZELENGTHVAL_STATIC), NULL);
//
// To avoid the white control background to be displayed in dialog
//
ETDTProc enableDlgTheme = (ETDTProc)pNppParam->getEnableThemeDlgTexture();
if (enableDlgTheme)
enableDlgTheme(_hSelf, ETDT_ENABLETAB);
@ -1123,6 +1148,60 @@ BOOL CALLBACK DefaultNewDocDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM)
folderBrowser(_hSelf, IDC_OPENSAVEDIR_ALWAYSON_EDIT);
return TRUE;
//
// Recent File History
//
case IDC_CHECK_DONTCHECKHISTORY:
nppGUI._checkHistoryFiles = !isCheckedOrNot(IDC_CHECK_DONTCHECKHISTORY);
return TRUE;
case IDC_CHECK_INSUBMENU:
pNppParam->setPutRecentFileInSubMenu(isCheckedOrNot(IDC_CHECK_INSUBMENU));
return TRUE;
case IDC_RADIO_ONLYFILENAME:
setCustomLen(0);
pNppParam->setRecentFileCustomLength(0);
return TRUE;
case IDC_RADIO_FULLFILENAMEPATH:
setCustomLen(0);
pNppParam->setRecentFileCustomLength(-1);
return TRUE;
case IDC_RADIO_CUSTOMIZELENTH:
{
int len = pNppParam->getRecentFileCustomLength();
if (len <= 0)
{
setCustomLen(100);
pNppParam->setRecentFileCustomLength(100);
}
return TRUE;
}
case IDC_CUSTOMIZELENGTHVAL_STATIC:
{
ValueDlg customLengthDlg;
customLengthDlg.init(NULL, _hSelf, pNppParam->getRecentFileCustomLength(), TEXT("Length: "));
POINT p;
::GetCursorPos(&p);
int size = customLengthDlg.doDialog(p);
if (size != -1)
{
::SetDlgItemInt(_hSelf, IDC_CUSTOMIZELENGTHVAL_STATIC, size, FALSE);
pNppParam->setRecentFileCustomLength(size);
}
return TRUE;
}
case IDM_SETTING_HISTORY_SIZE:
{
::SendMessage(_hParent, WM_COMMAND, IDM_SETTING_HISTORY_SIZE, 0);
::SetDlgItemInt(_hSelf, IDC_MAXNBFILEVAL_STATIC, pNppParam->getNbMaxRecentFile(), FALSE);
return TRUE;
}
default:
if (HIWORD(wParam) == CBN_SELCHANGE)
{

View File

@ -48,14 +48,7 @@ class SettingsDlg : public StaticDialog
{
public :
SettingsDlg() {};
virtual void destroy() {
_nbHistoryVal.destroy();
};
private :
URLCtrl _nbHistoryVal;
bool isCheckedOrNot(int checkControlID) const {
return (BST_CHECKED == ::SendMessage(::GetDlgItem(_hSelf, checkControlID), BM_GETCHECK, 0, 0));
};
BOOL CALLBACK run_dlgProc(UINT Message, WPARAM wParam, LPARAM lParam);
};
@ -92,13 +85,20 @@ class DefaultNewDocDlg : public StaticDialog
{
public :
DefaultNewDocDlg() {};
virtual void destroy() {
_nbHistoryVal.destroy();
_customLenVal.destroy();
};
private :
URLCtrl _nbHistoryVal;
URLCtrl _customLenVal;
std::vector<LangID_Name> _langList;
void makeOpenAnsiAsUtf8(bool doIt){
if (!doIt)
::SendDlgItemMessage(_hSelf, IDC_CHECK_OPENANSIASUTF8, BM_SETCHECK, BST_UNCHECKED, 0);
::EnableWindow(::GetDlgItem(_hSelf, IDC_CHECK_OPENANSIASUTF8), doIt);
};
void setCustomLen(int val);
BOOL CALLBACK run_dlgProc(UINT Message, WPARAM wParam, LPARAM lParam);
};
@ -147,16 +147,6 @@ private :
/*
class PrintSettings2Dlg : public StaticDialog
{
public :
PrintSettings2Dlg():_focusedEditCtrl(0), _selStart(0), _selEnd(0){};
private :
BOOL CALLBACK run_dlgProc(UINT Message, WPARAM wParam, LPARAM lParam);
};
*/
class PreferenceDlg : public StaticDialog
{

View File

@ -144,6 +144,12 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#define IDC_CHECK_OPENANSIASUTF8 (IDD_PREFERENCE_NEWDOCSETTING_BOX + 20)
#define IDC_RADIO_OTHERCP (IDD_PREFERENCE_NEWDOCSETTING_BOX + 21)
#define IDC_COMBO_OTHERCP (IDD_PREFERENCE_NEWDOCSETTING_BOX + 22)
#define IDC_GP_STATIC_RECENTFILES (IDD_PREFERENCE_NEWDOCSETTING_BOX + 23)
#define IDC_CHECK_INSUBMENU (IDD_PREFERENCE_NEWDOCSETTING_BOX + 24)
#define IDC_RADIO_ONLYFILENAME (IDD_PREFERENCE_NEWDOCSETTING_BOX + 25)
#define IDC_RADIO_FULLFILENAMEPATH (IDD_PREFERENCE_NEWDOCSETTING_BOX + 26)
#define IDC_RADIO_CUSTOMIZELENTH (IDD_PREFERENCE_NEWDOCSETTING_BOX + 27)
#define IDC_CUSTOMIZELENGTHVAL_STATIC (IDD_PREFERENCE_NEWDOCSETTING_BOX + 28)
#define IDD_PREFERENCE_LANG_BOX 6500 //(IDD_PREFERENCE_BOX + 500)
#define IDC_LIST_ENABLEDLANG (IDD_PREFERENCE_LANG_BOX + 1)

View File

@ -70,6 +70,10 @@ public :
return p;
};
bool isCheckedOrNot(int checkControlID) const {
return (BST_CHECKED == ::SendMessage(::GetDlgItem(_hSelf, checkControlID), BM_GETCHECK, 0, 0));
};
void destroy() {
::SendMessage(_hParent, NPPM_MODELESSDIALOG, MODELESSDIALOGREMOVE, (WPARAM)_hSelf);
::DestroyWindow(_hSelf);

View File

@ -56,11 +56,6 @@ public :
private :
virtual BOOL CALLBACK run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam);
bool isCheckedOrNot(int checkControlID) const {
return (BST_CHECKED == ::SendMessage(::GetDlgItem(_hSelf, checkControlID), BM_GETCHECK, 0, 0));
};
void check(int);
int m_Mode;

View File

@ -34,7 +34,7 @@ class LastRecentFileList
{
public :
LastRecentFileList() : _hasSeparators(false), _size(0), _locked(false) {
_userMax = (NppParameters::getInstance())->getNbMaxFile();
_userMax = (NppParameters::getInstance())->getNbMaxRecentFile();
};
void initMenu(HMENU hMenu, int idBase, int posBase, bool doSubMenu = false);

View File

@ -1594,6 +1594,10 @@
RelativePath="..\src\resource.h"
>
</File>
<File
RelativePath="..\src\WinControls\Preference\resource.h"
>
</File>
<File
RelativePath="..\src\WinControls\StaticDialog\RunDlg\RunDlg.h"
>