From a171d5fbdc4c9a17c1df38280968f09eee2b3447 Mon Sep 17 00:00:00 2001 From: Don Ho Date: Fri, 25 Oct 2013 07:32:04 +0000 Subject: [PATCH] [ENHANCEMENT] Add button tips in function list. git-svn-id: svn://svn.tuxfamily.org/svnroot/notepadplus/repository/trunk@1138 f5eea248-9336-0410-98b8-ebc06183d4e3 --- PowerEditor/installer/nativeLang/chinese.xml | 7 +- PowerEditor/installer/nativeLang/english.xml | 7 +- PowerEditor/installer/nativeLang/french.xml | 7 +- PowerEditor/src/Notepad_plus.cpp | 10 +++ .../FunctionList/functionListPanel.cpp | 24 ++++++- .../FunctionList/functionListPanel.h | 14 +++- PowerEditor/src/localization.cpp | 64 +++++++++++-------- PowerEditor/src/localization.h | 2 + 8 files changed, 104 insertions(+), 31 deletions(-) diff --git a/PowerEditor/installer/nativeLang/chinese.xml b/PowerEditor/installer/nativeLang/chinese.xml index a0c0a86b1..a2cbaf8a6 100644 --- a/PowerEditor/installer/nativeLang/chinese.xml +++ b/PowerEditor/installer/nativeLang/chinese.xml @@ -1,6 +1,6 @@ - +
@@ -777,6 +777,11 @@ + + + + + diff --git a/PowerEditor/installer/nativeLang/english.xml b/PowerEditor/installer/nativeLang/english.xml index efeb3a712..848c87b05 100644 --- a/PowerEditor/installer/nativeLang/english.xml +++ b/PowerEditor/installer/nativeLang/english.xml @@ -1,6 +1,6 @@ - +
@@ -777,6 +777,11 @@ + + + + + diff --git a/PowerEditor/installer/nativeLang/french.xml b/PowerEditor/installer/nativeLang/french.xml index 5c87c4eec..e52a51d5e 100644 --- a/PowerEditor/installer/nativeLang/french.xml +++ b/PowerEditor/installer/nativeLang/french.xml @@ -1,7 +1,7 @@ - +
@@ -798,6 +798,11 @@ + + + + + diff --git a/PowerEditor/src/Notepad_plus.cpp b/PowerEditor/src/Notepad_plus.cpp index eb0711267..8aa9293cf 100644 --- a/PowerEditor/src/Notepad_plus.cpp +++ b/PowerEditor/src/Notepad_plus.cpp @@ -5196,6 +5196,16 @@ void Notepad_plus::launchFunctionList() // In the case of Notepad++ internal function, it'll be the command ID which triggers this dialog data.dlgID = IDM_VIEW_FUNC_LIST; + NativeLangSpeaker *pNativeSpeaker = (NppParameters::getInstance())->getNativeLangSpeaker(); + generic_string title_temp = pNativeSpeaker->getFunctionListPanelLangStr("PanelTitle", FL_PANELTITLE); + + static TCHAR title[32]; + if (title_temp.length() < 32) + { + lstrcpy(title, title_temp.c_str()); + data.pszName = title; + } + ::SendMessage(_pPublicInterface->getHSelf(), NPPM_DMMREGASDCKDLG, 0, (LPARAM)&data); } _pFuncList->display(); diff --git a/PowerEditor/src/WinControls/FunctionList/functionListPanel.cpp b/PowerEditor/src/WinControls/FunctionList/functionListPanel.cpp index 9db49672b..b1a6c53fb 100644 --- a/PowerEditor/src/WinControls/FunctionList/functionListPanel.cpp +++ b/PowerEditor/src/WinControls/FunctionList/functionListPanel.cpp @@ -29,6 +29,7 @@ #include "precompiledHeaders.h" #include "functionListPanel.h" #include "ScintillaEditView.h" +#include "localization.h" #define CX_BITMAP 16 #define CY_BITMAP 16 @@ -374,7 +375,21 @@ bool FunctionListPanel::openSelection(const TreeView & treeView) void FunctionListPanel::notified(LPNMHDR notification) { - if (notification->hwndFrom == _treeView.getHSelf() || notification->hwndFrom == this->_treeViewSearchResult.getHSelf()) + if (notification->code == TTN_GETDISPINFO) + { + LPTOOLTIPTEXT lpttt = (LPTOOLTIPTEXT)notification; + lpttt->hinst = NULL; + + if (notification->idFrom == IDC_SORTBUTTON_FUNCLIST) + { + lstrcpy(lpttt->szText, _sortTipStr.c_str()); + } + else if (notification->idFrom == IDC_RELOADBUTTON_FUNCLIST) + { + lstrcpy(lpttt->szText, _reloadTipStr.c_str()); + } + } + else if (notification->hwndFrom == _treeView.getHSelf() || notification->hwndFrom == this->_treeViewSearchResult.getHSelf()) { const TreeView & treeView = notification->hwndFrom == _treeView.getHSelf()?_treeView:_treeViewSearchResult; switch (notification->code) @@ -549,7 +564,7 @@ BOOL CALLBACK FunctionListPanel::run_dlgProc(UINT message, WPARAM wParam, LPARAM int editHeight = 20; // Create toolbar menu //int style = WS_CHILD | WS_VISIBLE | WS_CLIPCHILDREN | WS_CLIPSIBLINGS | TBSTYLE_TOOLTIPS |TBSTYLE_FLAT | CCS_TOP | BTNS_AUTOSIZE | CCS_NOPARENTALIGN | CCS_NORESIZE | CCS_NODIVIDER; - int style = WS_CHILD | WS_VISIBLE | CCS_ADJUSTABLE | TBSTYLE_AUTOSIZE | TBSTYLE_FLAT | TBSTYLE_LIST | TBSTYLE_TRANSPARENT | BTNS_AUTOSIZE | BTNS_SEP; + int style = WS_CHILD | WS_VISIBLE | CCS_ADJUSTABLE | TBSTYLE_AUTOSIZE | TBSTYLE_FLAT | TBSTYLE_LIST | TBSTYLE_TRANSPARENT | BTNS_AUTOSIZE | BTNS_SEP | TBSTYLE_TOOLTIPS; _hToolbarMenu = CreateWindowEx(0,TOOLBARCLASSNAME,NULL, style, 0,0,0,0,_hSelf,(HMENU)0, _hInst, NULL); @@ -589,6 +604,11 @@ BOOL CALLBACK FunctionListPanel::run_dlgProc(UINT message, WPARAM wParam, LPARAM ::SendMessage(_hToolbarMenu, TB_AUTOSIZE, 0, 0); ShowWindow(_hToolbarMenu, SW_SHOW); + + // tips text for toolbar buttons + NativeLangSpeaker *pNativeSpeaker = (NppParameters::getInstance())->getNativeLangSpeaker(); + _sortTipStr = pNativeSpeaker->getAttrNameStr(_sortTipStr.c_str(), FL_FUCTIONLISTROOTNODE, FL_SORTLOCALNODENAME); + _reloadTipStr = pNativeSpeaker->getAttrNameStr(_reloadTipStr.c_str(), FL_FUCTIONLISTROOTNODE, FL_RELOADLOCALNODENAME); _hSearchEdit = CreateWindowEx(0L, L"Edit", NULL, WS_CHILD | WS_BORDER | WS_VISIBLE | ES_AUTOVSCROLL, diff --git a/PowerEditor/src/WinControls/FunctionList/functionListPanel.h b/PowerEditor/src/WinControls/FunctionList/functionListPanel.h index 22d176a5f..473c6f577 100644 --- a/PowerEditor/src/WinControls/FunctionList/functionListPanel.h +++ b/PowerEditor/src/WinControls/FunctionList/functionListPanel.h @@ -38,6 +38,14 @@ #include "functionParser.h" #include "TreeView.h" +#define FL_PANELTITLE TEXT("Function List") +#define FL_SORTTIP TEXT("sort") +#define FL_RELOADTIP TEXT("Reload") + +#define FL_FUCTIONLISTROOTNODE "FunctionList" +#define FL_SORTLOCALNODENAME "SortTip" +#define FL_RELOADLOCALNODENAME "ReloadTip" + class ScintillaEditView; struct FuncInfo { @@ -85,7 +93,8 @@ struct TreeParams { class FunctionListPanel : public DockingDlgInterface { public: - FunctionListPanel(): DockingDlgInterface(IDD_FUNCLIST_PANEL), _ppEditView(NULL), _pTreeView(&_treeView) {}; + FunctionListPanel(): DockingDlgInterface(IDD_FUNCLIST_PANEL), _ppEditView(NULL), _pTreeView(&_treeView), + _reloadTipStr(TEXT("Reload")), _sortTipStr(TEXT("Sort")) {}; void init(HINSTANCE hInst, HWND hPere, ScintillaEditView **ppEditView); @@ -118,6 +127,9 @@ private: TreeView _treeView; TreeView _treeViewSearchResult; + generic_string _sortTipStr; + generic_string _reloadTipStr; + ScintillaEditView **_ppEditView; FunctionParsersManager _funcParserMgr; std::vector _funcInfos; diff --git a/PowerEditor/src/localization.cpp b/PowerEditor/src/localization.cpp index 57ebda509..522378e2c 100644 --- a/PowerEditor/src/localization.cpp +++ b/PowerEditor/src/localization.cpp @@ -1058,20 +1058,15 @@ bool NativeLangSpeaker::changeDlgLang(HWND hDlg, const char *dlgTagName, char *t dlgNode = searchDlgNode(dlgNode, dlgTagName); if (!dlgNode) return false; -#ifdef UNICODE WcharMbcsConvertor *wmc = WcharMbcsConvertor::getInstance(); -#endif // Set Title const char *titre = (dlgNode->ToElement())->Attribute("title"); if ((titre && titre[0]) && hDlg) { -#ifdef UNICODE const wchar_t *nameW = wmc->char2wchar(titre, _nativeLangEncoding); ::SetWindowText(hDlg, nameW); -#else - ::SetWindowText(hDlg, titre); -#endif + if (title) strcpy(title, titre); } @@ -1090,12 +1085,8 @@ bool NativeLangSpeaker::changeDlgLang(HWND hDlg, const char *dlgTagName, char *t HWND hItem = ::GetDlgItem(hDlg, id); if (hItem) { -#ifdef UNICODE const wchar_t *nameW = wmc->char2wchar(name, _nativeLangEncoding); ::SetWindowText(hItem, nameW); -#else - ::SetWindowText(hItem, name); -#endif } } } @@ -1115,22 +1106,15 @@ bool NativeLangSpeaker::getMsgBoxLang(const char *msgBoxTagName, generic_string msgBoxNode = searchDlgNode(msgBoxNode, msgBoxTagName); if (!msgBoxNode) return false; -#ifdef UNICODE WcharMbcsConvertor *wmc = WcharMbcsConvertor::getInstance(); -#endif // Set Title const char *titre = (msgBoxNode->ToElement())->Attribute("title"); const char *msg = (msgBoxNode->ToElement())->Attribute("message"); if ((titre && titre[0]) && (msg && msg[0])) { -#ifdef UNICODE title = wmc->char2wchar(titre, _nativeLangEncoding); message = wmc->char2wchar(msg, _nativeLangEncoding); -#else - title = titre; - message = msg; -#endif return true; } return false; @@ -1167,12 +1151,8 @@ generic_string NativeLangSpeaker::getProjectPanelLangMenuStr(const char * nodeNa if (name && name[0]) { -#ifdef UNICODE WcharMbcsConvertor *wmc = WcharMbcsConvertor::getInstance(); return wmc->char2wchar(name, _nativeLangEncoding); -#else - return name; -#endif } return defaultStr; } @@ -1186,16 +1166,50 @@ generic_string NativeLangSpeaker::getProjectPanelLangStr(const char *nodeName, c targetNode = targetNode->FirstChild(nodeName); if (!targetNode) return defaultStr; + const char *name = (targetNode->ToElement())->Attribute("name"); + if (name && name[0]) + { + WcharMbcsConvertor *wmc = WcharMbcsConvertor::getInstance(); + return wmc->char2wchar(name, _nativeLangEncoding); + } + return defaultStr; +} + +generic_string NativeLangSpeaker::getAttrNameStr(const TCHAR *defaultStr, const char *nodeL1Name, const char *nodeL2Name) const +{ + if (!_nativeLangA) return defaultStr; + + TiXmlNodeA *targetNode = _nativeLangA->FirstChild(nodeL1Name); + if (!targetNode) return defaultStr; + if (nodeL2Name) + targetNode = targetNode->FirstChild(nodeL2Name); + + if (!targetNode) return defaultStr; + + const char *name = (targetNode->ToElement())->Attribute("name"); + if (name && name[0]) + { + WcharMbcsConvertor *wmc = WcharMbcsConvertor::getInstance(); + return wmc->char2wchar(name, _nativeLangEncoding); + } + return defaultStr; +} + +generic_string NativeLangSpeaker::getFunctionListPanelLangStr(const char *nodeName, const TCHAR *defaultStr) const +{ + if (!_nativeLangA) return defaultStr; + + TiXmlNodeA *targetNode = _nativeLangA->FirstChild("FunctionList"); + if (!targetNode) return defaultStr; + targetNode = targetNode->FirstChild(nodeName); + if (!targetNode) return defaultStr; + // Set Title const char *name = (targetNode->ToElement())->Attribute("name"); if (name && name[0]) { -#ifdef UNICODE WcharMbcsConvertor *wmc = WcharMbcsConvertor::getInstance(); return wmc->char2wchar(name, _nativeLangEncoding); -#else - return name; -#endif } return defaultStr; } diff --git a/PowerEditor/src/localization.h b/PowerEditor/src/localization.h index e72d42df5..10f4578c8 100644 --- a/PowerEditor/src/localization.h +++ b/PowerEditor/src/localization.h @@ -75,6 +75,8 @@ 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; + generic_string getFunctionListPanelLangStr(const char *nodeName, const TCHAR *defaultStr) const; + generic_string getAttrNameStr(const TCHAR *defaultStr, const char *nodeL1Name, const char *nodeL2Name = NULL) const; int messageBox(const char *msgBoxTagName, HWND hWnd, TCHAR *message, TCHAR *title, int msgBoxType, int intInfo = 0, TCHAR *strInfo = NULL); private: TiXmlNodeA *_nativeLangA;