From 43f4e4c45a257ee7533435e0f543da74fb4e80db Mon Sep 17 00:00:00 2001 From: Don Ho Date: Sat, 12 May 2012 09:31:00 +0000 Subject: [PATCH] [ENHANCEMENT] Enhance warning message when the amount of files to open is too important. git-svn-id: svn://svn.tuxfamily.org/svnroot/notepadplus/repository/trunk@909 f5eea248-9336-0410-98b8-ebc06183d4e3 --- PowerEditor/installer/nativeLang/english.xml | 3 ++ PowerEditor/src/NppIO.cpp | 7 ++-- PowerEditor/src/ScitillaComponent/Buffer.cpp | 7 ++++ PowerEditor/src/localization.cpp | 43 ++++++++++++++++++-- PowerEditor/src/localization.h | 2 +- 5 files changed, 55 insertions(+), 7 deletions(-) diff --git a/PowerEditor/installer/nativeLang/english.xml b/PowerEditor/installer/nativeLang/english.xml index aa29aa4b1..a1efcbfc5 100644 --- a/PowerEditor/installer/nativeLang/english.xml +++ b/PowerEditor/installer/nativeLang/english.xml @@ -610,6 +610,9 @@ + + + diff --git a/PowerEditor/src/NppIO.cpp b/PowerEditor/src/NppIO.cpp index 4e3d2b08d..115e4d5ec 100644 --- a/PowerEditor/src/NppIO.cpp +++ b/PowerEditor/src/NppIO.cpp @@ -197,9 +197,10 @@ BufferID Notepad_plus::doOpen(const TCHAR *fileName, bool isReadOnly, int encodi { int answer = _nativeLangSpeaker.messageBox("NbFileToOpenImportantWaring", _pPublicInterface->getHSelf(), - TEXT("Number of files to open are too important.\rAre you sure to open them?"), - TEXT("Amount of files to open is too large"), - MB_YESNO|MB_APPLMODAL); + TEXT("$INT_REPLACE$ files are about to be opened.\rAre you sure to open them?"), + TEXT("Amount of files to open is too large"), + MB_YESNO|MB_APPLMODAL, + nbFiles2Open); ok2Open = answer == IDYES; } diff --git a/PowerEditor/src/ScitillaComponent/Buffer.cpp b/PowerEditor/src/ScitillaComponent/Buffer.cpp index f4da4b269..3e074bd68 100644 --- a/PowerEditor/src/ScitillaComponent/Buffer.cpp +++ b/PowerEditor/src/ScitillaComponent/Buffer.cpp @@ -739,6 +739,13 @@ bool FileManager::loadFileData(Document doc, const TCHAR * filename, Utf8_16_Rea if(bufferSizeRequested > INT_MAX) { ::MessageBox(NULL, TEXT("File is too big to be opened by Notepad++"), TEXT("File open problem"), MB_OK|MB_APPLMODAL); + /* + _nativeLangSpeaker.messageBox("NbFileToOpenImportantWaring", + _pPublicInterface->getHSelf(), + TEXT("File is too big to be opened by Notepad++"), + TEXT("File open problem"), + MB_OK|MB_APPLMODAL); + */ fclose(fp); return false; } diff --git a/PowerEditor/src/localization.cpp b/PowerEditor/src/localization.cpp index 9987b28b8..f3d23b9a0 100644 --- a/PowerEditor/src/localization.cpp +++ b/PowerEditor/src/localization.cpp @@ -1321,12 +1321,49 @@ generic_string NativeLangSpeaker::getProjectPanelLangStr(const char *nodeName, c return defaultStr; } -int NativeLangSpeaker::messageBox(const char *msgBoxTagName, HWND hWnd, TCHAR *defaultMessage, TCHAR *defaultTitle, int msgBoxType) +int NativeLangSpeaker::messageBox(const char *msgBoxTagName, HWND hWnd, TCHAR *defaultMessage, TCHAR *defaultTitle, int msgBoxType, int intInfo, TCHAR *strInfo) { generic_string msg, title; - if (getMsgBoxLang(msgBoxTagName, title, msg)) + size_t index; + TCHAR int2Write[256]; + TCHAR intPlaceHolderSymbol[] = TEXT("$INT_REPLACE$"); + TCHAR strPlaceHolderSymbol[] = TEXT("$STR_REPLACE$"); + + size_t intPlaceHolderLen = lstrlen(intPlaceHolderSymbol); + size_t strPlaceHolderLen = lstrlen(strPlaceHolderSymbol); + + generic_sprintf(int2Write, TEXT("%d"), intInfo); + + if (!getMsgBoxLang(msgBoxTagName, title, msg)) { - return ::MessageBox(hWnd, msg.c_str(), title.c_str(), msgBoxType); + title = defaultTitle; + msg = defaultMessage; } + index = title.find(intPlaceHolderSymbol); + if (index != string::npos) + title.replace(index, intPlaceHolderLen, int2Write); + + index = msg.find(intPlaceHolderSymbol); + if (index != string::npos) + msg.replace(index, intPlaceHolderLen, int2Write); + + if (strInfo) + { + index = title.find(strPlaceHolderSymbol); + if (index != string::npos) + title.replace(index, strPlaceHolderLen, strInfo); + + index = msg.find(strPlaceHolderSymbol); + if (index != string::npos) + msg.replace(index, strPlaceHolderLen, strInfo); + } + return ::MessageBox(hWnd, msg.c_str(), title.c_str(), msgBoxType); + + /* + defaultTitle.replace(index, len, int2Write); + defaultTitle.replace(index, len, str2Write); + defaultMessage.replace(index, len, int2Write); + defaultMessage.replace(index, len, str2Write); return ::MessageBox(hWnd, defaultMessage, defaultTitle, msgBoxType); + */ } \ No newline at end of file diff --git a/PowerEditor/src/localization.h b/PowerEditor/src/localization.h index ba6704e0f..47349ea60 100644 --- a/PowerEditor/src/localization.h +++ b/PowerEditor/src/localization.h @@ -74,7 +74,7 @@ public: bool getMsgBoxLang(const char *msgBoxTagName, generic_string & title, generic_string & message); generic_string getProjectPanelLangMenuStr(const char * nodeName, int cmdID, const TCHAR *defaultStr) const; generic_string getProjectPanelLangStr(const char *nodeName, const TCHAR *defaultStr) const; - int messageBox(const char *msgBoxTagName, HWND hWnd, TCHAR *message, TCHAR *title, int msgBoxType); + int messageBox(const char *msgBoxTagName, HWND hWnd, TCHAR *message, TCHAR *title, int msgBoxType, int intInfo = 0, TCHAR *strInfo = NULL); private: TiXmlNodeA *_nativeLangA; int _nativeLangEncoding;